diff --git a/src/spring/azext_spring/apm.py b/src/spring/azext_spring/apm.py index e537ea33982..f6075977f2d 100644 --- a/src/spring/azext_spring/apm.py +++ b/src/spring/azext_spring/apm.py @@ -8,13 +8,13 @@ from azure.cli.core.commands.client_factory import get_mgmt_service_client from azure.cli.core.util import sdk_no_wait from azure.core.exceptions import ResourceNotFoundError -from azure.mgmt.applicationinsights import ApplicationInsightsManagementClient from knack.log import get_logger from azure.mgmt.core.tools import parse_resource_id, is_valid_resource_id from ._utils import get_portal_uri from .custom import try_create_application_insights from .vendored_sdks.appplatform.v2024_05_01_preview import models +from .vendored_sdks.applicationinsights import ApplicationInsightsManagementClient logger = get_logger(__name__) DEFAULT_APM_NAME = "default" diff --git a/src/spring/azext_spring/buildpack_binding.py b/src/spring/azext_spring/buildpack_binding.py index 7d0724cf99e..4465723b2b3 100644 --- a/src/spring/azext_spring/buildpack_binding.py +++ b/src/spring/azext_spring/buildpack_binding.py @@ -11,7 +11,7 @@ from azure.mgmt.core.tools import parse_resource_id, is_valid_resource_id from azure.cli.core.commands.client_factory import get_mgmt_service_client from azure.cli.core.azclierror import InvalidArgumentValueError -from azure.mgmt.applicationinsights import ApplicationInsightsManagementClient +from .vendored_sdks.applicationinsights import ApplicationInsightsManagementClient from azure.core.exceptions import ResourceNotFoundError from knack.log import get_logger diff --git a/src/spring/azext_spring/custom.py b/src/spring/azext_spring/custom.py index 55b4eb32cd6..361eec10467 100644 --- a/src/spring/azext_spring/custom.py +++ b/src/spring/azext_spring/custom.py @@ -30,7 +30,7 @@ from azure.cli.core.azclierror import ClientRequestError, FileOperationError, InvalidArgumentValueError, ResourceNotFoundError from azure.cli.core.commands.client_factory import get_mgmt_service_client, get_subscription_id from azure.cli.core.util import sdk_no_wait -from azure.mgmt.applicationinsights import ApplicationInsightsManagementClient +from .vendored_sdks.applicationinsights import ApplicationInsightsManagementClient from azure.cli.core.commands import cached_put from azure.mgmt.core.tools import resource_id from ._resource_quantity import validate_cpu, validate_memory diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/__init__.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/__init__.py new file mode 100644 index 00000000000..da2ffef8661 --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/__init__.py @@ -0,0 +1,32 @@ +# 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. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._application_insights_management_client import ApplicationInsightsManagementClient # type: ignore +from ._version import VERSION + +__version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ApplicationInsightsManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore + +_patch_sdk() diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/_application_insights_management_client.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/_application_insights_management_client.py new file mode 100644 index 00000000000..33a85b2fc75 --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/_application_insights_management_client.py @@ -0,0 +1,222 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING, cast +from typing_extensions import Self + +from azure.core.pipeline import policies +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.settings import settings +from azure.mgmt.core import ARMPipelineClient +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy +from azure.mgmt.core.tools import get_arm_endpoints + +from . import models as _models +from ._configuration import ApplicationInsightsManagementClientConfiguration +from ._utils.serialization import Deserializer, Serializer +from .operations import ( + APIKeysOperations, + AnalyticsItemsOperations, + AnnotationsOperations, + ComponentAvailableFeaturesOperations, + ComponentCurrentBillingFeaturesOperations, + ComponentFeatureCapabilitiesOperations, + ComponentLinkedStorageAccountsOperations, + ComponentQuotaStatusOperations, + ComponentsOperations, + DeletedWorkbooksOperations, + ExportConfigurationsOperations, + FavoritesOperations, + LiveTokenOperations, + Operations, + ProactiveDetectionConfigurationsOperations, + WebTestLocationsOperations, + WebTestsOperations, + WorkItemConfigurationsOperations, + WorkbookTemplatesOperations, + WorkbooksOperations, +) + +if TYPE_CHECKING: + from azure.core.credentials import TokenCredential + + +class ApplicationInsightsManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes + """Composite Swagger for Application Insights Management Client. + + :ivar components: ComponentsOperations operations + :vartype components: azure.mgmt.applicationinsights.operations.ComponentsOperations + :ivar annotations: AnnotationsOperations operations + :vartype annotations: azure.mgmt.applicationinsights.operations.AnnotationsOperations + :ivar api_keys: APIKeysOperations operations + :vartype api_keys: azure.mgmt.applicationinsights.operations.APIKeysOperations + :ivar export_configurations: ExportConfigurationsOperations operations + :vartype export_configurations: + azure.mgmt.applicationinsights.operations.ExportConfigurationsOperations + :ivar component_current_billing_features: ComponentCurrentBillingFeaturesOperations operations + :vartype component_current_billing_features: + azure.mgmt.applicationinsights.operations.ComponentCurrentBillingFeaturesOperations + :ivar component_quota_status: ComponentQuotaStatusOperations operations + :vartype component_quota_status: + azure.mgmt.applicationinsights.operations.ComponentQuotaStatusOperations + :ivar component_feature_capabilities: ComponentFeatureCapabilitiesOperations operations + :vartype component_feature_capabilities: + azure.mgmt.applicationinsights.operations.ComponentFeatureCapabilitiesOperations + :ivar component_available_features: ComponentAvailableFeaturesOperations operations + :vartype component_available_features: + azure.mgmt.applicationinsights.operations.ComponentAvailableFeaturesOperations + :ivar proactive_detection_configurations: ProactiveDetectionConfigurationsOperations operations + :vartype proactive_detection_configurations: + azure.mgmt.applicationinsights.operations.ProactiveDetectionConfigurationsOperations + :ivar work_item_configurations: WorkItemConfigurationsOperations operations + :vartype work_item_configurations: + azure.mgmt.applicationinsights.operations.WorkItemConfigurationsOperations + :ivar favorites: FavoritesOperations operations + :vartype favorites: azure.mgmt.applicationinsights.operations.FavoritesOperations + :ivar web_test_locations: WebTestLocationsOperations operations + :vartype web_test_locations: + azure.mgmt.applicationinsights.operations.WebTestLocationsOperations + :ivar web_tests: WebTestsOperations operations + :vartype web_tests: azure.mgmt.applicationinsights.operations.WebTestsOperations + :ivar analytics_items: AnalyticsItemsOperations operations + :vartype analytics_items: azure.mgmt.applicationinsights.operations.AnalyticsItemsOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.applicationinsights.operations.Operations + :ivar workbook_templates: WorkbookTemplatesOperations operations + :vartype workbook_templates: + azure.mgmt.applicationinsights.operations.WorkbookTemplatesOperations + :ivar workbooks: WorkbooksOperations operations + :vartype workbooks: azure.mgmt.applicationinsights.operations.WorkbooksOperations + :ivar live_token: LiveTokenOperations operations + :vartype live_token: azure.mgmt.applicationinsights.operations.LiveTokenOperations + :ivar component_linked_storage_accounts: ComponentLinkedStorageAccountsOperations operations + :vartype component_linked_storage_accounts: + azure.mgmt.applicationinsights.operations.ComponentLinkedStorageAccountsOperations + :ivar deleted_workbooks: DeletedWorkbooksOperations operations + :vartype deleted_workbooks: + azure.mgmt.applicationinsights.operations.DeletedWorkbooksOperations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :param base_url: Service URL. Default value is None. + :type base_url: str + """ + + def __init__( + self, credential: "TokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any + ) -> None: + _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore + _endpoints = get_arm_endpoints(_cloud) + if not base_url: + base_url = _endpoints["resource_manager"] + credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) + self._config = ApplicationInsightsManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs + ) + + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + ARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, base_url), policies=_policies, **kwargs) + + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.components = ComponentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.annotations = AnnotationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.api_keys = APIKeysOperations(self._client, self._config, self._serialize, self._deserialize) + self.export_configurations = ExportConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.component_current_billing_features = ComponentCurrentBillingFeaturesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.component_quota_status = ComponentQuotaStatusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.component_feature_capabilities = ComponentFeatureCapabilitiesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.component_available_features = ComponentAvailableFeaturesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.proactive_detection_configurations = ProactiveDetectionConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.work_item_configurations = WorkItemConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.favorites = FavoritesOperations(self._client, self._config, self._serialize, self._deserialize) + self.web_test_locations = WebTestLocationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.web_tests = WebTestsOperations(self._client, self._config, self._serialize, self._deserialize) + self.analytics_items = AnalyticsItemsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.workbook_templates = WorkbookTemplatesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workbooks = WorkbooksOperations(self._client, self._config, self._serialize, self._deserialize) + self.live_token = LiveTokenOperations(self._client, self._config, self._serialize, self._deserialize) + self.component_linked_storage_accounts = ComponentLinkedStorageAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.deleted_workbooks = DeletedWorkbooksOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore + + def close(self) -> None: + self._client.close() + + def __enter__(self) -> Self: + self._client.__enter__() + return self + + def __exit__(self, *exc_details: Any) -> None: + self._client.__exit__(*exc_details) diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/_configuration.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/_configuration.py new file mode 100644 index 00000000000..5770b52de28 --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/_configuration.py @@ -0,0 +1,58 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + from azure.core.credentials import TokenCredential + + +class ApplicationInsightsManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long + """Configuration for ApplicationInsightsManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + """ + + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-applicationinsights/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) + self._configure(**kwargs) + + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") + if self.credential and not self.authentication_policy: + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/_patch.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/_patch.py new file mode 100644 index 00000000000..8bcb627aa47 --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/_patch.py @@ -0,0 +1,21 @@ +# 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. +# -------------------------------------------------------------------------- +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/_utils/__init__.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/_utils/__init__.py new file mode 100644 index 00000000000..0af9b28f660 --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/_utils/__init__.py @@ -0,0 +1,6 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/_utils/serialization.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/_utils/serialization.py new file mode 100644 index 00000000000..f5187701d7b --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/_utils/serialization.py @@ -0,0 +1,2032 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# 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. +# -------------------------------------------------------------------------- + +# pyright: reportUnnecessaryTypeIgnoreComment=false + +from base64 import b64decode, b64encode +import calendar +import datetime +import decimal +import email +from enum import Enum +import json +import logging +import re +import sys +import codecs +from typing import ( + Dict, + Any, + cast, + Optional, + Union, + AnyStr, + IO, + Mapping, + Callable, + MutableMapping, + List, +) + +try: + from urllib import quote # type: ignore +except ImportError: + from urllib.parse import quote +import xml.etree.ElementTree as ET + +import isodate # type: ignore +from typing_extensions import Self + +from azure.core.exceptions import DeserializationError, SerializationError +from azure.core.serialization import NULL as CoreNull + +_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") + +JSON = MutableMapping[str, Any] + + +class RawDeserializer: + + # Accept "text" because we're open minded people... + JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") + + # Name used in context + CONTEXT_NAME = "deserialized_data" + + @classmethod + def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: Optional[str] = None) -> Any: + """Decode data according to content-type. + + Accept a stream of data as well, but will be load at once in memory for now. + + If no content-type, will return the string version (not bytes, not stream) + + :param data: Input, could be bytes or stream (will be decoded with UTF8) or text + :type data: str or bytes or IO + :param str content_type: The content type. + :return: The deserialized data. + :rtype: object + """ + if hasattr(data, "read"): + # Assume a stream + data = cast(IO, data).read() + + if isinstance(data, bytes): + data_as_str = data.decode(encoding="utf-8-sig") + else: + # Explain to mypy the correct type. + data_as_str = cast(str, data) + + # Remove Byte Order Mark if present in string + data_as_str = data_as_str.lstrip(_BOM) + + if content_type is None: + return data + + if cls.JSON_REGEXP.match(content_type): + try: + return json.loads(data_as_str) + except ValueError as err: + raise DeserializationError("JSON is invalid: {}".format(err), err) from err + elif "xml" in (content_type or []): + try: + + try: + if isinstance(data, unicode): # type: ignore + # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string + data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore + except NameError: + pass + + return ET.fromstring(data_as_str) # nosec + except ET.ParseError as err: + # It might be because the server has an issue, and returned JSON with + # content-type XML.... + # So let's try a JSON load, and if it's still broken + # let's flow the initial exception + def _json_attemp(data): + try: + return True, json.loads(data) + except ValueError: + return False, None # Don't care about this one + + success, json_result = _json_attemp(data) + if success: + return json_result + # If i'm here, it's not JSON, it's not XML, let's scream + # and raise the last context in this block (the XML exception) + # The function hack is because Py2.7 messes up with exception + # context otherwise. + _LOGGER.critical("Wasn't XML not JSON, failing") + raise DeserializationError("XML is invalid") from err + elif content_type.startswith("text/"): + return data_as_str + raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) + + @classmethod + def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], headers: Mapping) -> Any: + """Deserialize from HTTP response. + + Use bytes and headers to NOT use any requests/aiohttp or whatever + specific implementation. + Headers will tested for "content-type" + + :param bytes body_bytes: The body of the response. + :param dict headers: The headers of the response. + :returns: The deserialized data. + :rtype: object + """ + # Try to use content-type from headers if available + content_type = None + if "content-type" in headers: + content_type = headers["content-type"].split(";")[0].strip().lower() + # Ouch, this server did not declare what it sent... + # Let's guess it's JSON... + # Also, since Autorest was considering that an empty body was a valid JSON, + # need that test as well.... + else: + content_type = "application/json" + + if body_bytes: + return cls.deserialize_from_text(body_bytes, content_type) + return None + + +_LOGGER = logging.getLogger(__name__) + +try: + _long_type = long # type: ignore +except NameError: + _long_type = int + +TZ_UTC = datetime.timezone.utc + +_FLATTEN = re.compile(r"(? None: + self.additional_properties: Optional[Dict[str, Any]] = {} + for k in kwargs: # pylint: disable=consider-using-dict-items + if k not in self._attribute_map: + _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) + elif k in self._validation and self._validation[k].get("readonly", False): + _LOGGER.warning("Readonly attribute %s will be ignored in class %s", k, self.__class__) + else: + setattr(self, k, kwargs[k]) + + def __eq__(self, other: Any) -> bool: + """Compare objects by comparing all attributes. + + :param object other: The object to compare + :returns: True if objects are equal + :rtype: bool + """ + if isinstance(other, self.__class__): + return self.__dict__ == other.__dict__ + return False + + def __ne__(self, other: Any) -> bool: + """Compare objects by comparing all attributes. + + :param object other: The object to compare + :returns: True if objects are not equal + :rtype: bool + """ + return not self.__eq__(other) + + def __str__(self) -> str: + return str(self.__dict__) + + @classmethod + def enable_additional_properties_sending(cls) -> None: + cls._attribute_map["additional_properties"] = {"key": "", "type": "{object}"} + + @classmethod + def is_xml_model(cls) -> bool: + try: + cls._xml_map # type: ignore + except AttributeError: + return False + return True + + @classmethod + def _create_xml_node(cls): + """Create XML node. + + :returns: The XML node + :rtype: xml.etree.ElementTree.Element + """ + try: + xml_map = cls._xml_map # type: ignore + except AttributeError: + xml_map = {} + + return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) + + def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: + """Return the JSON that would be sent to server from this model. + + This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. + + If you want XML serialization, you can pass the kwargs is_xml=True. + + :param bool keep_readonly: If you want to serialize the readonly attributes + :returns: A dict JSON compatible object + :rtype: dict + """ + serializer = Serializer(self._infer_class_models()) + return serializer._serialize( # type: ignore # pylint: disable=protected-access + self, keep_readonly=keep_readonly, **kwargs + ) + + def as_dict( + self, + keep_readonly: bool = True, + key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, + **kwargs: Any + ) -> JSON: + """Return a dict that can be serialized using json.dump. + + Advanced usage might optionally use a callback as parameter: + + .. code::python + + def my_key_transformer(key, attr_desc, value): + return key + + Key is the attribute name used in Python. Attr_desc + is a dict of metadata. Currently contains 'type' with the + msrest type and 'key' with the RestAPI encoded key. + Value is the current value in this object. + + The string returned will be used to serialize the key. + If the return type is a list, this is considered hierarchical + result dict. + + See the three examples in this file: + + - attribute_transformer + - full_restapi_key_transformer + - last_restapi_key_transformer + + If you want XML serialization, you can pass the kwargs is_xml=True. + + :param bool keep_readonly: If you want to serialize the readonly attributes + :param function key_transformer: A key transformer function. + :returns: A dict JSON compatible object + :rtype: dict + """ + serializer = Serializer(self._infer_class_models()) + return serializer._serialize( # type: ignore # pylint: disable=protected-access + self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs + ) + + @classmethod + def _infer_class_models(cls): + try: + str_models = cls.__module__.rsplit(".", 1)[0] + models = sys.modules[str_models] + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + if cls.__name__ not in client_models: + raise ValueError("Not Autorest generated code") + except Exception: # pylint: disable=broad-exception-caught + # Assume it's not Autorest generated (tests?). Add ourselves as dependencies. + client_models = {cls.__name__: cls} + return client_models + + @classmethod + def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self: + """Parse a str using the RestAPI syntax and return a model. + + :param str data: A str using RestAPI structure. JSON by default. + :param str content_type: JSON by default, set application/xml if XML. + :returns: An instance of this model + :raises DeserializationError: if something went wrong + :rtype: Self + """ + deserializer = Deserializer(cls._infer_class_models()) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore + + @classmethod + def from_dict( + cls, + data: Any, + key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, + content_type: Optional[str] = None, + ) -> Self: + """Parse a dict using given key extractor return a model. + + By default consider key + extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor + and last_rest_key_case_insensitive_extractor) + + :param dict data: A dict using RestAPI structure + :param function key_extractors: A key extractor function. + :param str content_type: JSON by default, set application/xml if XML. + :returns: An instance of this model + :raises DeserializationError: if something went wrong + :rtype: Self + """ + deserializer = Deserializer(cls._infer_class_models()) + deserializer.key_extractors = ( # type: ignore + [ # type: ignore + attribute_key_case_insensitive_extractor, + rest_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor, + ] + if key_extractors is None + else key_extractors + ) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore + + @classmethod + def _flatten_subtype(cls, key, objects): + if "_subtype_map" not in cls.__dict__: + return {} + result = dict(cls._subtype_map[key]) + for valuetype in cls._subtype_map[key].values(): + result.update(objects[valuetype]._flatten_subtype(key, objects)) # pylint: disable=protected-access + return result + + @classmethod + def _classify(cls, response, objects): + """Check the class _subtype_map for any child classes. + We want to ignore any inherited _subtype_maps. + + :param dict response: The initial data + :param dict objects: The class objects + :returns: The class to be used + :rtype: class + """ + for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): + subtype_value = None + + if not isinstance(response, ET.Element): + rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] + subtype_value = response.get(rest_api_response_key, None) or response.get(subtype_key, None) + else: + subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) + if subtype_value: + # Try to match base class. Can be class name only + # (bug to fix in Autorest to support x-ms-discriminator-name) + if cls.__name__ == subtype_value: + return cls + flatten_mapping_type = cls._flatten_subtype(subtype_key, objects) + try: + return objects[flatten_mapping_type[subtype_value]] # type: ignore + except KeyError: + _LOGGER.warning( + "Subtype value %s has no mapping, use base class %s.", + subtype_value, + cls.__name__, + ) + break + else: + _LOGGER.warning("Discriminator %s is absent or null, use base class %s.", subtype_key, cls.__name__) + break + return cls + + @classmethod + def _get_rest_key_parts(cls, attr_key): + """Get the RestAPI key of this attr, split it and decode part + :param str attr_key: Attribute key must be in attribute_map. + :returns: A list of RestAPI part + :rtype: list + """ + rest_split_key = _FLATTEN.split(cls._attribute_map[attr_key]["key"]) + return [_decode_attribute_map_key(key_part) for key_part in rest_split_key] + + +def _decode_attribute_map_key(key): + """This decode a key in an _attribute_map to the actual key we want to look at + inside the received data. + + :param str key: A key string from the generated code + :returns: The decoded key + :rtype: str + """ + return key.replace("\\.", ".") + + +class Serializer: # pylint: disable=too-many-public-methods + """Request object model serializer.""" + + basic_types = {str: "str", int: "int", bool: "bool", float: "float"} + + _xml_basic_types_serializers = {"bool": lambda x: str(x).lower()} + days = {0: "Mon", 1: "Tue", 2: "Wed", 3: "Thu", 4: "Fri", 5: "Sat", 6: "Sun"} + months = { + 1: "Jan", + 2: "Feb", + 3: "Mar", + 4: "Apr", + 5: "May", + 6: "Jun", + 7: "Jul", + 8: "Aug", + 9: "Sep", + 10: "Oct", + 11: "Nov", + 12: "Dec", + } + validation = { + "min_length": lambda x, y: len(x) < y, + "max_length": lambda x, y: len(x) > y, + "minimum": lambda x, y: x < y, + "maximum": lambda x, y: x > y, + "minimum_ex": lambda x, y: x <= y, + "maximum_ex": lambda x, y: x >= y, + "min_items": lambda x, y: len(x) < y, + "max_items": lambda x, y: len(x) > y, + "pattern": lambda x, y: not re.match(y, x, re.UNICODE), + "unique": lambda x, y: len(x) != len(set(x)), + "multiple": lambda x, y: x % y != 0, + } + + def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: + self.serialize_type = { + "iso-8601": Serializer.serialize_iso, + "rfc-1123": Serializer.serialize_rfc, + "unix-time": Serializer.serialize_unix, + "duration": Serializer.serialize_duration, + "date": Serializer.serialize_date, + "time": Serializer.serialize_time, + "decimal": Serializer.serialize_decimal, + "long": Serializer.serialize_long, + "bytearray": Serializer.serialize_bytearray, + "base64": Serializer.serialize_base64, + "object": self.serialize_object, + "[]": self.serialize_iter, + "{}": self.serialize_dict, + } + self.dependencies: Dict[str, type] = dict(classes) if classes else {} + self.key_transformer = full_restapi_key_transformer + self.client_side_validation = True + + def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, too-many-statements, too-many-locals + self, target_obj, data_type=None, **kwargs + ): + """Serialize data into a string according to type. + + :param object target_obj: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str, dict + :raises SerializationError: if serialization fails. + :returns: The serialized data. + """ + key_transformer = kwargs.get("key_transformer", self.key_transformer) + keep_readonly = kwargs.get("keep_readonly", False) + if target_obj is None: + return None + + attr_name = None + class_name = target_obj.__class__.__name__ + + if data_type: + return self.serialize_data(target_obj, data_type, **kwargs) + + if not hasattr(target_obj, "_attribute_map"): + data_type = type(target_obj).__name__ + if data_type in self.basic_types.values(): + return self.serialize_data(target_obj, data_type, **kwargs) + + # Force "is_xml" kwargs if we detect a XML model + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) + + serialized = {} + if is_xml_model_serialization: + serialized = target_obj._create_xml_node() # pylint: disable=protected-access + try: + attributes = target_obj._attribute_map # pylint: disable=protected-access + for attr, attr_desc in attributes.items(): + attr_name = attr + if not keep_readonly and target_obj._validation.get( # pylint: disable=protected-access + attr_name, {} + ).get("readonly", False): + continue + + if attr_name == "additional_properties" and attr_desc["key"] == "": + if target_obj.additional_properties is not None: + serialized.update(target_obj.additional_properties) + continue + try: + + orig_attr = getattr(target_obj, attr) + if is_xml_model_serialization: + pass # Don't provide "transformer" for XML for now. Keep "orig_attr" + else: # JSON + keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) + keys = keys if isinstance(keys, list) else [keys] + + kwargs["serialization_ctxt"] = attr_desc + new_attr = self.serialize_data(orig_attr, attr_desc["type"], **kwargs) + + if is_xml_model_serialization: + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + xml_prefix = xml_desc.get("prefix", None) + xml_ns = xml_desc.get("ns", None) + if xml_desc.get("attr", False): + if xml_ns: + ET.register_namespace(xml_prefix, xml_ns) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) + serialized.set(xml_name, new_attr) # type: ignore + continue + if xml_desc.get("text", False): + serialized.text = new_attr # type: ignore + continue + if isinstance(new_attr, list): + serialized.extend(new_attr) # type: ignore + elif isinstance(new_attr, ET.Element): + # If the down XML has no XML/Name, + # we MUST replace the tag with the local tag. But keeping the namespaces. + if "name" not in getattr(orig_attr, "_xml_map", {}): + splitted_tag = new_attr.tag.split("}") + if len(splitted_tag) == 2: # Namespace + new_attr.tag = "}".join([splitted_tag[0], xml_name]) + else: + new_attr.tag = xml_name + serialized.append(new_attr) # type: ignore + else: # That's a basic type + # Integrate namespace if necessary + local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) + local_node.text = str(new_attr) + serialized.append(local_node) # type: ignore + else: # JSON + for k in reversed(keys): # type: ignore + new_attr = {k: new_attr} + + _new_attr = new_attr + _serialized = serialized + for k in keys: # type: ignore + if k not in _serialized: + _serialized.update(_new_attr) # type: ignore + _new_attr = _new_attr[k] # type: ignore + _serialized = _serialized[k] + except ValueError as err: + if isinstance(err, SerializationError): + raise + + except (AttributeError, KeyError, TypeError) as err: + msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) + raise SerializationError(msg) from err + return serialized + + def body(self, data, data_type, **kwargs): + """Serialize data intended for a request body. + + :param object data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: dict + :raises SerializationError: if serialization fails. + :raises ValueError: if data is None + :returns: The serialized request body + """ + + # Just in case this is a dict + internal_data_type_str = data_type.strip("[]{}") + internal_data_type = self.dependencies.get(internal_data_type_str, None) + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + if internal_data_type and issubclass(internal_data_type, Model): + is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) + else: + is_xml_model_serialization = False + if internal_data_type and not isinstance(internal_data_type, Enum): + try: + deserializer = Deserializer(self.dependencies) + # Since it's on serialization, it's almost sure that format is not JSON REST + # We're not able to deal with additional properties for now. + deserializer.additional_properties_detection = False + if is_xml_model_serialization: + deserializer.key_extractors = [ # type: ignore + attribute_key_case_insensitive_extractor, + ] + else: + deserializer.key_extractors = [ + rest_key_case_insensitive_extractor, + attribute_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor, + ] + data = deserializer._deserialize(data_type, data) # pylint: disable=protected-access + except DeserializationError as err: + raise SerializationError("Unable to build a model: " + str(err)) from err + + return self._serialize(data, data_type, **kwargs) + + def url(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL path. + + :param str name: The name of the URL path parameter. + :param object data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :returns: The serialized URL path + :raises TypeError: if serialization fails. + :raises ValueError: if data is None + """ + try: + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + + if kwargs.get("skip_quote") is True: + output = str(output) + output = output.replace("{", quote("{")).replace("}", quote("}")) + else: + output = quote(str(output), safe="") + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return output + + def query(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL query. + + :param str name: The name of the query parameter. + :param object data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str, list + :raises TypeError: if serialization fails. + :raises ValueError: if data is None + :returns: The serialized query parameter + """ + try: + # Treat the list aside, since we don't want to encode the div separator + if data_type.startswith("["): + internal_data_type = data_type[1:-1] + do_quote = not kwargs.get("skip_quote", False) + return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) + + # Not a list, regular serialization + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + if kwargs.get("skip_quote") is True: + output = str(output) + else: + output = quote(str(output), safe="") + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return str(output) + + def header(self, name, data, data_type, **kwargs): + """Serialize data intended for a request header. + + :param str name: The name of the header. + :param object data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises TypeError: if serialization fails. + :raises ValueError: if data is None + :returns: The serialized header + """ + try: + if data_type in ["[str]"]: + data = ["" if d is None else d for d in data] + + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return str(output) + + def serialize_data(self, data, data_type, **kwargs): + """Serialize generic data according to supplied data type. + + :param object data: The data to be serialized. + :param str data_type: The type to be serialized from. + :raises AttributeError: if required data is None. + :raises ValueError: if data is None + :raises SerializationError: if serialization fails. + :returns: The serialized data. + :rtype: str, int, float, bool, dict, list + """ + if data is None: + raise ValueError("No value for given attribute") + + try: + if data is CoreNull: + return None + if data_type in self.basic_types.values(): + return self.serialize_basic(data, data_type, **kwargs) + + if data_type in self.serialize_type: + return self.serialize_type[data_type](data, **kwargs) + + # If dependencies is empty, try with current data class + # It has to be a subclass of Enum anyway + enum_type = self.dependencies.get(data_type, data.__class__) + if issubclass(enum_type, Enum): + return Serializer.serialize_enum(data, enum_obj=enum_type) + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.serialize_type: + return self.serialize_type[iter_type](data, data_type[1:-1], **kwargs) + + except (ValueError, TypeError) as err: + msg = "Unable to serialize value: {!r} as type: {!r}." + raise SerializationError(msg.format(data, data_type)) from err + return self._serialize(data, **kwargs) + + @classmethod + def _get_custom_serializers(cls, data_type, **kwargs): # pylint: disable=inconsistent-return-statements + custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) + if custom_serializer: + return custom_serializer + if kwargs.get("is_xml", False): + return cls._xml_basic_types_serializers.get(data_type) + + @classmethod + def serialize_basic(cls, data, data_type, **kwargs): + """Serialize basic builting data type. + Serializes objects to str, int, float or bool. + + Possible kwargs: + - basic_types_serializers dict[str, callable] : If set, use the callable as serializer + - is_xml bool : If set, use xml_basic_types_serializers + + :param obj data: Object to be serialized. + :param str data_type: Type of object in the iterable. + :rtype: str, int, float, bool + :return: serialized object + """ + custom_serializer = cls._get_custom_serializers(data_type, **kwargs) + if custom_serializer: + return custom_serializer(data) + if data_type == "str": + return cls.serialize_unicode(data) + return eval(data_type)(data) # nosec # pylint: disable=eval-used + + @classmethod + def serialize_unicode(cls, data): + """Special handling for serializing unicode strings in Py2. + Encode to UTF-8 if unicode, otherwise handle as a str. + + :param str data: Object to be serialized. + :rtype: str + :return: serialized object + """ + try: # If I received an enum, return its value + return data.value + except AttributeError: + pass + + try: + if isinstance(data, unicode): # type: ignore + # Don't change it, JSON and XML ElementTree are totally able + # to serialize correctly u'' strings + return data + except NameError: + return str(data) + return str(data) + + def serialize_iter(self, data, iter_type, div=None, **kwargs): + """Serialize iterable. + + Supported kwargs: + - serialization_ctxt dict : The current entry of _attribute_map, or same format. + serialization_ctxt['type'] should be same as data_type. + - is_xml bool : If set, serialize as XML + + :param list data: Object to be serialized. + :param str iter_type: Type of object in the iterable. + :param str div: If set, this str will be used to combine the elements + in the iterable into a combined string. Default is 'None'. + Defaults to False. + :rtype: list, str + :return: serialized iterable + """ + if isinstance(data, str): + raise SerializationError("Refuse str type as a valid iter type.") + + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + is_xml = kwargs.get("is_xml", False) + + serialized = [] + for d in data: + try: + serialized.append(self.serialize_data(d, iter_type, **kwargs)) + except ValueError as err: + if isinstance(err, SerializationError): + raise + serialized.append(None) + + if kwargs.get("do_quote", False): + serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] + + if div: + serialized = ["" if s is None else str(s) for s in serialized] + serialized = div.join(serialized) + + if "xml" in serialization_ctxt or is_xml: + # XML serialization is more complicated + xml_desc = serialization_ctxt.get("xml", {}) + xml_name = xml_desc.get("name") + if not xml_name: + xml_name = serialization_ctxt["key"] + + # Create a wrap node if necessary (use the fact that Element and list have "append") + is_wrapped = xml_desc.get("wrapped", False) + node_name = xml_desc.get("itemsName", xml_name) + if is_wrapped: + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + else: + final_result = [] + # All list elements to "local_node" + for el in serialized: + if isinstance(el, ET.Element): + el_node = el + else: + el_node = _create_xml_node(node_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + if el is not None: # Otherwise it writes "None" :-p + el_node.text = str(el) + final_result.append(el_node) + return final_result + return serialized + + def serialize_dict(self, attr, dict_type, **kwargs): + """Serialize a dictionary of objects. + + :param dict attr: Object to be serialized. + :param str dict_type: Type of object in the dictionary. + :rtype: dict + :return: serialized dictionary + """ + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) + except ValueError as err: + if isinstance(err, SerializationError): + raise + serialized[self.serialize_unicode(key)] = None + + if "xml" in serialization_ctxt: + # XML serialization is more complicated + xml_desc = serialization_ctxt["xml"] + xml_name = xml_desc["name"] + + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + for key, value in serialized.items(): + ET.SubElement(final_result, key).text = value + return final_result + + return serialized + + def serialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements + """Serialize a generic object. + This will be handled as a dictionary. If object passed in is not + a basic type (str, int, float, dict, list) it will simply be + cast to str. + + :param dict attr: Object to be serialized. + :rtype: dict or str + :return: serialized object + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + return attr + obj_type = type(attr) + if obj_type in self.basic_types: + return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) + if obj_type is _long_type: + return self.serialize_long(attr) + if obj_type is str: + return self.serialize_unicode(attr) + if obj_type is datetime.datetime: + return self.serialize_iso(attr) + if obj_type is datetime.date: + return self.serialize_date(attr) + if obj_type is datetime.time: + return self.serialize_time(attr) + if obj_type is datetime.timedelta: + return self.serialize_duration(attr) + if obj_type is decimal.Decimal: + return self.serialize_decimal(attr) + + # If it's a model or I know this dependency, serialize as a Model + if obj_type in self.dependencies.values() or isinstance(attr, Model): + return self._serialize(attr) + + if obj_type == dict: + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_object(value, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + return serialized + + if obj_type == list: + serialized = [] + for obj in attr: + try: + serialized.append(self.serialize_object(obj, **kwargs)) + except ValueError: + pass + return serialized + return str(attr) + + @staticmethod + def serialize_enum(attr, enum_obj=None): + try: + result = attr.value + except AttributeError: + result = attr + try: + enum_obj(result) # type: ignore + return result + except ValueError as exc: + for enum_value in enum_obj: # type: ignore + if enum_value.value.lower() == str(attr).lower(): + return enum_value.value + error = "{!r} is not valid value for enum {!r}" + raise SerializationError(error.format(attr, enum_obj)) from exc + + @staticmethod + def serialize_bytearray(attr, **kwargs): # pylint: disable=unused-argument + """Serialize bytearray into base-64 string. + + :param str attr: Object to be serialized. + :rtype: str + :return: serialized base64 + """ + return b64encode(attr).decode() + + @staticmethod + def serialize_base64(attr, **kwargs): # pylint: disable=unused-argument + """Serialize str into base-64 string. + + :param str attr: Object to be serialized. + :rtype: str + :return: serialized base64 + """ + encoded = b64encode(attr).decode("ascii") + return encoded.strip("=").replace("+", "-").replace("/", "_") + + @staticmethod + def serialize_decimal(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Decimal object to float. + + :param decimal attr: Object to be serialized. + :rtype: float + :return: serialized decimal + """ + return float(attr) + + @staticmethod + def serialize_long(attr, **kwargs): # pylint: disable=unused-argument + """Serialize long (Py2) or int (Py3). + + :param int attr: Object to be serialized. + :rtype: int/long + :return: serialized long + """ + return _long_type(attr) + + @staticmethod + def serialize_date(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Date object into ISO-8601 formatted string. + + :param Date attr: Object to be serialized. + :rtype: str + :return: serialized date + """ + if isinstance(attr, str): + attr = isodate.parse_date(attr) + t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) + return t + + @staticmethod + def serialize_time(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Time object into ISO-8601 formatted string. + + :param datetime.time attr: Object to be serialized. + :rtype: str + :return: serialized time + """ + if isinstance(attr, str): + attr = isodate.parse_time(attr) + t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) + if attr.microsecond: + t += ".{:02}".format(attr.microsecond) + return t + + @staticmethod + def serialize_duration(attr, **kwargs): # pylint: disable=unused-argument + """Serialize TimeDelta object into ISO-8601 formatted string. + + :param TimeDelta attr: Object to be serialized. + :rtype: str + :return: serialized duration + """ + if isinstance(attr, str): + attr = isodate.parse_duration(attr) + return isodate.duration_isoformat(attr) + + @staticmethod + def serialize_rfc(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Datetime object into RFC-1123 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises TypeError: if format invalid. + :return: serialized rfc + """ + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + except AttributeError as exc: + raise TypeError("RFC1123 object must be valid Datetime object.") from exc + + return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( + Serializer.days[utc.tm_wday], + utc.tm_mday, + Serializer.months[utc.tm_mon], + utc.tm_year, + utc.tm_hour, + utc.tm_min, + utc.tm_sec, + ) + + @staticmethod + def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Datetime object into ISO-8601 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises SerializationError: if format invalid. + :return: serialized iso + """ + if isinstance(attr, str): + attr = isodate.parse_datetime(attr) + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + if utc.tm_year > 9999 or utc.tm_year < 1: + raise OverflowError("Hit max or min date") + + microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") + if microseconds: + microseconds = "." + microseconds + date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( + utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec + ) + return date + microseconds + "Z" + except (ValueError, OverflowError) as err: + msg = "Unable to serialize datetime object." + raise SerializationError(msg) from err + except AttributeError as err: + msg = "ISO-8601 object must be valid Datetime object." + raise TypeError(msg) from err + + @staticmethod + def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param Datetime attr: Object to be serialized. + :rtype: int + :raises SerializationError: if format invalid + :return: serialied unix + """ + if isinstance(attr, int): + return attr + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + return int(calendar.timegm(attr.utctimetuple())) + except AttributeError as exc: + raise TypeError("Unix time object must be valid Datetime object.") from exc + + +def rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument + key = attr_desc["key"] + working_data = data + + while "." in key: + # Need the cast, as for some reasons "split" is typed as list[str | Any] + dict_keys = cast(List[str], _FLATTEN.split(key)) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = working_data.get(working_key, data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + return None + key = ".".join(dict_keys[1:]) + + return working_data.get(key) + + +def rest_key_case_insensitive_extractor( # pylint: disable=unused-argument, inconsistent-return-statements + attr, attr_desc, data +): + key = attr_desc["key"] + working_data = data + + while "." in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + return None + key = ".".join(dict_keys[1:]) + + if working_data: + return attribute_key_case_insensitive_extractor(key, None, working_data) + + +def last_rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument + """Extract the attribute in "data" based on the last part of the JSON path key. + + :param str attr: The attribute to extract + :param dict attr_desc: The attribute description + :param dict data: The data to extract from + :rtype: object + :returns: The extracted attribute + """ + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_extractor(dict_keys[-1], None, data) + + +def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): # pylint: disable=unused-argument + """Extract the attribute in "data" based on the last part of the JSON path key. + + This is the case insensitive version of "last_rest_key_extractor" + :param str attr: The attribute to extract + :param dict attr_desc: The attribute description + :param dict data: The data to extract from + :rtype: object + :returns: The extracted attribute + """ + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) + + +def attribute_key_extractor(attr, _, data): + return data.get(attr) + + +def attribute_key_case_insensitive_extractor(attr, _, data): + found_key = None + lower_attr = attr.lower() + for key in data: + if lower_attr == key.lower(): + found_key = key + break + + return data.get(found_key) + + +def _extract_name_from_internal_type(internal_type): + """Given an internal type XML description, extract correct XML name with namespace. + + :param dict internal_type: An model type + :rtype: tuple + :returns: A tuple XML name + namespace dict + """ + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + xml_name = internal_type_xml_map.get("name", internal_type.__name__) + xml_ns = internal_type_xml_map.get("ns", None) + if xml_ns: + xml_name = "{{{}}}{}".format(xml_ns, xml_name) + return xml_name + + +def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument,too-many-return-statements + if isinstance(data, dict): + return None + + # Test if this model is XML ready first + if not isinstance(data, ET.Element): + return None + + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + + # Look for a children + is_iter_type = attr_desc["type"].startswith("[") + is_wrapped = xml_desc.get("wrapped", False) + internal_type = attr_desc.get("internalType", None) + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + + # Integrate namespace if necessary + xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) + if xml_ns: + xml_name = "{{{}}}{}".format(xml_ns, xml_name) + + # If it's an attribute, that's simple + if xml_desc.get("attr", False): + return data.get(xml_name) + + # If it's x-ms-text, that's simple too + if xml_desc.get("text", False): + return data.text + + # Scenario where I take the local name: + # - Wrapped node + # - Internal type is an enum (considered basic types) + # - Internal type has no XML/Name node + if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or "name" not in internal_type_xml_map)): + children = data.findall(xml_name) + # If internal type has a local name and it's not a list, I use that name + elif not is_iter_type and internal_type and "name" in internal_type_xml_map: + xml_name = _extract_name_from_internal_type(internal_type) + children = data.findall(xml_name) + # That's an array + else: + if internal_type: # Complex type, ignore itemsName and use the complex type name + items_name = _extract_name_from_internal_type(internal_type) + else: + items_name = xml_desc.get("itemsName", xml_name) + children = data.findall(items_name) + + if len(children) == 0: + if is_iter_type: + if is_wrapped: + return None # is_wrapped no node, we want None + return [] # not wrapped, assume empty list + return None # Assume it's not there, maybe an optional node. + + # If is_iter_type and not wrapped, return all found children + if is_iter_type: + if not is_wrapped: + return children + # Iter and wrapped, should have found one node only (the wrap one) + if len(children) != 1: + raise DeserializationError( + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( + xml_name + ) + ) + return list(children[0]) # Might be empty list and that's ok. + + # Here it's not a itertype, we should have found one element only or empty + if len(children) > 1: + raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) + return children[0] + + +class Deserializer: + """Response object model deserializer. + + :param dict classes: Class type dictionary for deserializing complex types. + :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. + """ + + basic_types = {str: "str", int: "int", bool: "bool", float: "float"} + + valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") + + def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: + self.deserialize_type = { + "iso-8601": Deserializer.deserialize_iso, + "rfc-1123": Deserializer.deserialize_rfc, + "unix-time": Deserializer.deserialize_unix, + "duration": Deserializer.deserialize_duration, + "date": Deserializer.deserialize_date, + "time": Deserializer.deserialize_time, + "decimal": Deserializer.deserialize_decimal, + "long": Deserializer.deserialize_long, + "bytearray": Deserializer.deserialize_bytearray, + "base64": Deserializer.deserialize_base64, + "object": self.deserialize_object, + "[]": self.deserialize_iter, + "{}": self.deserialize_dict, + } + self.deserialize_expected_types = { + "duration": (isodate.Duration, datetime.timedelta), + "iso-8601": (datetime.datetime), + } + self.dependencies: Dict[str, type] = dict(classes) if classes else {} + self.key_extractors = [rest_key_extractor, xml_key_extractor] + # Additional properties only works if the "rest_key_extractor" is used to + # extract the keys. Making it to work whatever the key extractor is too much + # complicated, with no real scenario for now. + # So adding a flag to disable additional properties detection. This flag should be + # used if your expect the deserialization to NOT come from a JSON REST syntax. + # Otherwise, result are unexpected + self.additional_properties_detection = True + + def __call__(self, target_obj, response_data, content_type=None): + """Call the deserializer to process a REST response. + + :param str target_obj: Target data type to deserialize to. + :param requests.Response response_data: REST response object. + :param str content_type: Swagger "produces" if available. + :raises DeserializationError: if deserialization fails. + :return: Deserialized object. + :rtype: object + """ + data = self._unpack_content(response_data, content_type) + return self._deserialize(target_obj, data) + + def _deserialize(self, target_obj, data): # pylint: disable=inconsistent-return-statements + """Call the deserializer on a model. + + Data needs to be already deserialized as JSON or XML ElementTree + + :param str target_obj: Target data type to deserialize to. + :param object data: Object to deserialize. + :raises DeserializationError: if deserialization fails. + :return: Deserialized object. + :rtype: object + """ + # This is already a model, go recursive just in case + if hasattr(data, "_attribute_map"): + constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] + try: + for attr, mapconfig in data._attribute_map.items(): # pylint: disable=protected-access + if attr in constants: + continue + value = getattr(data, attr) + if value is None: + continue + local_type = mapconfig["type"] + internal_data_type = local_type.strip("[]{}") + if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): + continue + setattr(data, attr, self._deserialize(local_type, value)) + return data + except AttributeError: + return + + response, class_name = self._classify_target(target_obj, data) + + if isinstance(response, str): + return self.deserialize_data(data, response) + if isinstance(response, type) and issubclass(response, Enum): + return self.deserialize_enum(data, response) + + if data is None or data is CoreNull: + return data + try: + attributes = response._attribute_map # type: ignore # pylint: disable=protected-access + d_attrs = {} + for attr, attr_desc in attributes.items(): + # Check empty string. If it's not empty, someone has a real "additionalProperties"... + if attr == "additional_properties" and attr_desc["key"] == "": + continue + raw_value = None + # Enhance attr_desc with some dynamic data + attr_desc = attr_desc.copy() # Do a copy, do not change the real one + internal_data_type = attr_desc["type"].strip("[]{}") + if internal_data_type in self.dependencies: + attr_desc["internalType"] = self.dependencies[internal_data_type] + + for key_extractor in self.key_extractors: + found_value = key_extractor(attr, attr_desc, data) + if found_value is not None: + if raw_value is not None and raw_value != found_value: + msg = ( + "Ignoring extracted value '%s' from %s for key '%s'" + " (duplicate extraction, follow extractors order)" + ) + _LOGGER.warning(msg, found_value, key_extractor, attr) + continue + raw_value = found_value + + value = self.deserialize_data(raw_value, attr_desc["type"]) + d_attrs[attr] = value + except (AttributeError, TypeError, KeyError) as err: + msg = "Unable to deserialize to object: " + class_name # type: ignore + raise DeserializationError(msg) from err + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) + + def _build_additional_properties(self, attribute_map, data): + if not self.additional_properties_detection: + return None + if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != "": + # Check empty string. If it's not empty, someone has a real "additionalProperties" + return None + if isinstance(data, ET.Element): + data = {el.tag: el.text for el in data} + + known_keys = { + _decode_attribute_map_key(_FLATTEN.split(desc["key"])[0]) + for desc in attribute_map.values() + if desc["key"] != "" + } + present_keys = set(data.keys()) + missing_keys = present_keys - known_keys + return {key: data[key] for key in missing_keys} + + def _classify_target(self, target, data): + """Check to see whether the deserialization target object can + be classified into a subclass. + Once classification has been determined, initialize object. + + :param str target: The target object type to deserialize to. + :param str/dict data: The response data to deserialize. + :return: The classified target object and its class name. + :rtype: tuple + """ + if target is None: + return None, None + + if isinstance(target, str): + try: + target = self.dependencies[target] + except KeyError: + return target, target + + try: + target = target._classify(data, self.dependencies) # type: ignore # pylint: disable=protected-access + except AttributeError: + pass # Target is not a Model, no classify + return target, target.__class__.__name__ # type: ignore + + def failsafe_deserialize(self, target_obj, data, content_type=None): + """Ignores any errors encountered in deserialization, + and falls back to not deserializing the object. Recommended + for use in error deserialization, as we want to return the + HttpResponseError to users, and not have them deal with + a deserialization error. + + :param str target_obj: The target object type to deserialize to. + :param str/dict data: The response data to deserialize. + :param str content_type: Swagger "produces" if available. + :return: Deserialized object. + :rtype: object + """ + try: + return self(target_obj, data, content_type=content_type) + except: # pylint: disable=bare-except + _LOGGER.debug( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + @staticmethod + def _unpack_content(raw_data, content_type=None): + """Extract the correct structure for deserialization. + + If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. + if we can't, raise. Your Pipeline should have a RawDeserializer. + + If not a pipeline response and raw_data is bytes or string, use content-type + to decode it. If no content-type, try JSON. + + If raw_data is something else, bypass all logic and return it directly. + + :param obj raw_data: Data to be processed. + :param str content_type: How to parse if raw_data is a string/bytes. + :raises JSONDecodeError: If JSON is requested and parsing is impossible. + :raises UnicodeDecodeError: If bytes is not UTF8 + :rtype: object + :return: Unpacked content. + """ + # Assume this is enough to detect a Pipeline Response without importing it + context = getattr(raw_data, "context", {}) + if context: + if RawDeserializer.CONTEXT_NAME in context: + return context[RawDeserializer.CONTEXT_NAME] + raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") + + # Assume this is enough to recognize universal_http.ClientResponse without importing it + if hasattr(raw_data, "body"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) + + # Assume this enough to recognize requests.Response without importing it. + if hasattr(raw_data, "_content_consumed"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) + + if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): + return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore + return raw_data + + def _instantiate_model(self, response, attrs, additional_properties=None): + """Instantiate a response model passing in deserialized args. + + :param Response response: The response model class. + :param dict attrs: The deserialized response attributes. + :param dict additional_properties: Additional properties to be set. + :rtype: Response + :return: The instantiated response model. + """ + if callable(response): + subtype = getattr(response, "_subtype_map", {}) + try: + readonly = [ + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + if v.get("readonly") + ] + const = [ + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + if v.get("constant") + ] + kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} + response_obj = response(**kwargs) + for attr in readonly: + setattr(response_obj, attr, attrs.get(attr)) + if additional_properties: + response_obj.additional_properties = additional_properties # type: ignore + return response_obj + except TypeError as err: + msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore + raise DeserializationError(msg + str(err)) from err + else: + try: + for attr, value in attrs.items(): + setattr(response, attr, value) + return response + except Exception as exp: + msg = "Unable to populate response model. " + msg += "Type: {}, Error: {}".format(type(response), exp) + raise DeserializationError(msg) from exp + + def deserialize_data(self, data, data_type): # pylint: disable=too-many-return-statements + """Process data for deserialization according to data type. + + :param str data: The response string to be deserialized. + :param str data_type: The type to deserialize to. + :raises DeserializationError: if deserialization fails. + :return: Deserialized object. + :rtype: object + """ + if data is None: + return data + + try: + if not data_type: + return data + if data_type in self.basic_types.values(): + return self.deserialize_basic(data, data_type) + if data_type in self.deserialize_type: + if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): + return data + + is_a_text_parsing_type = lambda x: x not in [ # pylint: disable=unnecessary-lambda-assignment + "object", + "[]", + r"{}", + ] + if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: + return None + data_val = self.deserialize_type[data_type](data) + return data_val + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.deserialize_type: + return self.deserialize_type[iter_type](data, data_type[1:-1]) + + obj_type = self.dependencies[data_type] + if issubclass(obj_type, Enum): + if isinstance(data, ET.Element): + data = data.text + return self.deserialize_enum(data, obj_type) + + except (ValueError, TypeError, AttributeError) as err: + msg = "Unable to deserialize response data." + msg += " Data: {}, {}".format(data, data_type) + raise DeserializationError(msg) from err + return self._deserialize(obj_type, data) + + def deserialize_iter(self, attr, iter_type): + """Deserialize an iterable. + + :param list attr: Iterable to be deserialized. + :param str iter_type: The type of object in the iterable. + :return: Deserialized iterable. + :rtype: list + """ + if attr is None: + return None + if isinstance(attr, ET.Element): # If I receive an element here, get the children + attr = list(attr) + if not isinstance(attr, (list, set)): + raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(iter_type, type(attr))) + return [self.deserialize_data(a, iter_type) for a in attr] + + def deserialize_dict(self, attr, dict_type): + """Deserialize a dictionary. + + :param dict/list attr: Dictionary to be deserialized. Also accepts + a list of key, value pairs. + :param str dict_type: The object type of the items in the dictionary. + :return: Deserialized dictionary. + :rtype: dict + """ + if isinstance(attr, list): + return {x["key"]: self.deserialize_data(x["value"], dict_type) for x in attr} + + if isinstance(attr, ET.Element): + # Transform value into {"Key": "value"} + attr = {el.tag: el.text for el in attr} + return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} + + def deserialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements + """Deserialize a generic object. + This will be handled as a dictionary. + + :param dict attr: Dictionary to be deserialized. + :return: Deserialized object. + :rtype: dict + :raises TypeError: if non-builtin datatype encountered. + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + # Do no recurse on XML, just return the tree as-is + return attr + if isinstance(attr, str): + return self.deserialize_basic(attr, "str") + obj_type = type(attr) + if obj_type in self.basic_types: + return self.deserialize_basic(attr, self.basic_types[obj_type]) + if obj_type is _long_type: + return self.deserialize_long(attr) + + if obj_type == dict: + deserialized = {} + for key, value in attr.items(): + try: + deserialized[key] = self.deserialize_object(value, **kwargs) + except ValueError: + deserialized[key] = None + return deserialized + + if obj_type == list: + deserialized = [] + for obj in attr: + try: + deserialized.append(self.deserialize_object(obj, **kwargs)) + except ValueError: + pass + return deserialized + + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) + + def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return-statements + """Deserialize basic builtin data type from string. + Will attempt to convert to str, int, float and bool. + This function will also accept '1', '0', 'true' and 'false' as + valid bool values. + + :param str attr: response string to be deserialized. + :param str data_type: deserialization data type. + :return: Deserialized basic type. + :rtype: str, int, float or bool + :raises TypeError: if string format is not valid. + """ + # If we're here, data is supposed to be a basic type. + # If it's still an XML node, take the text + if isinstance(attr, ET.Element): + attr = attr.text + if not attr: + if data_type == "str": + # None or '', node is empty string. + return "" + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None + + if data_type == "bool": + if attr in [True, False, 1, 0]: + return bool(attr) + if isinstance(attr, str): + if attr.lower() in ["true", "1"]: + return True + if attr.lower() in ["false", "0"]: + return False + raise TypeError("Invalid boolean value: {}".format(attr)) + + if data_type == "str": + return self.deserialize_unicode(attr) + return eval(data_type)(attr) # nosec # pylint: disable=eval-used + + @staticmethod + def deserialize_unicode(data): + """Preserve unicode objects in Python 2, otherwise return data + as a string. + + :param str data: response string to be deserialized. + :return: Deserialized string. + :rtype: str or unicode + """ + # We might be here because we have an enum modeled as string, + # and we try to deserialize a partial dict with enum inside + if isinstance(data, Enum): + return data + + # Consider this is real string + try: + if isinstance(data, unicode): # type: ignore + return data + except NameError: + return str(data) + return str(data) + + @staticmethod + def deserialize_enum(data, enum_obj): + """Deserialize string into enum object. + + If the string is not a valid enum value it will be returned as-is + and a warning will be logged. + + :param str data: Response string to be deserialized. If this value is + None or invalid it will be returned as-is. + :param Enum enum_obj: Enum object to deserialize to. + :return: Deserialized enum object. + :rtype: Enum + """ + if isinstance(data, enum_obj) or data is None: + return data + if isinstance(data, Enum): + data = data.value + if isinstance(data, int): + # Workaround. We might consider remove it in the future. + try: + return list(enum_obj.__members__.values())[data] + except IndexError as exc: + error = "{!r} is not a valid index for enum {!r}" + raise DeserializationError(error.format(data, enum_obj)) from exc + try: + return enum_obj(str(data)) + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(data).lower(): + return enum_value + # We don't fail anymore for unknown value, we deserialize as a string + _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) + return Deserializer.deserialize_unicode(data) + + @staticmethod + def deserialize_bytearray(attr): + """Deserialize string into bytearray. + + :param str attr: response string to be deserialized. + :return: Deserialized bytearray + :rtype: bytearray + :raises TypeError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return bytearray(b64decode(attr)) # type: ignore + + @staticmethod + def deserialize_base64(attr): + """Deserialize base64 encoded string into string. + + :param str attr: response string to be deserialized. + :return: Deserialized base64 string + :rtype: bytearray + :raises TypeError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore + attr = attr + padding # type: ignore + encoded = attr.replace("-", "+").replace("_", "/") + return b64decode(encoded) + + @staticmethod + def deserialize_decimal(attr): + """Deserialize string into Decimal object. + + :param str attr: response string to be deserialized. + :return: Deserialized decimal + :raises DeserializationError: if string format invalid. + :rtype: decimal + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + return decimal.Decimal(str(attr)) # type: ignore + except decimal.DecimalException as err: + msg = "Invalid decimal {}".format(attr) + raise DeserializationError(msg) from err + + @staticmethod + def deserialize_long(attr): + """Deserialize string into long (Py2) or int (Py3). + + :param str attr: response string to be deserialized. + :return: Deserialized int + :rtype: long or int + :raises ValueError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return _long_type(attr) # type: ignore + + @staticmethod + def deserialize_duration(attr): + """Deserialize ISO-8601 formatted string into TimeDelta object. + + :param str attr: response string to be deserialized. + :return: Deserialized duration + :rtype: TimeDelta + :raises DeserializationError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + duration = isodate.parse_duration(attr) + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize duration object." + raise DeserializationError(msg) from err + return duration + + @staticmethod + def deserialize_date(attr): + """Deserialize ISO-8601 formatted string into Date object. + + :param str attr: response string to be deserialized. + :return: Deserialized date + :rtype: Date + :raises DeserializationError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. + return isodate.parse_date(attr, defaultmonth=0, defaultday=0) + + @staticmethod + def deserialize_time(attr): + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :return: Deserialized time + :rtype: datetime.time + :raises DeserializationError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + return isodate.parse_time(attr) + + @staticmethod + def deserialize_rfc(attr): + """Deserialize RFC-1123 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :return: Deserialized RFC datetime + :rtype: Datetime + :raises DeserializationError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + parsed_date = email.utils.parsedate_tz(attr) # type: ignore + date_obj = datetime.datetime( + *parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) + ) + if not date_obj.tzinfo: + date_obj = date_obj.astimezone(tz=TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to rfc datetime object." + raise DeserializationError(msg) from err + return date_obj + + @staticmethod + def deserialize_iso(attr): + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :return: Deserialized ISO datetime + :rtype: Datetime + :raises DeserializationError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + attr = attr.upper() # type: ignore + match = Deserializer.valid_date.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split(".") + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize datetime object." + raise DeserializationError(msg) from err + return date_obj + + @staticmethod + def deserialize_unix(attr): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param int attr: Object to be serialized. + :return: Deserialized datetime + :rtype: Datetime + :raises DeserializationError: if format invalid + """ + if isinstance(attr, ET.Element): + attr = int(attr.text) # type: ignore + try: + attr = int(attr) + date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to unix datetime object." + raise DeserializationError(msg) from err + return date_obj diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/_version.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/_version.py new file mode 100644 index 00000000000..11fa84a5f06 --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/_version.py @@ -0,0 +1,8 @@ +# 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. +# -------------------------------------------------------------------------- + +VERSION = "0.0.0b1" diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/__init__.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/__init__.py new file mode 100644 index 00000000000..52caca38e9e --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/__init__.py @@ -0,0 +1,29 @@ +# 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. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._application_insights_management_client import ApplicationInsightsManagementClient # type: ignore + +try: + from ._patch import __all__ as _patch_all + from ._patch import * +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ApplicationInsightsManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore + +_patch_sdk() diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/_application_insights_management_client.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/_application_insights_management_client.py new file mode 100644 index 00000000000..ead873c2885 --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/_application_insights_management_client.py @@ -0,0 +1,227 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING, cast +from typing_extensions import Self + +from azure.core.pipeline import policies +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.settings import settings +from azure.mgmt.core import AsyncARMPipelineClient +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy +from azure.mgmt.core.tools import get_arm_endpoints + +from .. import models as _models +from .._utils.serialization import Deserializer, Serializer +from ._configuration import ApplicationInsightsManagementClientConfiguration +from .operations import ( + APIKeysOperations, + AnalyticsItemsOperations, + AnnotationsOperations, + ComponentAvailableFeaturesOperations, + ComponentCurrentBillingFeaturesOperations, + ComponentFeatureCapabilitiesOperations, + ComponentLinkedStorageAccountsOperations, + ComponentQuotaStatusOperations, + ComponentsOperations, + DeletedWorkbooksOperations, + ExportConfigurationsOperations, + FavoritesOperations, + LiveTokenOperations, + Operations, + ProactiveDetectionConfigurationsOperations, + WebTestLocationsOperations, + WebTestsOperations, + WorkItemConfigurationsOperations, + WorkbookTemplatesOperations, + WorkbooksOperations, +) + +if TYPE_CHECKING: + from azure.core.credentials_async import AsyncTokenCredential + + +class ApplicationInsightsManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes + """Composite Swagger for Application Insights Management Client. + + :ivar components: ComponentsOperations operations + :vartype components: azure.mgmt.applicationinsights.aio.operations.ComponentsOperations + :ivar annotations: AnnotationsOperations operations + :vartype annotations: azure.mgmt.applicationinsights.aio.operations.AnnotationsOperations + :ivar api_keys: APIKeysOperations operations + :vartype api_keys: azure.mgmt.applicationinsights.aio.operations.APIKeysOperations + :ivar export_configurations: ExportConfigurationsOperations operations + :vartype export_configurations: + azure.mgmt.applicationinsights.aio.operations.ExportConfigurationsOperations + :ivar component_current_billing_features: ComponentCurrentBillingFeaturesOperations operations + :vartype component_current_billing_features: + azure.mgmt.applicationinsights.aio.operations.ComponentCurrentBillingFeaturesOperations + :ivar component_quota_status: ComponentQuotaStatusOperations operations + :vartype component_quota_status: + azure.mgmt.applicationinsights.aio.operations.ComponentQuotaStatusOperations + :ivar component_feature_capabilities: ComponentFeatureCapabilitiesOperations operations + :vartype component_feature_capabilities: + azure.mgmt.applicationinsights.aio.operations.ComponentFeatureCapabilitiesOperations + :ivar component_available_features: ComponentAvailableFeaturesOperations operations + :vartype component_available_features: + azure.mgmt.applicationinsights.aio.operations.ComponentAvailableFeaturesOperations + :ivar proactive_detection_configurations: ProactiveDetectionConfigurationsOperations operations + :vartype proactive_detection_configurations: + azure.mgmt.applicationinsights.aio.operations.ProactiveDetectionConfigurationsOperations + :ivar work_item_configurations: WorkItemConfigurationsOperations operations + :vartype work_item_configurations: + azure.mgmt.applicationinsights.aio.operations.WorkItemConfigurationsOperations + :ivar favorites: FavoritesOperations operations + :vartype favorites: azure.mgmt.applicationinsights.aio.operations.FavoritesOperations + :ivar web_test_locations: WebTestLocationsOperations operations + :vartype web_test_locations: + azure.mgmt.applicationinsights.aio.operations.WebTestLocationsOperations + :ivar web_tests: WebTestsOperations operations + :vartype web_tests: azure.mgmt.applicationinsights.aio.operations.WebTestsOperations + :ivar analytics_items: AnalyticsItemsOperations operations + :vartype analytics_items: + azure.mgmt.applicationinsights.aio.operations.AnalyticsItemsOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.applicationinsights.aio.operations.Operations + :ivar workbook_templates: WorkbookTemplatesOperations operations + :vartype workbook_templates: + azure.mgmt.applicationinsights.aio.operations.WorkbookTemplatesOperations + :ivar workbooks: WorkbooksOperations operations + :vartype workbooks: azure.mgmt.applicationinsights.aio.operations.WorkbooksOperations + :ivar live_token: LiveTokenOperations operations + :vartype live_token: azure.mgmt.applicationinsights.aio.operations.LiveTokenOperations + :ivar component_linked_storage_accounts: ComponentLinkedStorageAccountsOperations operations + :vartype component_linked_storage_accounts: + azure.mgmt.applicationinsights.aio.operations.ComponentLinkedStorageAccountsOperations + :ivar deleted_workbooks: DeletedWorkbooksOperations operations + :vartype deleted_workbooks: + azure.mgmt.applicationinsights.aio.operations.DeletedWorkbooksOperations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :param base_url: Service URL. Default value is None. + :type base_url: str + """ + + def __init__( + self, credential: "AsyncTokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any + ) -> None: + _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore + _endpoints = get_arm_endpoints(_cloud) + if not base_url: + base_url = _endpoints["resource_manager"] + credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) + self._config = ApplicationInsightsManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs + ) + + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + AsyncARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient( + base_url=cast(str, base_url), policies=_policies, **kwargs + ) + + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.components = ComponentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.annotations = AnnotationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.api_keys = APIKeysOperations(self._client, self._config, self._serialize, self._deserialize) + self.export_configurations = ExportConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.component_current_billing_features = ComponentCurrentBillingFeaturesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.component_quota_status = ComponentQuotaStatusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.component_feature_capabilities = ComponentFeatureCapabilitiesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.component_available_features = ComponentAvailableFeaturesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.proactive_detection_configurations = ProactiveDetectionConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.work_item_configurations = WorkItemConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.favorites = FavoritesOperations(self._client, self._config, self._serialize, self._deserialize) + self.web_test_locations = WebTestLocationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.web_tests = WebTestsOperations(self._client, self._config, self._serialize, self._deserialize) + self.analytics_items = AnalyticsItemsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.workbook_templates = WorkbookTemplatesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workbooks = WorkbooksOperations(self._client, self._config, self._serialize, self._deserialize) + self.live_token = LiveTokenOperations(self._client, self._config, self._serialize, self._deserialize) + self.component_linked_storage_accounts = ComponentLinkedStorageAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.deleted_workbooks = DeletedWorkbooksOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> Self: + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details: Any) -> None: + await self._client.__aexit__(*exc_details) diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/_configuration.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/_configuration.py new file mode 100644 index 00000000000..db231e2038e --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/_configuration.py @@ -0,0 +1,58 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + from azure.core.credentials_async import AsyncTokenCredential + + +class ApplicationInsightsManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long + """Configuration for ApplicationInsightsManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + """ + + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-applicationinsights/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) + self._configure(**kwargs) + + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") + if self.credential and not self.authentication_policy: + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/_patch.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/_patch.py new file mode 100644 index 00000000000..8bcb627aa47 --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/_patch.py @@ -0,0 +1,21 @@ +# 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. +# -------------------------------------------------------------------------- +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/__init__.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/__init__.py new file mode 100644 index 00000000000..be555323ff9 --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/__init__.py @@ -0,0 +1,63 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._components_operations import ComponentsOperations # type: ignore +from ._annotations_operations import AnnotationsOperations # type: ignore +from ._api_keys_operations import APIKeysOperations # type: ignore +from ._export_configurations_operations import ExportConfigurationsOperations # type: ignore +from ._component_current_billing_features_operations import ComponentCurrentBillingFeaturesOperations # type: ignore +from ._component_quota_status_operations import ComponentQuotaStatusOperations # type: ignore +from ._component_feature_capabilities_operations import ComponentFeatureCapabilitiesOperations # type: ignore +from ._component_available_features_operations import ComponentAvailableFeaturesOperations # type: ignore +from ._proactive_detection_configurations_operations import ProactiveDetectionConfigurationsOperations # type: ignore +from ._work_item_configurations_operations import WorkItemConfigurationsOperations # type: ignore +from ._favorites_operations import FavoritesOperations # type: ignore +from ._web_test_locations_operations import WebTestLocationsOperations # type: ignore +from ._web_tests_operations import WebTestsOperations # type: ignore +from ._analytics_items_operations import AnalyticsItemsOperations # type: ignore +from ._operations import Operations # type: ignore +from ._workbook_templates_operations import WorkbookTemplatesOperations # type: ignore +from ._workbooks_operations import WorkbooksOperations # type: ignore +from ._live_token_operations import LiveTokenOperations # type: ignore +from ._component_linked_storage_accounts_operations import ComponentLinkedStorageAccountsOperations # type: ignore +from ._deleted_workbooks_operations import DeletedWorkbooksOperations # type: ignore + +from ._patch import __all__ as _patch_all +from ._patch import * +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ComponentsOperations", + "AnnotationsOperations", + "APIKeysOperations", + "ExportConfigurationsOperations", + "ComponentCurrentBillingFeaturesOperations", + "ComponentQuotaStatusOperations", + "ComponentFeatureCapabilitiesOperations", + "ComponentAvailableFeaturesOperations", + "ProactiveDetectionConfigurationsOperations", + "WorkItemConfigurationsOperations", + "FavoritesOperations", + "WebTestLocationsOperations", + "WebTestsOperations", + "AnalyticsItemsOperations", + "Operations", + "WorkbookTemplatesOperations", + "WorkbooksOperations", + "LiveTokenOperations", + "ComponentLinkedStorageAccountsOperations", + "DeletedWorkbooksOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore +_patch_sdk() diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_analytics_items_operations.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_analytics_items_operations.py new file mode 100644 index 00000000000..3153e30fb9a --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_analytics_items_operations.py @@ -0,0 +1,454 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, overload + +from azure.core import AsyncPipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._analytics_items_operations import ( + build_delete_request, + build_get_request, + build_list_request, + build_put_request, +) +from .._configuration import ApplicationInsightsManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class AnalyticsItemsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.applicationinsights.aio.ApplicationInsightsManagementClient`'s + :attr:`analytics_items` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApplicationInsightsManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def list( + self, + resource_group_name: str, + resource_name: str, + scope_path: Union[str, _models.ItemScopePath], + scope: Optional[Union[str, _models.ItemScope]] = None, + type: Union[str, _models.ItemTypeParameter] = "none", + include_content: Optional[bool] = None, + **kwargs: Any + ) -> List[_models.ApplicationInsightsComponentAnalyticsItem]: + """Gets a list of Analytics Items defined within an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param scope_path: Enum indicating if this item definition is owned by a specific user or is + shared between all users with access to the Application Insights component. Known values are: + "analyticsItems" and "myanalyticsItems". Required. + :type scope_path: str or ~azure.mgmt.applicationinsights.models.ItemScopePath + :param scope: Enum indicating if this item definition is owned by a specific user or is shared + between all users with access to the Application Insights component. Known values are: "shared" + and "user". Default value is None. + :type scope: str or ~azure.mgmt.applicationinsights.models.ItemScope + :param type: Enum indicating the type of the Analytics item. Known values are: "none", "query", + "function", "folder", and "recent". Default value is "none". + :type type: str or ~azure.mgmt.applicationinsights.models.ItemTypeParameter + :param include_content: Flag indicating whether or not to return the content of each applicable + item. If false, only return the item information. Default value is None. + :type include_content: bool + :return: list of ApplicationInsightsComponentAnalyticsItem or the result of cls(response) + :rtype: list[~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentAnalyticsItem] + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + cls: ClsType[List[_models.ApplicationInsightsComponentAnalyticsItem]] = kwargs.pop("cls", None) + + _request = build_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + scope_path=scope_path, + subscription_id=self._config.subscription_id, + scope=scope, + type=type, + include_content=include_content, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("[ApplicationInsightsComponentAnalyticsItem]", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + resource_name: str, + scope_path: Union[str, _models.ItemScopePath], + id: Optional[str] = None, + name: Optional[str] = None, + **kwargs: Any + ) -> _models.ApplicationInsightsComponentAnalyticsItem: + """Gets a specific Analytics Items defined within an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param scope_path: Enum indicating if this item definition is owned by a specific user or is + shared between all users with access to the Application Insights component. Known values are: + "analyticsItems" and "myanalyticsItems". Required. + :type scope_path: str or ~azure.mgmt.applicationinsights.models.ItemScopePath + :param id: The Id of a specific item defined in the Application Insights component. Default + value is None. + :type id: str + :param name: The name of a specific item defined in the Application Insights component. Default + value is None. + :type name: str + :return: ApplicationInsightsComponentAnalyticsItem or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentAnalyticsItem + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + cls: ClsType[_models.ApplicationInsightsComponentAnalyticsItem] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + scope_path=scope_path, + subscription_id=self._config.subscription_id, + id=id, + name=name, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ApplicationInsightsComponentAnalyticsItem", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def put( + self, + resource_group_name: str, + resource_name: str, + scope_path: Union[str, _models.ItemScopePath], + item_properties: _models.ApplicationInsightsComponentAnalyticsItem, + override_item: Optional[bool] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApplicationInsightsComponentAnalyticsItem: + """Adds or Updates a specific Analytics Item within an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param scope_path: Enum indicating if this item definition is owned by a specific user or is + shared between all users with access to the Application Insights component. Known values are: + "analyticsItems" and "myanalyticsItems". Required. + :type scope_path: str or ~azure.mgmt.applicationinsights.models.ItemScopePath + :param item_properties: Properties that need to be specified to create a new item and add it to + an Application Insights component. Required. + :type item_properties: + ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentAnalyticsItem + :param override_item: Flag indicating whether or not to force save an item. This allows + overriding an item if it already exists. Default value is None. + :type override_item: bool + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationInsightsComponentAnalyticsItem or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentAnalyticsItem + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def put( + self, + resource_group_name: str, + resource_name: str, + scope_path: Union[str, _models.ItemScopePath], + item_properties: IO[bytes], + override_item: Optional[bool] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApplicationInsightsComponentAnalyticsItem: + """Adds or Updates a specific Analytics Item within an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param scope_path: Enum indicating if this item definition is owned by a specific user or is + shared between all users with access to the Application Insights component. Known values are: + "analyticsItems" and "myanalyticsItems". Required. + :type scope_path: str or ~azure.mgmt.applicationinsights.models.ItemScopePath + :param item_properties: Properties that need to be specified to create a new item and add it to + an Application Insights component. Required. + :type item_properties: IO[bytes] + :param override_item: Flag indicating whether or not to force save an item. This allows + overriding an item if it already exists. Default value is None. + :type override_item: bool + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationInsightsComponentAnalyticsItem or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentAnalyticsItem + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def put( + self, + resource_group_name: str, + resource_name: str, + scope_path: Union[str, _models.ItemScopePath], + item_properties: Union[_models.ApplicationInsightsComponentAnalyticsItem, IO[bytes]], + override_item: Optional[bool] = None, + **kwargs: Any + ) -> _models.ApplicationInsightsComponentAnalyticsItem: + """Adds or Updates a specific Analytics Item within an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param scope_path: Enum indicating if this item definition is owned by a specific user or is + shared between all users with access to the Application Insights component. Known values are: + "analyticsItems" and "myanalyticsItems". Required. + :type scope_path: str or ~azure.mgmt.applicationinsights.models.ItemScopePath + :param item_properties: Properties that need to be specified to create a new item and add it to + an Application Insights component. Is either a ApplicationInsightsComponentAnalyticsItem type + or a IO[bytes] type. Required. + :type item_properties: + ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentAnalyticsItem or IO[bytes] + :param override_item: Flag indicating whether or not to force save an item. This allows + overriding an item if it already exists. Default value is None. + :type override_item: bool + :return: ApplicationInsightsComponentAnalyticsItem or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentAnalyticsItem + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ApplicationInsightsComponentAnalyticsItem] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(item_properties, (IOBase, bytes)): + _content = item_properties + else: + _json = self._serialize.body(item_properties, "ApplicationInsightsComponentAnalyticsItem") + + _request = build_put_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + scope_path=scope_path, + subscription_id=self._config.subscription_id, + override_item=override_item, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ApplicationInsightsComponentAnalyticsItem", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + resource_name: str, + scope_path: Union[str, _models.ItemScopePath], + id: Optional[str] = None, + name: Optional[str] = None, + **kwargs: Any + ) -> None: + """Deletes a specific Analytics Items defined within an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param scope_path: Enum indicating if this item definition is owned by a specific user or is + shared between all users with access to the Application Insights component. Known values are: + "analyticsItems" and "myanalyticsItems". Required. + :type scope_path: str or ~azure.mgmt.applicationinsights.models.ItemScopePath + :param id: The Id of a specific item defined in the Application Insights component. Default + value is None. + :type id: str + :param name: The name of a specific item defined in the Application Insights component. Default + value is None. + :type name: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + scope_path=scope_path, + subscription_id=self._config.subscription_id, + id=id, + name=name, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_annotations_operations.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_annotations_operations.py new file mode 100644 index 00000000000..9dd110a0dc8 --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_annotations_operations.py @@ -0,0 +1,393 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, overload + +from azure.core import AsyncPipelineClient +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._annotations_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, +) +from .._configuration import ApplicationInsightsManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class AnnotationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.applicationinsights.aio.ApplicationInsightsManagementClient`'s + :attr:`annotations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApplicationInsightsManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, resource_name: str, start: str, end: str, **kwargs: Any + ) -> AsyncItemPaged["_models.Annotation"]: + """Gets the list of annotations for a component for given time range. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param start: The start time to query from for annotations, cannot be older than 90 days from + current date. Required. + :type start: str + :param end: The end time to query for annotations. Required. + :type end: str + :return: An iterator like instance of either Annotation or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.models.Annotation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + cls: ClsType[_models.AnnotationsListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + start=start, + end=end, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AnnotationsListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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.AnnotationError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @overload + async def create( + self, + resource_group_name: str, + resource_name: str, + annotation_properties: _models.Annotation, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> List[_models.Annotation]: + """Create an Annotation of an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param annotation_properties: Properties that need to be specified to create an annotation of a + Application Insights component. Required. + :type annotation_properties: ~azure.mgmt.applicationinsights.models.Annotation + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: list of Annotation or the result of cls(response) + :rtype: list[~azure.mgmt.applicationinsights.models.Annotation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + resource_name: str, + annotation_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> List[_models.Annotation]: + """Create an Annotation of an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param annotation_properties: Properties that need to be specified to create an annotation of a + Application Insights component. Required. + :type annotation_properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: list of Annotation or the result of cls(response) + :rtype: list[~azure.mgmt.applicationinsights.models.Annotation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + resource_name: str, + annotation_properties: Union[_models.Annotation, IO[bytes]], + **kwargs: Any + ) -> List[_models.Annotation]: + """Create an Annotation of an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param annotation_properties: Properties that need to be specified to create an annotation of a + Application Insights component. Is either a Annotation type or a IO[bytes] type. Required. + :type annotation_properties: ~azure.mgmt.applicationinsights.models.Annotation or IO[bytes] + :return: list of Annotation or the result of cls(response) + :rtype: list[~azure.mgmt.applicationinsights.models.Annotation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[List[_models.Annotation]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(annotation_properties, (IOBase, bytes)): + _content = annotation_properties + else: + _json = self._serialize.body(annotation_properties, "Annotation") + + _request = build_create_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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.AnnotationError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("[Annotation]", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete(self, resource_group_name: str, resource_name: str, annotation_id: str, **kwargs: Any) -> None: + """Delete an Annotation of an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param annotation_id: The unique annotation ID. This is unique within a Application Insights + component. Required. + :type annotation_id: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + annotation_id=annotation_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace_async + async def get( + self, resource_group_name: str, resource_name: str, annotation_id: str, **kwargs: Any + ) -> List[_models.Annotation]: + """Get the annotation for given id. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param annotation_id: The unique annotation ID. This is unique within a Application Insights + component. Required. + :type annotation_id: str + :return: list of Annotation or the result of cls(response) + :rtype: list[~azure.mgmt.applicationinsights.models.Annotation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + cls: ClsType[List[_models.Annotation]] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + annotation_id=annotation_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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.AnnotationError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("[Annotation]", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_api_keys_operations.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_api_keys_operations.py new file mode 100644 index 00000000000..dbfb34d0ac7 --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_api_keys_operations.py @@ -0,0 +1,391 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core import AsyncPipelineClient +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._api_keys_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, +) +from .._configuration import ApplicationInsightsManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class APIKeysOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.applicationinsights.aio.ApplicationInsightsManagementClient`'s + :attr:`api_keys` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApplicationInsightsManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ApplicationInsightsComponentAPIKey"]: + """Gets a list of API keys of an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :return: An iterator like instance of either ApplicationInsightsComponentAPIKey or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentAPIKey] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + cls: ClsType[_models.ApplicationInsightsComponentAPIKeyListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationInsightsComponentAPIKeyListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @overload + async def create( + self, + resource_group_name: str, + resource_name: str, + api_key_properties: _models.APIKeyRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApplicationInsightsComponentAPIKey: + """Create an API Key of an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param api_key_properties: Properties that need to be specified to create an API key of a + Application Insights component. Required. + :type api_key_properties: ~azure.mgmt.applicationinsights.models.APIKeyRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationInsightsComponentAPIKey or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentAPIKey + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + resource_name: str, + api_key_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApplicationInsightsComponentAPIKey: + """Create an API Key of an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param api_key_properties: Properties that need to be specified to create an API key of a + Application Insights component. Required. + :type api_key_properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationInsightsComponentAPIKey or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentAPIKey + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + resource_name: str, + api_key_properties: Union[_models.APIKeyRequest, IO[bytes]], + **kwargs: Any + ) -> _models.ApplicationInsightsComponentAPIKey: + """Create an API Key of an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param api_key_properties: Properties that need to be specified to create an API key of a + Application Insights component. Is either a APIKeyRequest type or a IO[bytes] type. Required. + :type api_key_properties: ~azure.mgmt.applicationinsights.models.APIKeyRequest or IO[bytes] + :return: ApplicationInsightsComponentAPIKey or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentAPIKey + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ApplicationInsightsComponentAPIKey] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(api_key_properties, (IOBase, bytes)): + _content = api_key_properties + else: + _json = self._serialize.body(api_key_properties, "APIKeyRequest") + + _request = build_create_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ApplicationInsightsComponentAPIKey", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, resource_group_name: str, resource_name: str, key_id: str, **kwargs: Any + ) -> _models.ApplicationInsightsComponentAPIKey: + """Delete an API Key of an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param key_id: The API Key ID. This is unique within a Application Insights component. + Required. + :type key_id: str + :return: ApplicationInsightsComponentAPIKey or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentAPIKey + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + cls: ClsType[_models.ApplicationInsightsComponentAPIKey] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + key_id=key_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ApplicationInsightsComponentAPIKey", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get( + self, resource_group_name: str, resource_name: str, key_id: str, **kwargs: Any + ) -> _models.ApplicationInsightsComponentAPIKey: + """Get the API Key for this key id. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param key_id: The API Key ID. This is unique within a Application Insights component. + Required. + :type key_id: str + :return: ApplicationInsightsComponentAPIKey or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentAPIKey + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + cls: ClsType[_models.ApplicationInsightsComponentAPIKey] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + key_id=key_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ApplicationInsightsComponentAPIKey", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_component_available_features_operations.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_component_available_features_operations.py new file mode 100644 index 00000000000..b6a73eeaf7c --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_component_available_features_operations.py @@ -0,0 +1,113 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core import AsyncPipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._component_available_features_operations import build_get_request +from .._configuration import ApplicationInsightsManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ComponentAvailableFeaturesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.applicationinsights.aio.ApplicationInsightsManagementClient`'s + :attr:`component_available_features` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApplicationInsightsManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.ApplicationInsightsComponentAvailableFeatures: + """Returns all available features of the application insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :return: ApplicationInsightsComponentAvailableFeatures or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentAvailableFeatures + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + cls: ClsType[_models.ApplicationInsightsComponentAvailableFeatures] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize( + "ApplicationInsightsComponentAvailableFeatures", pipeline_response.http_response + ) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_component_current_billing_features_operations.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_component_current_billing_features_operations.py new file mode 100644 index 00000000000..4700f24d87d --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_component_current_billing_features_operations.py @@ -0,0 +1,247 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core import AsyncPipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._component_current_billing_features_operations import build_get_request, build_update_request +from .._configuration import ApplicationInsightsManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ComponentCurrentBillingFeaturesOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.applicationinsights.aio.ApplicationInsightsManagementClient`'s + :attr:`component_current_billing_features` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApplicationInsightsManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.ApplicationInsightsComponentBillingFeatures: + """Returns current billing features for an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :return: ApplicationInsightsComponentBillingFeatures or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentBillingFeatures + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + cls: ClsType[_models.ApplicationInsightsComponentBillingFeatures] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ApplicationInsightsComponentBillingFeatures", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + resource_name: str, + billing_features_properties: _models.ApplicationInsightsComponentBillingFeatures, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApplicationInsightsComponentBillingFeatures: + """Update current billing features for an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param billing_features_properties: Properties that need to be specified to update billing + features for an Application Insights component. Required. + :type billing_features_properties: + ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentBillingFeatures + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationInsightsComponentBillingFeatures or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentBillingFeatures + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + resource_name: str, + billing_features_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApplicationInsightsComponentBillingFeatures: + """Update current billing features for an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param billing_features_properties: Properties that need to be specified to update billing + features for an Application Insights component. Required. + :type billing_features_properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationInsightsComponentBillingFeatures or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentBillingFeatures + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + resource_name: str, + billing_features_properties: Union[_models.ApplicationInsightsComponentBillingFeatures, IO[bytes]], + **kwargs: Any + ) -> _models.ApplicationInsightsComponentBillingFeatures: + """Update current billing features for an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param billing_features_properties: Properties that need to be specified to update billing + features for an Application Insights component. Is either a + ApplicationInsightsComponentBillingFeatures type or a IO[bytes] type. Required. + :type billing_features_properties: + ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentBillingFeatures or IO[bytes] + :return: ApplicationInsightsComponentBillingFeatures or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentBillingFeatures + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ApplicationInsightsComponentBillingFeatures] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(billing_features_properties, (IOBase, bytes)): + _content = billing_features_properties + else: + _json = self._serialize.body(billing_features_properties, "ApplicationInsightsComponentBillingFeatures") + + _request = build_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ApplicationInsightsComponentBillingFeatures", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_component_feature_capabilities_operations.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_component_feature_capabilities_operations.py new file mode 100644 index 00000000000..3c8d4ae5281 --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_component_feature_capabilities_operations.py @@ -0,0 +1,113 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core import AsyncPipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._component_feature_capabilities_operations import build_get_request +from .._configuration import ApplicationInsightsManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ComponentFeatureCapabilitiesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.applicationinsights.aio.ApplicationInsightsManagementClient`'s + :attr:`component_feature_capabilities` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApplicationInsightsManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.ApplicationInsightsComponentFeatureCapabilities: + """Returns feature capabilities of the application insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :return: ApplicationInsightsComponentFeatureCapabilities or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentFeatureCapabilities + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + cls: ClsType[_models.ApplicationInsightsComponentFeatureCapabilities] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize( + "ApplicationInsightsComponentFeatureCapabilities", pipeline_response.http_response + ) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_component_linked_storage_accounts_operations.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_component_linked_storage_accounts_operations.py new file mode 100644 index 00000000000..583d12941db --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_component_linked_storage_accounts_operations.py @@ -0,0 +1,478 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core import AsyncPipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._component_linked_storage_accounts_operations import ( + build_create_and_update_request, + build_delete_request, + build_get_request, + build_update_request, +) +from .._configuration import ApplicationInsightsManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ComponentLinkedStorageAccountsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.applicationinsights.aio.ApplicationInsightsManagementClient`'s + :attr:`component_linked_storage_accounts` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApplicationInsightsManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, resource_name: str, storage_type: Union[str, _models.StorageType], **kwargs: Any + ) -> _models.ComponentLinkedStorageAccounts: + """Returns the current linked storage settings for an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param storage_type: The type of the Application Insights component data source for the linked + storage account. "ServiceProfiler" Required. + :type storage_type: str or ~azure.mgmt.applicationinsights.models.StorageType + :return: ComponentLinkedStorageAccounts or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ComponentLinkedStorageAccounts + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01-preview")) + cls: ClsType[_models.ComponentLinkedStorageAccounts] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + storage_type=storage_type, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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.ErrorResponseLinkedStorage, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ComponentLinkedStorageAccounts", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_and_update( + self, + resource_group_name: str, + resource_name: str, + storage_type: Union[str, _models.StorageType], + linked_storage_accounts_properties: _models.ComponentLinkedStorageAccounts, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ComponentLinkedStorageAccounts: + """Replace current linked storage account for an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param storage_type: The type of the Application Insights component data source for the linked + storage account. "ServiceProfiler" Required. + :type storage_type: str or ~azure.mgmt.applicationinsights.models.StorageType + :param linked_storage_accounts_properties: Properties that need to be specified to update + linked storage accounts for an Application Insights component. Required. + :type linked_storage_accounts_properties: + ~azure.mgmt.applicationinsights.models.ComponentLinkedStorageAccounts + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ComponentLinkedStorageAccounts or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ComponentLinkedStorageAccounts + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_and_update( + self, + resource_group_name: str, + resource_name: str, + storage_type: Union[str, _models.StorageType], + linked_storage_accounts_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ComponentLinkedStorageAccounts: + """Replace current linked storage account for an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param storage_type: The type of the Application Insights component data source for the linked + storage account. "ServiceProfiler" Required. + :type storage_type: str or ~azure.mgmt.applicationinsights.models.StorageType + :param linked_storage_accounts_properties: Properties that need to be specified to update + linked storage accounts for an Application Insights component. Required. + :type linked_storage_accounts_properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ComponentLinkedStorageAccounts or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ComponentLinkedStorageAccounts + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_and_update( + self, + resource_group_name: str, + resource_name: str, + storage_type: Union[str, _models.StorageType], + linked_storage_accounts_properties: Union[_models.ComponentLinkedStorageAccounts, IO[bytes]], + **kwargs: Any + ) -> _models.ComponentLinkedStorageAccounts: + """Replace current linked storage account for an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param storage_type: The type of the Application Insights component data source for the linked + storage account. "ServiceProfiler" Required. + :type storage_type: str or ~azure.mgmt.applicationinsights.models.StorageType + :param linked_storage_accounts_properties: Properties that need to be specified to update + linked storage accounts for an Application Insights component. Is either a + ComponentLinkedStorageAccounts type or a IO[bytes] type. Required. + :type linked_storage_accounts_properties: + ~azure.mgmt.applicationinsights.models.ComponentLinkedStorageAccounts or IO[bytes] + :return: ComponentLinkedStorageAccounts or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ComponentLinkedStorageAccounts + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ComponentLinkedStorageAccounts] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(linked_storage_accounts_properties, (IOBase, bytes)): + _content = linked_storage_accounts_properties + else: + _json = self._serialize.body(linked_storage_accounts_properties, "ComponentLinkedStorageAccounts") + + _request = build_create_and_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + storage_type=storage_type, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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.ErrorResponseLinkedStorage, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ComponentLinkedStorageAccounts", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + resource_name: str, + storage_type: Union[str, _models.StorageType], + linked_storage_accounts_properties: _models.ComponentLinkedStorageAccountsPatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ComponentLinkedStorageAccounts: + """Update linked storage accounts for an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param storage_type: The type of the Application Insights component data source for the linked + storage account. "ServiceProfiler" Required. + :type storage_type: str or ~azure.mgmt.applicationinsights.models.StorageType + :param linked_storage_accounts_properties: Properties that need to be specified to update a + linked storage accounts for an Application Insights component. Required. + :type linked_storage_accounts_properties: + ~azure.mgmt.applicationinsights.models.ComponentLinkedStorageAccountsPatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ComponentLinkedStorageAccounts or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ComponentLinkedStorageAccounts + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + resource_name: str, + storage_type: Union[str, _models.StorageType], + linked_storage_accounts_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ComponentLinkedStorageAccounts: + """Update linked storage accounts for an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param storage_type: The type of the Application Insights component data source for the linked + storage account. "ServiceProfiler" Required. + :type storage_type: str or ~azure.mgmt.applicationinsights.models.StorageType + :param linked_storage_accounts_properties: Properties that need to be specified to update a + linked storage accounts for an Application Insights component. Required. + :type linked_storage_accounts_properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ComponentLinkedStorageAccounts or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ComponentLinkedStorageAccounts + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + resource_name: str, + storage_type: Union[str, _models.StorageType], + linked_storage_accounts_properties: Union[_models.ComponentLinkedStorageAccountsPatch, IO[bytes]], + **kwargs: Any + ) -> _models.ComponentLinkedStorageAccounts: + """Update linked storage accounts for an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param storage_type: The type of the Application Insights component data source for the linked + storage account. "ServiceProfiler" Required. + :type storage_type: str or ~azure.mgmt.applicationinsights.models.StorageType + :param linked_storage_accounts_properties: Properties that need to be specified to update a + linked storage accounts for an Application Insights component. Is either a + ComponentLinkedStorageAccountsPatch type or a IO[bytes] type. Required. + :type linked_storage_accounts_properties: + ~azure.mgmt.applicationinsights.models.ComponentLinkedStorageAccountsPatch or IO[bytes] + :return: ComponentLinkedStorageAccounts or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ComponentLinkedStorageAccounts + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ComponentLinkedStorageAccounts] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(linked_storage_accounts_properties, (IOBase, bytes)): + _content = linked_storage_accounts_properties + else: + _json = self._serialize.body(linked_storage_accounts_properties, "ComponentLinkedStorageAccountsPatch") + + _request = build_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + storage_type=storage_type, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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.ErrorResponseLinkedStorage, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ComponentLinkedStorageAccounts", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, resource_group_name: str, resource_name: str, storage_type: Union[str, _models.StorageType], **kwargs: Any + ) -> None: + """Delete linked storage accounts for an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param storage_type: The type of the Application Insights component data source for the linked + storage account. "ServiceProfiler" Required. + :type storage_type: str or ~azure.mgmt.applicationinsights.models.StorageType + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + storage_type=storage_type, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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.ErrorResponseLinkedStorage, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_component_quota_status_operations.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_component_quota_status_operations.py new file mode 100644 index 00000000000..8ce91316d5e --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_component_quota_status_operations.py @@ -0,0 +1,111 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core import AsyncPipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._component_quota_status_operations import build_get_request +from .._configuration import ApplicationInsightsManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ComponentQuotaStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.applicationinsights.aio.ApplicationInsightsManagementClient`'s + :attr:`component_quota_status` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApplicationInsightsManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.ApplicationInsightsComponentQuotaStatus: + """Returns daily data volume cap (quota) status for an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :return: ApplicationInsightsComponentQuotaStatus or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentQuotaStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + cls: ClsType[_models.ApplicationInsightsComponentQuotaStatus] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ApplicationInsightsComponentQuotaStatus", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_components_operations.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_components_operations.py new file mode 100644 index 00000000000..c3e4b45480e --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_components_operations.py @@ -0,0 +1,808 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core import AsyncPipelineClient +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._components_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_purge_status_request, + build_get_request, + build_list_by_resource_group_request, + build_list_request, + build_purge_request, + build_update_tags_request, +) +from .._configuration import ApplicationInsightsManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ComponentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.applicationinsights.aio.ApplicationInsightsManagementClient`'s + :attr:`components` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApplicationInsightsManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncItemPaged["_models.ApplicationInsightsComponent"]: + """Gets a list of all Application Insights components within a subscription. + + :return: An iterator like instance of either ApplicationInsightsComponent or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.models.ApplicationInsightsComponent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-02-02")) + cls: ClsType[_models.ApplicationInsightsComponentListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationInsightsComponentListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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.ErrorResponseComponents, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ApplicationInsightsComponent"]: + """Gets a list of Application Insights components within a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of either ApplicationInsightsComponent or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.models.ApplicationInsightsComponent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-02-02")) + cls: ClsType[_models.ApplicationInsightsComponentListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + 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, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationInsightsComponentListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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.ErrorResponseComponents, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def delete(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> None: + """Deletes an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-02-02")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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.ErrorResponseComponents, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace_async + async def get( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.ApplicationInsightsComponent: + """Returns an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :return: ApplicationInsightsComponent or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponent + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-02-02")) + cls: ClsType[_models.ApplicationInsightsComponent] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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.ErrorResponseComponents, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ApplicationInsightsComponent", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + resource_name: str, + insight_properties: _models.ApplicationInsightsComponent, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApplicationInsightsComponent: + """Creates (or updates) an Application Insights component. 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. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param insight_properties: Properties that need to be specified to create an Application + Insights component. Required. + :type insight_properties: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponent + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationInsightsComponent or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponent + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + resource_name: str, + insight_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApplicationInsightsComponent: + """Creates (or updates) an Application Insights component. 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. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param insight_properties: Properties that need to be specified to create an Application + Insights component. Required. + :type insight_properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationInsightsComponent or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponent + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + resource_name: str, + insight_properties: Union[_models.ApplicationInsightsComponent, IO[bytes]], + **kwargs: Any + ) -> _models.ApplicationInsightsComponent: + """Creates (or updates) an Application Insights component. 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. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param insight_properties: Properties that need to be specified to create an Application + Insights component. Is either a ApplicationInsightsComponent type or a IO[bytes] type. + Required. + :type insight_properties: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponent + or IO[bytes] + :return: ApplicationInsightsComponent or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponent + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-02-02")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ApplicationInsightsComponent] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(insight_properties, (IOBase, bytes)): + _content = insight_properties + else: + _json = self._serialize.body(insight_properties, "ApplicationInsightsComponent") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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.ErrorResponseComponents, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ApplicationInsightsComponent", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def update_tags( + self, + resource_group_name: str, + resource_name: str, + component_tags: _models.TagsResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApplicationInsightsComponent: + """Updates an existing component'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. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param component_tags: Updated tag information to set into the component instance. Required. + :type component_tags: ~azure.mgmt.applicationinsights.models.TagsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationInsightsComponent or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponent + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update_tags( + self, + resource_group_name: str, + resource_name: str, + component_tags: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApplicationInsightsComponent: + """Updates an existing component'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. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param component_tags: Updated tag information to set into the component instance. Required. + :type component_tags: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationInsightsComponent or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponent + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update_tags( + self, + resource_group_name: str, + resource_name: str, + component_tags: Union[_models.TagsResource, IO[bytes]], + **kwargs: Any + ) -> _models.ApplicationInsightsComponent: + """Updates an existing component'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. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param component_tags: Updated tag information to set into the component instance. Is either a + TagsResource type or a IO[bytes] type. Required. + :type component_tags: ~azure.mgmt.applicationinsights.models.TagsResource or IO[bytes] + :return: ApplicationInsightsComponent or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponent + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-02-02")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ApplicationInsightsComponent] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(component_tags, (IOBase, bytes)): + _content = component_tags + else: + _json = self._serialize.body(component_tags, "TagsResource") + + _request = build_update_tags_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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.ErrorResponseComponents, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ApplicationInsightsComponent", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def purge( + self, + resource_group_name: str, + resource_name: str, + body: _models.ComponentPurgeBody, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ComponentPurgeResponse: + """Purges data in an Application Insights component by a set of user-defined filters. + + In order to manage system resources, purge requests are throttled at 50 requests per hour. You + should batch the execution of purge requests by sending a single command whose predicate + includes all user identities that require purging. Use the in operator to specify multiple + identities. You should run the query prior to using for a purge request to verify that the + results are expected. + Note: this operation is intended for Classic resources, for workspace-based Application + Insights resource please run purge operation (directly on the + workspace)(https://docs.microsoft.com/en-us/rest/api/loganalytics/workspace-purge/purge) , + scoped to specific resource id. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param body: Describes the body of a request to purge data in a single table of an Application + Insights component. Required. + :type body: ~azure.mgmt.applicationinsights.models.ComponentPurgeBody + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ComponentPurgeResponse or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ComponentPurgeResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def purge( + self, + resource_group_name: str, + resource_name: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ComponentPurgeResponse: + """Purges data in an Application Insights component by a set of user-defined filters. + + In order to manage system resources, purge requests are throttled at 50 requests per hour. You + should batch the execution of purge requests by sending a single command whose predicate + includes all user identities that require purging. Use the in operator to specify multiple + identities. You should run the query prior to using for a purge request to verify that the + results are expected. + Note: this operation is intended for Classic resources, for workspace-based Application + Insights resource please run purge operation (directly on the + workspace)(https://docs.microsoft.com/en-us/rest/api/loganalytics/workspace-purge/purge) , + scoped to specific resource id. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param body: Describes the body of a request to purge data in a single table of an Application + Insights component. Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ComponentPurgeResponse or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ComponentPurgeResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def purge( + self, + resource_group_name: str, + resource_name: str, + body: Union[_models.ComponentPurgeBody, IO[bytes]], + **kwargs: Any + ) -> _models.ComponentPurgeResponse: + """Purges data in an Application Insights component by a set of user-defined filters. + + In order to manage system resources, purge requests are throttled at 50 requests per hour. You + should batch the execution of purge requests by sending a single command whose predicate + includes all user identities that require purging. Use the in operator to specify multiple + identities. You should run the query prior to using for a purge request to verify that the + results are expected. + Note: this operation is intended for Classic resources, for workspace-based Application + Insights resource please run purge operation (directly on the + workspace)(https://docs.microsoft.com/en-us/rest/api/loganalytics/workspace-purge/purge) , + scoped to specific resource id. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param body: Describes the body of a request to purge data in a single table of an Application + Insights component. Is either a ComponentPurgeBody type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.applicationinsights.models.ComponentPurgeBody or IO[bytes] + :return: ComponentPurgeResponse or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ComponentPurgeResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-02-02")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ComponentPurgeResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = self._serialize.body(body, "ComponentPurgeBody") + + _request = build_purge_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseComponents, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ComponentPurgeResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_purge_status( + self, resource_group_name: str, resource_name: str, purge_id: str, **kwargs: Any + ) -> _models.ComponentPurgeStatusResponse: + """Get status for an ongoing purge operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param purge_id: In a purge status request, this is the Id of the operation the status of which + is returned. Required. + :type purge_id: str + :return: ComponentPurgeStatusResponse or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ComponentPurgeStatusResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-02-02")) + cls: ClsType[_models.ComponentPurgeStatusResponse] = kwargs.pop("cls", None) + + _request = build_get_purge_status_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + purge_id=purge_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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.ErrorResponseComponents, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ComponentPurgeStatusResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_deleted_workbooks_operations.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_deleted_workbooks_operations.py new file mode 100644 index 00000000000..16b19481b2b --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_deleted_workbooks_operations.py @@ -0,0 +1,132 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, List, Optional, TypeVar, Union + +from azure.core import AsyncPipelineClient +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._deleted_workbooks_operations import build_list_by_subscription_request +from .._configuration import ApplicationInsightsManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class DeletedWorkbooksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.applicationinsights.aio.ApplicationInsightsManagementClient`'s + :attr:`deleted_workbooks` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApplicationInsightsManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_subscription( + self, + category: Optional[Union[str, _models.CategoryType]] = None, + tags: Optional[List[str]] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.DeletedWorkbook"]: + """Get all recently deleted Workbooks in a specified subscription. + + :param category: Category of workbook to return. Known values are: "workbook", "TSG", + "performance", and "retention". Default value is None. + :type category: str or ~azure.mgmt.applicationinsights.models.CategoryType + :param tags: Tags presents on each workbook returned. Default value is None. + :type tags: list[str] + :return: An iterator like instance of either DeletedWorkbook or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.models.DeletedWorkbook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01-preview")) + cls: ClsType[_models.DeletedWorkbooksListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + category=category, + tags=tags, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DeletedWorkbooksListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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.DeletedWorkbookError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_export_configurations_operations.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_export_configurations_operations.py new file mode 100644 index 00000000000..4111356232e --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_export_configurations_operations.py @@ -0,0 +1,537 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, overload + +from azure.core import AsyncPipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._export_configurations_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) +from .._configuration import ApplicationInsightsManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ExportConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.applicationinsights.aio.ApplicationInsightsManagementClient`'s + :attr:`export_configurations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApplicationInsightsManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def list( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> List[_models.ApplicationInsightsComponentExportConfiguration]: + """Gets a list of Continuous Export configuration of an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :return: list of ApplicationInsightsComponentExportConfiguration or the result of cls(response) + :rtype: + list[~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentExportConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + cls: ClsType[List[_models.ApplicationInsightsComponentExportConfiguration]] = kwargs.pop("cls", None) + + _request = build_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize( + "[ApplicationInsightsComponentExportConfiguration]", pipeline_response.http_response + ) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create( + self, + resource_group_name: str, + resource_name: str, + export_properties: _models.ApplicationInsightsComponentExportRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> List[_models.ApplicationInsightsComponentExportConfiguration]: + """Create a Continuous Export configuration of an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param export_properties: Properties that need to be specified to create a Continuous Export + configuration of a Application Insights component. Required. + :type export_properties: + ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentExportRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: list of ApplicationInsightsComponentExportConfiguration or the result of cls(response) + :rtype: + list[~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentExportConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + resource_name: str, + export_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> List[_models.ApplicationInsightsComponentExportConfiguration]: + """Create a Continuous Export configuration of an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param export_properties: Properties that need to be specified to create a Continuous Export + configuration of a Application Insights component. Required. + :type export_properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: list of ApplicationInsightsComponentExportConfiguration or the result of cls(response) + :rtype: + list[~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentExportConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + resource_name: str, + export_properties: Union[_models.ApplicationInsightsComponentExportRequest, IO[bytes]], + **kwargs: Any + ) -> List[_models.ApplicationInsightsComponentExportConfiguration]: + """Create a Continuous Export configuration of an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param export_properties: Properties that need to be specified to create a Continuous Export + configuration of a Application Insights component. Is either a + ApplicationInsightsComponentExportRequest type or a IO[bytes] type. Required. + :type export_properties: + ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentExportRequest or IO[bytes] + :return: list of ApplicationInsightsComponentExportConfiguration or the result of cls(response) + :rtype: + list[~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentExportConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[List[_models.ApplicationInsightsComponentExportConfiguration]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(export_properties, (IOBase, bytes)): + _content = export_properties + else: + _json = self._serialize.body(export_properties, "ApplicationInsightsComponentExportRequest") + + _request = build_create_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize( + "[ApplicationInsightsComponentExportConfiguration]", pipeline_response.http_response + ) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, resource_group_name: str, resource_name: str, export_id: str, **kwargs: Any + ) -> _models.ApplicationInsightsComponentExportConfiguration: + """Delete a Continuous Export configuration of an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param export_id: The Continuous Export configuration ID. This is unique within a Application + Insights component. Required. + :type export_id: str + :return: ApplicationInsightsComponentExportConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentExportConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + cls: ClsType[_models.ApplicationInsightsComponentExportConfiguration] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + export_id=export_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize( + "ApplicationInsightsComponentExportConfiguration", pipeline_response.http_response + ) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get( + self, resource_group_name: str, resource_name: str, export_id: str, **kwargs: Any + ) -> _models.ApplicationInsightsComponentExportConfiguration: + """Get the Continuous Export configuration for this export id. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param export_id: The Continuous Export configuration ID. This is unique within a Application + Insights component. Required. + :type export_id: str + :return: ApplicationInsightsComponentExportConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentExportConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + cls: ClsType[_models.ApplicationInsightsComponentExportConfiguration] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + export_id=export_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize( + "ApplicationInsightsComponentExportConfiguration", pipeline_response.http_response + ) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + resource_name: str, + export_id: str, + export_properties: _models.ApplicationInsightsComponentExportRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApplicationInsightsComponentExportConfiguration: + """Update the Continuous Export configuration for this export id. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param export_id: The Continuous Export configuration ID. This is unique within a Application + Insights component. Required. + :type export_id: str + :param export_properties: Properties that need to be specified to update the Continuous Export + configuration. Required. + :type export_properties: + ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentExportRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationInsightsComponentExportConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentExportConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + resource_name: str, + export_id: str, + export_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApplicationInsightsComponentExportConfiguration: + """Update the Continuous Export configuration for this export id. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param export_id: The Continuous Export configuration ID. This is unique within a Application + Insights component. Required. + :type export_id: str + :param export_properties: Properties that need to be specified to update the Continuous Export + configuration. Required. + :type export_properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationInsightsComponentExportConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentExportConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + resource_name: str, + export_id: str, + export_properties: Union[_models.ApplicationInsightsComponentExportRequest, IO[bytes]], + **kwargs: Any + ) -> _models.ApplicationInsightsComponentExportConfiguration: + """Update the Continuous Export configuration for this export id. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param export_id: The Continuous Export configuration ID. This is unique within a Application + Insights component. Required. + :type export_id: str + :param export_properties: Properties that need to be specified to update the Continuous Export + configuration. Is either a ApplicationInsightsComponentExportRequest type or a IO[bytes] type. + Required. + :type export_properties: + ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentExportRequest or IO[bytes] + :return: ApplicationInsightsComponentExportConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentExportConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ApplicationInsightsComponentExportConfiguration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(export_properties, (IOBase, bytes)): + _content = export_properties + else: + _json = self._serialize.body(export_properties, "ApplicationInsightsComponentExportRequest") + + _request = build_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + export_id=export_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize( + "ApplicationInsightsComponentExportConfiguration", pipeline_response.http_response + ) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_favorites_operations.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_favorites_operations.py new file mode 100644 index 00000000000..ddff36d0bb7 --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_favorites_operations.py @@ -0,0 +1,553 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, overload + +from azure.core import AsyncPipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._favorites_operations import ( + build_add_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) +from .._configuration import ApplicationInsightsManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class FavoritesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.applicationinsights.aio.ApplicationInsightsManagementClient`'s + :attr:`favorites` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApplicationInsightsManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def list( + self, + resource_group_name: str, + resource_name: str, + favorite_type: Optional[Union[str, _models.FavoriteType]] = None, + source_type: Optional[Union[str, _models.FavoriteSourceType]] = None, + can_fetch_content: Optional[bool] = None, + tags: Optional[List[str]] = None, + **kwargs: Any + ) -> List[_models.ApplicationInsightsComponentFavorite]: + """Gets a list of favorites defined within an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param favorite_type: The type of favorite. Value can be either shared or user. Known values + are: "shared" and "user". Default value is None. + :type favorite_type: str or ~azure.mgmt.applicationinsights.models.FavoriteType + :param source_type: Source type of favorite to return. When left out, the source type defaults + to 'other' (not present in this enum). Known values are: "retention", "notebook", "sessions", + "events", "userflows", "funnel", "impact", and "segmentation". Default value is None. + :type source_type: str or ~azure.mgmt.applicationinsights.models.FavoriteSourceType + :param can_fetch_content: Flag indicating whether or not to return the full content for each + applicable favorite. If false, only return summary content for favorites. Default value is + None. + :type can_fetch_content: bool + :param tags: Tags that must be present on each favorite returned. Default value is None. + :type tags: list[str] + :return: list of ApplicationInsightsComponentFavorite or the result of cls(response) + :rtype: list[~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentFavorite] + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + cls: ClsType[List[_models.ApplicationInsightsComponentFavorite]] = kwargs.pop("cls", None) + + _request = build_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + favorite_type=favorite_type, + source_type=source_type, + can_fetch_content=can_fetch_content, + tags=tags, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("[ApplicationInsightsComponentFavorite]", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get( + self, resource_group_name: str, resource_name: str, favorite_id: str, **kwargs: Any + ) -> _models.ApplicationInsightsComponentFavorite: + """Get a single favorite by its FavoriteId, defined within an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param favorite_id: The Id of a specific favorite defined in the Application Insights + component. Required. + :type favorite_id: str + :return: ApplicationInsightsComponentFavorite or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentFavorite + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + cls: ClsType[_models.ApplicationInsightsComponentFavorite] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + favorite_id=favorite_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ApplicationInsightsComponentFavorite", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def add( + self, + resource_group_name: str, + resource_name: str, + favorite_id: str, + favorite_properties: _models.ApplicationInsightsComponentFavorite, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApplicationInsightsComponentFavorite: + """Adds a new favorites to an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param favorite_id: The Id of a specific favorite defined in the Application Insights + component. Required. + :type favorite_id: str + :param favorite_properties: Properties that need to be specified to create a new favorite and + add it to an Application Insights component. Required. + :type favorite_properties: + ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentFavorite + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationInsightsComponentFavorite or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentFavorite + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def add( + self, + resource_group_name: str, + resource_name: str, + favorite_id: str, + favorite_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApplicationInsightsComponentFavorite: + """Adds a new favorites to an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param favorite_id: The Id of a specific favorite defined in the Application Insights + component. Required. + :type favorite_id: str + :param favorite_properties: Properties that need to be specified to create a new favorite and + add it to an Application Insights component. Required. + :type favorite_properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationInsightsComponentFavorite or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentFavorite + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def add( + self, + resource_group_name: str, + resource_name: str, + favorite_id: str, + favorite_properties: Union[_models.ApplicationInsightsComponentFavorite, IO[bytes]], + **kwargs: Any + ) -> _models.ApplicationInsightsComponentFavorite: + """Adds a new favorites to an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param favorite_id: The Id of a specific favorite defined in the Application Insights + component. Required. + :type favorite_id: str + :param favorite_properties: Properties that need to be specified to create a new favorite and + add it to an Application Insights component. Is either a ApplicationInsightsComponentFavorite + type or a IO[bytes] type. Required. + :type favorite_properties: + ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentFavorite or IO[bytes] + :return: ApplicationInsightsComponentFavorite or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentFavorite + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ApplicationInsightsComponentFavorite] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(favorite_properties, (IOBase, bytes)): + _content = favorite_properties + else: + _json = self._serialize.body(favorite_properties, "ApplicationInsightsComponentFavorite") + + _request = build_add_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + favorite_id=favorite_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ApplicationInsightsComponentFavorite", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + resource_name: str, + favorite_id: str, + favorite_properties: _models.ApplicationInsightsComponentFavorite, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApplicationInsightsComponentFavorite: + """Updates a favorite that has already been added to an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param favorite_id: The Id of a specific favorite defined in the Application Insights + component. Required. + :type favorite_id: str + :param favorite_properties: Properties that need to be specified to update the existing + favorite. Required. + :type favorite_properties: + ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentFavorite + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationInsightsComponentFavorite or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentFavorite + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + resource_name: str, + favorite_id: str, + favorite_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApplicationInsightsComponentFavorite: + """Updates a favorite that has already been added to an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param favorite_id: The Id of a specific favorite defined in the Application Insights + component. Required. + :type favorite_id: str + :param favorite_properties: Properties that need to be specified to update the existing + favorite. Required. + :type favorite_properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationInsightsComponentFavorite or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentFavorite + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + resource_name: str, + favorite_id: str, + favorite_properties: Union[_models.ApplicationInsightsComponentFavorite, IO[bytes]], + **kwargs: Any + ) -> _models.ApplicationInsightsComponentFavorite: + """Updates a favorite that has already been added to an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param favorite_id: The Id of a specific favorite defined in the Application Insights + component. Required. + :type favorite_id: str + :param favorite_properties: Properties that need to be specified to update the existing + favorite. Is either a ApplicationInsightsComponentFavorite type or a IO[bytes] type. Required. + :type favorite_properties: + ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentFavorite or IO[bytes] + :return: ApplicationInsightsComponentFavorite or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentFavorite + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ApplicationInsightsComponentFavorite] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(favorite_properties, (IOBase, bytes)): + _content = favorite_properties + else: + _json = self._serialize.body(favorite_properties, "ApplicationInsightsComponentFavorite") + + _request = build_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + favorite_id=favorite_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ApplicationInsightsComponentFavorite", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete(self, resource_group_name: str, resource_name: str, favorite_id: str, **kwargs: Any) -> None: + """Remove a favorite that is associated to an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param favorite_id: The Id of a specific favorite defined in the Application Insights + component. Required. + :type favorite_id: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + favorite_id=favorite_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_live_token_operations.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_live_token_operations.py new file mode 100644 index 00000000000..ace6ed0f5ad --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_live_token_operations.py @@ -0,0 +1,105 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core import AsyncPipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._live_token_operations import build_get_request +from .._configuration import ApplicationInsightsManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class LiveTokenOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.applicationinsights.aio.ApplicationInsightsManagementClient`'s + :attr:`live_token` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApplicationInsightsManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get(self, resource_uri: str, **kwargs: Any) -> _models.LiveTokenResponse: + """**Gets an access token for live metrics stream data.**. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :return: LiveTokenResponse or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.LiveTokenResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-14")) + cls: ClsType[_models.LiveTokenResponse] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_uri=resource_uri, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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.ErrorResponseLinkedStorage, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("LiveTokenResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_operations.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_operations.py new file mode 100644 index 00000000000..14cc2d1cf70 --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_operations.py @@ -0,0 +1,119 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core import AsyncPipelineClient +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._operations import build_list_request +from .._configuration import ApplicationInsightsManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.applicationinsights.aio.ApplicationInsightsManagementClient`'s + :attr:`operations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApplicationInsightsManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncItemPaged["_models.Operation"]: + """Lists all of the available insights REST API operations. + + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-08")) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("OperationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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) diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_patch.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_patch.py new file mode 100644 index 00000000000..8bcb627aa47 --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_patch.py @@ -0,0 +1,21 @@ +# 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. +# -------------------------------------------------------------------------- +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_proactive_detection_configurations_operations.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_proactive_detection_configurations_operations.py new file mode 100644 index 00000000000..09e92f5e5bb --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_proactive_detection_configurations_operations.py @@ -0,0 +1,348 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, overload + +from azure.core import AsyncPipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._proactive_detection_configurations_operations import ( + build_get_request, + build_list_request, + build_update_request, +) +from .._configuration import ApplicationInsightsManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ProactiveDetectionConfigurationsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.applicationinsights.aio.ApplicationInsightsManagementClient`'s + :attr:`proactive_detection_configurations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApplicationInsightsManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def list( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> List[_models.ApplicationInsightsComponentProactiveDetectionConfiguration]: + """Gets a list of ProactiveDetection configurations of an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :return: list of ApplicationInsightsComponentProactiveDetectionConfiguration or the result of + cls(response) + :rtype: + list[~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentProactiveDetectionConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + cls: ClsType[List[_models.ApplicationInsightsComponentProactiveDetectionConfiguration]] = kwargs.pop( + "cls", None + ) + + _request = build_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize( + "[ApplicationInsightsComponentProactiveDetectionConfiguration]", pipeline_response.http_response + ) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get( + self, resource_group_name: str, resource_name: str, configuration_id: str, **kwargs: Any + ) -> _models.ApplicationInsightsComponentProactiveDetectionConfiguration: + """Get the ProactiveDetection configuration for this configuration id. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param configuration_id: The ProactiveDetection configuration ID. This is unique within a + Application Insights component. Required. + :type configuration_id: str + :return: ApplicationInsightsComponentProactiveDetectionConfiguration or the result of + cls(response) + :rtype: + ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentProactiveDetectionConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + cls: ClsType[_models.ApplicationInsightsComponentProactiveDetectionConfiguration] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + configuration_id=configuration_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize( + "ApplicationInsightsComponentProactiveDetectionConfiguration", pipeline_response.http_response + ) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + resource_name: str, + configuration_id: str, + proactive_detection_properties: _models.ApplicationInsightsComponentProactiveDetectionConfiguration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApplicationInsightsComponentProactiveDetectionConfiguration: + """Update the ProactiveDetection configuration for this configuration id. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param configuration_id: The ProactiveDetection configuration ID. This is unique within a + Application Insights component. Required. + :type configuration_id: str + :param proactive_detection_properties: Properties that need to be specified to update the + ProactiveDetection configuration. Required. + :type proactive_detection_properties: + ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentProactiveDetectionConfiguration + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationInsightsComponentProactiveDetectionConfiguration or the result of + cls(response) + :rtype: + ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentProactiveDetectionConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + resource_name: str, + configuration_id: str, + proactive_detection_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApplicationInsightsComponentProactiveDetectionConfiguration: + """Update the ProactiveDetection configuration for this configuration id. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param configuration_id: The ProactiveDetection configuration ID. This is unique within a + Application Insights component. Required. + :type configuration_id: str + :param proactive_detection_properties: Properties that need to be specified to update the + ProactiveDetection configuration. Required. + :type proactive_detection_properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationInsightsComponentProactiveDetectionConfiguration or the result of + cls(response) + :rtype: + ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentProactiveDetectionConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + resource_name: str, + configuration_id: str, + proactive_detection_properties: Union[ + _models.ApplicationInsightsComponentProactiveDetectionConfiguration, IO[bytes] + ], + **kwargs: Any + ) -> _models.ApplicationInsightsComponentProactiveDetectionConfiguration: + """Update the ProactiveDetection configuration for this configuration id. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param configuration_id: The ProactiveDetection configuration ID. This is unique within a + Application Insights component. Required. + :type configuration_id: str + :param proactive_detection_properties: Properties that need to be specified to update the + ProactiveDetection configuration. Is either a + ApplicationInsightsComponentProactiveDetectionConfiguration type or a IO[bytes] type. Required. + :type proactive_detection_properties: + ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentProactiveDetectionConfiguration + or IO[bytes] + :return: ApplicationInsightsComponentProactiveDetectionConfiguration or the result of + cls(response) + :rtype: + ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentProactiveDetectionConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ApplicationInsightsComponentProactiveDetectionConfiguration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(proactive_detection_properties, (IOBase, bytes)): + _content = proactive_detection_properties + else: + _json = self._serialize.body( + proactive_detection_properties, "ApplicationInsightsComponentProactiveDetectionConfiguration" + ) + + _request = build_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + configuration_id=configuration_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize( + "ApplicationInsightsComponentProactiveDetectionConfiguration", pipeline_response.http_response + ) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_web_test_locations_operations.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_web_test_locations_operations.py new file mode 100644 index 00000000000..1aa4451028c --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_web_test_locations_operations.py @@ -0,0 +1,130 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core import AsyncPipelineClient +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._web_test_locations_operations import build_list_request +from .._configuration import ApplicationInsightsManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class WebTestLocationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.applicationinsights.aio.ApplicationInsightsManagementClient`'s + :attr:`web_test_locations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApplicationInsightsManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ApplicationInsightsComponentWebTestLocation"]: + """Gets a list of web test locations available to this Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :return: An iterator like instance of either ApplicationInsightsComponentWebTestLocation or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentWebTestLocation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + cls: ClsType[_models.ApplicationInsightsWebTestLocationsListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationInsightsWebTestLocationsListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_web_tests_operations.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_web_tests_operations.py new file mode 100644 index 00000000000..629f1c458f7 --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_web_tests_operations.py @@ -0,0 +1,638 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core import AsyncPipelineClient +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._web_tests_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_component_request, + build_list_by_resource_group_request, + build_list_request, + build_update_tags_request, +) +from .._configuration import ApplicationInsightsManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class WebTestsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.applicationinsights.aio.ApplicationInsightsManagementClient`'s + :attr:`web_tests` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApplicationInsightsManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncItemPaged["_models.WebTest"]: + """Get all Application Insights web tests defined for the specified resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of either WebTest or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.models.WebTest] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) + cls: ClsType[_models.WebTestListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + 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, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("WebTestListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get(self, resource_group_name: str, web_test_name: str, **kwargs: Any) -> _models.WebTest: + """Get a specific Application Insights web test definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param web_test_name: The name of the Application Insights WebTest resource. Required. + :type web_test_name: str + :return: WebTest or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.WebTest + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) + cls: ClsType[_models.WebTest] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + web_test_name=web_test_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("WebTest", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + web_test_name: str, + web_test_definition: _models.WebTest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.WebTest: + """Creates or updates an Application Insights web test definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param web_test_name: The name of the Application Insights WebTest resource. Required. + :type web_test_name: str + :param web_test_definition: Properties that need to be specified to create or update an + Application Insights web test definition. Required. + :type web_test_definition: ~azure.mgmt.applicationinsights.models.WebTest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: WebTest or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.WebTest + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + web_test_name: str, + web_test_definition: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.WebTest: + """Creates or updates an Application Insights web test definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param web_test_name: The name of the Application Insights WebTest resource. Required. + :type web_test_name: str + :param web_test_definition: Properties that need to be specified to create or update an + Application Insights web test definition. Required. + :type web_test_definition: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: WebTest or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.WebTest + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + web_test_name: str, + web_test_definition: Union[_models.WebTest, IO[bytes]], + **kwargs: Any + ) -> _models.WebTest: + """Creates or updates an Application Insights web test definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param web_test_name: The name of the Application Insights WebTest resource. Required. + :type web_test_name: str + :param web_test_definition: Properties that need to be specified to create or update an + Application Insights web test definition. Is either a WebTest type or a IO[bytes] type. + Required. + :type web_test_definition: ~azure.mgmt.applicationinsights.models.WebTest or IO[bytes] + :return: WebTest or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.WebTest + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.WebTest] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(web_test_definition, (IOBase, bytes)): + _content = web_test_definition + else: + _json = self._serialize.body(web_test_definition, "WebTest") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + web_test_name=web_test_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("WebTest", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def update_tags( + self, + resource_group_name: str, + web_test_name: str, + web_test_tags: _models.TagsResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.WebTest: + """Updates the tags associated with an Application Insights web test. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param web_test_name: The name of the Application Insights WebTest resource. Required. + :type web_test_name: str + :param web_test_tags: Updated tag information to associate with the web test resource. + Required. + :type web_test_tags: ~azure.mgmt.applicationinsights.models.TagsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: WebTest or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.WebTest + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update_tags( + self, + resource_group_name: str, + web_test_name: str, + web_test_tags: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.WebTest: + """Updates the tags associated with an Application Insights web test. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param web_test_name: The name of the Application Insights WebTest resource. Required. + :type web_test_name: str + :param web_test_tags: Updated tag information to associate with the web test resource. + Required. + :type web_test_tags: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: WebTest or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.WebTest + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update_tags( + self, + resource_group_name: str, + web_test_name: str, + web_test_tags: Union[_models.TagsResource, IO[bytes]], + **kwargs: Any + ) -> _models.WebTest: + """Updates the tags associated with an Application Insights web test. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param web_test_name: The name of the Application Insights WebTest resource. Required. + :type web_test_name: str + :param web_test_tags: Updated tag information to associate with the web test resource. Is + either a TagsResource type or a IO[bytes] type. Required. + :type web_test_tags: ~azure.mgmt.applicationinsights.models.TagsResource or IO[bytes] + :return: WebTest or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.WebTest + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.WebTest] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(web_test_tags, (IOBase, bytes)): + _content = web_test_tags + else: + _json = self._serialize.body(web_test_tags, "TagsResource") + + _request = build_update_tags_request( + resource_group_name=resource_group_name, + web_test_name=web_test_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("WebTest", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete(self, resource_group_name: str, web_test_name: str, **kwargs: Any) -> None: + """Deletes an Application Insights web test. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param web_test_name: The name of the Application Insights WebTest resource. Required. + :type web_test_name: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + web_test_name=web_test_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncItemPaged["_models.WebTest"]: + """Get all Application Insights web test definitions for the specified subscription. + + :return: An iterator like instance of either WebTest or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.models.WebTest] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) + cls: ClsType[_models.WebTestListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("WebTestListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_component( + self, component_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.WebTest"]: + """Get all Application Insights web tests defined for the specified component. + + :param component_name: The name of the Application Insights component resource. Required. + :type component_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of either WebTest or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.models.WebTest] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) + cls: ClsType[_models.WebTestListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_component_request( + component_name=component_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("WebTestListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_work_item_configurations_operations.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_work_item_configurations_operations.py new file mode 100644 index 00000000000..711951a2ab7 --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_work_item_configurations_operations.py @@ -0,0 +1,597 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core import AsyncPipelineClient +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._work_item_configurations_operations import ( + build_create_request, + build_delete_request, + build_get_default_request, + build_get_item_request, + build_list_request, + build_update_item_request, +) +from .._configuration import ApplicationInsightsManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class WorkItemConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.applicationinsights.aio.ApplicationInsightsManagementClient`'s + :attr:`work_item_configurations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApplicationInsightsManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.WorkItemConfiguration"]: + """Gets the list work item configurations that exist for the application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :return: An iterator like instance of either WorkItemConfiguration or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.models.WorkItemConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + cls: ClsType[_models.WorkItemConfigurationsListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("WorkItemConfigurationsListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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.WorkItemConfigurationError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @overload + async def create( + self, + resource_group_name: str, + resource_name: str, + work_item_configuration_properties: _models.WorkItemCreateConfiguration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.WorkItemConfiguration: + """Create a work item configuration for an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param work_item_configuration_properties: Properties that need to be specified to create a + work item configuration of a Application Insights component. Required. + :type work_item_configuration_properties: + ~azure.mgmt.applicationinsights.models.WorkItemCreateConfiguration + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: WorkItemConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.WorkItemConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + resource_name: str, + work_item_configuration_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.WorkItemConfiguration: + """Create a work item configuration for an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param work_item_configuration_properties: Properties that need to be specified to create a + work item configuration of a Application Insights component. Required. + :type work_item_configuration_properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: WorkItemConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.WorkItemConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + resource_name: str, + work_item_configuration_properties: Union[_models.WorkItemCreateConfiguration, IO[bytes]], + **kwargs: Any + ) -> _models.WorkItemConfiguration: + """Create a work item configuration for an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param work_item_configuration_properties: Properties that need to be specified to create a + work item configuration of a Application Insights component. Is either a + WorkItemCreateConfiguration type or a IO[bytes] type. Required. + :type work_item_configuration_properties: + ~azure.mgmt.applicationinsights.models.WorkItemCreateConfiguration or IO[bytes] + :return: WorkItemConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.WorkItemConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.WorkItemConfiguration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(work_item_configuration_properties, (IOBase, bytes)): + _content = work_item_configuration_properties + else: + _json = self._serialize.body(work_item_configuration_properties, "WorkItemCreateConfiguration") + + _request = build_create_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("WorkItemConfiguration", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_default( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.WorkItemConfiguration: + """Gets default work item configurations that exist for the application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :return: WorkItemConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.WorkItemConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + cls: ClsType[_models.WorkItemConfiguration] = kwargs.pop("cls", None) + + _request = build_get_default_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("WorkItemConfiguration", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, resource_group_name: str, resource_name: str, work_item_config_id: str, **kwargs: Any + ) -> None: + """Delete a work item configuration of an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param work_item_config_id: The unique work item configuration Id. This can be either friendly + name of connector as defined in connector configuration. Required. + :type work_item_config_id: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + work_item_config_id=work_item_config_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace_async + async def get_item( + self, resource_group_name: str, resource_name: str, work_item_config_id: str, **kwargs: Any + ) -> _models.WorkItemConfiguration: + """Gets specified work item configuration for an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param work_item_config_id: The unique work item configuration Id. This can be either friendly + name of connector as defined in connector configuration. Required. + :type work_item_config_id: str + :return: WorkItemConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.WorkItemConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + cls: ClsType[_models.WorkItemConfiguration] = kwargs.pop("cls", None) + + _request = build_get_item_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + work_item_config_id=work_item_config_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("WorkItemConfiguration", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def update_item( + self, + resource_group_name: str, + resource_name: str, + work_item_config_id: str, + work_item_configuration_properties: _models.WorkItemCreateConfiguration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.WorkItemConfiguration: + """Update a work item configuration for an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param work_item_config_id: The unique work item configuration Id. This can be either friendly + name of connector as defined in connector configuration. Required. + :type work_item_config_id: str + :param work_item_configuration_properties: Properties that need to be specified to update a + work item configuration for this Application Insights component. Required. + :type work_item_configuration_properties: + ~azure.mgmt.applicationinsights.models.WorkItemCreateConfiguration + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: WorkItemConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.WorkItemConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update_item( + self, + resource_group_name: str, + resource_name: str, + work_item_config_id: str, + work_item_configuration_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.WorkItemConfiguration: + """Update a work item configuration for an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param work_item_config_id: The unique work item configuration Id. This can be either friendly + name of connector as defined in connector configuration. Required. + :type work_item_config_id: str + :param work_item_configuration_properties: Properties that need to be specified to update a + work item configuration for this Application Insights component. Required. + :type work_item_configuration_properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: WorkItemConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.WorkItemConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update_item( + self, + resource_group_name: str, + resource_name: str, + work_item_config_id: str, + work_item_configuration_properties: Union[_models.WorkItemCreateConfiguration, IO[bytes]], + **kwargs: Any + ) -> _models.WorkItemConfiguration: + """Update a work item configuration for an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param work_item_config_id: The unique work item configuration Id. This can be either friendly + name of connector as defined in connector configuration. Required. + :type work_item_config_id: str + :param work_item_configuration_properties: Properties that need to be specified to update a + work item configuration for this Application Insights component. Is either a + WorkItemCreateConfiguration type or a IO[bytes] type. Required. + :type work_item_configuration_properties: + ~azure.mgmt.applicationinsights.models.WorkItemCreateConfiguration or IO[bytes] + :return: WorkItemConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.WorkItemConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.WorkItemConfiguration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(work_item_configuration_properties, (IOBase, bytes)): + _content = work_item_configuration_properties + else: + _json = self._serialize.body(work_item_configuration_properties, "WorkItemCreateConfiguration") + + _request = build_update_item_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + work_item_config_id=work_item_config_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("WorkItemConfiguration", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_workbook_templates_operations.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_workbook_templates_operations.py new file mode 100644 index 00000000000..9bbe4554f5c --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_workbook_templates_operations.py @@ -0,0 +1,517 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core import AsyncPipelineClient +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._workbook_templates_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_update_request, +) +from .._configuration import ApplicationInsightsManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class WorkbookTemplatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.applicationinsights.aio.ApplicationInsightsManagementClient`'s + :attr:`workbook_templates` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApplicationInsightsManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.WorkbookTemplate"]: + """Get all Workbook templates defined within a specified resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of either WorkbookTemplate or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.models.WorkbookTemplate] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-20")) + cls: ClsType[_models.WorkbookTemplatesListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + 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, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("WorkbookTemplatesListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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.WorkbookTemplateError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.WorkbookTemplate: + """Get a single workbook template by its resourceName. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :return: WorkbookTemplate or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.WorkbookTemplate + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-20")) + cls: ClsType[_models.WorkbookTemplate] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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.WorkbookTemplateError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("WorkbookTemplate", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> None: + """Delete a workbook template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-20")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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.WorkbookTemplateError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + resource_name: str, + workbook_template_properties: _models.WorkbookTemplate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.WorkbookTemplate: + """Create a new workbook template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param workbook_template_properties: Properties that need to be specified to create a new + workbook. Required. + :type workbook_template_properties: ~azure.mgmt.applicationinsights.models.WorkbookTemplate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: WorkbookTemplate or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.WorkbookTemplate + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + resource_name: str, + workbook_template_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.WorkbookTemplate: + """Create a new workbook template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param workbook_template_properties: Properties that need to be specified to create a new + workbook. Required. + :type workbook_template_properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: WorkbookTemplate or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.WorkbookTemplate + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + resource_name: str, + workbook_template_properties: Union[_models.WorkbookTemplate, IO[bytes]], + **kwargs: Any + ) -> _models.WorkbookTemplate: + """Create a new workbook template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param workbook_template_properties: Properties that need to be specified to create a new + workbook. Is either a WorkbookTemplate type or a IO[bytes] type. Required. + :type workbook_template_properties: ~azure.mgmt.applicationinsights.models.WorkbookTemplate or + IO[bytes] + :return: WorkbookTemplate or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.WorkbookTemplate + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-20")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.WorkbookTemplate] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(workbook_template_properties, (IOBase, bytes)): + _content = workbook_template_properties + else: + _json = self._serialize.body(workbook_template_properties, "WorkbookTemplate") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.WorkbookTemplateError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("WorkbookTemplate", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + resource_name: str, + workbook_template_update_parameters: Optional[_models.WorkbookTemplateUpdateParameters] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.WorkbookTemplate: + """Updates a workbook template that has already been added. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param workbook_template_update_parameters: Properties that need to be specified to patch a + workbook template. Default value is None. + :type workbook_template_update_parameters: + ~azure.mgmt.applicationinsights.models.WorkbookTemplateUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: WorkbookTemplate or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.WorkbookTemplate + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + resource_name: str, + workbook_template_update_parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.WorkbookTemplate: + """Updates a workbook template that has already been added. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param workbook_template_update_parameters: Properties that need to be specified to patch a + workbook template. Default value is None. + :type workbook_template_update_parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: WorkbookTemplate or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.WorkbookTemplate + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + resource_name: str, + workbook_template_update_parameters: Optional[ + Union[_models.WorkbookTemplateUpdateParameters, IO[bytes]] + ] = None, + **kwargs: Any + ) -> _models.WorkbookTemplate: + """Updates a workbook template that has already been added. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param workbook_template_update_parameters: Properties that need to be specified to patch a + workbook template. Is either a WorkbookTemplateUpdateParameters type or a IO[bytes] type. + Default value is None. + :type workbook_template_update_parameters: + ~azure.mgmt.applicationinsights.models.WorkbookTemplateUpdateParameters or IO[bytes] + :return: WorkbookTemplate or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.WorkbookTemplate + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-20")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.WorkbookTemplate] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(workbook_template_update_parameters, (IOBase, bytes)): + _content = workbook_template_update_parameters + else: + if workbook_template_update_parameters is not None: + _json = self._serialize.body(workbook_template_update_parameters, "WorkbookTemplateUpdateParameters") + else: + _json = None + + _request = build_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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.WorkbookTemplateError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("WorkbookTemplate", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_workbooks_operations.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_workbooks_operations.py new file mode 100644 index 00000000000..8849e530866 --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/aio/operations/_workbooks_operations.py @@ -0,0 +1,789 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, overload + +from azure.core import AsyncPipelineClient +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer +from ...operations._workbooks_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_revision_get_request, + build_revisions_list_request, + build_update_request, +) +from .._configuration import ApplicationInsightsManagementClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class WorkbooksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.applicationinsights.aio.ApplicationInsightsManagementClient`'s + :attr:`workbooks` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApplicationInsightsManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_subscription( + self, + category: Union[str, _models.CategoryType], + tags: Optional[List[str]] = None, + can_fetch_content: Optional[bool] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.Workbook"]: + """Get all Workbooks defined within a specified subscription and category. + + :param category: Category of workbook to return. Known values are: "workbook", "TSG", + "performance", and "retention". Required. + :type category: str or ~azure.mgmt.applicationinsights.models.CategoryType + :param tags: Tags presents on each workbook returned. Default value is None. + :type tags: list[str] + :param can_fetch_content: Flag indicating whether or not to return the full content for each + applicable workbook. If false, only return summary content for workbooks. Default value is + None. + :type can_fetch_content: bool + :return: An iterator like instance of either Workbook or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.models.Workbook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01")) + cls: ClsType[_models.WorkbooksListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + category=category, + tags=tags, + can_fetch_content=can_fetch_content, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("WorkbooksListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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.WorkbookError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + category: Union[str, _models.CategoryType], + tags: Optional[List[str]] = None, + source_id: Optional[str] = None, + can_fetch_content: Optional[bool] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.Workbook"]: + """Get all Workbooks defined within a specified resource group and category. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param category: Category of workbook to return. Known values are: "workbook", "TSG", + "performance", and "retention". Required. + :type category: str or ~azure.mgmt.applicationinsights.models.CategoryType + :param tags: Tags presents on each workbook returned. Default value is None. + :type tags: list[str] + :param source_id: Azure Resource Id that will fetch all linked workbooks. Default value is + None. + :type source_id: str + :param can_fetch_content: Flag indicating whether or not to return the full content for each + applicable workbook. If false, only return summary content for workbooks. Default value is + None. + :type can_fetch_content: bool + :return: An iterator like instance of either Workbook or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.models.Workbook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01")) + cls: ClsType[_models.WorkbooksListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + 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, + category=category, + tags=tags, + source_id=source_id, + can_fetch_content=can_fetch_content, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("WorkbooksListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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.WorkbookError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, resource_group_name: str, resource_name: str, can_fetch_content: Optional[bool] = None, **kwargs: Any + ) -> _models.Workbook: + """Get a single workbook by its resourceName. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the workbook resource. The value must be an UUID. Required. + :type resource_name: str + :param can_fetch_content: Flag indicating whether or not to return the full content for each + applicable workbook. If false, only return summary content for workbooks. Default value is + None. + :type can_fetch_content: bool + :return: Workbook or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.Workbook + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01")) + cls: ClsType[_models.Workbook] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + can_fetch_content=can_fetch_content, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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.WorkbookError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Workbook", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> None: + """Delete a workbook. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the workbook resource. The value must be an UUID. Required. + :type resource_name: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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.WorkbookError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + resource_name: str, + workbook_properties: _models.Workbook, + source_id: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Workbook: + """Create a new workbook. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the workbook resource. The value must be an UUID. Required. + :type resource_name: str + :param workbook_properties: Properties that need to be specified to create a new workbook. + Required. + :type workbook_properties: ~azure.mgmt.applicationinsights.models.Workbook + :param source_id: Azure Resource Id that will fetch all linked workbooks. Default value is + None. + :type source_id: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Workbook or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.Workbook + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + resource_name: str, + workbook_properties: IO[bytes], + source_id: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Workbook: + """Create a new workbook. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the workbook resource. The value must be an UUID. Required. + :type resource_name: str + :param workbook_properties: Properties that need to be specified to create a new workbook. + Required. + :type workbook_properties: IO[bytes] + :param source_id: Azure Resource Id that will fetch all linked workbooks. Default value is + None. + :type source_id: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: Workbook or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.Workbook + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + resource_name: str, + workbook_properties: Union[_models.Workbook, IO[bytes]], + source_id: Optional[str] = None, + **kwargs: Any + ) -> _models.Workbook: + """Create a new workbook. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the workbook resource. The value must be an UUID. Required. + :type resource_name: str + :param workbook_properties: Properties that need to be specified to create a new workbook. Is + either a Workbook type or a IO[bytes] type. Required. + :type workbook_properties: ~azure.mgmt.applicationinsights.models.Workbook or IO[bytes] + :param source_id: Azure Resource Id that will fetch all linked workbooks. Default value is + None. + :type source_id: str + :return: Workbook or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.Workbook + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Workbook] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(workbook_properties, (IOBase, bytes)): + _content = workbook_properties + else: + _json = self._serialize.body(workbook_properties, "Workbook") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + source_id=source_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Workbook", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + resource_name: str, + source_id: Optional[str] = None, + workbook_update_parameters: Optional[_models.WorkbookUpdateParameters] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Workbook: + """Updates a workbook that has already been added. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the workbook resource. The value must be an UUID. Required. + :type resource_name: str + :param source_id: Azure Resource Id that will fetch all linked workbooks. Default value is + None. + :type source_id: str + :param workbook_update_parameters: Properties that need to be specified to create a new + workbook. Default value is None. + :type workbook_update_parameters: + ~azure.mgmt.applicationinsights.models.WorkbookUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Workbook or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.Workbook + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + resource_name: str, + source_id: Optional[str] = None, + workbook_update_parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Workbook: + """Updates a workbook that has already been added. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the workbook resource. The value must be an UUID. Required. + :type resource_name: str + :param source_id: Azure Resource Id that will fetch all linked workbooks. Default value is + None. + :type source_id: str + :param workbook_update_parameters: Properties that need to be specified to create a new + workbook. Default value is None. + :type workbook_update_parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: Workbook or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.Workbook + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + resource_name: str, + source_id: Optional[str] = None, + workbook_update_parameters: Optional[Union[_models.WorkbookUpdateParameters, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.Workbook: + """Updates a workbook that has already been added. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the workbook resource. The value must be an UUID. Required. + :type resource_name: str + :param source_id: Azure Resource Id that will fetch all linked workbooks. Default value is + None. + :type source_id: str + :param workbook_update_parameters: Properties that need to be specified to create a new + workbook. Is either a WorkbookUpdateParameters type or a IO[bytes] type. Default value is None. + :type workbook_update_parameters: + ~azure.mgmt.applicationinsights.models.WorkbookUpdateParameters or IO[bytes] + :return: Workbook or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.Workbook + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Workbook] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(workbook_update_parameters, (IOBase, bytes)): + _content = workbook_update_parameters + else: + if workbook_update_parameters is not None: + _json = self._serialize.body(workbook_update_parameters, "WorkbookUpdateParameters") + else: + _json = None + + _request = build_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + source_id=source_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Workbook", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def revisions_list( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.Workbook"]: + """Get the revisions for the workbook defined by its resourceName. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the workbook resource. The value must be an UUID. Required. + :type resource_name: str + :return: An iterator like instance of either Workbook or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.applicationinsights.models.Workbook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01")) + cls: ClsType[_models.WorkbooksListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_revisions_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("WorkbooksListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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.WorkbookError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def revision_get( + self, resource_group_name: str, resource_name: str, revision_id: str, **kwargs: Any + ) -> _models.Workbook: + """Get a single workbook revision defined by its revisionId. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the workbook resource. The value must be an UUID. Required. + :type resource_name: str + :param revision_id: The id of the workbook's revision. Required. + :type revision_id: str + :return: Workbook or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.Workbook + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01")) + cls: ClsType[_models.Workbook] = kwargs.pop("cls", None) + + _request = build_revision_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + revision_id=revision_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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.WorkbookError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Workbook", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/models/__init__.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/models/__init__.py new file mode 100644 index 00000000000..823347bc3cb --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/models/__init__.py @@ -0,0 +1,248 @@ +# 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. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + + +from ._models_py3 import ( # type: ignore + APIKeyRequest, + Annotation, + AnnotationError, + AnnotationsListResult, + ApplicationInsightsComponent, + ApplicationInsightsComponentAPIKey, + ApplicationInsightsComponentAPIKeyListResult, + ApplicationInsightsComponentAnalyticsItem, + ApplicationInsightsComponentAnalyticsItemProperties, + ApplicationInsightsComponentAvailableFeatures, + ApplicationInsightsComponentBillingFeatures, + ApplicationInsightsComponentDataVolumeCap, + ApplicationInsightsComponentExportConfiguration, + ApplicationInsightsComponentExportRequest, + ApplicationInsightsComponentFavorite, + ApplicationInsightsComponentFeature, + ApplicationInsightsComponentFeatureCapabilities, + ApplicationInsightsComponentFeatureCapability, + ApplicationInsightsComponentListResult, + ApplicationInsightsComponentProactiveDetectionConfiguration, + ApplicationInsightsComponentProactiveDetectionConfigurationRuleDefinitions, + ApplicationInsightsComponentQuotaStatus, + ApplicationInsightsComponentWebTestLocation, + ApplicationInsightsWebTestLocationsListResult, + ComponentLinkedStorageAccounts, + ComponentLinkedStorageAccountsPatch, + ComponentPurgeBody, + ComponentPurgeBodyFilters, + ComponentPurgeResponse, + ComponentPurgeStatusResponse, + ComponentsResource, + DeletedWorkbook, + DeletedWorkbookError, + DeletedWorkbookErrorDefinition, + DeletedWorkbookInnerErrorTrace, + DeletedWorkbookResource, + DeletedWorkbooksListResult, + ErrorFieldContract, + ErrorResponse, + ErrorResponseComponents, + ErrorResponseComponentsError, + ErrorResponseLinkedStorage, + ErrorResponseLinkedStorageError, + HeaderField, + InnerError, + LiveTokenResponse, + ManagedServiceIdentity, + Operation, + OperationDisplay, + OperationInfo, + OperationListResult, + OperationLive, + OperationsListResult, + PrivateLinkScopedResource, + ProxyResource, + Resource, + ResourceAutoGenerated, + SystemData, + TagsResource, + TrackedResource, + TrackedResourceAutoGenerated, + UserAssignedIdentity, + WebTest, + WebTestGeolocation, + WebTestListResult, + WebTestPropertiesConfiguration, + WebTestPropertiesRequest, + WebTestPropertiesValidationRules, + WebTestPropertiesValidationRulesContentValidation, + WebtestsResource, + WorkItemConfiguration, + WorkItemConfigurationError, + WorkItemConfigurationsListResult, + WorkItemCreateConfiguration, + Workbook, + WorkbookError, + WorkbookErrorDefinition, + WorkbookInnerErrorTrace, + WorkbookResource, + WorkbookResourceIdentity, + WorkbookTemplate, + WorkbookTemplateError, + WorkbookTemplateErrorBody, + WorkbookTemplateErrorFieldContract, + WorkbookTemplateGallery, + WorkbookTemplateLocalizedGallery, + WorkbookTemplateResource, + WorkbookTemplateUpdateParameters, + WorkbookTemplatesListResult, + WorkbookUpdateParameters, + WorkbooksListResult, +) + +from ._application_insights_management_client_enums import ( # type: ignore + ApplicationType, + CategoryType, + CreatedByType, + FavoriteSourceType, + FavoriteType, + FlowType, + IngestionMode, + ItemScope, + ItemScopePath, + ItemType, + ItemTypeParameter, + ManagedServiceIdentityType, + PublicNetworkAccessType, + PurgeState, + RequestSource, + StorageType, + WebTestKind, + WorkbookSharedTypeKind, + WorkbookUpdateSharedTypeKind, +) +from ._patch import __all__ as _patch_all +from ._patch import * +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "APIKeyRequest", + "Annotation", + "AnnotationError", + "AnnotationsListResult", + "ApplicationInsightsComponent", + "ApplicationInsightsComponentAPIKey", + "ApplicationInsightsComponentAPIKeyListResult", + "ApplicationInsightsComponentAnalyticsItem", + "ApplicationInsightsComponentAnalyticsItemProperties", + "ApplicationInsightsComponentAvailableFeatures", + "ApplicationInsightsComponentBillingFeatures", + "ApplicationInsightsComponentDataVolumeCap", + "ApplicationInsightsComponentExportConfiguration", + "ApplicationInsightsComponentExportRequest", + "ApplicationInsightsComponentFavorite", + "ApplicationInsightsComponentFeature", + "ApplicationInsightsComponentFeatureCapabilities", + "ApplicationInsightsComponentFeatureCapability", + "ApplicationInsightsComponentListResult", + "ApplicationInsightsComponentProactiveDetectionConfiguration", + "ApplicationInsightsComponentProactiveDetectionConfigurationRuleDefinitions", + "ApplicationInsightsComponentQuotaStatus", + "ApplicationInsightsComponentWebTestLocation", + "ApplicationInsightsWebTestLocationsListResult", + "ComponentLinkedStorageAccounts", + "ComponentLinkedStorageAccountsPatch", + "ComponentPurgeBody", + "ComponentPurgeBodyFilters", + "ComponentPurgeResponse", + "ComponentPurgeStatusResponse", + "ComponentsResource", + "DeletedWorkbook", + "DeletedWorkbookError", + "DeletedWorkbookErrorDefinition", + "DeletedWorkbookInnerErrorTrace", + "DeletedWorkbookResource", + "DeletedWorkbooksListResult", + "ErrorFieldContract", + "ErrorResponse", + "ErrorResponseComponents", + "ErrorResponseComponentsError", + "ErrorResponseLinkedStorage", + "ErrorResponseLinkedStorageError", + "HeaderField", + "InnerError", + "LiveTokenResponse", + "ManagedServiceIdentity", + "Operation", + "OperationDisplay", + "OperationInfo", + "OperationListResult", + "OperationLive", + "OperationsListResult", + "PrivateLinkScopedResource", + "ProxyResource", + "Resource", + "ResourceAutoGenerated", + "SystemData", + "TagsResource", + "TrackedResource", + "TrackedResourceAutoGenerated", + "UserAssignedIdentity", + "WebTest", + "WebTestGeolocation", + "WebTestListResult", + "WebTestPropertiesConfiguration", + "WebTestPropertiesRequest", + "WebTestPropertiesValidationRules", + "WebTestPropertiesValidationRulesContentValidation", + "WebtestsResource", + "WorkItemConfiguration", + "WorkItemConfigurationError", + "WorkItemConfigurationsListResult", + "WorkItemCreateConfiguration", + "Workbook", + "WorkbookError", + "WorkbookErrorDefinition", + "WorkbookInnerErrorTrace", + "WorkbookResource", + "WorkbookResourceIdentity", + "WorkbookTemplate", + "WorkbookTemplateError", + "WorkbookTemplateErrorBody", + "WorkbookTemplateErrorFieldContract", + "WorkbookTemplateGallery", + "WorkbookTemplateLocalizedGallery", + "WorkbookTemplateResource", + "WorkbookTemplateUpdateParameters", + "WorkbookTemplatesListResult", + "WorkbookUpdateParameters", + "WorkbooksListResult", + "ApplicationType", + "CategoryType", + "CreatedByType", + "FavoriteSourceType", + "FavoriteType", + "FlowType", + "IngestionMode", + "ItemScope", + "ItemScopePath", + "ItemType", + "ItemTypeParameter", + "ManagedServiceIdentityType", + "PublicNetworkAccessType", + "PurgeState", + "RequestSource", + "StorageType", + "WebTestKind", + "WorkbookSharedTypeKind", + "WorkbookUpdateSharedTypeKind", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore +_patch_sdk() diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/models/_application_insights_management_client_enums.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/models/_application_insights_management_client_enums.py new file mode 100644 index 00000000000..a38616606d7 --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/models/_application_insights_management_client_enums.py @@ -0,0 +1,172 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class ApplicationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of application being monitored.""" + + WEB = "web" + OTHER = "other" + + +class CategoryType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """CategoryType.""" + + WORKBOOK = "workbook" + TSG = "TSG" + PERFORMANCE = "performance" + RETENTION = "retention" + + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + + +class FavoriteSourceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """FavoriteSourceType.""" + + RETENTION = "retention" + NOTEBOOK = "notebook" + SESSIONS = "sessions" + EVENTS = "events" + USERFLOWS = "userflows" + FUNNEL = "funnel" + IMPACT = "impact" + SEGMENTATION = "segmentation" + + +class FavoriteType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum indicating if this favorite definition is owned by a specific user or is shared between + all users with access to the Application Insights component. + """ + + SHARED = "shared" + USER = "user" + + +class FlowType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Used by the Application Insights system to determine what kind of flow this component was + created by. This is to be set to 'Bluefield' when creating/updating a component via the REST + API. + """ + + BLUEFIELD = "Bluefield" + + +class IngestionMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates the flow of the ingestion.""" + + APPLICATION_INSIGHTS = "ApplicationInsights" + APPLICATION_INSIGHTS_WITH_DIAGNOSTIC_SETTINGS = "ApplicationInsightsWithDiagnosticSettings" + LOG_ANALYTICS = "LogAnalytics" + + +class ItemScope(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum indicating if this item definition is owned by a specific user or is shared between all + users with access to the Application Insights component. + """ + + SHARED = "shared" + USER = "user" + + +class ItemScopePath(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ItemScopePath.""" + + ANALYTICS_ITEMS = "analyticsItems" + MYANALYTICS_ITEMS = "myanalyticsItems" + + +class ItemType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum indicating the type of the Analytics item.""" + + NONE = "none" + QUERY = "query" + RECENT = "recent" + FUNCTION = "function" + + +class ItemTypeParameter(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ItemTypeParameter.""" + + NONE = "none" + QUERY = "query" + FUNCTION = "function" + FOLDER = "folder" + RECENT = "recent" + + +class ManagedServiceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of managed service identity (where both SystemAssigned and UserAssigned types are + allowed). + """ + + NONE = "None" + SYSTEM_ASSIGNED = "SystemAssigned" + USER_ASSIGNED = "UserAssigned" + SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned,UserAssigned" + + +class PublicNetworkAccessType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The network access type for operating on the Application Insights Component. By default it is + Enabled. + """ + + ENABLED = "Enabled" + """Enables connectivity to Application Insights through public DNS.""" + DISABLED = "Disabled" + """Disables public connectivity to Application Insights through public DNS.""" + + +class PurgeState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Status of the operation represented by the requested Id.""" + + PENDING = "pending" + COMPLETED = "completed" + + +class RequestSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Describes what tool created this Application Insights component. Customers using this API + should set this to the default 'rest'. + """ + + REST = "rest" + + +class StorageType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """StorageType.""" + + SERVICE_PROFILER = "ServiceProfiler" + + +class WebTestKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The kind of WebTest that this web test watches. Choices are ping, multistep and standard.""" + + PING = "ping" + MULTISTEP = "multistep" + STANDARD = "standard" + + +class WorkbookSharedTypeKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The kind of workbook. Only valid value is shared.""" + + SHARED = "shared" + + +class WorkbookUpdateSharedTypeKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The kind of workbook. Only valid value is shared.""" + + SHARED = "shared" diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/models/_models_py3.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/models/_models_py3.py new file mode 100644 index 00000000000..edb76c1936d --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/models/_models_py3.py @@ -0,0 +1,4481 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from collections.abc import MutableMapping +import datetime +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union + +from .._utils import serialization as _serialization + +if TYPE_CHECKING: + from .. import models as _models +JSON = MutableMapping[str, Any] + + +class Annotation(_serialization.Model): + """Annotation associated with an application insights resource. + + :ivar annotation_name: Name of annotation. + :vartype annotation_name: str + :ivar category: Category of annotation, free form. + :vartype category: str + :ivar event_time: Time when event occurred. + :vartype event_time: ~datetime.datetime + :ivar id: Unique Id for annotation. + :vartype id: str + :ivar properties: Serialized JSON object for detailed properties. + :vartype properties: str + :ivar related_annotation: Related parent annotation if any. + :vartype related_annotation: str + """ + + _attribute_map = { + "annotation_name": {"key": "AnnotationName", "type": "str"}, + "category": {"key": "Category", "type": "str"}, + "event_time": {"key": "EventTime", "type": "iso-8601"}, + "id": {"key": "Id", "type": "str"}, + "properties": {"key": "Properties", "type": "str"}, + "related_annotation": {"key": "RelatedAnnotation", "type": "str"}, + } + + def __init__( + self, + *, + annotation_name: Optional[str] = None, + category: Optional[str] = None, + event_time: Optional[datetime.datetime] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin + properties: Optional[str] = None, + related_annotation: str = "null", + **kwargs: Any + ) -> None: + """ + :keyword annotation_name: Name of annotation. + :paramtype annotation_name: str + :keyword category: Category of annotation, free form. + :paramtype category: str + :keyword event_time: Time when event occurred. + :paramtype event_time: ~datetime.datetime + :keyword id: Unique Id for annotation. + :paramtype id: str + :keyword properties: Serialized JSON object for detailed properties. + :paramtype properties: str + :keyword related_annotation: Related parent annotation if any. + :paramtype related_annotation: str + """ + super().__init__(**kwargs) + self.annotation_name = annotation_name + self.category = category + self.event_time = event_time + self.id = id + self.properties = properties + self.related_annotation = related_annotation + + +class AnnotationError(_serialization.Model): + """Error associated with trying to create annotation with Id that already exist. + + :ivar code: Error detail code and explanation. + :vartype code: str + :ivar message: Error message. + :vartype message: str + :ivar innererror: Inner error. + :vartype innererror: ~azure.mgmt.applicationinsights.models.InnerError + """ + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "innererror": {"key": "innererror", "type": "InnerError"}, + } + + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + innererror: Optional["_models.InnerError"] = None, + **kwargs: Any + ) -> None: + """ + :keyword code: Error detail code and explanation. + :paramtype code: str + :keyword message: Error message. + :paramtype message: str + :keyword innererror: Inner error. + :paramtype innererror: ~azure.mgmt.applicationinsights.models.InnerError + """ + super().__init__(**kwargs) + self.code = code + self.message = message + self.innererror = innererror + + +class AnnotationsListResult(_serialization.Model): + """Annotations list result. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: An array of annotations. + :vartype value: list[~azure.mgmt.applicationinsights.models.Annotation] + """ + + _validation = { + "value": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Annotation]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value: Optional[List["_models.Annotation"]] = None + + +class APIKeyRequest(_serialization.Model): + """An Application Insights component API Key creation request definition. + + :ivar name: The name of the API Key. + :vartype name: str + :ivar linked_read_properties: The read access rights of this API Key. + :vartype linked_read_properties: list[str] + :ivar linked_write_properties: The write access rights of this API Key. + :vartype linked_write_properties: list[str] + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "linked_read_properties": {"key": "linkedReadProperties", "type": "[str]"}, + "linked_write_properties": {"key": "linkedWriteProperties", "type": "[str]"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + linked_read_properties: Optional[List[str]] = None, + linked_write_properties: Optional[List[str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: The name of the API Key. + :paramtype name: str + :keyword linked_read_properties: The read access rights of this API Key. + :paramtype linked_read_properties: list[str] + :keyword linked_write_properties: The write access rights of this API Key. + :paramtype linked_write_properties: list[str] + """ + super().__init__(**kwargs) + self.name = name + self.linked_read_properties = linked_read_properties + self.linked_write_properties = linked_write_properties + + +class ComponentsResource(_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 server. + + :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: Resource location. Required. + :vartype location: str + :ivar 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: Any) -> None: + """ + :keyword location: Resource location. Required. + :paramtype location: str + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + self.location = location + self.tags = tags + + +class ApplicationInsightsComponent(ComponentsResource): + """An Application Insights component 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 server. + + :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: Resource location. Required. + :vartype location: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar kind: The kind of application that this component refers to, used to customize UI. This + value is a freeform string, values should typically be one of the following: web, ios, other, + store, java, phone. Required. + :vartype kind: str + :ivar etag: Resource etag. + :vartype etag: str + :ivar application_id: The unique ID of your application. This field mirrors the 'Name' field + and cannot be changed. + :vartype application_id: str + :ivar app_id: Application Insights Unique ID for your Application. + :vartype app_id: str + :ivar name_properties_name: Application name. + :vartype name_properties_name: str + :ivar application_type: Type of application being monitored. Known values are: "web" and + "other". + :vartype application_type: str or ~azure.mgmt.applicationinsights.models.ApplicationType + :ivar flow_type: Used by the Application Insights system to determine what kind of flow this + component was created by. This is to be set to 'Bluefield' when creating/updating a component + via the REST API. "Bluefield" + :vartype flow_type: str or ~azure.mgmt.applicationinsights.models.FlowType + :ivar request_source: Describes what tool created this Application Insights component. + Customers using this API should set this to the default 'rest'. "rest" + :vartype request_source: str or ~azure.mgmt.applicationinsights.models.RequestSource + :ivar instrumentation_key: Application Insights Instrumentation key. A read-only value that + applications can use to identify the destination for all telemetry sent to Azure Application + Insights. This value will be supplied upon construction of each new Application Insights + component. + :vartype instrumentation_key: str + :ivar creation_date: Creation Date for the Application Insights component, in ISO 8601 format. + :vartype creation_date: ~datetime.datetime + :ivar tenant_id: Azure Tenant Id. + :vartype tenant_id: str + :ivar hockey_app_id: The unique application ID created when a new application is added to + HockeyApp, used for communications with HockeyApp. + :vartype hockey_app_id: str + :ivar hockey_app_token: Token used to authenticate communications with between Application + Insights and HockeyApp. + :vartype hockey_app_token: str + :ivar provisioning_state: Current state of this component: 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 + :ivar sampling_percentage: Percentage of the data produced by the application being monitored + that is being sampled for Application Insights telemetry. + :vartype sampling_percentage: float + :ivar connection_string: Application Insights component connection string. + :vartype connection_string: str + :ivar retention_in_days: Retention period in days. + :vartype retention_in_days: int + :ivar disable_ip_masking: Disable IP masking. + :vartype disable_ip_masking: bool + :ivar immediate_purge_data_on30_days: Purge data immediately after 30 days. + :vartype immediate_purge_data_on30_days: bool + :ivar workspace_resource_id: Resource Id of the log analytics workspace which the data will be + ingested to. This property is required to create an application with this API version. + Applications from older versions will not have this property. + :vartype workspace_resource_id: str + :ivar la_migration_date: The date which the component got migrated to LA, in ISO 8601 format. + :vartype la_migration_date: ~datetime.datetime + :ivar private_link_scoped_resources: List of linked private link scope resources. + :vartype private_link_scoped_resources: + list[~azure.mgmt.applicationinsights.models.PrivateLinkScopedResource] + :ivar public_network_access_for_ingestion: The network access type for accessing Application + Insights ingestion. Known values are: "Enabled" and "Disabled". + :vartype public_network_access_for_ingestion: str or + ~azure.mgmt.applicationinsights.models.PublicNetworkAccessType + :ivar public_network_access_for_query: The network access type for accessing Application + Insights query. Known values are: "Enabled" and "Disabled". + :vartype public_network_access_for_query: str or + ~azure.mgmt.applicationinsights.models.PublicNetworkAccessType + :ivar ingestion_mode: Indicates the flow of the ingestion. Known values are: + "ApplicationInsights", "ApplicationInsightsWithDiagnosticSettings", and "LogAnalytics". + :vartype ingestion_mode: str or ~azure.mgmt.applicationinsights.models.IngestionMode + :ivar disable_local_auth: Disable Non-AAD based Auth. + :vartype disable_local_auth: bool + :ivar force_customer_storage_for_profiler: Force users to create their own storage account for + profiler and debugger. + :vartype force_customer_storage_for_profiler: bool + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "kind": {"required": True}, + "application_id": {"readonly": True}, + "app_id": {"readonly": True}, + "name_properties_name": {"readonly": True}, + "instrumentation_key": {"readonly": True}, + "creation_date": {"readonly": True}, + "tenant_id": {"readonly": True}, + "hockey_app_token": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "connection_string": {"readonly": True}, + "la_migration_date": {"readonly": True}, + "private_link_scoped_resources": {"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}"}, + "kind": {"key": "kind", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "application_id": {"key": "properties.ApplicationId", "type": "str"}, + "app_id": {"key": "properties.AppId", "type": "str"}, + "name_properties_name": {"key": "properties.Name", "type": "str"}, + "application_type": {"key": "properties.Application_Type", "type": "str"}, + "flow_type": {"key": "properties.Flow_Type", "type": "str"}, + "request_source": {"key": "properties.Request_Source", "type": "str"}, + "instrumentation_key": {"key": "properties.InstrumentationKey", "type": "str"}, + "creation_date": {"key": "properties.CreationDate", "type": "iso-8601"}, + "tenant_id": {"key": "properties.TenantId", "type": "str"}, + "hockey_app_id": {"key": "properties.HockeyAppId", "type": "str"}, + "hockey_app_token": {"key": "properties.HockeyAppToken", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "sampling_percentage": {"key": "properties.SamplingPercentage", "type": "float"}, + "connection_string": {"key": "properties.ConnectionString", "type": "str"}, + "retention_in_days": {"key": "properties.RetentionInDays", "type": "int"}, + "disable_ip_masking": {"key": "properties.DisableIpMasking", "type": "bool"}, + "immediate_purge_data_on30_days": {"key": "properties.ImmediatePurgeDataOn30Days", "type": "bool"}, + "workspace_resource_id": {"key": "properties.WorkspaceResourceId", "type": "str"}, + "la_migration_date": {"key": "properties.LaMigrationDate", "type": "iso-8601"}, + "private_link_scoped_resources": { + "key": "properties.PrivateLinkScopedResources", + "type": "[PrivateLinkScopedResource]", + }, + "public_network_access_for_ingestion": {"key": "properties.publicNetworkAccessForIngestion", "type": "str"}, + "public_network_access_for_query": {"key": "properties.publicNetworkAccessForQuery", "type": "str"}, + "ingestion_mode": {"key": "properties.IngestionMode", "type": "str"}, + "disable_local_auth": {"key": "properties.DisableLocalAuth", "type": "bool"}, + "force_customer_storage_for_profiler": {"key": "properties.ForceCustomerStorageForProfiler", "type": "bool"}, + } + + def __init__( # pylint: disable=too-many-locals + self, + *, + location: str, + kind: str, + tags: Optional[Dict[str, str]] = None, + etag: Optional[str] = None, + application_type: Union[str, "_models.ApplicationType"] = "web", + flow_type: Union[str, "_models.FlowType"] = "Bluefield", + request_source: Union[str, "_models.RequestSource"] = "rest", + hockey_app_id: Optional[str] = None, + sampling_percentage: Optional[float] = None, + retention_in_days: Optional[int] = None, + disable_ip_masking: Optional[bool] = None, + immediate_purge_data_on30_days: Optional[bool] = None, + workspace_resource_id: Optional[str] = None, + public_network_access_for_ingestion: Union[str, "_models.PublicNetworkAccessType"] = "Enabled", + public_network_access_for_query: Union[str, "_models.PublicNetworkAccessType"] = "Enabled", + ingestion_mode: Union[str, "_models.IngestionMode"] = "LogAnalytics", + disable_local_auth: Optional[bool] = None, + force_customer_storage_for_profiler: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword location: Resource location. Required. + :paramtype location: str + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword kind: The kind of application that this component refers to, used to customize UI. + This value is a freeform string, values should typically be one of the following: web, ios, + other, store, java, phone. Required. + :paramtype kind: str + :keyword etag: Resource etag. + :paramtype etag: str + :keyword application_type: Type of application being monitored. Known values are: "web" and + "other". + :paramtype application_type: str or ~azure.mgmt.applicationinsights.models.ApplicationType + :keyword flow_type: Used by the Application Insights system to determine what kind of flow this + component was created by. This is to be set to 'Bluefield' when creating/updating a component + via the REST API. "Bluefield" + :paramtype flow_type: str or ~azure.mgmt.applicationinsights.models.FlowType + :keyword request_source: Describes what tool created this Application Insights component. + Customers using this API should set this to the default 'rest'. "rest" + :paramtype request_source: str or ~azure.mgmt.applicationinsights.models.RequestSource + :keyword hockey_app_id: The unique application ID created when a new application is added to + HockeyApp, used for communications with HockeyApp. + :paramtype hockey_app_id: str + :keyword sampling_percentage: Percentage of the data produced by the application being + monitored that is being sampled for Application Insights telemetry. + :paramtype sampling_percentage: float + :keyword retention_in_days: Retention period in days. + :paramtype retention_in_days: int + :keyword disable_ip_masking: Disable IP masking. + :paramtype disable_ip_masking: bool + :keyword immediate_purge_data_on30_days: Purge data immediately after 30 days. + :paramtype immediate_purge_data_on30_days: bool + :keyword workspace_resource_id: Resource Id of the log analytics workspace which the data will + be ingested to. This property is required to create an application with this API version. + Applications from older versions will not have this property. + :paramtype workspace_resource_id: str + :keyword public_network_access_for_ingestion: The network access type for accessing Application + Insights ingestion. Known values are: "Enabled" and "Disabled". + :paramtype public_network_access_for_ingestion: str or + ~azure.mgmt.applicationinsights.models.PublicNetworkAccessType + :keyword public_network_access_for_query: The network access type for accessing Application + Insights query. Known values are: "Enabled" and "Disabled". + :paramtype public_network_access_for_query: str or + ~azure.mgmt.applicationinsights.models.PublicNetworkAccessType + :keyword ingestion_mode: Indicates the flow of the ingestion. Known values are: + "ApplicationInsights", "ApplicationInsightsWithDiagnosticSettings", and "LogAnalytics". + :paramtype ingestion_mode: str or ~azure.mgmt.applicationinsights.models.IngestionMode + :keyword disable_local_auth: Disable Non-AAD based Auth. + :paramtype disable_local_auth: bool + :keyword force_customer_storage_for_profiler: Force users to create their own storage account + for profiler and debugger. + :paramtype force_customer_storage_for_profiler: bool + """ + super().__init__(location=location, tags=tags, **kwargs) + self.kind = kind + self.etag = etag + self.application_id: Optional[str] = None + self.app_id: Optional[str] = None + self.name_properties_name: Optional[str] = None + self.application_type = application_type + self.flow_type = flow_type + self.request_source = request_source + self.instrumentation_key: Optional[str] = None + self.creation_date: Optional[datetime.datetime] = None + self.tenant_id: Optional[str] = None + self.hockey_app_id = hockey_app_id + self.hockey_app_token: Optional[str] = None + self.provisioning_state: Optional[str] = None + self.sampling_percentage = sampling_percentage + self.connection_string: Optional[str] = None + self.retention_in_days = retention_in_days + self.disable_ip_masking = disable_ip_masking + self.immediate_purge_data_on30_days = immediate_purge_data_on30_days + self.workspace_resource_id = workspace_resource_id + self.la_migration_date: Optional[datetime.datetime] = None + self.private_link_scoped_resources: Optional[List["_models.PrivateLinkScopedResource"]] = None + self.public_network_access_for_ingestion = public_network_access_for_ingestion + self.public_network_access_for_query = public_network_access_for_query + self.ingestion_mode = ingestion_mode + self.disable_local_auth = disable_local_auth + self.force_customer_storage_for_profiler = force_customer_storage_for_profiler + + +class ApplicationInsightsComponentAnalyticsItem(_serialization.Model): # pylint: disable=name-too-long + """Properties that define an Analytics item that is associated to an Application Insights + component. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Internally assigned unique id of the item definition. + :vartype id: str + :ivar name: The user-defined name of the item. + :vartype name: str + :ivar content: The content of this item. + :vartype content: str + :ivar version: This instance's version of the data model. This can change as new features are + added. + :vartype version: str + :ivar scope: Enum indicating if this item definition is owned by a specific user or is shared + between all users with access to the Application Insights component. Known values are: "shared" + and "user". + :vartype scope: str or ~azure.mgmt.applicationinsights.models.ItemScope + :ivar type: Enum indicating the type of the Analytics item. Known values are: "none", "query", + "recent", and "function". + :vartype type: str or ~azure.mgmt.applicationinsights.models.ItemType + :ivar time_created: Date and time in UTC when this item was created. + :vartype time_created: str + :ivar time_modified: Date and time in UTC of the last modification that was made to this item. + :vartype time_modified: str + :ivar properties: A set of properties that can be defined in the context of a specific item + type. Each type may have its own properties. + :vartype properties: + ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentAnalyticsItemProperties + """ + + _validation = { + "version": {"readonly": True}, + "time_created": {"readonly": True}, + "time_modified": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "Id", "type": "str"}, + "name": {"key": "Name", "type": "str"}, + "content": {"key": "Content", "type": "str"}, + "version": {"key": "Version", "type": "str"}, + "scope": {"key": "Scope", "type": "str"}, + "type": {"key": "Type", "type": "str"}, + "time_created": {"key": "TimeCreated", "type": "str"}, + "time_modified": {"key": "TimeModified", "type": "str"}, + "properties": {"key": "Properties", "type": "ApplicationInsightsComponentAnalyticsItemProperties"}, + } + + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + name: Optional[str] = None, + content: Optional[str] = None, + scope: Optional[Union[str, "_models.ItemScope"]] = None, + type: Optional[Union[str, "_models.ItemType"]] = None, + properties: Optional["_models.ApplicationInsightsComponentAnalyticsItemProperties"] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: Internally assigned unique id of the item definition. + :paramtype id: str + :keyword name: The user-defined name of the item. + :paramtype name: str + :keyword content: The content of this item. + :paramtype content: str + :keyword scope: Enum indicating if this item definition is owned by a specific user or is + shared between all users with access to the Application Insights component. Known values are: + "shared" and "user". + :paramtype scope: str or ~azure.mgmt.applicationinsights.models.ItemScope + :keyword type: Enum indicating the type of the Analytics item. Known values are: "none", + "query", "recent", and "function". + :paramtype type: str or ~azure.mgmt.applicationinsights.models.ItemType + :keyword properties: A set of properties that can be defined in the context of a specific item + type. Each type may have its own properties. + :paramtype properties: + ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentAnalyticsItemProperties + """ + super().__init__(**kwargs) + self.id = id + self.name = name + self.content = content + self.version: Optional[str] = None + self.scope = scope + self.type = type + self.time_created: Optional[str] = None + self.time_modified: Optional[str] = None + self.properties = properties + + +class ApplicationInsightsComponentAnalyticsItemProperties(_serialization.Model): # pylint: disable=name-too-long + """A set of properties that can be defined in the context of a specific item type. Each type may + have its own properties. + + :ivar function_alias: A function alias, used when the type of the item is Function. + :vartype function_alias: str + """ + + _attribute_map = { + "function_alias": {"key": "functionAlias", "type": "str"}, + } + + def __init__(self, *, function_alias: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword function_alias: A function alias, used when the type of the item is Function. + :paramtype function_alias: str + """ + super().__init__(**kwargs) + self.function_alias = function_alias + + +class ApplicationInsightsComponentAPIKey(_serialization.Model): + """Properties that define an API key of an Application Insights Component. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The unique ID of the API key inside an Application Insights component. It is auto + generated when the API key is created. + :vartype id: str + :ivar api_key: The API key value. It will be only return once when the API Key was created. + :vartype api_key: str + :ivar created_date: The create date of this API key. + :vartype created_date: str + :ivar name: The name of the API key. + :vartype name: str + :ivar linked_read_properties: The read access rights of this API Key. + :vartype linked_read_properties: list[str] + :ivar linked_write_properties: The write access rights of this API Key. + :vartype linked_write_properties: list[str] + """ + + _validation = { + "id": {"readonly": True}, + "api_key": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "api_key": {"key": "apiKey", "type": "str"}, + "created_date": {"key": "createdDate", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "linked_read_properties": {"key": "linkedReadProperties", "type": "[str]"}, + "linked_write_properties": {"key": "linkedWriteProperties", "type": "[str]"}, + } + + def __init__( + self, + *, + created_date: Optional[str] = None, + name: Optional[str] = None, + linked_read_properties: Optional[List[str]] = None, + linked_write_properties: Optional[List[str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword created_date: The create date of this API key. + :paramtype created_date: str + :keyword name: The name of the API key. + :paramtype name: str + :keyword linked_read_properties: The read access rights of this API Key. + :paramtype linked_read_properties: list[str] + :keyword linked_write_properties: The write access rights of this API Key. + :paramtype linked_write_properties: list[str] + """ + super().__init__(**kwargs) + self.id: Optional[str] = None + self.api_key: Optional[str] = None + self.created_date = created_date + self.name = name + self.linked_read_properties = linked_read_properties + self.linked_write_properties = linked_write_properties + + +class ApplicationInsightsComponentAPIKeyListResult(_serialization.Model): # pylint: disable=name-too-long + """Describes the list of API Keys of an Application Insights Component. + + All required parameters must be populated in order to send to server. + + :ivar value: List of API Key definitions. Required. + :vartype value: list[~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentAPIKey] + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[ApplicationInsightsComponentAPIKey]"}, + } + + def __init__(self, *, value: List["_models.ApplicationInsightsComponentAPIKey"], **kwargs: Any) -> None: + """ + :keyword value: List of API Key definitions. Required. + :paramtype value: + list[~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentAPIKey] + """ + super().__init__(**kwargs) + self.value = value + + +class ApplicationInsightsComponentAvailableFeatures(_serialization.Model): # pylint: disable=name-too-long + """An Application Insights component available features. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar result: A list of Application Insights component feature. + :vartype result: + list[~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentFeature] + """ + + _validation = { + "result": {"readonly": True}, + } + + _attribute_map = { + "result": {"key": "Result", "type": "[ApplicationInsightsComponentFeature]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.result: Optional[List["_models.ApplicationInsightsComponentFeature"]] = None + + +class ApplicationInsightsComponentBillingFeatures(_serialization.Model): # pylint: disable=name-too-long + """An Application Insights component billing features. + + :ivar data_volume_cap: An Application Insights component daily data volume cap. + :vartype data_volume_cap: + ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentDataVolumeCap + :ivar current_billing_features: Current enabled pricing plan. When the component is in the + Enterprise plan, this will list both 'Basic' and 'Application Insights Enterprise'. + :vartype current_billing_features: list[str] + """ + + _attribute_map = { + "data_volume_cap": {"key": "DataVolumeCap", "type": "ApplicationInsightsComponentDataVolumeCap"}, + "current_billing_features": {"key": "CurrentBillingFeatures", "type": "[str]"}, + } + + def __init__( + self, + *, + data_volume_cap: Optional["_models.ApplicationInsightsComponentDataVolumeCap"] = None, + current_billing_features: Optional[List[str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword data_volume_cap: An Application Insights component daily data volume cap. + :paramtype data_volume_cap: + ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentDataVolumeCap + :keyword current_billing_features: Current enabled pricing plan. When the component is in the + Enterprise plan, this will list both 'Basic' and 'Application Insights Enterprise'. + :paramtype current_billing_features: list[str] + """ + super().__init__(**kwargs) + self.data_volume_cap = data_volume_cap + self.current_billing_features = current_billing_features + + +class ApplicationInsightsComponentDataVolumeCap(_serialization.Model): # pylint: disable=name-too-long + """An Application Insights component daily data volume cap. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar cap: Daily data volume cap in GB. + :vartype cap: float + :ivar reset_time: Daily data volume cap UTC reset hour. + :vartype reset_time: int + :ivar warning_threshold: Reserved, not used for now. + :vartype warning_threshold: int + :ivar stop_send_notification_when_hit_threshold: Reserved, not used for now. + :vartype stop_send_notification_when_hit_threshold: bool + :ivar stop_send_notification_when_hit_cap: Do not send a notification email when the daily data + volume cap is met. + :vartype stop_send_notification_when_hit_cap: bool + :ivar max_history_cap: Maximum daily data volume cap that the user can set for this component. + :vartype max_history_cap: float + """ + + _validation = { + "reset_time": {"readonly": True}, + "max_history_cap": {"readonly": True}, + } + + _attribute_map = { + "cap": {"key": "Cap", "type": "float"}, + "reset_time": {"key": "ResetTime", "type": "int"}, + "warning_threshold": {"key": "WarningThreshold", "type": "int"}, + "stop_send_notification_when_hit_threshold": {"key": "StopSendNotificationWhenHitThreshold", "type": "bool"}, + "stop_send_notification_when_hit_cap": {"key": "StopSendNotificationWhenHitCap", "type": "bool"}, + "max_history_cap": {"key": "MaxHistoryCap", "type": "float"}, + } + + def __init__( + self, + *, + cap: Optional[float] = None, + warning_threshold: Optional[int] = None, + stop_send_notification_when_hit_threshold: Optional[bool] = None, + stop_send_notification_when_hit_cap: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword cap: Daily data volume cap in GB. + :paramtype cap: float + :keyword warning_threshold: Reserved, not used for now. + :paramtype warning_threshold: int + :keyword stop_send_notification_when_hit_threshold: Reserved, not used for now. + :paramtype stop_send_notification_when_hit_threshold: bool + :keyword stop_send_notification_when_hit_cap: Do not send a notification email when the daily + data volume cap is met. + :paramtype stop_send_notification_when_hit_cap: bool + """ + super().__init__(**kwargs) + self.cap = cap + self.reset_time: Optional[int] = None + self.warning_threshold = warning_threshold + self.stop_send_notification_when_hit_threshold = stop_send_notification_when_hit_threshold + self.stop_send_notification_when_hit_cap = stop_send_notification_when_hit_cap + self.max_history_cap: Optional[float] = None + + +class ApplicationInsightsComponentExportConfiguration(_serialization.Model): # pylint: disable=name-too-long + """Properties that define a Continuous Export configuration. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar export_id: The unique ID of the export configuration inside an Application Insights + component. It is auto generated when the Continuous Export configuration is created. + :vartype export_id: str + :ivar instrumentation_key: The instrumentation key of the Application Insights component. + :vartype instrumentation_key: str + :ivar record_types: This comma separated list of document types that will be exported. The + possible values include 'Requests', 'Event', 'Exceptions', 'Metrics', 'PageViews', + 'PageViewPerformance', 'Rdd', 'PerformanceCounters', 'Availability', 'Messages'. + :vartype record_types: str + :ivar application_name: The name of the Application Insights component. + :vartype application_name: str + :ivar subscription_id: The subscription of the Application Insights component. + :vartype subscription_id: str + :ivar resource_group: The resource group of the Application Insights component. + :vartype resource_group: str + :ivar destination_storage_subscription_id: The destination storage account subscription ID. + :vartype destination_storage_subscription_id: str + :ivar destination_storage_location_id: The destination account location ID. + :vartype destination_storage_location_id: str + :ivar destination_account_id: The name of destination account. + :vartype destination_account_id: str + :ivar destination_type: The destination type. + :vartype destination_type: str + :ivar is_user_enabled: This will be 'true' if the Continuous Export configuration is enabled, + otherwise it will be 'false'. + :vartype is_user_enabled: str + :ivar last_user_update: Last time the Continuous Export configuration was updated. + :vartype last_user_update: str + :ivar notification_queue_enabled: Deprecated. + :vartype notification_queue_enabled: str + :ivar export_status: This indicates current Continuous Export configuration status. The + possible values are 'Preparing', 'Success', 'Failure'. + :vartype export_status: str + :ivar last_success_time: The last time data was successfully delivered to the destination + storage container for this Continuous Export configuration. + :vartype last_success_time: str + :ivar last_gap_time: The last time the Continuous Export configuration started failing. + :vartype last_gap_time: str + :ivar permanent_error_reason: This is the reason the Continuous Export configuration started + failing. It can be 'AzureStorageNotFound' or 'AzureStorageAccessDenied'. + :vartype permanent_error_reason: str + :ivar storage_name: The name of the destination storage account. + :vartype storage_name: str + :ivar container_name: The name of the destination storage container. + :vartype container_name: str + """ + + _validation = { + "export_id": {"readonly": True}, + "instrumentation_key": {"readonly": True}, + "application_name": {"readonly": True}, + "subscription_id": {"readonly": True}, + "resource_group": {"readonly": True}, + "destination_storage_subscription_id": {"readonly": True}, + "destination_storage_location_id": {"readonly": True}, + "destination_account_id": {"readonly": True}, + "destination_type": {"readonly": True}, + "is_user_enabled": {"readonly": True}, + "last_user_update": {"readonly": True}, + "export_status": {"readonly": True}, + "last_success_time": {"readonly": True}, + "last_gap_time": {"readonly": True}, + "permanent_error_reason": {"readonly": True}, + "storage_name": {"readonly": True}, + "container_name": {"readonly": True}, + } + + _attribute_map = { + "export_id": {"key": "ExportId", "type": "str"}, + "instrumentation_key": {"key": "InstrumentationKey", "type": "str"}, + "record_types": {"key": "RecordTypes", "type": "str"}, + "application_name": {"key": "ApplicationName", "type": "str"}, + "subscription_id": {"key": "SubscriptionId", "type": "str"}, + "resource_group": {"key": "ResourceGroup", "type": "str"}, + "destination_storage_subscription_id": {"key": "DestinationStorageSubscriptionId", "type": "str"}, + "destination_storage_location_id": {"key": "DestinationStorageLocationId", "type": "str"}, + "destination_account_id": {"key": "DestinationAccountId", "type": "str"}, + "destination_type": {"key": "DestinationType", "type": "str"}, + "is_user_enabled": {"key": "IsUserEnabled", "type": "str"}, + "last_user_update": {"key": "LastUserUpdate", "type": "str"}, + "notification_queue_enabled": {"key": "NotificationQueueEnabled", "type": "str"}, + "export_status": {"key": "ExportStatus", "type": "str"}, + "last_success_time": {"key": "LastSuccessTime", "type": "str"}, + "last_gap_time": {"key": "LastGapTime", "type": "str"}, + "permanent_error_reason": {"key": "PermanentErrorReason", "type": "str"}, + "storage_name": {"key": "StorageName", "type": "str"}, + "container_name": {"key": "ContainerName", "type": "str"}, + } + + def __init__( + self, *, record_types: Optional[str] = None, notification_queue_enabled: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword record_types: This comma separated list of document types that will be exported. The + possible values include 'Requests', 'Event', 'Exceptions', 'Metrics', 'PageViews', + 'PageViewPerformance', 'Rdd', 'PerformanceCounters', 'Availability', 'Messages'. + :paramtype record_types: str + :keyword notification_queue_enabled: Deprecated. + :paramtype notification_queue_enabled: str + """ + super().__init__(**kwargs) + self.export_id: Optional[str] = None + self.instrumentation_key: Optional[str] = None + self.record_types = record_types + self.application_name: Optional[str] = None + self.subscription_id: Optional[str] = None + self.resource_group: Optional[str] = None + self.destination_storage_subscription_id: Optional[str] = None + self.destination_storage_location_id: Optional[str] = None + self.destination_account_id: Optional[str] = None + self.destination_type: Optional[str] = None + self.is_user_enabled: Optional[str] = None + self.last_user_update: Optional[str] = None + self.notification_queue_enabled = notification_queue_enabled + self.export_status: Optional[str] = None + self.last_success_time: Optional[str] = None + self.last_gap_time: Optional[str] = None + self.permanent_error_reason: Optional[str] = None + self.storage_name: Optional[str] = None + self.container_name: Optional[str] = None + + +class ApplicationInsightsComponentExportRequest(_serialization.Model): # pylint: disable=name-too-long + """An Application Insights component Continuous Export configuration request definition. + + :ivar record_types: The document types to be exported, as comma separated values. Allowed + values include 'Requests', 'Event', 'Exceptions', 'Metrics', 'PageViews', + 'PageViewPerformance', 'Rdd', 'PerformanceCounters', 'Availability', 'Messages'. + :vartype record_types: str + :ivar destination_type: The Continuous Export destination type. This has to be 'Blob'. + :vartype destination_type: str + :ivar destination_address: The SAS URL for the destination storage container. It must grant + write permission. + :vartype destination_address: str + :ivar is_enabled: Set to 'true' to create a Continuous Export configuration as enabled, + otherwise set it to 'false'. + :vartype is_enabled: str + :ivar notification_queue_enabled: Deprecated. + :vartype notification_queue_enabled: str + :ivar notification_queue_uri: Deprecated. + :vartype notification_queue_uri: str + :ivar destination_storage_subscription_id: The subscription ID of the destination storage + container. + :vartype destination_storage_subscription_id: str + :ivar destination_storage_location_id: The location ID of the destination storage container. + :vartype destination_storage_location_id: str + :ivar destination_account_id: The name of destination storage account. + :vartype destination_account_id: str + """ + + _attribute_map = { + "record_types": {"key": "RecordTypes", "type": "str"}, + "destination_type": {"key": "DestinationType", "type": "str"}, + "destination_address": {"key": "DestinationAddress", "type": "str"}, + "is_enabled": {"key": "IsEnabled", "type": "str"}, + "notification_queue_enabled": {"key": "NotificationQueueEnabled", "type": "str"}, + "notification_queue_uri": {"key": "NotificationQueueUri", "type": "str"}, + "destination_storage_subscription_id": {"key": "DestinationStorageSubscriptionId", "type": "str"}, + "destination_storage_location_id": {"key": "DestinationStorageLocationId", "type": "str"}, + "destination_account_id": {"key": "DestinationAccountId", "type": "str"}, + } + + def __init__( + self, + *, + record_types: Optional[str] = None, + destination_type: Optional[str] = None, + destination_address: Optional[str] = None, + is_enabled: Optional[str] = None, + notification_queue_enabled: Optional[str] = None, + notification_queue_uri: Optional[str] = None, + destination_storage_subscription_id: Optional[str] = None, + destination_storage_location_id: Optional[str] = None, + destination_account_id: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword record_types: The document types to be exported, as comma separated values. Allowed + values include 'Requests', 'Event', 'Exceptions', 'Metrics', 'PageViews', + 'PageViewPerformance', 'Rdd', 'PerformanceCounters', 'Availability', 'Messages'. + :paramtype record_types: str + :keyword destination_type: The Continuous Export destination type. This has to be 'Blob'. + :paramtype destination_type: str + :keyword destination_address: The SAS URL for the destination storage container. It must grant + write permission. + :paramtype destination_address: str + :keyword is_enabled: Set to 'true' to create a Continuous Export configuration as enabled, + otherwise set it to 'false'. + :paramtype is_enabled: str + :keyword notification_queue_enabled: Deprecated. + :paramtype notification_queue_enabled: str + :keyword notification_queue_uri: Deprecated. + :paramtype notification_queue_uri: str + :keyword destination_storage_subscription_id: The subscription ID of the destination storage + container. + :paramtype destination_storage_subscription_id: str + :keyword destination_storage_location_id: The location ID of the destination storage container. + :paramtype destination_storage_location_id: str + :keyword destination_account_id: The name of destination storage account. + :paramtype destination_account_id: str + """ + super().__init__(**kwargs) + self.record_types = record_types + self.destination_type = destination_type + self.destination_address = destination_address + self.is_enabled = is_enabled + self.notification_queue_enabled = notification_queue_enabled + self.notification_queue_uri = notification_queue_uri + self.destination_storage_subscription_id = destination_storage_subscription_id + self.destination_storage_location_id = destination_storage_location_id + self.destination_account_id = destination_account_id + + +class ApplicationInsightsComponentFavorite(_serialization.Model): + """Properties that define a favorite that is associated to an Application Insights component. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The user-defined name of the favorite. + :vartype name: str + :ivar config: Configuration of this particular favorite, which are driven by the Azure portal + UX. Configuration data is a string containing valid JSON. + :vartype config: str + :ivar version: This instance's version of the data model. This can change as new features are + added that can be marked favorite. Current examples include MetricsExplorer (ME) and Search. + :vartype version: str + :ivar favorite_id: Internally assigned unique id of the favorite definition. + :vartype favorite_id: str + :ivar favorite_type: Enum indicating if this favorite definition is owned by a specific user or + is shared between all users with access to the Application Insights component. Known values + are: "shared" and "user". + :vartype favorite_type: str or ~azure.mgmt.applicationinsights.models.FavoriteType + :ivar source_type: The source of the favorite definition. + :vartype source_type: str + :ivar time_modified: Date and time in UTC of the last modification that was made to this + favorite definition. + :vartype time_modified: str + :ivar tags: A list of 0 or more tags that are associated with this favorite definition. + :vartype tags: list[str] + :ivar category: Favorite category, as defined by the user at creation time. + :vartype category: str + :ivar is_generated_from_template: Flag denoting wether or not this favorite was generated from + a template. + :vartype is_generated_from_template: bool + :ivar user_id: Unique user id of the specific user that owns this favorite. + :vartype user_id: str + """ + + _validation = { + "favorite_id": {"readonly": True}, + "time_modified": {"readonly": True}, + "user_id": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "Name", "type": "str"}, + "config": {"key": "Config", "type": "str"}, + "version": {"key": "Version", "type": "str"}, + "favorite_id": {"key": "FavoriteId", "type": "str"}, + "favorite_type": {"key": "FavoriteType", "type": "str"}, + "source_type": {"key": "SourceType", "type": "str"}, + "time_modified": {"key": "TimeModified", "type": "str"}, + "tags": {"key": "Tags", "type": "[str]"}, + "category": {"key": "Category", "type": "str"}, + "is_generated_from_template": {"key": "IsGeneratedFromTemplate", "type": "bool"}, + "user_id": {"key": "UserId", "type": "str"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + config: Optional[str] = None, + version: Optional[str] = None, + favorite_type: Optional[Union[str, "_models.FavoriteType"]] = None, + source_type: Optional[str] = None, + tags: Optional[List[str]] = None, + category: Optional[str] = None, + is_generated_from_template: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: The user-defined name of the favorite. + :paramtype name: str + :keyword config: Configuration of this particular favorite, which are driven by the Azure + portal UX. Configuration data is a string containing valid JSON. + :paramtype config: str + :keyword version: This instance's version of the data model. This can change as new features + are added that can be marked favorite. Current examples include MetricsExplorer (ME) and + Search. + :paramtype version: str + :keyword favorite_type: Enum indicating if this favorite definition is owned by a specific user + or is shared between all users with access to the Application Insights component. Known values + are: "shared" and "user". + :paramtype favorite_type: str or ~azure.mgmt.applicationinsights.models.FavoriteType + :keyword source_type: The source of the favorite definition. + :paramtype source_type: str + :keyword tags: A list of 0 or more tags that are associated with this favorite definition. + :paramtype tags: list[str] + :keyword category: Favorite category, as defined by the user at creation time. + :paramtype category: str + :keyword is_generated_from_template: Flag denoting wether or not this favorite was generated + from a template. + :paramtype is_generated_from_template: bool + """ + super().__init__(**kwargs) + self.name = name + self.config = config + self.version = version + self.favorite_id: Optional[str] = None + self.favorite_type = favorite_type + self.source_type = source_type + self.time_modified: Optional[str] = None + self.tags = tags + self.category = category + self.is_generated_from_template = is_generated_from_template + self.user_id: Optional[str] = None + + +class ApplicationInsightsComponentFeature(_serialization.Model): + """An Application Insights component daily data volume cap status. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar feature_name: The pricing feature name. + :vartype feature_name: str + :ivar meter_id: The meter id used for the feature. + :vartype meter_id: str + :ivar meter_rate_frequency: The meter rate for the feature's meter. + :vartype meter_rate_frequency: str + :ivar resouce_id: Reserved, not used now. + :vartype resouce_id: str + :ivar is_hidden: Reserved, not used now. + :vartype is_hidden: bool + :ivar capabilities: A list of Application Insights component feature capability. + :vartype capabilities: + list[~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentFeatureCapability] + :ivar title: Display name of the feature. + :vartype title: str + :ivar is_main_feature: Whether can apply addon feature on to it. + :vartype is_main_feature: bool + :ivar supported_addon_features: The add on features on main feature. + :vartype supported_addon_features: str + """ + + _validation = { + "feature_name": {"readonly": True}, + "meter_id": {"readonly": True}, + "meter_rate_frequency": {"readonly": True}, + "resouce_id": {"readonly": True}, + "is_hidden": {"readonly": True}, + "capabilities": {"readonly": True}, + "title": {"readonly": True}, + "is_main_feature": {"readonly": True}, + "supported_addon_features": {"readonly": True}, + } + + _attribute_map = { + "feature_name": {"key": "FeatureName", "type": "str"}, + "meter_id": {"key": "MeterId", "type": "str"}, + "meter_rate_frequency": {"key": "MeterRateFrequency", "type": "str"}, + "resouce_id": {"key": "ResouceId", "type": "str"}, + "is_hidden": {"key": "IsHidden", "type": "bool"}, + "capabilities": {"key": "Capabilities", "type": "[ApplicationInsightsComponentFeatureCapability]"}, + "title": {"key": "Title", "type": "str"}, + "is_main_feature": {"key": "IsMainFeature", "type": "bool"}, + "supported_addon_features": {"key": "SupportedAddonFeatures", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.feature_name: Optional[str] = None + self.meter_id: Optional[str] = None + self.meter_rate_frequency: Optional[str] = None + self.resouce_id: Optional[str] = None + self.is_hidden: Optional[bool] = None + self.capabilities: Optional[List["_models.ApplicationInsightsComponentFeatureCapability"]] = None + self.title: Optional[str] = None + self.is_main_feature: Optional[bool] = None + self.supported_addon_features: Optional[str] = None + + +class ApplicationInsightsComponentFeatureCapabilities(_serialization.Model): # pylint: disable=name-too-long + """An Application Insights component feature capabilities. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar support_export_data: Whether allow to use continuous export feature. + :vartype support_export_data: bool + :ivar burst_throttle_policy: Reserved, not used now. + :vartype burst_throttle_policy: str + :ivar metadata_class: Reserved, not used now. + :vartype metadata_class: str + :ivar live_stream_metrics: Reserved, not used now. + :vartype live_stream_metrics: bool + :ivar application_map: Reserved, not used now. + :vartype application_map: bool + :ivar work_item_integration: Whether allow to use work item integration feature. + :vartype work_item_integration: bool + :ivar power_bi_integration: Reserved, not used now. + :vartype power_bi_integration: bool + :ivar open_schema: Reserved, not used now. + :vartype open_schema: bool + :ivar proactive_detection: Reserved, not used now. + :vartype proactive_detection: bool + :ivar analytics_integration: Reserved, not used now. + :vartype analytics_integration: bool + :ivar multiple_step_web_test: Whether allow to use multiple steps web test feature. + :vartype multiple_step_web_test: bool + :ivar api_access_level: Reserved, not used now. + :vartype api_access_level: str + :ivar tracking_type: The application insights component used tracking type. + :vartype tracking_type: str + :ivar daily_cap: Daily data volume cap in GB. + :vartype daily_cap: float + :ivar daily_cap_reset_time: Daily data volume cap UTC reset hour. + :vartype daily_cap_reset_time: float + :ivar throttle_rate: Reserved, not used now. + :vartype throttle_rate: float + """ + + _validation = { + "support_export_data": {"readonly": True}, + "burst_throttle_policy": {"readonly": True}, + "metadata_class": {"readonly": True}, + "live_stream_metrics": {"readonly": True}, + "application_map": {"readonly": True}, + "work_item_integration": {"readonly": True}, + "power_bi_integration": {"readonly": True}, + "open_schema": {"readonly": True}, + "proactive_detection": {"readonly": True}, + "analytics_integration": {"readonly": True}, + "multiple_step_web_test": {"readonly": True}, + "api_access_level": {"readonly": True}, + "tracking_type": {"readonly": True}, + "daily_cap": {"readonly": True}, + "daily_cap_reset_time": {"readonly": True}, + "throttle_rate": {"readonly": True}, + } + + _attribute_map = { + "support_export_data": {"key": "SupportExportData", "type": "bool"}, + "burst_throttle_policy": {"key": "BurstThrottlePolicy", "type": "str"}, + "metadata_class": {"key": "MetadataClass", "type": "str"}, + "live_stream_metrics": {"key": "LiveStreamMetrics", "type": "bool"}, + "application_map": {"key": "ApplicationMap", "type": "bool"}, + "work_item_integration": {"key": "WorkItemIntegration", "type": "bool"}, + "power_bi_integration": {"key": "PowerBIIntegration", "type": "bool"}, + "open_schema": {"key": "OpenSchema", "type": "bool"}, + "proactive_detection": {"key": "ProactiveDetection", "type": "bool"}, + "analytics_integration": {"key": "AnalyticsIntegration", "type": "bool"}, + "multiple_step_web_test": {"key": "MultipleStepWebTest", "type": "bool"}, + "api_access_level": {"key": "ApiAccessLevel", "type": "str"}, + "tracking_type": {"key": "TrackingType", "type": "str"}, + "daily_cap": {"key": "DailyCap", "type": "float"}, + "daily_cap_reset_time": {"key": "DailyCapResetTime", "type": "float"}, + "throttle_rate": {"key": "ThrottleRate", "type": "float"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.support_export_data: Optional[bool] = None + self.burst_throttle_policy: Optional[str] = None + self.metadata_class: Optional[str] = None + self.live_stream_metrics: Optional[bool] = None + self.application_map: Optional[bool] = None + self.work_item_integration: Optional[bool] = None + self.power_bi_integration: Optional[bool] = None + self.open_schema: Optional[bool] = None + self.proactive_detection: Optional[bool] = None + self.analytics_integration: Optional[bool] = None + self.multiple_step_web_test: Optional[bool] = None + self.api_access_level: Optional[str] = None + self.tracking_type: Optional[str] = None + self.daily_cap: Optional[float] = None + self.daily_cap_reset_time: Optional[float] = None + self.throttle_rate: Optional[float] = None + + +class ApplicationInsightsComponentFeatureCapability(_serialization.Model): # pylint: disable=name-too-long + """An Application Insights component feature capability. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the capability. + :vartype name: str + :ivar description: The description of the capability. + :vartype description: str + :ivar value: The value of the capability. + :vartype value: str + :ivar unit: The unit of the capability. + :vartype unit: str + :ivar meter_id: The meter used for the capability. + :vartype meter_id: str + :ivar meter_rate_frequency: The meter rate of the meter. + :vartype meter_rate_frequency: str + """ + + _validation = { + "name": {"readonly": True}, + "description": {"readonly": True}, + "value": {"readonly": True}, + "unit": {"readonly": True}, + "meter_id": {"readonly": True}, + "meter_rate_frequency": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "Name", "type": "str"}, + "description": {"key": "Description", "type": "str"}, + "value": {"key": "Value", "type": "str"}, + "unit": {"key": "Unit", "type": "str"}, + "meter_id": {"key": "MeterId", "type": "str"}, + "meter_rate_frequency": {"key": "MeterRateFrequency", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.name: Optional[str] = None + self.description: Optional[str] = None + self.value: Optional[str] = None + self.unit: Optional[str] = None + self.meter_id: Optional[str] = None + self.meter_rate_frequency: Optional[str] = None + + +class ApplicationInsightsComponentListResult(_serialization.Model): + """Describes the list of Application Insights Resources. + + All required parameters must be populated in order to send to server. + + :ivar value: List of Application Insights component definitions. Required. + :vartype value: list[~azure.mgmt.applicationinsights.models.ApplicationInsightsComponent] + :ivar next_link: The URI to get the next set of Application Insights component definitions if + too many components where returned in the result set. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[ApplicationInsightsComponent]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: List["_models.ApplicationInsightsComponent"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: List of Application Insights component definitions. Required. + :paramtype value: list[~azure.mgmt.applicationinsights.models.ApplicationInsightsComponent] + :keyword next_link: The URI to get the next set of Application Insights component definitions + if too many components where returned in the result set. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ApplicationInsightsComponentProactiveDetectionConfiguration( + _serialization.Model +): # pylint: disable=name-too-long + """Properties that define a ProactiveDetection configuration. + + :ivar name: The rule name. + :vartype name: str + :ivar enabled: A flag that indicates whether this rule is enabled by the user. + :vartype enabled: bool + :ivar send_emails_to_subscription_owners: A flag that indicated whether notifications on this + rule should be sent to subscription owners. + :vartype send_emails_to_subscription_owners: bool + :ivar custom_emails: Custom email addresses for this rule notifications. + :vartype custom_emails: list[str] + :ivar last_updated_time: The last time this rule was updated. + :vartype last_updated_time: str + :ivar rule_definitions: Static definitions of the ProactiveDetection configuration rule (same + values for all components). + :vartype rule_definitions: + ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentProactiveDetectionConfigurationRuleDefinitions + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "enabled": {"key": "enabled", "type": "bool"}, + "send_emails_to_subscription_owners": {"key": "sendEmailsToSubscriptionOwners", "type": "bool"}, + "custom_emails": {"key": "customEmails", "type": "[str]"}, + "last_updated_time": {"key": "lastUpdatedTime", "type": "str"}, + "rule_definitions": { + "key": "ruleDefinitions", + "type": "ApplicationInsightsComponentProactiveDetectionConfigurationRuleDefinitions", + }, + } + + def __init__( + self, + *, + name: Optional[str] = None, + enabled: Optional[bool] = None, + send_emails_to_subscription_owners: Optional[bool] = None, + custom_emails: Optional[List[str]] = None, + last_updated_time: Optional[str] = None, + rule_definitions: Optional[ + "_models.ApplicationInsightsComponentProactiveDetectionConfigurationRuleDefinitions" + ] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: The rule name. + :paramtype name: str + :keyword enabled: A flag that indicates whether this rule is enabled by the user. + :paramtype enabled: bool + :keyword send_emails_to_subscription_owners: A flag that indicated whether notifications on + this rule should be sent to subscription owners. + :paramtype send_emails_to_subscription_owners: bool + :keyword custom_emails: Custom email addresses for this rule notifications. + :paramtype custom_emails: list[str] + :keyword last_updated_time: The last time this rule was updated. + :paramtype last_updated_time: str + :keyword rule_definitions: Static definitions of the ProactiveDetection configuration rule + (same values for all components). + :paramtype rule_definitions: + ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentProactiveDetectionConfigurationRuleDefinitions + """ + super().__init__(**kwargs) + self.name = name + self.enabled = enabled + self.send_emails_to_subscription_owners = send_emails_to_subscription_owners + self.custom_emails = custom_emails + self.last_updated_time = last_updated_time + self.rule_definitions = rule_definitions + + +class ApplicationInsightsComponentProactiveDetectionConfigurationRuleDefinitions( + _serialization.Model +): # pylint: disable=name-too-long + """Static definitions of the ProactiveDetection configuration rule (same values for all + components). + + :ivar name: The rule name. + :vartype name: str + :ivar display_name: The rule name as it is displayed in UI. + :vartype display_name: str + :ivar description: The rule description. + :vartype description: str + :ivar help_url: URL which displays additional info about the proactive detection rule. + :vartype help_url: str + :ivar is_hidden: A flag indicating whether the rule is hidden (from the UI). + :vartype is_hidden: bool + :ivar is_enabled_by_default: A flag indicating whether the rule is enabled by default. + :vartype is_enabled_by_default: bool + :ivar is_in_preview: A flag indicating whether the rule is in preview. + :vartype is_in_preview: bool + :ivar supports_email_notifications: A flag indicating whether email notifications are supported + for detections for this rule. + :vartype supports_email_notifications: bool + """ + + _attribute_map = { + "name": {"key": "Name", "type": "str"}, + "display_name": {"key": "DisplayName", "type": "str"}, + "description": {"key": "Description", "type": "str"}, + "help_url": {"key": "HelpUrl", "type": "str"}, + "is_hidden": {"key": "IsHidden", "type": "bool"}, + "is_enabled_by_default": {"key": "IsEnabledByDefault", "type": "bool"}, + "is_in_preview": {"key": "IsInPreview", "type": "bool"}, + "supports_email_notifications": {"key": "SupportsEmailNotifications", "type": "bool"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + display_name: Optional[str] = None, + description: Optional[str] = None, + help_url: Optional[str] = None, + is_hidden: Optional[bool] = None, + is_enabled_by_default: Optional[bool] = None, + is_in_preview: Optional[bool] = None, + supports_email_notifications: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: The rule name. + :paramtype name: str + :keyword display_name: The rule name as it is displayed in UI. + :paramtype display_name: str + :keyword description: The rule description. + :paramtype description: str + :keyword help_url: URL which displays additional info about the proactive detection rule. + :paramtype help_url: str + :keyword is_hidden: A flag indicating whether the rule is hidden (from the UI). + :paramtype is_hidden: bool + :keyword is_enabled_by_default: A flag indicating whether the rule is enabled by default. + :paramtype is_enabled_by_default: bool + :keyword is_in_preview: A flag indicating whether the rule is in preview. + :paramtype is_in_preview: bool + :keyword supports_email_notifications: A flag indicating whether email notifications are + supported for detections for this rule. + :paramtype supports_email_notifications: bool + """ + super().__init__(**kwargs) + self.name = name + self.display_name = display_name + self.description = description + self.help_url = help_url + self.is_hidden = is_hidden + self.is_enabled_by_default = is_enabled_by_default + self.is_in_preview = is_in_preview + self.supports_email_notifications = supports_email_notifications + + +class ApplicationInsightsComponentQuotaStatus(_serialization.Model): + """An Application Insights component daily data volume cap status. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar app_id: The Application ID for the Application Insights component. + :vartype app_id: str + :ivar should_be_throttled: The daily data volume cap is met, and data ingestion will be + stopped. + :vartype should_be_throttled: bool + :ivar expiration_time: Date and time when the daily data volume cap will be reset, and data + ingestion will resume. + :vartype expiration_time: str + """ + + _validation = { + "app_id": {"readonly": True}, + "should_be_throttled": {"readonly": True}, + "expiration_time": {"readonly": True}, + } + + _attribute_map = { + "app_id": {"key": "AppId", "type": "str"}, + "should_be_throttled": {"key": "ShouldBeThrottled", "type": "bool"}, + "expiration_time": {"key": "ExpirationTime", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.app_id: Optional[str] = None + self.should_be_throttled: Optional[bool] = None + self.expiration_time: Optional[str] = None + + +class ApplicationInsightsComponentWebTestLocation(_serialization.Model): # pylint: disable=name-too-long + """Properties that define a web test location available to an Application Insights Component. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar display_name: The display name of the web test location. + :vartype display_name: str + :ivar tag: Internally defined geographic location tag. + :vartype tag: str + """ + + _validation = { + "display_name": {"readonly": True}, + "tag": {"readonly": True}, + } + + _attribute_map = { + "display_name": {"key": "DisplayName", "type": "str"}, + "tag": {"key": "Tag", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.display_name: Optional[str] = None + self.tag: Optional[str] = None + + +class ApplicationInsightsWebTestLocationsListResult(_serialization.Model): # pylint: disable=name-too-long + """Describes the list of web test locations available to an Application Insights Component. + + All required parameters must be populated in order to send to server. + + :ivar value: List of web test locations. Required. + :vartype value: + list[~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentWebTestLocation] + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[ApplicationInsightsComponentWebTestLocation]"}, + } + + def __init__(self, *, value: List["_models.ApplicationInsightsComponentWebTestLocation"], **kwargs: Any) -> None: + """ + :keyword value: List of web test locations. Required. + :paramtype value: + list[~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentWebTestLocation] + """ + super().__init__(**kwargs) + self.value = value + + +class Resource(_serialization.Model): + """Common fields that are returned in the response for all Azure Resource Manager resources. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + + +class ProxyResource(Resource): + """The resource model definition for a Azure Resource Manager proxy resource. It will not have + tags and a location. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + """ + + +class ComponentLinkedStorageAccounts(ProxyResource): + """An Application Insights component linked storage accounts. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar linked_storage_account: Linked storage account resource ID. + :vartype linked_storage_account: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "linked_storage_account": {"key": "properties.linkedStorageAccount", "type": "str"}, + } + + def __init__(self, *, linked_storage_account: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword linked_storage_account: Linked storage account resource ID. + :paramtype linked_storage_account: str + """ + super().__init__(**kwargs) + self.linked_storage_account = linked_storage_account + + +class ComponentLinkedStorageAccountsPatch(_serialization.Model): + """An Application Insights component linked storage accounts patch. + + :ivar linked_storage_account: Linked storage account resource ID. + :vartype linked_storage_account: str + """ + + _attribute_map = { + "linked_storage_account": {"key": "properties.linkedStorageAccount", "type": "str"}, + } + + def __init__(self, *, linked_storage_account: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword linked_storage_account: Linked storage account resource ID. + :paramtype linked_storage_account: str + """ + super().__init__(**kwargs) + self.linked_storage_account = linked_storage_account + + +class ComponentPurgeBody(_serialization.Model): + """Describes the body of a purge request for an App Insights component. + + All required parameters must be populated in order to send to server. + + :ivar table: Table from which to purge data. Required. + :vartype table: str + :ivar filters: The set of columns and filters (queries) to run over them to purge the resulting + data. Required. + :vartype filters: list[~azure.mgmt.applicationinsights.models.ComponentPurgeBodyFilters] + """ + + _validation = { + "table": {"required": True}, + "filters": {"required": True}, + } + + _attribute_map = { + "table": {"key": "table", "type": "str"}, + "filters": {"key": "filters", "type": "[ComponentPurgeBodyFilters]"}, + } + + def __init__(self, *, table: str, filters: List["_models.ComponentPurgeBodyFilters"], **kwargs: Any) -> None: + """ + :keyword table: Table from which to purge data. Required. + :paramtype table: str + :keyword filters: The set of columns and filters (queries) to run over them to purge the + resulting data. Required. + :paramtype filters: list[~azure.mgmt.applicationinsights.models.ComponentPurgeBodyFilters] + """ + super().__init__(**kwargs) + self.table = table + self.filters = filters + + +class ComponentPurgeBodyFilters(_serialization.Model): + """User-defined filters to return data which will be purged from the table. + + :ivar column: The column of the table over which the given query should run. + :vartype column: str + :ivar operator: A query operator to evaluate over the provided column and value(s). Supported + operators are ==, =~, in, in~, >, >=, <, <=, between, and have the same behavior as they would + in a KQL query. + :vartype operator: str + :ivar value: the value for the operator to function over. This can be a number (e.g., > 100), a + string (timestamp >= '2017-09-01') or array of values. + :vartype value: any + :ivar key: When filtering over custom dimensions, this key will be used as the name of the + custom dimension. + :vartype key: str + """ + + _attribute_map = { + "column": {"key": "column", "type": "str"}, + "operator": {"key": "operator", "type": "str"}, + "value": {"key": "value", "type": "object"}, + "key": {"key": "key", "type": "str"}, + } + + def __init__( + self, + *, + column: Optional[str] = None, + operator: Optional[str] = None, + value: Optional[Any] = None, + key: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword column: The column of the table over which the given query should run. + :paramtype column: str + :keyword operator: A query operator to evaluate over the provided column and value(s). + Supported operators are ==, =~, in, in~, >, >=, <, <=, between, and have the same behavior as + they would in a KQL query. + :paramtype operator: str + :keyword value: the value for the operator to function over. This can be a number (e.g., > + 100), a string (timestamp >= '2017-09-01') or array of values. + :paramtype value: any + :keyword key: When filtering over custom dimensions, this key will be used as the name of the + custom dimension. + :paramtype key: str + """ + super().__init__(**kwargs) + self.column = column + self.operator = operator + self.value = value + self.key = key + + +class ComponentPurgeResponse(_serialization.Model): + """Response containing operationId for a specific purge action. + + All required parameters must be populated in order to send to server. + + :ivar operation_id: Id to use when querying for status for a particular purge operation. + Required. + :vartype operation_id: str + """ + + _validation = { + "operation_id": {"required": True}, + } + + _attribute_map = { + "operation_id": {"key": "operationId", "type": "str"}, + } + + def __init__(self, *, operation_id: str, **kwargs: Any) -> None: + """ + :keyword operation_id: Id to use when querying for status for a particular purge operation. + Required. + :paramtype operation_id: str + """ + super().__init__(**kwargs) + self.operation_id = operation_id + + +class ComponentPurgeStatusResponse(_serialization.Model): + """Response containing status for a specific purge operation. + + All required parameters must be populated in order to send to server. + + :ivar status: Status of the operation represented by the requested Id. Required. Known values + are: "pending" and "completed". + :vartype status: str or ~azure.mgmt.applicationinsights.models.PurgeState + """ + + _validation = { + "status": {"required": True}, + } + + _attribute_map = { + "status": {"key": "status", "type": "str"}, + } + + def __init__(self, *, status: Union[str, "_models.PurgeState"], **kwargs: Any) -> None: + """ + :keyword status: Status of the operation represented by the requested Id. Required. Known + values are: "pending" and "completed". + :paramtype status: str or ~azure.mgmt.applicationinsights.models.PurgeState + """ + super().__init__(**kwargs) + self.status = status + + +class ResourceAutoGenerated(_serialization.Model): + """Common fields that are returned in the response for all Azure Resource Manager resources. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.applicationinsights.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: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + self.system_data: Optional["_models.SystemData"] = None + + +class TrackedResourceAutoGenerated(ResourceAutoGenerated): + """The resource model definition for an Azure Resource Manager tracked top level resource which + has 'tags' and a 'location'. + + 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 server. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.applicationinsights.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + } + + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + """ + super().__init__(**kwargs) + self.tags = tags + self.location = location + + +class DeletedWorkbookResource(TrackedResourceAutoGenerated): + """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 server. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.applicationinsights.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar kind: The kind of workbook. Only valid value is shared. "shared" + :vartype kind: str or ~azure.mgmt.applicationinsights.models.WorkbookSharedTypeKind + :ivar etag: Resource etag. + :vartype etag: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + kind: Optional[Union[str, "_models.WorkbookSharedTypeKind"]] = None, + etag: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + :keyword kind: The kind of workbook. Only valid value is shared. "shared" + :paramtype kind: str or ~azure.mgmt.applicationinsights.models.WorkbookSharedTypeKind + :keyword etag: Resource etag. + :paramtype etag: str + """ + super().__init__(tags=tags, location=location, **kwargs) + self.kind = kind + self.etag = etag + + +class DeletedWorkbook(DeletedWorkbookResource): + """A workbook 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 server. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.applicationinsights.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar kind: The kind of workbook. Only valid value is shared. "shared" + :vartype kind: str or ~azure.mgmt.applicationinsights.models.WorkbookSharedTypeKind + :ivar etag: Resource etag. + :vartype etag: str + :ivar display_name: The user-defined name (display name) of the workbook. + :vartype display_name: str + :ivar serialized_data: Configuration of this particular workbook. Configuration data is a + string containing valid JSON. + :vartype serialized_data: str + :ivar version: Workbook schema version format, like 'Notebook/1.0', which should match the + workbook in serializedData. + :vartype version: str + :ivar time_modified: Date and time in UTC of the last modification that was made to this + workbook definition. + :vartype time_modified: ~datetime.datetime + :ivar category: Workbook category, as defined by the user at creation time. + :vartype category: str + :ivar tags_properties_tags: Being deprecated, please use the other tags field. + :vartype tags_properties_tags: list[str] + :ivar user_id: Unique user id of the specific user that owns this workbook. + :vartype user_id: str + :ivar source_id: ResourceId for a source resource. + :vartype source_id: str + :ivar storage_uri: The resourceId to the storage account when bring your own storage is used. + :vartype storage_uri: str + :ivar description: The description of the workbook. + :vartype description: str + :ivar revision: The unique revision id for this workbook definition. + :vartype revision: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + "time_modified": {"readonly": True}, + "user_id": {"readonly": True}, + "revision": {"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"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "serialized_data": {"key": "properties.serializedData", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "time_modified": {"key": "properties.timeModified", "type": "iso-8601"}, + "category": {"key": "properties.category", "type": "str"}, + "tags_properties_tags": {"key": "properties.tags", "type": "[str]"}, + "user_id": {"key": "properties.userId", "type": "str"}, + "source_id": {"key": "properties.sourceId", "type": "str"}, + "storage_uri": {"key": "properties.storageUri", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "revision": {"key": "properties.revision", "type": "str"}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + kind: Optional[Union[str, "_models.WorkbookSharedTypeKind"]] = None, + etag: Optional[str] = None, + display_name: Optional[str] = None, + serialized_data: Optional[str] = None, + version: Optional[str] = None, + category: Optional[str] = None, + tags_properties_tags: Optional[List[str]] = None, + source_id: Optional[str] = None, + storage_uri: Optional[str] = None, + description: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + :keyword kind: The kind of workbook. Only valid value is shared. "shared" + :paramtype kind: str or ~azure.mgmt.applicationinsights.models.WorkbookSharedTypeKind + :keyword etag: Resource etag. + :paramtype etag: str + :keyword display_name: The user-defined name (display name) of the workbook. + :paramtype display_name: str + :keyword serialized_data: Configuration of this particular workbook. Configuration data is a + string containing valid JSON. + :paramtype serialized_data: str + :keyword version: Workbook schema version format, like 'Notebook/1.0', which should match the + workbook in serializedData. + :paramtype version: str + :keyword category: Workbook category, as defined by the user at creation time. + :paramtype category: str + :keyword tags_properties_tags: Being deprecated, please use the other tags field. + :paramtype tags_properties_tags: list[str] + :keyword source_id: ResourceId for a source resource. + :paramtype source_id: str + :keyword storage_uri: The resourceId to the storage account when bring your own storage is + used. + :paramtype storage_uri: str + :keyword description: The description of the workbook. + :paramtype description: str + """ + super().__init__(tags=tags, location=location, kind=kind, etag=etag, **kwargs) + self.display_name = display_name + self.serialized_data = serialized_data + self.version = version + self.time_modified: Optional[datetime.datetime] = None + self.category = category + self.tags_properties_tags = tags_properties_tags + self.user_id: Optional[str] = None + self.source_id = source_id + self.storage_uri = storage_uri + self.description = description + self.revision: Optional[str] = None + + +class DeletedWorkbookError(_serialization.Model): + """Error response. + + :ivar error: The error details. + :vartype error: ~azure.mgmt.applicationinsights.models.DeletedWorkbookErrorDefinition + """ + + _attribute_map = { + "error": {"key": "error", "type": "DeletedWorkbookErrorDefinition"}, + } + + def __init__(self, *, error: Optional["_models.DeletedWorkbookErrorDefinition"] = None, **kwargs: Any) -> None: + """ + :keyword error: The error details. + :paramtype error: ~azure.mgmt.applicationinsights.models.DeletedWorkbookErrorDefinition + """ + super().__init__(**kwargs) + self.error = error + + +class DeletedWorkbookErrorDefinition(_serialization.Model): + """Error definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: Service specific error code which serves as the substatus for the HTTP error code. + :vartype code: str + :ivar message: Description of the error. + :vartype message: str + :ivar innererror: Internal error details. + :vartype innererror: ~azure.mgmt.applicationinsights.models.DeletedWorkbookInnerErrorTrace + """ + + _validation = { + "code": {"readonly": True}, + "message": {"readonly": True}, + "innererror": {"readonly": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "innererror": {"key": "innererror", "type": "DeletedWorkbookInnerErrorTrace"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.code: Optional[str] = None + self.message: Optional[str] = None + self.innererror: Optional["_models.DeletedWorkbookInnerErrorTrace"] = None + + +class DeletedWorkbookInnerErrorTrace(_serialization.Model): + """Error details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar trace: detailed error trace. + :vartype trace: list[str] + """ + + _validation = { + "trace": {"readonly": True}, + } + + _attribute_map = { + "trace": {"key": "trace", "type": "[str]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.trace: Optional[List[str]] = None + + +class DeletedWorkbooksListResult(_serialization.Model): + """Workbook list result. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: An array of workbooks. + :vartype value: list[~azure.mgmt.applicationinsights.models.DeletedWorkbook] + :ivar next_link: + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[DeletedWorkbook]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value: Optional[List["_models.DeletedWorkbook"]] = None + self.next_link = next_link + + +class ErrorFieldContract(_serialization.Model): + """Error Field contract. + + :ivar code: Property level error code. + :vartype code: str + :ivar message: Human-readable representation of property-level error. + :vartype message: str + :ivar target: Property name. + :vartype target: str + """ + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + } + + def __init__( + self, *, code: Optional[str] = None, message: Optional[str] = None, target: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword code: Property level error code. + :paramtype code: str + :keyword message: Human-readable representation of property-level error. + :paramtype message: str + :keyword target: Property name. + :paramtype target: str + """ + super().__init__(**kwargs) + self.code = code + self.message = message + self.target = target + + +class ErrorResponse(_serialization.Model): + """Error response indicates Insights service is not able to process the incoming request. The + reason is provided in the error message. + + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str + :ivar details: The list of invalid fields send in request, in case of validation error. + :vartype details: list[~azure.mgmt.applicationinsights.models.ErrorFieldContract] + """ + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "details": {"key": "details", "type": "[ErrorFieldContract]"}, + } + + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + details: Optional[List["_models.ErrorFieldContract"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + :keyword details: The list of invalid fields send in request, in case of validation error. + :paramtype details: list[~azure.mgmt.applicationinsights.models.ErrorFieldContract] + """ + super().__init__(**kwargs) + self.code = code + self.message = message + self.details = details + + +class ErrorResponseComponents(_serialization.Model): + """ErrorResponseComponents. + + :ivar error: Error response indicates Insights service is not able to process the incoming + request. The reason is provided in the error message. + :vartype error: ~azure.mgmt.applicationinsights.models.ErrorResponseComponentsError + """ + + _attribute_map = { + "error": {"key": "error", "type": "ErrorResponseComponentsError"}, + } + + def __init__(self, *, error: Optional["_models.ErrorResponseComponentsError"] = None, **kwargs: Any) -> None: + """ + :keyword error: Error response indicates Insights service is not able to process the incoming + request. The reason is provided in the error message. + :paramtype error: ~azure.mgmt.applicationinsights.models.ErrorResponseComponentsError + """ + super().__init__(**kwargs) + self.error = error + + +class ErrorResponseComponentsError(_serialization.Model): + """Error response indicates Insights service is not able to process the incoming request. The + reason is provided in the error message. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str + """ + + _validation = { + "code": {"readonly": True}, + "message": {"readonly": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.code: Optional[str] = None + self.message: Optional[str] = None + + +class ErrorResponseLinkedStorage(_serialization.Model): + """ErrorResponseLinkedStorage. + + :ivar error: Error response indicates Insights service is not able to process the incoming + request. The reason is provided in the error message. + :vartype error: ~azure.mgmt.applicationinsights.models.ErrorResponseLinkedStorageError + """ + + _attribute_map = { + "error": {"key": "error", "type": "ErrorResponseLinkedStorageError"}, + } + + def __init__(self, *, error: Optional["_models.ErrorResponseLinkedStorageError"] = None, **kwargs: Any) -> None: + """ + :keyword error: Error response indicates Insights service is not able to process the incoming + request. The reason is provided in the error message. + :paramtype error: ~azure.mgmt.applicationinsights.models.ErrorResponseLinkedStorageError + """ + super().__init__(**kwargs) + self.error = error + + +class ErrorResponseLinkedStorageError(_serialization.Model): + """Error response indicates Insights service is not able to process the incoming request. The + reason is provided in the error message. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str + """ + + _validation = { + "code": {"readonly": True}, + "message": {"readonly": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.code: Optional[str] = None + self.message: Optional[str] = None + + +class HeaderField(_serialization.Model): + """A header to add to the WebTest. + + :ivar header_field_name: The name of the header. + :vartype header_field_name: str + :ivar header_field_value: The value of the header. + :vartype header_field_value: str + """ + + _attribute_map = { + "header_field_name": {"key": "key", "type": "str"}, + "header_field_value": {"key": "value", "type": "str"}, + } + + def __init__( + self, *, header_field_name: Optional[str] = None, header_field_value: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword header_field_name: The name of the header. + :paramtype header_field_name: str + :keyword header_field_value: The value of the header. + :paramtype header_field_value: str + """ + super().__init__(**kwargs) + self.header_field_name = header_field_name + self.header_field_value = header_field_value + + +class InnerError(_serialization.Model): + """Inner error. + + :ivar diagnosticcontext: Provides correlation for request. + :vartype diagnosticcontext: str + :ivar time: Request time. + :vartype time: ~datetime.datetime + """ + + _attribute_map = { + "diagnosticcontext": {"key": "diagnosticcontext", "type": "str"}, + "time": {"key": "time", "type": "iso-8601"}, + } + + def __init__( + self, *, diagnosticcontext: Optional[str] = None, time: Optional[datetime.datetime] = None, **kwargs: Any + ) -> None: + """ + :keyword diagnosticcontext: Provides correlation for request. + :paramtype diagnosticcontext: str + :keyword time: Request time. + :paramtype time: ~datetime.datetime + """ + super().__init__(**kwargs) + self.diagnosticcontext = diagnosticcontext + self.time = time + + +class LiveTokenResponse(_serialization.Model): + """The response to a live token query. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar live_token: JWT token for accessing live metrics stream data. + :vartype live_token: str + """ + + _validation = { + "live_token": {"readonly": True}, + } + + _attribute_map = { + "live_token": {"key": "liveToken", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.live_token: Optional[str] = None + + +class ManagedServiceIdentity(_serialization.Model): + """Managed service identity (system assigned and/or user assigned identities). + + 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 server. + + :ivar principal_id: The service principal ID of the system assigned identity. This property + will only be provided for a system assigned identity. + :vartype principal_id: str + :ivar tenant_id: The tenant ID of the system assigned identity. This property will only be + provided for a system assigned identity. + :vartype tenant_id: str + :ivar type: Type of managed service identity (where both SystemAssigned and UserAssigned types + are allowed). Required. Known values are: "None", "SystemAssigned", "UserAssigned", and + "SystemAssigned,UserAssigned". + :vartype type: str or ~azure.mgmt.applicationinsights.models.ManagedServiceIdentityType + :ivar user_assigned_identities: The set of user assigned identities associated with the + resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. + The dictionary values can be empty objects ({}) in requests. + :vartype user_assigned_identities: dict[str, + ~azure.mgmt.applicationinsights.models.UserAssignedIdentity] + """ + + _validation = { + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, + "type": {"required": True}, + } + + _attribute_map = { + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserAssignedIdentity}"}, + } + + def __init__( + self, + *, + type: Union[str, "_models.ManagedServiceIdentityType"], + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentity"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword type: Type of managed service identity (where both SystemAssigned and UserAssigned + types are allowed). Required. Known values are: "None", "SystemAssigned", "UserAssigned", and + "SystemAssigned,UserAssigned". + :paramtype type: str or ~azure.mgmt.applicationinsights.models.ManagedServiceIdentityType + :keyword user_assigned_identities: The set of user assigned identities associated with the + resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. + The dictionary values can be empty objects ({}) in requests. + :paramtype user_assigned_identities: dict[str, + ~azure.mgmt.applicationinsights.models.UserAssignedIdentity] + """ + super().__init__(**kwargs) + self.principal_id: Optional[str] = None + self.tenant_id: Optional[str] = None + self.type = type + self.user_assigned_identities = user_assigned_identities + + +class Operation(_serialization.Model): + """Azure Workbooks REST API operation. + + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.applicationinsights.models.OperationDisplay + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, + } + + def __init__( + self, *, name: Optional[str] = None, display: Optional["_models.OperationDisplay"] = None, **kwargs: Any + ) -> None: + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.applicationinsights.models.OperationDisplay + """ + super().__init__(**kwargs) + self.name = name + self.display = display + + +class OperationDisplay(_serialization.Model): + """The object that represents the operation. + + :ivar provider: Service provider: Microsoft.Insights. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Profile, endpoint, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str + """ + + _attribute_map = { + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + } + + def __init__( + self, + *, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword provider: Service provider: Microsoft.Insights. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Profile, endpoint, etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + """ + super().__init__(**kwargs) + self.provider = provider + self.resource = resource + self.operation = operation + + +class OperationInfo(_serialization.Model): + """Information about an operation. + + :ivar provider: Name of the provider. + :vartype provider: str + :ivar resource: Name of the resource type. + :vartype resource: str + :ivar operation: Name of the operation. + :vartype operation: str + :ivar description: Description of the operation. + :vartype description: str + """ + + _attribute_map = { + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, + } + + def __init__( + self, + *, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + description: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword provider: Name of the provider. + :paramtype provider: str + :keyword resource: Name of the resource type. + :paramtype resource: str + :keyword operation: Name of the operation. + :paramtype operation: str + :keyword description: Description of the operation. + :paramtype description: str + """ + super().__init__(**kwargs) + self.provider = provider + self.resource = resource + self.operation = operation + self.description = description + + +class OperationListResult(_serialization.Model): + """Result of the request to list Azure Workbooks operations. It contains a list of operations and + a URL link to get the next set of results. + + :ivar value: List of Workbook operations supported by the Microsoft.Insights resource provider. + :vartype value: list[~azure.mgmt.applicationinsights.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: List of Workbook operations supported by the Microsoft.Insights resource + provider. + :paramtype value: list[~azure.mgmt.applicationinsights.models.Operation] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class OperationLive(_serialization.Model): + """Represents an operation returned by the GetOperations request. + + :ivar name: Name of the operation. + :vartype name: str + :ivar is_data_action: Indicates whether the operation is a data action. + :vartype is_data_action: bool + :ivar display: Display name of the operation. + :vartype display: ~azure.mgmt.applicationinsights.models.OperationInfo + :ivar origin: Origin of the operation. + :vartype origin: str + :ivar properties: Properties of the operation. + :vartype properties: JSON + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "display": {"key": "display", "type": "OperationInfo"}, + "origin": {"key": "origin", "type": "str"}, + "properties": {"key": "properties", "type": "object"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + is_data_action: Optional[bool] = None, + display: Optional["_models.OperationInfo"] = None, + origin: Optional[str] = None, + properties: Optional[JSON] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: Name of the operation. + :paramtype name: str + :keyword is_data_action: Indicates whether the operation is a data action. + :paramtype is_data_action: bool + :keyword display: Display name of the operation. + :paramtype display: ~azure.mgmt.applicationinsights.models.OperationInfo + :keyword origin: Origin of the operation. + :paramtype origin: str + :keyword properties: Properties of the operation. + :paramtype properties: JSON + """ + super().__init__(**kwargs) + self.name = name + self.is_data_action = is_data_action + self.display = display + self.origin = origin + self.properties = properties + + +class OperationsListResult(_serialization.Model): + """Result of the List Operations operation. + + :ivar value: A collection of operations. + :vartype value: list[~azure.mgmt.applicationinsights.models.OperationLive] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[OperationLive]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.OperationLive"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: A collection of operations. + :paramtype value: list[~azure.mgmt.applicationinsights.models.OperationLive] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PrivateLinkScopedResource(_serialization.Model): + """The private link scope resource reference. + + :ivar resource_id: The full resource Id of the private link scope resource. + :vartype resource_id: str + :ivar scope_id: The private link scope unique Identifier. + :vartype scope_id: str + """ + + _attribute_map = { + "resource_id": {"key": "ResourceId", "type": "str"}, + "scope_id": {"key": "ScopeId", "type": "str"}, + } + + def __init__(self, *, resource_id: Optional[str] = None, scope_id: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword resource_id: The full resource Id of the private link scope resource. + :paramtype resource_id: str + :keyword scope_id: The private link scope unique Identifier. + :paramtype scope_id: str + """ + super().__init__(**kwargs) + self.resource_id = resource_id + self.scope_id = scope_id + + +class SystemData(_serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :vartype created_by_type: str or ~azure.mgmt.applicationinsights.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: 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. Known values + are: "User", "Application", "ManagedIdentity", and "Key". + :vartype last_modified_by_type: str or ~azure.mgmt.applicationinsights.models.CreatedByType + :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, "_models.CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :paramtype created_by_type: str or ~azure.mgmt.applicationinsights.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: 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. Known + values are: "User", "Application", "ManagedIdentity", and "Key". + :paramtype last_modified_by_type: str or ~azure.mgmt.applicationinsights.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ + super().__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 TagsResource(_serialization.Model): + """A container holding only the Tags for a resource, allowing the user to update the tags on a + WebTest instance. + + :ivar 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: Any) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.tags = tags + + +class TrackedResource(Resource): + """The resource model definition for an Azure Resource Manager tracked top level resource which + has 'tags' and a 'location'. + + 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 server. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: 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"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + } + + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + """ + super().__init__(**kwargs) + self.tags = tags + self.location = location + + +class UserAssignedIdentity(_serialization.Model): + """User assigned identity properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal ID of the assigned identity. + :vartype principal_id: str + :ivar client_id: The client ID of the assigned identity. + :vartype client_id: str + """ + + _validation = { + "principal_id": {"readonly": True}, + "client_id": {"readonly": True}, + } + + _attribute_map = { + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.principal_id: Optional[str] = None + self.client_id: Optional[str] = None + + +class WebtestsResource(_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 server. + + :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: Resource location. Required. + :vartype location: str + :ivar 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: Any) -> None: + """ + :keyword location: Resource location. Required. + :paramtype location: str + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + self.location = location + self.tags = tags + + +class WebTest(WebtestsResource): + """An Application Insights WebTest 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 server. + + :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: Resource location. Required. + :vartype location: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar kind: The kind of WebTest that this web test watches. Choices are ping, multistep and + standard. Known values are: "ping", "multistep", and "standard". + :vartype kind: str or ~azure.mgmt.applicationinsights.models.WebTestKind + :ivar synthetic_monitor_id: Unique ID of this WebTest. This is typically the same value as the + Name field. + :vartype synthetic_monitor_id: str + :ivar web_test_name: User defined name if this WebTest. + :vartype web_test_name: str + :ivar description: User defined description for this WebTest. + :vartype description: str + :ivar enabled: Is the test actively being monitored. + :vartype enabled: bool + :ivar frequency: Interval in seconds between test runs for this WebTest. Default value is 300. + :vartype frequency: int + :ivar timeout: Seconds until this WebTest will timeout and fail. Default value is 30. + :vartype timeout: int + :ivar web_test_kind: The kind of web test this is, valid choices are ping, multistep and + standard. Known values are: "ping", "multistep", and "standard". + :vartype web_test_kind: str or ~azure.mgmt.applicationinsights.models.WebTestKind + :ivar retry_enabled: Allow for retries should this WebTest fail. + :vartype retry_enabled: bool + :ivar locations: A list of where to physically run the tests from to give global coverage for + accessibility of your application. + :vartype locations: list[~azure.mgmt.applicationinsights.models.WebTestGeolocation] + :ivar configuration: An XML configuration specification for a WebTest. + :vartype configuration: ~azure.mgmt.applicationinsights.models.WebTestPropertiesConfiguration + :ivar provisioning_state: Current state of this component, 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 + :ivar request: The collection of request properties. + :vartype request: ~azure.mgmt.applicationinsights.models.WebTestPropertiesRequest + :ivar validation_rules: The collection of validation rule properties. + :vartype validation_rules: + ~azure.mgmt.applicationinsights.models.WebTestPropertiesValidationRules + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": 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}"}, + "kind": {"key": "kind", "type": "str"}, + "synthetic_monitor_id": {"key": "properties.SyntheticMonitorId", "type": "str"}, + "web_test_name": {"key": "properties.Name", "type": "str"}, + "description": {"key": "properties.Description", "type": "str"}, + "enabled": {"key": "properties.Enabled", "type": "bool"}, + "frequency": {"key": "properties.Frequency", "type": "int"}, + "timeout": {"key": "properties.Timeout", "type": "int"}, + "web_test_kind": {"key": "properties.Kind", "type": "str"}, + "retry_enabled": {"key": "properties.RetryEnabled", "type": "bool"}, + "locations": {"key": "properties.Locations", "type": "[WebTestGeolocation]"}, + "configuration": {"key": "properties.Configuration", "type": "WebTestPropertiesConfiguration"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "request": {"key": "properties.Request", "type": "WebTestPropertiesRequest"}, + "validation_rules": {"key": "properties.ValidationRules", "type": "WebTestPropertiesValidationRules"}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + kind: Optional[Union[str, "_models.WebTestKind"]] = None, + synthetic_monitor_id: Optional[str] = None, + web_test_name: Optional[str] = None, + description: Optional[str] = None, + enabled: Optional[bool] = None, + frequency: int = 300, + timeout: int = 30, + web_test_kind: Optional[Union[str, "_models.WebTestKind"]] = None, + retry_enabled: Optional[bool] = None, + locations: Optional[List["_models.WebTestGeolocation"]] = None, + configuration: Optional["_models.WebTestPropertiesConfiguration"] = None, + request: Optional["_models.WebTestPropertiesRequest"] = None, + validation_rules: Optional["_models.WebTestPropertiesValidationRules"] = None, + **kwargs: Any + ) -> None: + """ + :keyword location: Resource location. Required. + :paramtype location: str + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword kind: The kind of WebTest that this web test watches. Choices are ping, multistep and + standard. Known values are: "ping", "multistep", and "standard". + :paramtype kind: str or ~azure.mgmt.applicationinsights.models.WebTestKind + :keyword synthetic_monitor_id: Unique ID of this WebTest. This is typically the same value as + the Name field. + :paramtype synthetic_monitor_id: str + :keyword web_test_name: User defined name if this WebTest. + :paramtype web_test_name: str + :keyword description: User defined description for this WebTest. + :paramtype description: str + :keyword enabled: Is the test actively being monitored. + :paramtype enabled: bool + :keyword frequency: Interval in seconds between test runs for this WebTest. Default value is + 300. + :paramtype frequency: int + :keyword timeout: Seconds until this WebTest will timeout and fail. Default value is 30. + :paramtype timeout: int + :keyword web_test_kind: The kind of web test this is, valid choices are ping, multistep and + standard. Known values are: "ping", "multistep", and "standard". + :paramtype web_test_kind: str or ~azure.mgmt.applicationinsights.models.WebTestKind + :keyword retry_enabled: Allow for retries should this WebTest fail. + :paramtype retry_enabled: bool + :keyword locations: A list of where to physically run the tests from to give global coverage + for accessibility of your application. + :paramtype locations: list[~azure.mgmt.applicationinsights.models.WebTestGeolocation] + :keyword configuration: An XML configuration specification for a WebTest. + :paramtype configuration: ~azure.mgmt.applicationinsights.models.WebTestPropertiesConfiguration + :keyword request: The collection of request properties. + :paramtype request: ~azure.mgmt.applicationinsights.models.WebTestPropertiesRequest + :keyword validation_rules: The collection of validation rule properties. + :paramtype validation_rules: + ~azure.mgmt.applicationinsights.models.WebTestPropertiesValidationRules + """ + super().__init__(location=location, tags=tags, **kwargs) + self.kind = kind + self.synthetic_monitor_id = synthetic_monitor_id + self.web_test_name = web_test_name + self.description = description + self.enabled = enabled + self.frequency = frequency + self.timeout = timeout + self.web_test_kind = web_test_kind + self.retry_enabled = retry_enabled + self.locations = locations + self.configuration = configuration + self.provisioning_state: Optional[str] = None + self.request = request + self.validation_rules = validation_rules + + +class WebTestGeolocation(_serialization.Model): + """Geo-physical location to run a WebTest from. You must specify one or more locations for the + test to run from. + + :ivar location: Location ID for the WebTest to run from. + :vartype location: str + """ + + _attribute_map = { + "location": {"key": "Id", "type": "str"}, + } + + def __init__(self, *, location: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword location: Location ID for the WebTest to run from. + :paramtype location: str + """ + super().__init__(**kwargs) + self.location = location + + +class WebTestListResult(_serialization.Model): + """A list of 0 or more Application Insights WebTest definitions. + + All required parameters must be populated in order to send to server. + + :ivar value: Set of Application Insights WebTest definitions. Required. + :vartype value: list[~azure.mgmt.applicationinsights.models.WebTest] + :ivar next_link: The link to get the next part of the returned list of WebTest, should the + return set be too large for a single request. May be null. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[WebTest]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: List["_models.WebTest"], next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword value: Set of Application Insights WebTest definitions. Required. + :paramtype value: list[~azure.mgmt.applicationinsights.models.WebTest] + :keyword next_link: The link to get the next part of the returned list of WebTest, should the + return set be too large for a single request. May be null. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class WebTestPropertiesConfiguration(_serialization.Model): + """An XML configuration specification for a WebTest. + + :ivar web_test: The XML specification of a WebTest to run against an application. + :vartype web_test: str + """ + + _attribute_map = { + "web_test": {"key": "WebTest", "type": "str"}, + } + + def __init__(self, *, web_test: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword web_test: The XML specification of a WebTest to run against an application. + :paramtype web_test: str + """ + super().__init__(**kwargs) + self.web_test = web_test + + +class WebTestPropertiesRequest(_serialization.Model): + """The collection of request properties. + + :ivar request_url: Url location to test. + :vartype request_url: str + :ivar headers: List of headers and their values to add to the WebTest call. + :vartype headers: list[~azure.mgmt.applicationinsights.models.HeaderField] + :ivar http_verb: Http verb to use for this web test. + :vartype http_verb: str + :ivar request_body: Base64 encoded string body to send with this web test. + :vartype request_body: str + :ivar parse_dependent_requests: Parse Dependent request for this WebTest. + :vartype parse_dependent_requests: bool + :ivar follow_redirects: Follow redirects for this web test. + :vartype follow_redirects: bool + """ + + _attribute_map = { + "request_url": {"key": "RequestUrl", "type": "str"}, + "headers": {"key": "Headers", "type": "[HeaderField]"}, + "http_verb": {"key": "HttpVerb", "type": "str"}, + "request_body": {"key": "RequestBody", "type": "str"}, + "parse_dependent_requests": {"key": "ParseDependentRequests", "type": "bool"}, + "follow_redirects": {"key": "FollowRedirects", "type": "bool"}, + } + + def __init__( + self, + *, + request_url: Optional[str] = None, + headers: Optional[List["_models.HeaderField"]] = None, + http_verb: Optional[str] = None, + request_body: Optional[str] = None, + parse_dependent_requests: Optional[bool] = None, + follow_redirects: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword request_url: Url location to test. + :paramtype request_url: str + :keyword headers: List of headers and their values to add to the WebTest call. + :paramtype headers: list[~azure.mgmt.applicationinsights.models.HeaderField] + :keyword http_verb: Http verb to use for this web test. + :paramtype http_verb: str + :keyword request_body: Base64 encoded string body to send with this web test. + :paramtype request_body: str + :keyword parse_dependent_requests: Parse Dependent request for this WebTest. + :paramtype parse_dependent_requests: bool + :keyword follow_redirects: Follow redirects for this web test. + :paramtype follow_redirects: bool + """ + super().__init__(**kwargs) + self.request_url = request_url + self.headers = headers + self.http_verb = http_verb + self.request_body = request_body + self.parse_dependent_requests = parse_dependent_requests + self.follow_redirects = follow_redirects + + +class WebTestPropertiesValidationRules(_serialization.Model): + """The collection of validation rule properties. + + :ivar content_validation: The collection of content validation properties. + :vartype content_validation: + ~azure.mgmt.applicationinsights.models.WebTestPropertiesValidationRulesContentValidation + :ivar ssl_check: Checks to see if the SSL cert is still valid. + :vartype ssl_check: bool + :ivar ssl_cert_remaining_lifetime_check: A number of days to check still remain before the the + existing SSL cert expires. Value must be positive and the SSLCheck must be set to true. + :vartype ssl_cert_remaining_lifetime_check: int + :ivar expected_http_status_code: Validate that the WebTest returns the http status code + provided. + :vartype expected_http_status_code: int + :ivar ignore_http_status_code: When set, validation will ignore the status code. + :vartype ignore_http_status_code: bool + """ + + _attribute_map = { + "content_validation": {"key": "ContentValidation", "type": "WebTestPropertiesValidationRulesContentValidation"}, + "ssl_check": {"key": "SSLCheck", "type": "bool"}, + "ssl_cert_remaining_lifetime_check": {"key": "SSLCertRemainingLifetimeCheck", "type": "int"}, + "expected_http_status_code": {"key": "ExpectedHttpStatusCode", "type": "int"}, + "ignore_http_status_code": {"key": "IgnoreHttpStatusCode", "type": "bool"}, + } + + def __init__( + self, + *, + content_validation: Optional["_models.WebTestPropertiesValidationRulesContentValidation"] = None, + ssl_check: Optional[bool] = None, + ssl_cert_remaining_lifetime_check: Optional[int] = None, + expected_http_status_code: Optional[int] = None, + ignore_http_status_code: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword content_validation: The collection of content validation properties. + :paramtype content_validation: + ~azure.mgmt.applicationinsights.models.WebTestPropertiesValidationRulesContentValidation + :keyword ssl_check: Checks to see if the SSL cert is still valid. + :paramtype ssl_check: bool + :keyword ssl_cert_remaining_lifetime_check: A number of days to check still remain before the + the existing SSL cert expires. Value must be positive and the SSLCheck must be set to true. + :paramtype ssl_cert_remaining_lifetime_check: int + :keyword expected_http_status_code: Validate that the WebTest returns the http status code + provided. + :paramtype expected_http_status_code: int + :keyword ignore_http_status_code: When set, validation will ignore the status code. + :paramtype ignore_http_status_code: bool + """ + super().__init__(**kwargs) + self.content_validation = content_validation + self.ssl_check = ssl_check + self.ssl_cert_remaining_lifetime_check = ssl_cert_remaining_lifetime_check + self.expected_http_status_code = expected_http_status_code + self.ignore_http_status_code = ignore_http_status_code + + +class WebTestPropertiesValidationRulesContentValidation(_serialization.Model): # pylint: disable=name-too-long + """The collection of content validation properties. + + :ivar content_match: Content to look for in the return of the WebTest. Must not be null or + empty. + :vartype content_match: str + :ivar ignore_case: When set, this value makes the ContentMatch validation case insensitive. + :vartype ignore_case: bool + :ivar pass_if_text_found: When true, validation will pass if there is a match for the + ContentMatch string. If false, validation will fail if there is a match. + :vartype pass_if_text_found: bool + """ + + _attribute_map = { + "content_match": {"key": "ContentMatch", "type": "str"}, + "ignore_case": {"key": "IgnoreCase", "type": "bool"}, + "pass_if_text_found": {"key": "PassIfTextFound", "type": "bool"}, + } + + def __init__( + self, + *, + content_match: Optional[str] = None, + ignore_case: Optional[bool] = None, + pass_if_text_found: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword content_match: Content to look for in the return of the WebTest. Must not be null or + empty. + :paramtype content_match: str + :keyword ignore_case: When set, this value makes the ContentMatch validation case insensitive. + :paramtype ignore_case: bool + :keyword pass_if_text_found: When true, validation will pass if there is a match for the + ContentMatch string. If false, validation will fail if there is a match. + :paramtype pass_if_text_found: bool + """ + super().__init__(**kwargs) + self.content_match = content_match + self.ignore_case = ignore_case + self.pass_if_text_found = pass_if_text_found + + +class WorkbookResource(TrackedResource): + """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 server. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar identity: Identity used for BYOS. + :vartype identity: ~azure.mgmt.applicationinsights.models.WorkbookResourceIdentity + :ivar kind: The kind of workbook. Only valid value is shared. "shared" + :vartype kind: str or ~azure.mgmt.applicationinsights.models.WorkbookSharedTypeKind + :ivar etag: Resource etag. + :vartype etag: 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"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "identity": {"key": "identity", "type": "WorkbookResourceIdentity"}, + "kind": {"key": "kind", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + identity: Optional["_models.WorkbookResourceIdentity"] = None, + kind: Optional[Union[str, "_models.WorkbookSharedTypeKind"]] = None, + etag: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + :keyword identity: Identity used for BYOS. + :paramtype identity: ~azure.mgmt.applicationinsights.models.WorkbookResourceIdentity + :keyword kind: The kind of workbook. Only valid value is shared. "shared" + :paramtype kind: str or ~azure.mgmt.applicationinsights.models.WorkbookSharedTypeKind + :keyword etag: Resource etag. + :paramtype etag: str + """ + super().__init__(tags=tags, location=location, **kwargs) + self.identity = identity + self.kind = kind + self.etag = etag + + +class Workbook(WorkbookResource): + """A workbook 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 server. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar identity: Identity used for BYOS. + :vartype identity: ~azure.mgmt.applicationinsights.models.WorkbookResourceIdentity + :ivar kind: The kind of workbook. Only valid value is shared. "shared" + :vartype kind: str or ~azure.mgmt.applicationinsights.models.WorkbookSharedTypeKind + :ivar etag: Resource etag. + :vartype etag: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.applicationinsights.models.SystemData + :ivar display_name: The user-defined name (display name) of the workbook. + :vartype display_name: str + :ivar serialized_data: Configuration of this particular workbook. Configuration data is a + string containing valid JSON. + :vartype serialized_data: str + :ivar version: Workbook schema version format, like 'Notebook/1.0', which should match the + workbook in serializedData. + :vartype version: str + :ivar time_modified: Date and time in UTC of the last modification that was made to this + workbook definition. + :vartype time_modified: ~datetime.datetime + :ivar category: Workbook category, as defined by the user at creation time. + :vartype category: str + :ivar tags_properties_tags: Being deprecated, please use the other tags field. + :vartype tags_properties_tags: list[str] + :ivar user_id: Unique user id of the specific user that owns this workbook. + :vartype user_id: str + :ivar source_id: ResourceId for a source resource. + :vartype source_id: str + :ivar storage_uri: The resourceId to the storage account when bring your own storage is used. + :vartype storage_uri: str + :ivar description: The description of the workbook. + :vartype description: str + :ivar revision: The unique revision id for this workbook definition. + :vartype revision: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, + "time_modified": {"readonly": True}, + "user_id": {"readonly": True}, + "revision": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "identity": {"key": "identity", "type": "WorkbookResourceIdentity"}, + "kind": {"key": "kind", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "serialized_data": {"key": "properties.serializedData", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "time_modified": {"key": "properties.timeModified", "type": "iso-8601"}, + "category": {"key": "properties.category", "type": "str"}, + "tags_properties_tags": {"key": "properties.tags", "type": "[str]"}, + "user_id": {"key": "properties.userId", "type": "str"}, + "source_id": {"key": "properties.sourceId", "type": "str"}, + "storage_uri": {"key": "properties.storageUri", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "revision": {"key": "properties.revision", "type": "str"}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + identity: Optional["_models.WorkbookResourceIdentity"] = None, + kind: Optional[Union[str, "_models.WorkbookSharedTypeKind"]] = None, + etag: Optional[str] = None, + display_name: Optional[str] = None, + serialized_data: Optional[str] = None, + version: Optional[str] = None, + category: Optional[str] = None, + tags_properties_tags: Optional[List[str]] = None, + source_id: Optional[str] = None, + storage_uri: Optional[str] = None, + description: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + :keyword identity: Identity used for BYOS. + :paramtype identity: ~azure.mgmt.applicationinsights.models.WorkbookResourceIdentity + :keyword kind: The kind of workbook. Only valid value is shared. "shared" + :paramtype kind: str or ~azure.mgmt.applicationinsights.models.WorkbookSharedTypeKind + :keyword etag: Resource etag. + :paramtype etag: str + :keyword display_name: The user-defined name (display name) of the workbook. + :paramtype display_name: str + :keyword serialized_data: Configuration of this particular workbook. Configuration data is a + string containing valid JSON. + :paramtype serialized_data: str + :keyword version: Workbook schema version format, like 'Notebook/1.0', which should match the + workbook in serializedData. + :paramtype version: str + :keyword category: Workbook category, as defined by the user at creation time. + :paramtype category: str + :keyword tags_properties_tags: Being deprecated, please use the other tags field. + :paramtype tags_properties_tags: list[str] + :keyword source_id: ResourceId for a source resource. + :paramtype source_id: str + :keyword storage_uri: The resourceId to the storage account when bring your own storage is + used. + :paramtype storage_uri: str + :keyword description: The description of the workbook. + :paramtype description: str + """ + super().__init__(tags=tags, location=location, identity=identity, kind=kind, etag=etag, **kwargs) + self.system_data: Optional["_models.SystemData"] = None + self.display_name = display_name + self.serialized_data = serialized_data + self.version = version + self.time_modified: Optional[datetime.datetime] = None + self.category = category + self.tags_properties_tags = tags_properties_tags + self.user_id: Optional[str] = None + self.source_id = source_id + self.storage_uri = storage_uri + self.description = description + self.revision: Optional[str] = None + + +class WorkbookError(_serialization.Model): + """Error response. + + :ivar error: The error details. + :vartype error: ~azure.mgmt.applicationinsights.models.WorkbookErrorDefinition + """ + + _attribute_map = { + "error": {"key": "error", "type": "WorkbookErrorDefinition"}, + } + + def __init__(self, *, error: Optional["_models.WorkbookErrorDefinition"] = None, **kwargs: Any) -> None: + """ + :keyword error: The error details. + :paramtype error: ~azure.mgmt.applicationinsights.models.WorkbookErrorDefinition + """ + super().__init__(**kwargs) + self.error = error + + +class WorkbookErrorDefinition(_serialization.Model): + """Error definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: Service specific error code which serves as the substatus for the HTTP error code. + :vartype code: str + :ivar message: Description of the error. + :vartype message: str + :ivar innererror: Internal error details. + :vartype innererror: ~azure.mgmt.applicationinsights.models.WorkbookInnerErrorTrace + """ + + _validation = { + "code": {"readonly": True}, + "message": {"readonly": True}, + "innererror": {"readonly": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "innererror": {"key": "innererror", "type": "WorkbookInnerErrorTrace"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.code: Optional[str] = None + self.message: Optional[str] = None + self.innererror: Optional["_models.WorkbookInnerErrorTrace"] = None + + +class WorkbookInnerErrorTrace(_serialization.Model): + """Error details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar trace: detailed error trace. + :vartype trace: list[str] + """ + + _validation = { + "trace": {"readonly": True}, + } + + _attribute_map = { + "trace": {"key": "trace", "type": "[str]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.trace: Optional[List[str]] = None + + +class WorkbookResourceIdentity(ManagedServiceIdentity): + """Identity used for BYOS. + + 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 server. + + :ivar principal_id: The service principal ID of the system assigned identity. This property + will only be provided for a system assigned identity. + :vartype principal_id: str + :ivar tenant_id: The tenant ID of the system assigned identity. This property will only be + provided for a system assigned identity. + :vartype tenant_id: str + :ivar type: Type of managed service identity (where both SystemAssigned and UserAssigned types + are allowed). Required. Known values are: "None", "SystemAssigned", "UserAssigned", and + "SystemAssigned,UserAssigned". + :vartype type: str or ~azure.mgmt.applicationinsights.models.ManagedServiceIdentityType + :ivar user_assigned_identities: The set of user assigned identities associated with the + resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. + The dictionary values can be empty objects ({}) in requests. + :vartype user_assigned_identities: dict[str, + ~azure.mgmt.applicationinsights.models.UserAssignedIdentity] + """ + + +class WorkbooksListResult(_serialization.Model): + """Workbook list result. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: An array of workbooks. + :vartype value: list[~azure.mgmt.applicationinsights.models.Workbook] + :ivar next_link: + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Workbook]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value: Optional[List["_models.Workbook"]] = None + self.next_link = next_link + + +class WorkbookTemplateResource(_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 server. + + :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: Resource location. Required. + :vartype location: str + :ivar 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: Any) -> None: + """ + :keyword location: Resource location. Required. + :paramtype location: str + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + self.location = location + self.tags = tags + + +class WorkbookTemplate(WorkbookTemplateResource): + """An Application Insights workbook template 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 server. + + :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: Resource location. Required. + :vartype location: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar priority: Priority of the template. Determines which template to open when a workbook + gallery is opened in viewer mode. + :vartype priority: int + :ivar author: Information about the author of the workbook template. + :vartype author: str + :ivar template_data: Valid JSON object containing workbook template payload. + :vartype template_data: JSON + :ivar galleries: Workbook galleries supported by the template. + :vartype galleries: list[~azure.mgmt.applicationinsights.models.WorkbookTemplateGallery] + :ivar localized: Key value pair of localized gallery. Each key is the locale code of languages + supported by the Azure portal. + :vartype localized: dict[str, + list[~azure.mgmt.applicationinsights.models.WorkbookTemplateLocalizedGallery]] + """ + + _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}"}, + "priority": {"key": "properties.priority", "type": "int"}, + "author": {"key": "properties.author", "type": "str"}, + "template_data": {"key": "properties.templateData", "type": "object"}, + "galleries": {"key": "properties.galleries", "type": "[WorkbookTemplateGallery]"}, + "localized": {"key": "properties.localized", "type": "{[WorkbookTemplateLocalizedGallery]}"}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + priority: Optional[int] = None, + author: Optional[str] = None, + template_data: Optional[JSON] = None, + galleries: Optional[List["_models.WorkbookTemplateGallery"]] = None, + localized: Optional[Dict[str, List["_models.WorkbookTemplateLocalizedGallery"]]] = None, + **kwargs: Any + ) -> None: + """ + :keyword location: Resource location. Required. + :paramtype location: str + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword priority: Priority of the template. Determines which template to open when a workbook + gallery is opened in viewer mode. + :paramtype priority: int + :keyword author: Information about the author of the workbook template. + :paramtype author: str + :keyword template_data: Valid JSON object containing workbook template payload. + :paramtype template_data: JSON + :keyword galleries: Workbook galleries supported by the template. + :paramtype galleries: list[~azure.mgmt.applicationinsights.models.WorkbookTemplateGallery] + :keyword localized: Key value pair of localized gallery. Each key is the locale code of + languages supported by the Azure portal. + :paramtype localized: dict[str, + list[~azure.mgmt.applicationinsights.models.WorkbookTemplateLocalizedGallery]] + """ + super().__init__(location=location, tags=tags, **kwargs) + self.priority = priority + self.author = author + self.template_data = template_data + self.galleries = galleries + self.localized = localized + + +class WorkbookTemplateError(_serialization.Model): + """Error message that will indicate why the operation failed. + + :ivar error: Error message object that will indicate why the operation failed. + :vartype error: ~azure.mgmt.applicationinsights.models.WorkbookTemplateErrorBody + """ + + _attribute_map = { + "error": {"key": "error", "type": "WorkbookTemplateErrorBody"}, + } + + def __init__(self, *, error: Optional["_models.WorkbookTemplateErrorBody"] = None, **kwargs: Any) -> None: + """ + :keyword error: Error message object that will indicate why the operation failed. + :paramtype error: ~azure.mgmt.applicationinsights.models.WorkbookTemplateErrorBody + """ + super().__init__(**kwargs) + self.error = error + + +class WorkbookTemplateErrorBody(_serialization.Model): + """Error message body that will indicate why the operation failed. + + :ivar code: Service-defined error code. This code serves as a sub-status for the HTTP error + code specified in the response. + :vartype code: str + :ivar message: Human-readable representation of the error. + :vartype message: str + :ivar details: The list of invalid fields send in request, in case of validation error. + :vartype details: + list[~azure.mgmt.applicationinsights.models.WorkbookTemplateErrorFieldContract] + """ + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "details": {"key": "details", "type": "[WorkbookTemplateErrorFieldContract]"}, + } + + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + details: Optional[List["_models.WorkbookTemplateErrorFieldContract"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword code: Service-defined error code. This code serves as a sub-status for the HTTP error + code specified in the response. + :paramtype code: str + :keyword message: Human-readable representation of the error. + :paramtype message: str + :keyword details: The list of invalid fields send in request, in case of validation error. + :paramtype details: + list[~azure.mgmt.applicationinsights.models.WorkbookTemplateErrorFieldContract] + """ + super().__init__(**kwargs) + self.code = code + self.message = message + self.details = details + + +class WorkbookTemplateErrorFieldContract(_serialization.Model): + """Error Field contract. + + :ivar code: Property level error code. + :vartype code: str + :ivar message: Human-readable representation of property-level error. + :vartype message: str + :ivar target: Property name. + :vartype target: str + """ + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + } + + def __init__( + self, *, code: Optional[str] = None, message: Optional[str] = None, target: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword code: Property level error code. + :paramtype code: str + :keyword message: Human-readable representation of property-level error. + :paramtype message: str + :keyword target: Property name. + :paramtype target: str + """ + super().__init__(**kwargs) + self.code = code + self.message = message + self.target = target + + +class WorkbookTemplateGallery(_serialization.Model): + """Gallery information for a workbook template. + + :ivar name: Name of the workbook template in the gallery. + :vartype name: str + :ivar category: Category for the gallery. + :vartype category: str + :ivar type: Type of workbook supported by the workbook template. + :vartype type: str + :ivar order: Order of the template within the gallery. + :vartype order: int + :ivar resource_type: Azure resource type supported by the gallery. + :vartype resource_type: str + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "category": {"key": "category", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "order": {"key": "order", "type": "int"}, + "resource_type": {"key": "resourceType", "type": "str"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + category: Optional[str] = None, + type: Optional[str] = None, + order: Optional[int] = None, + resource_type: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: Name of the workbook template in the gallery. + :paramtype name: str + :keyword category: Category for the gallery. + :paramtype category: str + :keyword type: Type of workbook supported by the workbook template. + :paramtype type: str + :keyword order: Order of the template within the gallery. + :paramtype order: int + :keyword resource_type: Azure resource type supported by the gallery. + :paramtype resource_type: str + """ + super().__init__(**kwargs) + self.name = name + self.category = category + self.type = type + self.order = order + self.resource_type = resource_type + + +class WorkbookTemplateLocalizedGallery(_serialization.Model): + """Localized template data and gallery information. + + :ivar template_data: Valid JSON object containing workbook template payload. + :vartype template_data: JSON + :ivar galleries: Workbook galleries supported by the template. + :vartype galleries: list[~azure.mgmt.applicationinsights.models.WorkbookTemplateGallery] + """ + + _attribute_map = { + "template_data": {"key": "templateData", "type": "object"}, + "galleries": {"key": "galleries", "type": "[WorkbookTemplateGallery]"}, + } + + def __init__( + self, + *, + template_data: Optional[JSON] = None, + galleries: Optional[List["_models.WorkbookTemplateGallery"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword template_data: Valid JSON object containing workbook template payload. + :paramtype template_data: JSON + :keyword galleries: Workbook galleries supported by the template. + :paramtype galleries: list[~azure.mgmt.applicationinsights.models.WorkbookTemplateGallery] + """ + super().__init__(**kwargs) + self.template_data = template_data + self.galleries = galleries + + +class WorkbookTemplatesListResult(_serialization.Model): + """WorkbookTemplate list result. + + :ivar value: An array of workbook templates. + :vartype value: list[~azure.mgmt.applicationinsights.models.WorkbookTemplate] + """ + + _attribute_map = { + "value": {"key": "value", "type": "[WorkbookTemplate]"}, + } + + def __init__(self, *, value: Optional[List["_models.WorkbookTemplate"]] = None, **kwargs: Any) -> None: + """ + :keyword value: An array of workbook templates. + :paramtype value: list[~azure.mgmt.applicationinsights.models.WorkbookTemplate] + """ + super().__init__(**kwargs) + self.value = value + + +class WorkbookTemplateUpdateParameters(_serialization.Model): + """The parameters that can be provided when updating workbook template. + + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar priority: Priority of the template. Determines which template to open when a workbook + gallery is opened in viewer mode. + :vartype priority: int + :ivar author: Information about the author of the workbook template. + :vartype author: str + :ivar template_data: Valid JSON object containing workbook template payload. + :vartype template_data: JSON + :ivar galleries: Workbook galleries supported by the template. + :vartype galleries: list[~azure.mgmt.applicationinsights.models.WorkbookTemplateGallery] + :ivar localized: Key value pair of localized gallery. Each key is the locale code of languages + supported by the Azure portal. + :vartype localized: dict[str, + list[~azure.mgmt.applicationinsights.models.WorkbookTemplateLocalizedGallery]] + """ + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + "priority": {"key": "properties.priority", "type": "int"}, + "author": {"key": "properties.author", "type": "str"}, + "template_data": {"key": "properties.templateData", "type": "object"}, + "galleries": {"key": "properties.galleries", "type": "[WorkbookTemplateGallery]"}, + "localized": {"key": "properties.localized", "type": "{[WorkbookTemplateLocalizedGallery]}"}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + priority: Optional[int] = None, + author: Optional[str] = None, + template_data: Optional[JSON] = None, + galleries: Optional[List["_models.WorkbookTemplateGallery"]] = None, + localized: Optional[Dict[str, List["_models.WorkbookTemplateLocalizedGallery"]]] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword priority: Priority of the template. Determines which template to open when a workbook + gallery is opened in viewer mode. + :paramtype priority: int + :keyword author: Information about the author of the workbook template. + :paramtype author: str + :keyword template_data: Valid JSON object containing workbook template payload. + :paramtype template_data: JSON + :keyword galleries: Workbook galleries supported by the template. + :paramtype galleries: list[~azure.mgmt.applicationinsights.models.WorkbookTemplateGallery] + :keyword localized: Key value pair of localized gallery. Each key is the locale code of + languages supported by the Azure portal. + :paramtype localized: dict[str, + list[~azure.mgmt.applicationinsights.models.WorkbookTemplateLocalizedGallery]] + """ + super().__init__(**kwargs) + self.tags = tags + self.priority = priority + self.author = author + self.template_data = template_data + self.galleries = galleries + self.localized = localized + + +class WorkbookUpdateParameters(_serialization.Model): + """The parameters that can be provided when updating workbook properties properties. + + :ivar kind: The kind of workbook. Only valid value is shared. "shared" + :vartype kind: str or ~azure.mgmt.applicationinsights.models.WorkbookUpdateSharedTypeKind + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar display_name: The user-defined name (display name) of the workbook. + :vartype display_name: str + :ivar serialized_data: Configuration of this particular workbook. Configuration data is a + string containing valid JSON. + :vartype serialized_data: str + :ivar category: Workbook category, as defined by the user at creation time. + :vartype category: str + :ivar tags_properties_tags: A list of 0 or more tags that are associated with this workbook + definition. + :vartype tags_properties_tags: list[str] + :ivar description: The description of the workbook. + :vartype description: str + :ivar revision: The unique revision id for this workbook definition. + :vartype revision: str + """ + + _attribute_map = { + "kind": {"key": "kind", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "serialized_data": {"key": "properties.serializedData", "type": "str"}, + "category": {"key": "properties.category", "type": "str"}, + "tags_properties_tags": {"key": "properties.tags", "type": "[str]"}, + "description": {"key": "properties.description", "type": "str"}, + "revision": {"key": "properties.revision", "type": "str"}, + } + + def __init__( + self, + *, + kind: Optional[Union[str, "_models.WorkbookUpdateSharedTypeKind"]] = None, + tags: Optional[Dict[str, str]] = None, + display_name: Optional[str] = None, + serialized_data: Optional[str] = None, + category: Optional[str] = None, + tags_properties_tags: Optional[List[str]] = None, + description: Optional[str] = None, + revision: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword kind: The kind of workbook. Only valid value is shared. "shared" + :paramtype kind: str or ~azure.mgmt.applicationinsights.models.WorkbookUpdateSharedTypeKind + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword display_name: The user-defined name (display name) of the workbook. + :paramtype display_name: str + :keyword serialized_data: Configuration of this particular workbook. Configuration data is a + string containing valid JSON. + :paramtype serialized_data: str + :keyword category: Workbook category, as defined by the user at creation time. + :paramtype category: str + :keyword tags_properties_tags: A list of 0 or more tags that are associated with this workbook + definition. + :paramtype tags_properties_tags: list[str] + :keyword description: The description of the workbook. + :paramtype description: str + :keyword revision: The unique revision id for this workbook definition. + :paramtype revision: str + """ + super().__init__(**kwargs) + self.kind = kind + self.tags = tags + self.display_name = display_name + self.serialized_data = serialized_data + self.category = category + self.tags_properties_tags = tags_properties_tags + self.description = description + self.revision = revision + + +class WorkItemConfiguration(_serialization.Model): + """Work item configuration associated with an application insights resource. + + :ivar connector_id: Connector identifier where work item is created. + :vartype connector_id: str + :ivar config_display_name: Configuration friendly name. + :vartype config_display_name: str + :ivar is_default: Boolean value indicating whether configuration is default. + :vartype is_default: bool + :ivar id: Unique Id for work item. + :vartype id: str + :ivar config_properties: Serialized JSON object for detailed properties. + :vartype config_properties: str + """ + + _attribute_map = { + "connector_id": {"key": "ConnectorId", "type": "str"}, + "config_display_name": {"key": "ConfigDisplayName", "type": "str"}, + "is_default": {"key": "IsDefault", "type": "bool"}, + "id": {"key": "Id", "type": "str"}, + "config_properties": {"key": "ConfigProperties", "type": "str"}, + } + + def __init__( + self, + *, + connector_id: Optional[str] = None, + config_display_name: Optional[str] = None, + is_default: Optional[bool] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin + config_properties: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword connector_id: Connector identifier where work item is created. + :paramtype connector_id: str + :keyword config_display_name: Configuration friendly name. + :paramtype config_display_name: str + :keyword is_default: Boolean value indicating whether configuration is default. + :paramtype is_default: bool + :keyword id: Unique Id for work item. + :paramtype id: str + :keyword config_properties: Serialized JSON object for detailed properties. + :paramtype config_properties: str + """ + super().__init__(**kwargs) + self.connector_id = connector_id + self.config_display_name = config_display_name + self.is_default = is_default + self.id = id + self.config_properties = config_properties + + +class WorkItemConfigurationError(_serialization.Model): + """Error associated with trying to get work item configuration or configurations. + + :ivar code: Error detail code and explanation. + :vartype code: str + :ivar message: Error message. + :vartype message: str + :ivar innererror: Inner error. + :vartype innererror: ~azure.mgmt.applicationinsights.models.InnerError + """ + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "innererror": {"key": "innererror", "type": "InnerError"}, + } + + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + innererror: Optional["_models.InnerError"] = None, + **kwargs: Any + ) -> None: + """ + :keyword code: Error detail code and explanation. + :paramtype code: str + :keyword message: Error message. + :paramtype message: str + :keyword innererror: Inner error. + :paramtype innererror: ~azure.mgmt.applicationinsights.models.InnerError + """ + super().__init__(**kwargs) + self.code = code + self.message = message + self.innererror = innererror + + +class WorkItemConfigurationsListResult(_serialization.Model): + """Work item configuration list result. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: An array of work item configurations. + :vartype value: list[~azure.mgmt.applicationinsights.models.WorkItemConfiguration] + """ + + _validation = { + "value": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[WorkItemConfiguration]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value: Optional[List["_models.WorkItemConfiguration"]] = None + + +class WorkItemCreateConfiguration(_serialization.Model): + """Work item configuration creation payload. + + :ivar connector_id: Unique connector id. + :vartype connector_id: str + :ivar connector_data_configuration: Serialized JSON object for detailed properties. + :vartype connector_data_configuration: str + :ivar validate_only: Boolean indicating validate only. + :vartype validate_only: bool + :ivar work_item_properties: Custom work item properties. + :vartype work_item_properties: dict[str, str] + """ + + _attribute_map = { + "connector_id": {"key": "ConnectorId", "type": "str"}, + "connector_data_configuration": {"key": "ConnectorDataConfiguration", "type": "str"}, + "validate_only": {"key": "ValidateOnly", "type": "bool"}, + "work_item_properties": {"key": "WorkItemProperties", "type": "{str}"}, + } + + def __init__( + self, + *, + connector_id: Optional[str] = None, + connector_data_configuration: Optional[str] = None, + validate_only: Optional[bool] = None, + work_item_properties: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword connector_id: Unique connector id. + :paramtype connector_id: str + :keyword connector_data_configuration: Serialized JSON object for detailed properties. + :paramtype connector_data_configuration: str + :keyword validate_only: Boolean indicating validate only. + :paramtype validate_only: bool + :keyword work_item_properties: Custom work item properties. + :paramtype work_item_properties: dict[str, str] + """ + super().__init__(**kwargs) + self.connector_id = connector_id + self.connector_data_configuration = connector_data_configuration + self.validate_only = validate_only + self.work_item_properties = work_item_properties diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/models/_patch.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/models/_patch.py new file mode 100644 index 00000000000..8bcb627aa47 --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/models/_patch.py @@ -0,0 +1,21 @@ +# 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. +# -------------------------------------------------------------------------- +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/__init__.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/__init__.py new file mode 100644 index 00000000000..be555323ff9 --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/__init__.py @@ -0,0 +1,63 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._components_operations import ComponentsOperations # type: ignore +from ._annotations_operations import AnnotationsOperations # type: ignore +from ._api_keys_operations import APIKeysOperations # type: ignore +from ._export_configurations_operations import ExportConfigurationsOperations # type: ignore +from ._component_current_billing_features_operations import ComponentCurrentBillingFeaturesOperations # type: ignore +from ._component_quota_status_operations import ComponentQuotaStatusOperations # type: ignore +from ._component_feature_capabilities_operations import ComponentFeatureCapabilitiesOperations # type: ignore +from ._component_available_features_operations import ComponentAvailableFeaturesOperations # type: ignore +from ._proactive_detection_configurations_operations import ProactiveDetectionConfigurationsOperations # type: ignore +from ._work_item_configurations_operations import WorkItemConfigurationsOperations # type: ignore +from ._favorites_operations import FavoritesOperations # type: ignore +from ._web_test_locations_operations import WebTestLocationsOperations # type: ignore +from ._web_tests_operations import WebTestsOperations # type: ignore +from ._analytics_items_operations import AnalyticsItemsOperations # type: ignore +from ._operations import Operations # type: ignore +from ._workbook_templates_operations import WorkbookTemplatesOperations # type: ignore +from ._workbooks_operations import WorkbooksOperations # type: ignore +from ._live_token_operations import LiveTokenOperations # type: ignore +from ._component_linked_storage_accounts_operations import ComponentLinkedStorageAccountsOperations # type: ignore +from ._deleted_workbooks_operations import DeletedWorkbooksOperations # type: ignore + +from ._patch import __all__ as _patch_all +from ._patch import * +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ComponentsOperations", + "AnnotationsOperations", + "APIKeysOperations", + "ExportConfigurationsOperations", + "ComponentCurrentBillingFeaturesOperations", + "ComponentQuotaStatusOperations", + "ComponentFeatureCapabilitiesOperations", + "ComponentAvailableFeaturesOperations", + "ProactiveDetectionConfigurationsOperations", + "WorkItemConfigurationsOperations", + "FavoritesOperations", + "WebTestLocationsOperations", + "WebTestsOperations", + "AnalyticsItemsOperations", + "Operations", + "WorkbookTemplatesOperations", + "WorkbooksOperations", + "LiveTokenOperations", + "ComponentLinkedStorageAccountsOperations", + "DeletedWorkbooksOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore +_patch_sdk() diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_analytics_items_operations.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_analytics_items_operations.py new file mode 100644 index 00000000000..7e4fc0c4fd9 --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_analytics_items_operations.py @@ -0,0 +1,629 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, overload + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._configuration import ApplicationInsightsManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, + resource_name: str, + scope_path: Union[str, _models.ItemScopePath], + subscription_id: str, + *, + scope: Optional[Union[str, _models.ItemScope]] = None, + type: Union[str, _models.ItemTypeParameter] = "none", + include_content: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/{scopePath}", + ) + 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 + ), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "scopePath": _SERIALIZER.url("scope_path", scope_path, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if scope is not None: + _params["scope"] = _SERIALIZER.query("scope", scope, "str") + if type is not None: + _params["type"] = _SERIALIZER.query("type", type, "str") + if include_content is not None: + _params["includeContent"] = _SERIALIZER.query("include_content", include_content, "bool") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, + resource_name: str, + scope_path: Union[str, _models.ItemScopePath], + subscription_id: str, + *, + id: Optional[str] = None, + name: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/{scopePath}/item", + ) + 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 + ), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "scopePath": _SERIALIZER.url("scope_path", scope_path, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if id is not None: + _params["id"] = _SERIALIZER.query("id", id, "str") + if name is not None: + _params["name"] = _SERIALIZER.query("name", name, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_put_request( + resource_group_name: str, + resource_name: str, + scope_path: Union[str, _models.ItemScopePath], + subscription_id: str, + *, + override_item: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/{scopePath}/item", + ) + 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 + ), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "scopePath": _SERIALIZER.url("scope_path", scope_path, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if override_item is not None: + _params["overrideItem"] = _SERIALIZER.query("override_item", override_item, "bool") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + resource_name: str, + scope_path: Union[str, _models.ItemScopePath], + subscription_id: str, + *, + id: Optional[str] = None, + name: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/{scopePath}/item", + ) + 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 + ), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "scopePath": _SERIALIZER.url("scope_path", scope_path, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if id is not None: + _params["id"] = _SERIALIZER.query("id", id, "str") + if name is not None: + _params["name"] = _SERIALIZER.query("name", name, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +class AnalyticsItemsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.applicationinsights.ApplicationInsightsManagementClient`'s + :attr:`analytics_items` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApplicationInsightsManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, + resource_group_name: str, + resource_name: str, + scope_path: Union[str, _models.ItemScopePath], + scope: Optional[Union[str, _models.ItemScope]] = None, + type: Union[str, _models.ItemTypeParameter] = "none", + include_content: Optional[bool] = None, + **kwargs: Any + ) -> List[_models.ApplicationInsightsComponentAnalyticsItem]: + """Gets a list of Analytics Items defined within an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param scope_path: Enum indicating if this item definition is owned by a specific user or is + shared between all users with access to the Application Insights component. Known values are: + "analyticsItems" and "myanalyticsItems". Required. + :type scope_path: str or ~azure.mgmt.applicationinsights.models.ItemScopePath + :param scope: Enum indicating if this item definition is owned by a specific user or is shared + between all users with access to the Application Insights component. Known values are: "shared" + and "user". Default value is None. + :type scope: str or ~azure.mgmt.applicationinsights.models.ItemScope + :param type: Enum indicating the type of the Analytics item. Known values are: "none", "query", + "function", "folder", and "recent". Default value is "none". + :type type: str or ~azure.mgmt.applicationinsights.models.ItemTypeParameter + :param include_content: Flag indicating whether or not to return the content of each applicable + item. If false, only return the item information. Default value is None. + :type include_content: bool + :return: list of ApplicationInsightsComponentAnalyticsItem or the result of cls(response) + :rtype: list[~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentAnalyticsItem] + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + cls: ClsType[List[_models.ApplicationInsightsComponentAnalyticsItem]] = kwargs.pop("cls", None) + + _request = build_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + scope_path=scope_path, + subscription_id=self._config.subscription_id, + scope=scope, + type=type, + include_content=include_content, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("[ApplicationInsightsComponentAnalyticsItem]", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get( + self, + resource_group_name: str, + resource_name: str, + scope_path: Union[str, _models.ItemScopePath], + id: Optional[str] = None, + name: Optional[str] = None, + **kwargs: Any + ) -> _models.ApplicationInsightsComponentAnalyticsItem: + """Gets a specific Analytics Items defined within an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param scope_path: Enum indicating if this item definition is owned by a specific user or is + shared between all users with access to the Application Insights component. Known values are: + "analyticsItems" and "myanalyticsItems". Required. + :type scope_path: str or ~azure.mgmt.applicationinsights.models.ItemScopePath + :param id: The Id of a specific item defined in the Application Insights component. Default + value is None. + :type id: str + :param name: The name of a specific item defined in the Application Insights component. Default + value is None. + :type name: str + :return: ApplicationInsightsComponentAnalyticsItem or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentAnalyticsItem + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + cls: ClsType[_models.ApplicationInsightsComponentAnalyticsItem] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + scope_path=scope_path, + subscription_id=self._config.subscription_id, + id=id, + name=name, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ApplicationInsightsComponentAnalyticsItem", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def put( + self, + resource_group_name: str, + resource_name: str, + scope_path: Union[str, _models.ItemScopePath], + item_properties: _models.ApplicationInsightsComponentAnalyticsItem, + override_item: Optional[bool] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApplicationInsightsComponentAnalyticsItem: + """Adds or Updates a specific Analytics Item within an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param scope_path: Enum indicating if this item definition is owned by a specific user or is + shared between all users with access to the Application Insights component. Known values are: + "analyticsItems" and "myanalyticsItems". Required. + :type scope_path: str or ~azure.mgmt.applicationinsights.models.ItemScopePath + :param item_properties: Properties that need to be specified to create a new item and add it to + an Application Insights component. Required. + :type item_properties: + ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentAnalyticsItem + :param override_item: Flag indicating whether or not to force save an item. This allows + overriding an item if it already exists. Default value is None. + :type override_item: bool + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationInsightsComponentAnalyticsItem or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentAnalyticsItem + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def put( + self, + resource_group_name: str, + resource_name: str, + scope_path: Union[str, _models.ItemScopePath], + item_properties: IO[bytes], + override_item: Optional[bool] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApplicationInsightsComponentAnalyticsItem: + """Adds or Updates a specific Analytics Item within an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param scope_path: Enum indicating if this item definition is owned by a specific user or is + shared between all users with access to the Application Insights component. Known values are: + "analyticsItems" and "myanalyticsItems". Required. + :type scope_path: str or ~azure.mgmt.applicationinsights.models.ItemScopePath + :param item_properties: Properties that need to be specified to create a new item and add it to + an Application Insights component. Required. + :type item_properties: IO[bytes] + :param override_item: Flag indicating whether or not to force save an item. This allows + overriding an item if it already exists. Default value is None. + :type override_item: bool + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationInsightsComponentAnalyticsItem or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentAnalyticsItem + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def put( + self, + resource_group_name: str, + resource_name: str, + scope_path: Union[str, _models.ItemScopePath], + item_properties: Union[_models.ApplicationInsightsComponentAnalyticsItem, IO[bytes]], + override_item: Optional[bool] = None, + **kwargs: Any + ) -> _models.ApplicationInsightsComponentAnalyticsItem: + """Adds or Updates a specific Analytics Item within an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param scope_path: Enum indicating if this item definition is owned by a specific user or is + shared between all users with access to the Application Insights component. Known values are: + "analyticsItems" and "myanalyticsItems". Required. + :type scope_path: str or ~azure.mgmt.applicationinsights.models.ItemScopePath + :param item_properties: Properties that need to be specified to create a new item and add it to + an Application Insights component. Is either a ApplicationInsightsComponentAnalyticsItem type + or a IO[bytes] type. Required. + :type item_properties: + ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentAnalyticsItem or IO[bytes] + :param override_item: Flag indicating whether or not to force save an item. This allows + overriding an item if it already exists. Default value is None. + :type override_item: bool + :return: ApplicationInsightsComponentAnalyticsItem or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentAnalyticsItem + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ApplicationInsightsComponentAnalyticsItem] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(item_properties, (IOBase, bytes)): + _content = item_properties + else: + _json = self._serialize.body(item_properties, "ApplicationInsightsComponentAnalyticsItem") + + _request = build_put_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + scope_path=scope_path, + subscription_id=self._config.subscription_id, + override_item=override_item, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ApplicationInsightsComponentAnalyticsItem", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + resource_name: str, + scope_path: Union[str, _models.ItemScopePath], + id: Optional[str] = None, + name: Optional[str] = None, + **kwargs: Any + ) -> None: + """Deletes a specific Analytics Items defined within an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param scope_path: Enum indicating if this item definition is owned by a specific user or is + shared between all users with access to the Application Insights component. Known values are: + "analyticsItems" and "myanalyticsItems". Required. + :type scope_path: str or ~azure.mgmt.applicationinsights.models.ItemScopePath + :param id: The Id of a specific item defined in the Application Insights component. Default + value is None. + :type id: str + :param name: The name of a specific item defined in the Application Insights component. Default + value is None. + :type name: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + scope_path=scope_path, + subscription_id=self._config.subscription_id, + id=id, + name=name, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_annotations_operations.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_annotations_operations.py new file mode 100644 index 00000000000..624de7ba9c0 --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_annotations_operations.py @@ -0,0 +1,524 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, overload + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._configuration import ApplicationInsightsManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, resource_name: str, subscription_id: str, *, start: str, end: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/Annotations", + ) + 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), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["start"] = _SERIALIZER.query("start", start, "str") + _params["end"] = _SERIALIZER.query("end", end, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/Annotations", + ) + 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), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, resource_name: str, annotation_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/Annotations/{annotationId}", + ) + 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), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "annotationId": _SERIALIZER.url("annotation_id", annotation_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_get_request( + resource_group_name: str, resource_name: str, annotation_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/Annotations/{annotationId}", + ) + 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), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "annotationId": _SERIALIZER.url("annotation_id", annotation_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class AnnotationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.applicationinsights.ApplicationInsightsManagementClient`'s + :attr:`annotations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApplicationInsightsManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, resource_name: str, start: str, end: str, **kwargs: Any + ) -> ItemPaged["_models.Annotation"]: + """Gets the list of annotations for a component for given time range. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param start: The start time to query from for annotations, cannot be older than 90 days from + current date. Required. + :type start: str + :param end: The end time to query for annotations. Required. + :type end: str + :return: An iterator like instance of either Annotation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.models.Annotation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + cls: ClsType[_models.AnnotationsListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + start=start, + end=end, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AnnotationsListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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.AnnotationError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @overload + def create( + self, + resource_group_name: str, + resource_name: str, + annotation_properties: _models.Annotation, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> List[_models.Annotation]: + """Create an Annotation of an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param annotation_properties: Properties that need to be specified to create an annotation of a + Application Insights component. Required. + :type annotation_properties: ~azure.mgmt.applicationinsights.models.Annotation + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: list of Annotation or the result of cls(response) + :rtype: list[~azure.mgmt.applicationinsights.models.Annotation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + resource_name: str, + annotation_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> List[_models.Annotation]: + """Create an Annotation of an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param annotation_properties: Properties that need to be specified to create an annotation of a + Application Insights component. Required. + :type annotation_properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: list of Annotation or the result of cls(response) + :rtype: list[~azure.mgmt.applicationinsights.models.Annotation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + resource_name: str, + annotation_properties: Union[_models.Annotation, IO[bytes]], + **kwargs: Any + ) -> List[_models.Annotation]: + """Create an Annotation of an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param annotation_properties: Properties that need to be specified to create an annotation of a + Application Insights component. Is either a Annotation type or a IO[bytes] type. Required. + :type annotation_properties: ~azure.mgmt.applicationinsights.models.Annotation or IO[bytes] + :return: list of Annotation or the result of cls(response) + :rtype: list[~azure.mgmt.applicationinsights.models.Annotation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[List[_models.Annotation]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(annotation_properties, (IOBase, bytes)): + _content = annotation_properties + else: + _json = self._serialize.body(annotation_properties, "Annotation") + + _request = build_create_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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.AnnotationError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("[Annotation]", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, annotation_id: str, **kwargs: Any + ) -> None: + """Delete an Annotation of an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param annotation_id: The unique annotation ID. This is unique within a Application Insights + component. Required. + :type annotation_id: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + annotation_id=annotation_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def get( + self, resource_group_name: str, resource_name: str, annotation_id: str, **kwargs: Any + ) -> List[_models.Annotation]: + """Get the annotation for given id. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param annotation_id: The unique annotation ID. This is unique within a Application Insights + component. Required. + :type annotation_id: str + :return: list of Annotation or the result of cls(response) + :rtype: list[~azure.mgmt.applicationinsights.models.Annotation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + cls: ClsType[List[_models.Annotation]] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + annotation_id=annotation_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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.AnnotationError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("[Annotation]", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_api_keys_operations.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_api_keys_operations.py new file mode 100644 index 00000000000..72fdc26967a --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_api_keys_operations.py @@ -0,0 +1,524 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._configuration import ApplicationInsightsManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ApiKeys", + ) + 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), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ApiKeys", + ) + 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), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, resource_name: str, key_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/APIKeys/{keyId}", + ) + 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), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "keyId": _SERIALIZER.url("key_id", key_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, resource_name: str, key_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/APIKeys/{keyId}", + ) + 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), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "keyId": _SERIALIZER.url("key_id", key_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class APIKeysOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.applicationinsights.ApplicationInsightsManagementClient`'s + :attr:`api_keys` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApplicationInsightsManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> ItemPaged["_models.ApplicationInsightsComponentAPIKey"]: + """Gets a list of API keys of an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :return: An iterator like instance of either ApplicationInsightsComponentAPIKey or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentAPIKey] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + cls: ClsType[_models.ApplicationInsightsComponentAPIKeyListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationInsightsComponentAPIKeyListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @overload + def create( + self, + resource_group_name: str, + resource_name: str, + api_key_properties: _models.APIKeyRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApplicationInsightsComponentAPIKey: + """Create an API Key of an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param api_key_properties: Properties that need to be specified to create an API key of a + Application Insights component. Required. + :type api_key_properties: ~azure.mgmt.applicationinsights.models.APIKeyRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationInsightsComponentAPIKey or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentAPIKey + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + resource_name: str, + api_key_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApplicationInsightsComponentAPIKey: + """Create an API Key of an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param api_key_properties: Properties that need to be specified to create an API key of a + Application Insights component. Required. + :type api_key_properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationInsightsComponentAPIKey or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentAPIKey + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + resource_name: str, + api_key_properties: Union[_models.APIKeyRequest, IO[bytes]], + **kwargs: Any + ) -> _models.ApplicationInsightsComponentAPIKey: + """Create an API Key of an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param api_key_properties: Properties that need to be specified to create an API key of a + Application Insights component. Is either a APIKeyRequest type or a IO[bytes] type. Required. + :type api_key_properties: ~azure.mgmt.applicationinsights.models.APIKeyRequest or IO[bytes] + :return: ApplicationInsightsComponentAPIKey or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentAPIKey + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ApplicationInsightsComponentAPIKey] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(api_key_properties, (IOBase, bytes)): + _content = api_key_properties + else: + _json = self._serialize.body(api_key_properties, "APIKeyRequest") + + _request = build_create_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ApplicationInsightsComponentAPIKey", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( + self, resource_group_name: str, resource_name: str, key_id: str, **kwargs: Any + ) -> _models.ApplicationInsightsComponentAPIKey: + """Delete an API Key of an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param key_id: The API Key ID. This is unique within a Application Insights component. + Required. + :type key_id: str + :return: ApplicationInsightsComponentAPIKey or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentAPIKey + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + cls: ClsType[_models.ApplicationInsightsComponentAPIKey] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + key_id=key_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ApplicationInsightsComponentAPIKey", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get( + self, resource_group_name: str, resource_name: str, key_id: str, **kwargs: Any + ) -> _models.ApplicationInsightsComponentAPIKey: + """Get the API Key for this key id. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param key_id: The API Key ID. This is unique within a Application Insights component. + Required. + :type key_id: str + :return: ApplicationInsightsComponentAPIKey or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentAPIKey + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + cls: ClsType[_models.ApplicationInsightsComponentAPIKey] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + key_id=key_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ApplicationInsightsComponentAPIKey", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_component_available_features_operations.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_component_available_features_operations.py new file mode 100644 index 00000000000..b923955fc4c --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_component_available_features_operations.py @@ -0,0 +1,147 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._configuration import ApplicationInsightsManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request(resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/getavailablebillingfeatures", + ) + 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), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ComponentAvailableFeaturesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.applicationinsights.ApplicationInsightsManagementClient`'s + :attr:`component_available_features` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApplicationInsightsManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.ApplicationInsightsComponentAvailableFeatures: + """Returns all available features of the application insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :return: ApplicationInsightsComponentAvailableFeatures or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentAvailableFeatures + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + cls: ClsType[_models.ApplicationInsightsComponentAvailableFeatures] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize( + "ApplicationInsightsComponentAvailableFeatures", pipeline_response.http_response + ) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_component_current_billing_features_operations.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_component_current_billing_features_operations.py new file mode 100644 index 00000000000..7708e8ab710 --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_component_current_billing_features_operations.py @@ -0,0 +1,317 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._configuration import ApplicationInsightsManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request(resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/currentbillingfeatures", + ) + 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), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/currentbillingfeatures", + ) + 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), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +class ComponentCurrentBillingFeaturesOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.applicationinsights.ApplicationInsightsManagementClient`'s + :attr:`component_current_billing_features` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApplicationInsightsManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.ApplicationInsightsComponentBillingFeatures: + """Returns current billing features for an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :return: ApplicationInsightsComponentBillingFeatures or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentBillingFeatures + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + cls: ClsType[_models.ApplicationInsightsComponentBillingFeatures] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ApplicationInsightsComponentBillingFeatures", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_group_name: str, + resource_name: str, + billing_features_properties: _models.ApplicationInsightsComponentBillingFeatures, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApplicationInsightsComponentBillingFeatures: + """Update current billing features for an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param billing_features_properties: Properties that need to be specified to update billing + features for an Application Insights component. Required. + :type billing_features_properties: + ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentBillingFeatures + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationInsightsComponentBillingFeatures or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentBillingFeatures + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + resource_name: str, + billing_features_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApplicationInsightsComponentBillingFeatures: + """Update current billing features for an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param billing_features_properties: Properties that need to be specified to update billing + features for an Application Insights component. Required. + :type billing_features_properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationInsightsComponentBillingFeatures or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentBillingFeatures + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + resource_name: str, + billing_features_properties: Union[_models.ApplicationInsightsComponentBillingFeatures, IO[bytes]], + **kwargs: Any + ) -> _models.ApplicationInsightsComponentBillingFeatures: + """Update current billing features for an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param billing_features_properties: Properties that need to be specified to update billing + features for an Application Insights component. Is either a + ApplicationInsightsComponentBillingFeatures type or a IO[bytes] type. Required. + :type billing_features_properties: + ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentBillingFeatures or IO[bytes] + :return: ApplicationInsightsComponentBillingFeatures or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentBillingFeatures + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ApplicationInsightsComponentBillingFeatures] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(billing_features_properties, (IOBase, bytes)): + _content = billing_features_properties + else: + _json = self._serialize.body(billing_features_properties, "ApplicationInsightsComponentBillingFeatures") + + _request = build_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ApplicationInsightsComponentBillingFeatures", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_component_feature_capabilities_operations.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_component_feature_capabilities_operations.py new file mode 100644 index 00000000000..7b9f0340a93 --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_component_feature_capabilities_operations.py @@ -0,0 +1,147 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._configuration import ApplicationInsightsManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request(resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/featurecapabilities", + ) + 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), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ComponentFeatureCapabilitiesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.applicationinsights.ApplicationInsightsManagementClient`'s + :attr:`component_feature_capabilities` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApplicationInsightsManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.ApplicationInsightsComponentFeatureCapabilities: + """Returns feature capabilities of the application insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :return: ApplicationInsightsComponentFeatureCapabilities or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentFeatureCapabilities + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + cls: ClsType[_models.ApplicationInsightsComponentFeatureCapabilities] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize( + "ApplicationInsightsComponentFeatureCapabilities", pipeline_response.http_response + ) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_component_linked_storage_accounts_operations.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_component_linked_storage_accounts_operations.py new file mode 100644 index 00000000000..8156d2eaf6f --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_component_linked_storage_accounts_operations.py @@ -0,0 +1,634 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._configuration import ApplicationInsightsManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, + resource_name: str, + storage_type: Union[str, _models.StorageType], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/linkedStorageAccounts/{storageType}", + ) + 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), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "storageType": _SERIALIZER.url("storage_type", storage_type, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_and_update_request( + resource_group_name: str, + resource_name: str, + storage_type: Union[str, _models.StorageType], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/linkedStorageAccounts/{storageType}", + ) + 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), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "storageType": _SERIALIZER.url("storage_type", storage_type, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, + resource_name: str, + storage_type: Union[str, _models.StorageType], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/linkedStorageAccounts/{storageType}", + ) + 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), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "storageType": _SERIALIZER.url("storage_type", storage_type, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + resource_name: str, + storage_type: Union[str, _models.StorageType], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/linkedStorageAccounts/{storageType}", + ) + 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), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "storageType": _SERIALIZER.url("storage_type", storage_type, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class ComponentLinkedStorageAccountsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.applicationinsights.ApplicationInsightsManagementClient`'s + :attr:`component_linked_storage_accounts` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApplicationInsightsManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, resource_name: str, storage_type: Union[str, _models.StorageType], **kwargs: Any + ) -> _models.ComponentLinkedStorageAccounts: + """Returns the current linked storage settings for an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param storage_type: The type of the Application Insights component data source for the linked + storage account. "ServiceProfiler" Required. + :type storage_type: str or ~azure.mgmt.applicationinsights.models.StorageType + :return: ComponentLinkedStorageAccounts or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ComponentLinkedStorageAccounts + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01-preview")) + cls: ClsType[_models.ComponentLinkedStorageAccounts] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + storage_type=storage_type, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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.ErrorResponseLinkedStorage, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ComponentLinkedStorageAccounts", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_and_update( + self, + resource_group_name: str, + resource_name: str, + storage_type: Union[str, _models.StorageType], + linked_storage_accounts_properties: _models.ComponentLinkedStorageAccounts, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ComponentLinkedStorageAccounts: + """Replace current linked storage account for an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param storage_type: The type of the Application Insights component data source for the linked + storage account. "ServiceProfiler" Required. + :type storage_type: str or ~azure.mgmt.applicationinsights.models.StorageType + :param linked_storage_accounts_properties: Properties that need to be specified to update + linked storage accounts for an Application Insights component. Required. + :type linked_storage_accounts_properties: + ~azure.mgmt.applicationinsights.models.ComponentLinkedStorageAccounts + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ComponentLinkedStorageAccounts or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ComponentLinkedStorageAccounts + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_and_update( + self, + resource_group_name: str, + resource_name: str, + storage_type: Union[str, _models.StorageType], + linked_storage_accounts_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ComponentLinkedStorageAccounts: + """Replace current linked storage account for an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param storage_type: The type of the Application Insights component data source for the linked + storage account. "ServiceProfiler" Required. + :type storage_type: str or ~azure.mgmt.applicationinsights.models.StorageType + :param linked_storage_accounts_properties: Properties that need to be specified to update + linked storage accounts for an Application Insights component. Required. + :type linked_storage_accounts_properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ComponentLinkedStorageAccounts or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ComponentLinkedStorageAccounts + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_and_update( + self, + resource_group_name: str, + resource_name: str, + storage_type: Union[str, _models.StorageType], + linked_storage_accounts_properties: Union[_models.ComponentLinkedStorageAccounts, IO[bytes]], + **kwargs: Any + ) -> _models.ComponentLinkedStorageAccounts: + """Replace current linked storage account for an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param storage_type: The type of the Application Insights component data source for the linked + storage account. "ServiceProfiler" Required. + :type storage_type: str or ~azure.mgmt.applicationinsights.models.StorageType + :param linked_storage_accounts_properties: Properties that need to be specified to update + linked storage accounts for an Application Insights component. Is either a + ComponentLinkedStorageAccounts type or a IO[bytes] type. Required. + :type linked_storage_accounts_properties: + ~azure.mgmt.applicationinsights.models.ComponentLinkedStorageAccounts or IO[bytes] + :return: ComponentLinkedStorageAccounts or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ComponentLinkedStorageAccounts + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ComponentLinkedStorageAccounts] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(linked_storage_accounts_properties, (IOBase, bytes)): + _content = linked_storage_accounts_properties + else: + _json = self._serialize.body(linked_storage_accounts_properties, "ComponentLinkedStorageAccounts") + + _request = build_create_and_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + storage_type=storage_type, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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.ErrorResponseLinkedStorage, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ComponentLinkedStorageAccounts", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_group_name: str, + resource_name: str, + storage_type: Union[str, _models.StorageType], + linked_storage_accounts_properties: _models.ComponentLinkedStorageAccountsPatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ComponentLinkedStorageAccounts: + """Update linked storage accounts for an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param storage_type: The type of the Application Insights component data source for the linked + storage account. "ServiceProfiler" Required. + :type storage_type: str or ~azure.mgmt.applicationinsights.models.StorageType + :param linked_storage_accounts_properties: Properties that need to be specified to update a + linked storage accounts for an Application Insights component. Required. + :type linked_storage_accounts_properties: + ~azure.mgmt.applicationinsights.models.ComponentLinkedStorageAccountsPatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ComponentLinkedStorageAccounts or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ComponentLinkedStorageAccounts + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + resource_name: str, + storage_type: Union[str, _models.StorageType], + linked_storage_accounts_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ComponentLinkedStorageAccounts: + """Update linked storage accounts for an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param storage_type: The type of the Application Insights component data source for the linked + storage account. "ServiceProfiler" Required. + :type storage_type: str or ~azure.mgmt.applicationinsights.models.StorageType + :param linked_storage_accounts_properties: Properties that need to be specified to update a + linked storage accounts for an Application Insights component. Required. + :type linked_storage_accounts_properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ComponentLinkedStorageAccounts or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ComponentLinkedStorageAccounts + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + resource_name: str, + storage_type: Union[str, _models.StorageType], + linked_storage_accounts_properties: Union[_models.ComponentLinkedStorageAccountsPatch, IO[bytes]], + **kwargs: Any + ) -> _models.ComponentLinkedStorageAccounts: + """Update linked storage accounts for an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param storage_type: The type of the Application Insights component data source for the linked + storage account. "ServiceProfiler" Required. + :type storage_type: str or ~azure.mgmt.applicationinsights.models.StorageType + :param linked_storage_accounts_properties: Properties that need to be specified to update a + linked storage accounts for an Application Insights component. Is either a + ComponentLinkedStorageAccountsPatch type or a IO[bytes] type. Required. + :type linked_storage_accounts_properties: + ~azure.mgmt.applicationinsights.models.ComponentLinkedStorageAccountsPatch or IO[bytes] + :return: ComponentLinkedStorageAccounts or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ComponentLinkedStorageAccounts + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ComponentLinkedStorageAccounts] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(linked_storage_accounts_properties, (IOBase, bytes)): + _content = linked_storage_accounts_properties + else: + _json = self._serialize.body(linked_storage_accounts_properties, "ComponentLinkedStorageAccountsPatch") + + _request = build_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + storage_type=storage_type, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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.ErrorResponseLinkedStorage, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ComponentLinkedStorageAccounts", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, storage_type: Union[str, _models.StorageType], **kwargs: Any + ) -> None: + """Delete linked storage accounts for an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param storage_type: The type of the Application Insights component data source for the linked + storage account. "ServiceProfiler" Required. + :type storage_type: str or ~azure.mgmt.applicationinsights.models.StorageType + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + storage_type=storage_type, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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.ErrorResponseLinkedStorage, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_component_quota_status_operations.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_component_quota_status_operations.py new file mode 100644 index 00000000000..4e5d7412543 --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_component_quota_status_operations.py @@ -0,0 +1,145 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._configuration import ApplicationInsightsManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request(resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/quotastatus", + ) + 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), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ComponentQuotaStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.applicationinsights.ApplicationInsightsManagementClient`'s + :attr:`component_quota_status` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApplicationInsightsManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.ApplicationInsightsComponentQuotaStatus: + """Returns daily data volume cap (quota) status for an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :return: ApplicationInsightsComponentQuotaStatus or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentQuotaStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + cls: ClsType[_models.ApplicationInsightsComponentQuotaStatus] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ApplicationInsightsComponentQuotaStatus", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_components_operations.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_components_operations.py new file mode 100644 index 00000000000..4662d3e7f28 --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_components_operations.py @@ -0,0 +1,1061 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._configuration import ApplicationInsightsManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-02-02")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/components") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-02-02")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components", + ) + 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: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-02-02")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}", + ) + 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), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-02-02")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}", + ) + 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), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-02-02")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}", + ) + 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), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_tags_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-02-02")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}", + ) + 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), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_purge_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-02-02")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/purge", + ) + 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), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_purge_status_request( + resource_group_name: str, resource_name: str, purge_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-02-02")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/operations/{purgeId}", + ) + 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), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "purgeId": _SERIALIZER.url("purge_id", purge_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ComponentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.applicationinsights.ApplicationInsightsManagementClient`'s + :attr:`components` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApplicationInsightsManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> ItemPaged["_models.ApplicationInsightsComponent"]: + """Gets a list of all Application Insights components within a subscription. + + :return: An iterator like instance of either ApplicationInsightsComponent or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.models.ApplicationInsightsComponent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-02-02")) + cls: ClsType[_models.ApplicationInsightsComponentListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationInsightsComponentListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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.ErrorResponseComponents, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> ItemPaged["_models.ApplicationInsightsComponent"]: + """Gets a list of Application Insights components within a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of either ApplicationInsightsComponent or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.models.ApplicationInsightsComponent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-02-02")) + cls: ClsType[_models.ApplicationInsightsComponentListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + 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, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationInsightsComponentListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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.ErrorResponseComponents, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> None: + """Deletes an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-02-02")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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.ErrorResponseComponents, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.ApplicationInsightsComponent: + """Returns an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :return: ApplicationInsightsComponent or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponent + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-02-02")) + cls: ClsType[_models.ApplicationInsightsComponent] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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.ErrorResponseComponents, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ApplicationInsightsComponent", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + resource_name: str, + insight_properties: _models.ApplicationInsightsComponent, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApplicationInsightsComponent: + """Creates (or updates) an Application Insights component. 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. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param insight_properties: Properties that need to be specified to create an Application + Insights component. Required. + :type insight_properties: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponent + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationInsightsComponent or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponent + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + resource_name: str, + insight_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApplicationInsightsComponent: + """Creates (or updates) an Application Insights component. 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. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param insight_properties: Properties that need to be specified to create an Application + Insights component. Required. + :type insight_properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationInsightsComponent or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponent + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + resource_name: str, + insight_properties: Union[_models.ApplicationInsightsComponent, IO[bytes]], + **kwargs: Any + ) -> _models.ApplicationInsightsComponent: + """Creates (or updates) an Application Insights component. 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. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param insight_properties: Properties that need to be specified to create an Application + Insights component. Is either a ApplicationInsightsComponent type or a IO[bytes] type. + Required. + :type insight_properties: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponent + or IO[bytes] + :return: ApplicationInsightsComponent or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponent + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-02-02")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ApplicationInsightsComponent] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(insight_properties, (IOBase, bytes)): + _content = insight_properties + else: + _json = self._serialize.body(insight_properties, "ApplicationInsightsComponent") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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.ErrorResponseComponents, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ApplicationInsightsComponent", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update_tags( + self, + resource_group_name: str, + resource_name: str, + component_tags: _models.TagsResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApplicationInsightsComponent: + """Updates an existing component'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. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param component_tags: Updated tag information to set into the component instance. Required. + :type component_tags: ~azure.mgmt.applicationinsights.models.TagsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationInsightsComponent or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponent + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update_tags( + self, + resource_group_name: str, + resource_name: str, + component_tags: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApplicationInsightsComponent: + """Updates an existing component'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. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param component_tags: Updated tag information to set into the component instance. Required. + :type component_tags: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationInsightsComponent or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponent + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update_tags( + self, + resource_group_name: str, + resource_name: str, + component_tags: Union[_models.TagsResource, IO[bytes]], + **kwargs: Any + ) -> _models.ApplicationInsightsComponent: + """Updates an existing component'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. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param component_tags: Updated tag information to set into the component instance. Is either a + TagsResource type or a IO[bytes] type. Required. + :type component_tags: ~azure.mgmt.applicationinsights.models.TagsResource or IO[bytes] + :return: ApplicationInsightsComponent or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponent + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-02-02")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ApplicationInsightsComponent] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(component_tags, (IOBase, bytes)): + _content = component_tags + else: + _json = self._serialize.body(component_tags, "TagsResource") + + _request = build_update_tags_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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.ErrorResponseComponents, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ApplicationInsightsComponent", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def purge( + self, + resource_group_name: str, + resource_name: str, + body: _models.ComponentPurgeBody, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ComponentPurgeResponse: + """Purges data in an Application Insights component by a set of user-defined filters. + + In order to manage system resources, purge requests are throttled at 50 requests per hour. You + should batch the execution of purge requests by sending a single command whose predicate + includes all user identities that require purging. Use the in operator to specify multiple + identities. You should run the query prior to using for a purge request to verify that the + results are expected. + Note: this operation is intended for Classic resources, for workspace-based Application + Insights resource please run purge operation (directly on the + workspace)(https://docs.microsoft.com/en-us/rest/api/loganalytics/workspace-purge/purge) , + scoped to specific resource id. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param body: Describes the body of a request to purge data in a single table of an Application + Insights component. Required. + :type body: ~azure.mgmt.applicationinsights.models.ComponentPurgeBody + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ComponentPurgeResponse or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ComponentPurgeResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def purge( + self, + resource_group_name: str, + resource_name: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ComponentPurgeResponse: + """Purges data in an Application Insights component by a set of user-defined filters. + + In order to manage system resources, purge requests are throttled at 50 requests per hour. You + should batch the execution of purge requests by sending a single command whose predicate + includes all user identities that require purging. Use the in operator to specify multiple + identities. You should run the query prior to using for a purge request to verify that the + results are expected. + Note: this operation is intended for Classic resources, for workspace-based Application + Insights resource please run purge operation (directly on the + workspace)(https://docs.microsoft.com/en-us/rest/api/loganalytics/workspace-purge/purge) , + scoped to specific resource id. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param body: Describes the body of a request to purge data in a single table of an Application + Insights component. Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ComponentPurgeResponse or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ComponentPurgeResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def purge( + self, + resource_group_name: str, + resource_name: str, + body: Union[_models.ComponentPurgeBody, IO[bytes]], + **kwargs: Any + ) -> _models.ComponentPurgeResponse: + """Purges data in an Application Insights component by a set of user-defined filters. + + In order to manage system resources, purge requests are throttled at 50 requests per hour. You + should batch the execution of purge requests by sending a single command whose predicate + includes all user identities that require purging. Use the in operator to specify multiple + identities. You should run the query prior to using for a purge request to verify that the + results are expected. + Note: this operation is intended for Classic resources, for workspace-based Application + Insights resource please run purge operation (directly on the + workspace)(https://docs.microsoft.com/en-us/rest/api/loganalytics/workspace-purge/purge) , + scoped to specific resource id. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param body: Describes the body of a request to purge data in a single table of an Application + Insights component. Is either a ComponentPurgeBody type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.applicationinsights.models.ComponentPurgeBody or IO[bytes] + :return: ComponentPurgeResponse or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ComponentPurgeResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-02-02")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ComponentPurgeResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = self._serialize.body(body, "ComponentPurgeBody") + + _request = build_purge_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseComponents, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ComponentPurgeResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_purge_status( + self, resource_group_name: str, resource_name: str, purge_id: str, **kwargs: Any + ) -> _models.ComponentPurgeStatusResponse: + """Get status for an ongoing purge operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param purge_id: In a purge status request, this is the Id of the operation the status of which + is returned. Required. + :type purge_id: str + :return: ComponentPurgeStatusResponse or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ComponentPurgeStatusResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-02-02")) + cls: ClsType[_models.ComponentPurgeStatusResponse] = kwargs.pop("cls", None) + + _request = build_get_purge_status_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + purge_id=purge_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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.ErrorResponseComponents, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ComponentPurgeStatusResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_deleted_workbooks_operations.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_deleted_workbooks_operations.py new file mode 100644 index 00000000000..85f2783270b --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_deleted_workbooks_operations.py @@ -0,0 +1,167 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, List, Optional, TypeVar, Union + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._configuration import ApplicationInsightsManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_subscription_request( + subscription_id: str, + *, + category: Optional[Union[str, _models.CategoryType]] = None, + tags: Optional[List[str]] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/deletedWorkbooks") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if category is not None: + _params["category"] = _SERIALIZER.query("category", category, "str") + if tags is not None: + _params["tags"] = _SERIALIZER.query("tags", tags, "[str]", div=",") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class DeletedWorkbooksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.applicationinsights.ApplicationInsightsManagementClient`'s + :attr:`deleted_workbooks` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApplicationInsightsManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_subscription( + self, + category: Optional[Union[str, _models.CategoryType]] = None, + tags: Optional[List[str]] = None, + **kwargs: Any + ) -> ItemPaged["_models.DeletedWorkbook"]: + """Get all recently deleted Workbooks in a specified subscription. + + :param category: Category of workbook to return. Known values are: "workbook", "TSG", + "performance", and "retention". Default value is None. + :type category: str or ~azure.mgmt.applicationinsights.models.CategoryType + :param tags: Tags presents on each workbook returned. Default value is None. + :type tags: list[str] + :return: An iterator like instance of either DeletedWorkbook or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.models.DeletedWorkbook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01-preview")) + cls: ClsType[_models.DeletedWorkbooksListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + category=category, + tags=tags, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("DeletedWorkbooksListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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.DeletedWorkbookError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_export_configurations_operations.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_export_configurations_operations.py new file mode 100644 index 00000000000..801039ccff8 --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_export_configurations_operations.py @@ -0,0 +1,708 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, overload + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._configuration import ApplicationInsightsManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/exportconfiguration", + ) + 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), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/exportconfiguration", + ) + 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), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, resource_name: str, export_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/exportconfiguration/{exportId}", + ) + 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), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "exportId": _SERIALIZER.url("export_id", export_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, resource_name: str, export_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/exportconfiguration/{exportId}", + ) + 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), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "exportId": _SERIALIZER.url("export_id", export_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, resource_name: str, export_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/exportconfiguration/{exportId}", + ) + 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), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "exportId": _SERIALIZER.url("export_id", export_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +class ExportConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.applicationinsights.ApplicationInsightsManagementClient`'s + :attr:`export_configurations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApplicationInsightsManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> List[_models.ApplicationInsightsComponentExportConfiguration]: + """Gets a list of Continuous Export configuration of an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :return: list of ApplicationInsightsComponentExportConfiguration or the result of cls(response) + :rtype: + list[~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentExportConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + cls: ClsType[List[_models.ApplicationInsightsComponentExportConfiguration]] = kwargs.pop("cls", None) + + _request = build_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize( + "[ApplicationInsightsComponentExportConfiguration]", pipeline_response.http_response + ) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create( + self, + resource_group_name: str, + resource_name: str, + export_properties: _models.ApplicationInsightsComponentExportRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> List[_models.ApplicationInsightsComponentExportConfiguration]: + """Create a Continuous Export configuration of an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param export_properties: Properties that need to be specified to create a Continuous Export + configuration of a Application Insights component. Required. + :type export_properties: + ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentExportRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: list of ApplicationInsightsComponentExportConfiguration or the result of cls(response) + :rtype: + list[~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentExportConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + resource_name: str, + export_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> List[_models.ApplicationInsightsComponentExportConfiguration]: + """Create a Continuous Export configuration of an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param export_properties: Properties that need to be specified to create a Continuous Export + configuration of a Application Insights component. Required. + :type export_properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: list of ApplicationInsightsComponentExportConfiguration or the result of cls(response) + :rtype: + list[~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentExportConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + resource_name: str, + export_properties: Union[_models.ApplicationInsightsComponentExportRequest, IO[bytes]], + **kwargs: Any + ) -> List[_models.ApplicationInsightsComponentExportConfiguration]: + """Create a Continuous Export configuration of an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param export_properties: Properties that need to be specified to create a Continuous Export + configuration of a Application Insights component. Is either a + ApplicationInsightsComponentExportRequest type or a IO[bytes] type. Required. + :type export_properties: + ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentExportRequest or IO[bytes] + :return: list of ApplicationInsightsComponentExportConfiguration or the result of cls(response) + :rtype: + list[~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentExportConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[List[_models.ApplicationInsightsComponentExportConfiguration]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(export_properties, (IOBase, bytes)): + _content = export_properties + else: + _json = self._serialize.body(export_properties, "ApplicationInsightsComponentExportRequest") + + _request = build_create_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize( + "[ApplicationInsightsComponentExportConfiguration]", pipeline_response.http_response + ) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( + self, resource_group_name: str, resource_name: str, export_id: str, **kwargs: Any + ) -> _models.ApplicationInsightsComponentExportConfiguration: + """Delete a Continuous Export configuration of an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param export_id: The Continuous Export configuration ID. This is unique within a Application + Insights component. Required. + :type export_id: str + :return: ApplicationInsightsComponentExportConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentExportConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + cls: ClsType[_models.ApplicationInsightsComponentExportConfiguration] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + export_id=export_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize( + "ApplicationInsightsComponentExportConfiguration", pipeline_response.http_response + ) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get( + self, resource_group_name: str, resource_name: str, export_id: str, **kwargs: Any + ) -> _models.ApplicationInsightsComponentExportConfiguration: + """Get the Continuous Export configuration for this export id. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param export_id: The Continuous Export configuration ID. This is unique within a Application + Insights component. Required. + :type export_id: str + :return: ApplicationInsightsComponentExportConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentExportConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + cls: ClsType[_models.ApplicationInsightsComponentExportConfiguration] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + export_id=export_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize( + "ApplicationInsightsComponentExportConfiguration", pipeline_response.http_response + ) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_group_name: str, + resource_name: str, + export_id: str, + export_properties: _models.ApplicationInsightsComponentExportRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApplicationInsightsComponentExportConfiguration: + """Update the Continuous Export configuration for this export id. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param export_id: The Continuous Export configuration ID. This is unique within a Application + Insights component. Required. + :type export_id: str + :param export_properties: Properties that need to be specified to update the Continuous Export + configuration. Required. + :type export_properties: + ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentExportRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationInsightsComponentExportConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentExportConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + resource_name: str, + export_id: str, + export_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApplicationInsightsComponentExportConfiguration: + """Update the Continuous Export configuration for this export id. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param export_id: The Continuous Export configuration ID. This is unique within a Application + Insights component. Required. + :type export_id: str + :param export_properties: Properties that need to be specified to update the Continuous Export + configuration. Required. + :type export_properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationInsightsComponentExportConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentExportConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + resource_name: str, + export_id: str, + export_properties: Union[_models.ApplicationInsightsComponentExportRequest, IO[bytes]], + **kwargs: Any + ) -> _models.ApplicationInsightsComponentExportConfiguration: + """Update the Continuous Export configuration for this export id. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param export_id: The Continuous Export configuration ID. This is unique within a Application + Insights component. Required. + :type export_id: str + :param export_properties: Properties that need to be specified to update the Continuous Export + configuration. Is either a ApplicationInsightsComponentExportRequest type or a IO[bytes] type. + Required. + :type export_properties: + ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentExportRequest or IO[bytes] + :return: ApplicationInsightsComponentExportConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentExportConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ApplicationInsightsComponentExportConfiguration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(export_properties, (IOBase, bytes)): + _content = export_properties + else: + _json = self._serialize.body(export_properties, "ApplicationInsightsComponentExportRequest") + + _request = build_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + export_id=export_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize( + "ApplicationInsightsComponentExportConfiguration", pipeline_response.http_response + ) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_favorites_operations.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_favorites_operations.py new file mode 100644 index 00000000000..3cdb09ff9ab --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_favorites_operations.py @@ -0,0 +1,737 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, overload + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._configuration import ApplicationInsightsManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, + resource_name: str, + subscription_id: str, + *, + favorite_type: Optional[Union[str, _models.FavoriteType]] = None, + source_type: Optional[Union[str, _models.FavoriteSourceType]] = None, + can_fetch_content: Optional[bool] = None, + tags: Optional[List[str]] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/favorites", + ) + 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), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if favorite_type is not None: + _params["favoriteType"] = _SERIALIZER.query("favorite_type", favorite_type, "str") + if source_type is not None: + _params["sourceType"] = _SERIALIZER.query("source_type", source_type, "str") + if can_fetch_content is not None: + _params["canFetchContent"] = _SERIALIZER.query("can_fetch_content", can_fetch_content, "bool") + if tags is not None: + _params["tags"] = _SERIALIZER.query("tags", tags, "[str]", div=",") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, resource_name: str, favorite_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/favorites/{favoriteId}", + ) + 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), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "favoriteId": _SERIALIZER.url("favorite_id", favorite_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_add_request( + resource_group_name: str, resource_name: str, favorite_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/favorites/{favoriteId}", + ) + 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), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "favoriteId": _SERIALIZER.url("favorite_id", favorite_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, resource_name: str, favorite_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/favorites/{favoriteId}", + ) + 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), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "favoriteId": _SERIALIZER.url("favorite_id", favorite_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, resource_name: str, favorite_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/favorites/{favoriteId}", + ) + 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), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "favoriteId": _SERIALIZER.url("favorite_id", favorite_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +class FavoritesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.applicationinsights.ApplicationInsightsManagementClient`'s + :attr:`favorites` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApplicationInsightsManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, + resource_group_name: str, + resource_name: str, + favorite_type: Optional[Union[str, _models.FavoriteType]] = None, + source_type: Optional[Union[str, _models.FavoriteSourceType]] = None, + can_fetch_content: Optional[bool] = None, + tags: Optional[List[str]] = None, + **kwargs: Any + ) -> List[_models.ApplicationInsightsComponentFavorite]: + """Gets a list of favorites defined within an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param favorite_type: The type of favorite. Value can be either shared or user. Known values + are: "shared" and "user". Default value is None. + :type favorite_type: str or ~azure.mgmt.applicationinsights.models.FavoriteType + :param source_type: Source type of favorite to return. When left out, the source type defaults + to 'other' (not present in this enum). Known values are: "retention", "notebook", "sessions", + "events", "userflows", "funnel", "impact", and "segmentation". Default value is None. + :type source_type: str or ~azure.mgmt.applicationinsights.models.FavoriteSourceType + :param can_fetch_content: Flag indicating whether or not to return the full content for each + applicable favorite. If false, only return summary content for favorites. Default value is + None. + :type can_fetch_content: bool + :param tags: Tags that must be present on each favorite returned. Default value is None. + :type tags: list[str] + :return: list of ApplicationInsightsComponentFavorite or the result of cls(response) + :rtype: list[~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentFavorite] + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + cls: ClsType[List[_models.ApplicationInsightsComponentFavorite]] = kwargs.pop("cls", None) + + _request = build_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + favorite_type=favorite_type, + source_type=source_type, + can_fetch_content=can_fetch_content, + tags=tags, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("[ApplicationInsightsComponentFavorite]", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get( + self, resource_group_name: str, resource_name: str, favorite_id: str, **kwargs: Any + ) -> _models.ApplicationInsightsComponentFavorite: + """Get a single favorite by its FavoriteId, defined within an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param favorite_id: The Id of a specific favorite defined in the Application Insights + component. Required. + :type favorite_id: str + :return: ApplicationInsightsComponentFavorite or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentFavorite + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + cls: ClsType[_models.ApplicationInsightsComponentFavorite] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + favorite_id=favorite_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ApplicationInsightsComponentFavorite", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def add( + self, + resource_group_name: str, + resource_name: str, + favorite_id: str, + favorite_properties: _models.ApplicationInsightsComponentFavorite, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApplicationInsightsComponentFavorite: + """Adds a new favorites to an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param favorite_id: The Id of a specific favorite defined in the Application Insights + component. Required. + :type favorite_id: str + :param favorite_properties: Properties that need to be specified to create a new favorite and + add it to an Application Insights component. Required. + :type favorite_properties: + ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentFavorite + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationInsightsComponentFavorite or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentFavorite + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def add( + self, + resource_group_name: str, + resource_name: str, + favorite_id: str, + favorite_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApplicationInsightsComponentFavorite: + """Adds a new favorites to an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param favorite_id: The Id of a specific favorite defined in the Application Insights + component. Required. + :type favorite_id: str + :param favorite_properties: Properties that need to be specified to create a new favorite and + add it to an Application Insights component. Required. + :type favorite_properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationInsightsComponentFavorite or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentFavorite + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def add( + self, + resource_group_name: str, + resource_name: str, + favorite_id: str, + favorite_properties: Union[_models.ApplicationInsightsComponentFavorite, IO[bytes]], + **kwargs: Any + ) -> _models.ApplicationInsightsComponentFavorite: + """Adds a new favorites to an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param favorite_id: The Id of a specific favorite defined in the Application Insights + component. Required. + :type favorite_id: str + :param favorite_properties: Properties that need to be specified to create a new favorite and + add it to an Application Insights component. Is either a ApplicationInsightsComponentFavorite + type or a IO[bytes] type. Required. + :type favorite_properties: + ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentFavorite or IO[bytes] + :return: ApplicationInsightsComponentFavorite or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentFavorite + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ApplicationInsightsComponentFavorite] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(favorite_properties, (IOBase, bytes)): + _content = favorite_properties + else: + _json = self._serialize.body(favorite_properties, "ApplicationInsightsComponentFavorite") + + _request = build_add_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + favorite_id=favorite_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ApplicationInsightsComponentFavorite", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_group_name: str, + resource_name: str, + favorite_id: str, + favorite_properties: _models.ApplicationInsightsComponentFavorite, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApplicationInsightsComponentFavorite: + """Updates a favorite that has already been added to an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param favorite_id: The Id of a specific favorite defined in the Application Insights + component. Required. + :type favorite_id: str + :param favorite_properties: Properties that need to be specified to update the existing + favorite. Required. + :type favorite_properties: + ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentFavorite + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationInsightsComponentFavorite or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentFavorite + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + resource_name: str, + favorite_id: str, + favorite_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApplicationInsightsComponentFavorite: + """Updates a favorite that has already been added to an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param favorite_id: The Id of a specific favorite defined in the Application Insights + component. Required. + :type favorite_id: str + :param favorite_properties: Properties that need to be specified to update the existing + favorite. Required. + :type favorite_properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationInsightsComponentFavorite or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentFavorite + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + resource_name: str, + favorite_id: str, + favorite_properties: Union[_models.ApplicationInsightsComponentFavorite, IO[bytes]], + **kwargs: Any + ) -> _models.ApplicationInsightsComponentFavorite: + """Updates a favorite that has already been added to an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param favorite_id: The Id of a specific favorite defined in the Application Insights + component. Required. + :type favorite_id: str + :param favorite_properties: Properties that need to be specified to update the existing + favorite. Is either a ApplicationInsightsComponentFavorite type or a IO[bytes] type. Required. + :type favorite_properties: + ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentFavorite or IO[bytes] + :return: ApplicationInsightsComponentFavorite or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentFavorite + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ApplicationInsightsComponentFavorite] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(favorite_properties, (IOBase, bytes)): + _content = favorite_properties + else: + _json = self._serialize.body(favorite_properties, "ApplicationInsightsComponentFavorite") + + _request = build_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + favorite_id=favorite_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ApplicationInsightsComponentFavorite", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, favorite_id: str, **kwargs: Any + ) -> None: + """Remove a favorite that is associated to an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param favorite_id: The Id of a specific favorite defined in the Application Insights + component. Required. + :type favorite_id: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + favorite_id=favorite_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_live_token_operations.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_live_token_operations.py new file mode 100644 index 00000000000..961959fc368 --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_live_token_operations.py @@ -0,0 +1,131 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._configuration import ApplicationInsightsManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request(resource_uri: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-14")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/generatelivetoken") + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class LiveTokenOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.applicationinsights.ApplicationInsightsManagementClient`'s + :attr:`live_token` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApplicationInsightsManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, resource_uri: str, **kwargs: Any) -> _models.LiveTokenResponse: + """**Gets an access token for live metrics stream data.**. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :return: LiveTokenResponse or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.LiveTokenResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-14")) + cls: ClsType[_models.LiveTokenResponse] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_uri=resource_uri, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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.ErrorResponseLinkedStorage, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("LiveTokenResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_operations.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_operations.py new file mode 100644 index 00000000000..9239529aac9 --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_operations.py @@ -0,0 +1,139 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._configuration import ApplicationInsightsManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-08")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Insights/operations") + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.applicationinsights.ApplicationInsightsManagementClient`'s + :attr:`operations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApplicationInsightsManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> ItemPaged["_models.Operation"]: + """Lists all of the available insights REST API operations. + + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-08")) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("OperationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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) diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_patch.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_patch.py new file mode 100644 index 00000000000..8bcb627aa47 --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_patch.py @@ -0,0 +1,21 @@ +# 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. +# -------------------------------------------------------------------------- +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_proactive_detection_configurations_operations.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_proactive_detection_configurations_operations.py new file mode 100644 index 00000000000..d654002879f --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_proactive_detection_configurations_operations.py @@ -0,0 +1,451 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, overload + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._configuration import ApplicationInsightsManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ProactiveDetectionConfigs", + ) + 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), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, resource_name: str, configuration_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ProactiveDetectionConfigs/{ConfigurationId}", + ) + 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), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "ConfigurationId": _SERIALIZER.url("configuration_id", configuration_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, resource_name: str, configuration_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ProactiveDetectionConfigs/{ConfigurationId}", + ) + 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), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "ConfigurationId": _SERIALIZER.url("configuration_id", configuration_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +class ProactiveDetectionConfigurationsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.applicationinsights.ApplicationInsightsManagementClient`'s + :attr:`proactive_detection_configurations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApplicationInsightsManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> List[_models.ApplicationInsightsComponentProactiveDetectionConfiguration]: + """Gets a list of ProactiveDetection configurations of an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :return: list of ApplicationInsightsComponentProactiveDetectionConfiguration or the result of + cls(response) + :rtype: + list[~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentProactiveDetectionConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + cls: ClsType[List[_models.ApplicationInsightsComponentProactiveDetectionConfiguration]] = kwargs.pop( + "cls", None + ) + + _request = build_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize( + "[ApplicationInsightsComponentProactiveDetectionConfiguration]", pipeline_response.http_response + ) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get( + self, resource_group_name: str, resource_name: str, configuration_id: str, **kwargs: Any + ) -> _models.ApplicationInsightsComponentProactiveDetectionConfiguration: + """Get the ProactiveDetection configuration for this configuration id. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param configuration_id: The ProactiveDetection configuration ID. This is unique within a + Application Insights component. Required. + :type configuration_id: str + :return: ApplicationInsightsComponentProactiveDetectionConfiguration or the result of + cls(response) + :rtype: + ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentProactiveDetectionConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + cls: ClsType[_models.ApplicationInsightsComponentProactiveDetectionConfiguration] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + configuration_id=configuration_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize( + "ApplicationInsightsComponentProactiveDetectionConfiguration", pipeline_response.http_response + ) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_group_name: str, + resource_name: str, + configuration_id: str, + proactive_detection_properties: _models.ApplicationInsightsComponentProactiveDetectionConfiguration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApplicationInsightsComponentProactiveDetectionConfiguration: + """Update the ProactiveDetection configuration for this configuration id. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param configuration_id: The ProactiveDetection configuration ID. This is unique within a + Application Insights component. Required. + :type configuration_id: str + :param proactive_detection_properties: Properties that need to be specified to update the + ProactiveDetection configuration. Required. + :type proactive_detection_properties: + ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentProactiveDetectionConfiguration + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationInsightsComponentProactiveDetectionConfiguration or the result of + cls(response) + :rtype: + ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentProactiveDetectionConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + resource_name: str, + configuration_id: str, + proactive_detection_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApplicationInsightsComponentProactiveDetectionConfiguration: + """Update the ProactiveDetection configuration for this configuration id. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param configuration_id: The ProactiveDetection configuration ID. This is unique within a + Application Insights component. Required. + :type configuration_id: str + :param proactive_detection_properties: Properties that need to be specified to update the + ProactiveDetection configuration. Required. + :type proactive_detection_properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ApplicationInsightsComponentProactiveDetectionConfiguration or the result of + cls(response) + :rtype: + ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentProactiveDetectionConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + resource_name: str, + configuration_id: str, + proactive_detection_properties: Union[ + _models.ApplicationInsightsComponentProactiveDetectionConfiguration, IO[bytes] + ], + **kwargs: Any + ) -> _models.ApplicationInsightsComponentProactiveDetectionConfiguration: + """Update the ProactiveDetection configuration for this configuration id. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param configuration_id: The ProactiveDetection configuration ID. This is unique within a + Application Insights component. Required. + :type configuration_id: str + :param proactive_detection_properties: Properties that need to be specified to update the + ProactiveDetection configuration. Is either a + ApplicationInsightsComponentProactiveDetectionConfiguration type or a IO[bytes] type. Required. + :type proactive_detection_properties: + ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentProactiveDetectionConfiguration + or IO[bytes] + :return: ApplicationInsightsComponentProactiveDetectionConfiguration or the result of + cls(response) + :rtype: + ~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentProactiveDetectionConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ApplicationInsightsComponentProactiveDetectionConfiguration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(proactive_detection_properties, (IOBase, bytes)): + _content = proactive_detection_properties + else: + _json = self._serialize.body( + proactive_detection_properties, "ApplicationInsightsComponentProactiveDetectionConfiguration" + ) + + _request = build_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + configuration_id=configuration_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize( + "ApplicationInsightsComponentProactiveDetectionConfiguration", pipeline_response.http_response + ) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_web_test_locations_operations.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_web_test_locations_operations.py new file mode 100644 index 00000000000..184c88e1c58 --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_web_test_locations_operations.py @@ -0,0 +1,165 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._configuration import ApplicationInsightsManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/syntheticmonitorlocations", + ) + 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), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class WebTestLocationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.applicationinsights.ApplicationInsightsManagementClient`'s + :attr:`web_test_locations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApplicationInsightsManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> ItemPaged["_models.ApplicationInsightsComponentWebTestLocation"]: + """Gets a list of web test locations available to this Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :return: An iterator like instance of either ApplicationInsightsComponentWebTestLocation or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.models.ApplicationInsightsComponentWebTestLocation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + cls: ClsType[_models.ApplicationInsightsWebTestLocationsListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApplicationInsightsWebTestLocationsListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_web_tests_operations.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_web_tests_operations.py new file mode 100644 index 00000000000..2e8462a2a4d --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_web_tests_operations.py @@ -0,0 +1,851 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._configuration import ApplicationInsightsManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests", + ) + 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: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(resource_group_name: str, web_test_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}", + ) + 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), + "webTestName": _SERIALIZER.url("web_test_name", web_test_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, web_test_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}", + ) + 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), + "webTestName": _SERIALIZER.url("web_test_name", web_test_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_tags_request( + resource_group_name: str, web_test_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}", + ) + 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), + "webTestName": _SERIALIZER.url("web_test_name", web_test_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, web_test_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}", + ) + 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 + ), + "webTestName": _SERIALIZER.url("web_test_name", web_test_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/webtests") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_component_request( + component_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{componentName}/webtests", + ) + path_format_arguments = { + "componentName": _SERIALIZER.url("component_name", component_name, "str"), + "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: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class WebTestsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.applicationinsights.ApplicationInsightsManagementClient`'s + :attr:`web_tests` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApplicationInsightsManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.WebTest"]: + """Get all Application Insights web tests defined for the specified resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of either WebTest or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.models.WebTest] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) + cls: ClsType[_models.WebTestListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + 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, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("WebTestListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get(self, resource_group_name: str, web_test_name: str, **kwargs: Any) -> _models.WebTest: + """Get a specific Application Insights web test definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param web_test_name: The name of the Application Insights WebTest resource. Required. + :type web_test_name: str + :return: WebTest or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.WebTest + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) + cls: ClsType[_models.WebTest] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + web_test_name=web_test_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("WebTest", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + web_test_name: str, + web_test_definition: _models.WebTest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.WebTest: + """Creates or updates an Application Insights web test definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param web_test_name: The name of the Application Insights WebTest resource. Required. + :type web_test_name: str + :param web_test_definition: Properties that need to be specified to create or update an + Application Insights web test definition. Required. + :type web_test_definition: ~azure.mgmt.applicationinsights.models.WebTest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: WebTest or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.WebTest + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + web_test_name: str, + web_test_definition: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.WebTest: + """Creates or updates an Application Insights web test definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param web_test_name: The name of the Application Insights WebTest resource. Required. + :type web_test_name: str + :param web_test_definition: Properties that need to be specified to create or update an + Application Insights web test definition. Required. + :type web_test_definition: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: WebTest or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.WebTest + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + web_test_name: str, + web_test_definition: Union[_models.WebTest, IO[bytes]], + **kwargs: Any + ) -> _models.WebTest: + """Creates or updates an Application Insights web test definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param web_test_name: The name of the Application Insights WebTest resource. Required. + :type web_test_name: str + :param web_test_definition: Properties that need to be specified to create or update an + Application Insights web test definition. Is either a WebTest type or a IO[bytes] type. + Required. + :type web_test_definition: ~azure.mgmt.applicationinsights.models.WebTest or IO[bytes] + :return: WebTest or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.WebTest + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.WebTest] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(web_test_definition, (IOBase, bytes)): + _content = web_test_definition + else: + _json = self._serialize.body(web_test_definition, "WebTest") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + web_test_name=web_test_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("WebTest", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update_tags( + self, + resource_group_name: str, + web_test_name: str, + web_test_tags: _models.TagsResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.WebTest: + """Updates the tags associated with an Application Insights web test. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param web_test_name: The name of the Application Insights WebTest resource. Required. + :type web_test_name: str + :param web_test_tags: Updated tag information to associate with the web test resource. + Required. + :type web_test_tags: ~azure.mgmt.applicationinsights.models.TagsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: WebTest or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.WebTest + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update_tags( + self, + resource_group_name: str, + web_test_name: str, + web_test_tags: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.WebTest: + """Updates the tags associated with an Application Insights web test. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param web_test_name: The name of the Application Insights WebTest resource. Required. + :type web_test_name: str + :param web_test_tags: Updated tag information to associate with the web test resource. + Required. + :type web_test_tags: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: WebTest or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.WebTest + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update_tags( + self, + resource_group_name: str, + web_test_name: str, + web_test_tags: Union[_models.TagsResource, IO[bytes]], + **kwargs: Any + ) -> _models.WebTest: + """Updates the tags associated with an Application Insights web test. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param web_test_name: The name of the Application Insights WebTest resource. Required. + :type web_test_name: str + :param web_test_tags: Updated tag information to associate with the web test resource. Is + either a TagsResource type or a IO[bytes] type. Required. + :type web_test_tags: ~azure.mgmt.applicationinsights.models.TagsResource or IO[bytes] + :return: WebTest or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.WebTest + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.WebTest] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(web_test_tags, (IOBase, bytes)): + _content = web_test_tags + else: + _json = self._serialize.body(web_test_tags, "TagsResource") + + _request = build_update_tags_request( + resource_group_name=resource_group_name, + web_test_name=web_test_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("WebTest", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, web_test_name: str, **kwargs: Any + ) -> None: + """Deletes an Application Insights web test. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param web_test_name: The name of the Application Insights WebTest resource. Required. + :type web_test_name: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + web_test_name=web_test_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list(self, **kwargs: Any) -> ItemPaged["_models.WebTest"]: + """Get all Application Insights web test definitions for the specified subscription. + + :return: An iterator like instance of either WebTest or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.models.WebTest] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) + cls: ClsType[_models.WebTestListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("WebTestListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_component( + self, component_name: str, resource_group_name: str, **kwargs: Any + ) -> ItemPaged["_models.WebTest"]: + """Get all Application Insights web tests defined for the specified component. + + :param component_name: The name of the Application Insights component resource. Required. + :type component_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of either WebTest or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.models.WebTest] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) + cls: ClsType[_models.WebTestListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_component_request( + component_name=component_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("WebTestListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_work_item_configurations_operations.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_work_item_configurations_operations.py new file mode 100644 index 00000000000..374255496c2 --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_work_item_configurations_operations.py @@ -0,0 +1,791 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._configuration import ApplicationInsightsManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/WorkItemConfigs", + ) + 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), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/WorkItemConfigs", + ) + 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), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_default_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/DefaultWorkItemConfig", + ) + 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), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, resource_name: str, work_item_config_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/WorkItemConfigs/{workItemConfigId}", + ) + 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), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "workItemConfigId": _SERIALIZER.url("work_item_config_id", work_item_config_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_get_item_request( + resource_group_name: str, resource_name: str, work_item_config_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/WorkItemConfigs/{workItemConfigId}", + ) + 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), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "workItemConfigId": _SERIALIZER.url("work_item_config_id", work_item_config_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_item_request( + resource_group_name: str, resource_name: str, work_item_config_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/WorkItemConfigs/{workItemConfigId}", + ) + 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), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "workItemConfigId": _SERIALIZER.url("work_item_config_id", work_item_config_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +class WorkItemConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.applicationinsights.ApplicationInsightsManagementClient`'s + :attr:`work_item_configurations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApplicationInsightsManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> ItemPaged["_models.WorkItemConfiguration"]: + """Gets the list work item configurations that exist for the application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :return: An iterator like instance of either WorkItemConfiguration or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.models.WorkItemConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + cls: ClsType[_models.WorkItemConfigurationsListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("WorkItemConfigurationsListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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.WorkItemConfigurationError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @overload + def create( + self, + resource_group_name: str, + resource_name: str, + work_item_configuration_properties: _models.WorkItemCreateConfiguration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.WorkItemConfiguration: + """Create a work item configuration for an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param work_item_configuration_properties: Properties that need to be specified to create a + work item configuration of a Application Insights component. Required. + :type work_item_configuration_properties: + ~azure.mgmt.applicationinsights.models.WorkItemCreateConfiguration + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: WorkItemConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.WorkItemConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + resource_name: str, + work_item_configuration_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.WorkItemConfiguration: + """Create a work item configuration for an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param work_item_configuration_properties: Properties that need to be specified to create a + work item configuration of a Application Insights component. Required. + :type work_item_configuration_properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: WorkItemConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.WorkItemConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + resource_name: str, + work_item_configuration_properties: Union[_models.WorkItemCreateConfiguration, IO[bytes]], + **kwargs: Any + ) -> _models.WorkItemConfiguration: + """Create a work item configuration for an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param work_item_configuration_properties: Properties that need to be specified to create a + work item configuration of a Application Insights component. Is either a + WorkItemCreateConfiguration type or a IO[bytes] type. Required. + :type work_item_configuration_properties: + ~azure.mgmt.applicationinsights.models.WorkItemCreateConfiguration or IO[bytes] + :return: WorkItemConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.WorkItemConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.WorkItemConfiguration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(work_item_configuration_properties, (IOBase, bytes)): + _content = work_item_configuration_properties + else: + _json = self._serialize.body(work_item_configuration_properties, "WorkItemCreateConfiguration") + + _request = build_create_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("WorkItemConfiguration", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_default(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.WorkItemConfiguration: + """Gets default work item configurations that exist for the application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :return: WorkItemConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.WorkItemConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + cls: ClsType[_models.WorkItemConfiguration] = kwargs.pop("cls", None) + + _request = build_get_default_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("WorkItemConfiguration", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, work_item_config_id: str, **kwargs: Any + ) -> None: + """Delete a work item configuration of an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param work_item_config_id: The unique work item configuration Id. This can be either friendly + name of connector as defined in connector configuration. Required. + :type work_item_config_id: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + work_item_config_id=work_item_config_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def get_item( + self, resource_group_name: str, resource_name: str, work_item_config_id: str, **kwargs: Any + ) -> _models.WorkItemConfiguration: + """Gets specified work item configuration for an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param work_item_config_id: The unique work item configuration Id. This can be either friendly + name of connector as defined in connector configuration. Required. + :type work_item_config_id: str + :return: WorkItemConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.WorkItemConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + cls: ClsType[_models.WorkItemConfiguration] = kwargs.pop("cls", None) + + _request = build_get_item_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + work_item_config_id=work_item_config_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("WorkItemConfiguration", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update_item( + self, + resource_group_name: str, + resource_name: str, + work_item_config_id: str, + work_item_configuration_properties: _models.WorkItemCreateConfiguration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.WorkItemConfiguration: + """Update a work item configuration for an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param work_item_config_id: The unique work item configuration Id. This can be either friendly + name of connector as defined in connector configuration. Required. + :type work_item_config_id: str + :param work_item_configuration_properties: Properties that need to be specified to update a + work item configuration for this Application Insights component. Required. + :type work_item_configuration_properties: + ~azure.mgmt.applicationinsights.models.WorkItemCreateConfiguration + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: WorkItemConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.WorkItemConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update_item( + self, + resource_group_name: str, + resource_name: str, + work_item_config_id: str, + work_item_configuration_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.WorkItemConfiguration: + """Update a work item configuration for an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param work_item_config_id: The unique work item configuration Id. This can be either friendly + name of connector as defined in connector configuration. Required. + :type work_item_config_id: str + :param work_item_configuration_properties: Properties that need to be specified to update a + work item configuration for this Application Insights component. Required. + :type work_item_configuration_properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: WorkItemConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.WorkItemConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update_item( + self, + resource_group_name: str, + resource_name: str, + work_item_config_id: str, + work_item_configuration_properties: Union[_models.WorkItemCreateConfiguration, IO[bytes]], + **kwargs: Any + ) -> _models.WorkItemConfiguration: + """Update a work item configuration for an Application Insights component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param work_item_config_id: The unique work item configuration Id. This can be either friendly + name of connector as defined in connector configuration. Required. + :type work_item_config_id: str + :param work_item_configuration_properties: Properties that need to be specified to update a + work item configuration for this Application Insights component. Is either a + WorkItemCreateConfiguration type or a IO[bytes] type. Required. + :type work_item_configuration_properties: + ~azure.mgmt.applicationinsights.models.WorkItemCreateConfiguration or IO[bytes] + :return: WorkItemConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.WorkItemConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.WorkItemConfiguration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(work_item_configuration_properties, (IOBase, bytes)): + _content = work_item_configuration_properties + else: + _json = self._serialize.body(work_item_configuration_properties, "WorkItemCreateConfiguration") + + _request = build_update_item_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + work_item_config_id=work_item_config_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("WorkItemConfiguration", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_workbook_templates_operations.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_workbook_templates_operations.py new file mode 100644 index 00000000000..01e7af11686 --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_workbook_templates_operations.py @@ -0,0 +1,678 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._configuration import ApplicationInsightsManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-20")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooktemplates", + ) + 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 + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-20")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooktemplates/{resourceName}", + ) + 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 + ), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-20")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooktemplates/{resourceName}", + ) + 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 + ), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-20")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooktemplates/{resourceName}", + ) + 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 + ), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-20")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooktemplates/{resourceName}", + ) + 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 + ), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +class WorkbookTemplatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.applicationinsights.ApplicationInsightsManagementClient`'s + :attr:`workbook_templates` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApplicationInsightsManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.WorkbookTemplate"]: + """Get all Workbook templates defined within a specified resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of either WorkbookTemplate or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.models.WorkbookTemplate] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-20")) + cls: ClsType[_models.WorkbookTemplatesListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + 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, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("WorkbookTemplatesListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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.WorkbookTemplateError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.WorkbookTemplate: + """Get a single workbook template by its resourceName. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :return: WorkbookTemplate or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.WorkbookTemplate + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-20")) + cls: ClsType[_models.WorkbookTemplate] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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.WorkbookTemplateError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("WorkbookTemplate", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> None: + """Delete a workbook template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-20")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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.WorkbookTemplateError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + resource_name: str, + workbook_template_properties: _models.WorkbookTemplate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.WorkbookTemplate: + """Create a new workbook template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param workbook_template_properties: Properties that need to be specified to create a new + workbook. Required. + :type workbook_template_properties: ~azure.mgmt.applicationinsights.models.WorkbookTemplate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: WorkbookTemplate or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.WorkbookTemplate + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + resource_name: str, + workbook_template_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.WorkbookTemplate: + """Create a new workbook template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param workbook_template_properties: Properties that need to be specified to create a new + workbook. Required. + :type workbook_template_properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: WorkbookTemplate or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.WorkbookTemplate + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + resource_name: str, + workbook_template_properties: Union[_models.WorkbookTemplate, IO[bytes]], + **kwargs: Any + ) -> _models.WorkbookTemplate: + """Create a new workbook template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param workbook_template_properties: Properties that need to be specified to create a new + workbook. Is either a WorkbookTemplate type or a IO[bytes] type. Required. + :type workbook_template_properties: ~azure.mgmt.applicationinsights.models.WorkbookTemplate or + IO[bytes] + :return: WorkbookTemplate or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.WorkbookTemplate + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-20")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.WorkbookTemplate] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(workbook_template_properties, (IOBase, bytes)): + _content = workbook_template_properties + else: + _json = self._serialize.body(workbook_template_properties, "WorkbookTemplate") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.WorkbookTemplateError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("WorkbookTemplate", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_group_name: str, + resource_name: str, + workbook_template_update_parameters: Optional[_models.WorkbookTemplateUpdateParameters] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.WorkbookTemplate: + """Updates a workbook template that has already been added. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param workbook_template_update_parameters: Properties that need to be specified to patch a + workbook template. Default value is None. + :type workbook_template_update_parameters: + ~azure.mgmt.applicationinsights.models.WorkbookTemplateUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: WorkbookTemplate or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.WorkbookTemplate + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + resource_name: str, + workbook_template_update_parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.WorkbookTemplate: + """Updates a workbook template that has already been added. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param workbook_template_update_parameters: Properties that need to be specified to patch a + workbook template. Default value is None. + :type workbook_template_update_parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: WorkbookTemplate or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.WorkbookTemplate + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + resource_name: str, + workbook_template_update_parameters: Optional[ + Union[_models.WorkbookTemplateUpdateParameters, IO[bytes]] + ] = None, + **kwargs: Any + ) -> _models.WorkbookTemplate: + """Updates a workbook template that has already been added. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the Application Insights component resource. Required. + :type resource_name: str + :param workbook_template_update_parameters: Properties that need to be specified to patch a + workbook template. Is either a WorkbookTemplateUpdateParameters type or a IO[bytes] type. + Default value is None. + :type workbook_template_update_parameters: + ~azure.mgmt.applicationinsights.models.WorkbookTemplateUpdateParameters or IO[bytes] + :return: WorkbookTemplate or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.WorkbookTemplate + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-20")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.WorkbookTemplate] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(workbook_template_update_parameters, (IOBase, bytes)): + _content = workbook_template_update_parameters + else: + if workbook_template_update_parameters is not None: + _json = self._serialize.body(workbook_template_update_parameters, "WorkbookTemplateUpdateParameters") + else: + _json = None + + _request = build_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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.WorkbookTemplateError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("WorkbookTemplate", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_workbooks_operations.py b/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_workbooks_operations.py new file mode 100644 index 00000000000..5f7ac656c70 --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/operations/_workbooks_operations.py @@ -0,0 +1,1089 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, overload + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._configuration import ApplicationInsightsManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_subscription_request( + subscription_id: str, + *, + category: Union[str, _models.CategoryType], + tags: Optional[List[str]] = None, + can_fetch_content: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/workbooks") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["category"] = _SERIALIZER.query("category", category, "str") + if tags is not None: + _params["tags"] = _SERIALIZER.query("tags", tags, "[str]", div=",") + if can_fetch_content is not None: + _params["canFetchContent"] = _SERIALIZER.query("can_fetch_content", can_fetch_content, "bool") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + *, + category: Union[str, _models.CategoryType], + tags: Optional[List[str]] = None, + source_id: Optional[str] = None, + can_fetch_content: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks", + ) + 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 + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["category"] = _SERIALIZER.query("category", category, "str") + if tags is not None: + _params["tags"] = _SERIALIZER.query("tags", tags, "[str]", div=",") + if source_id is not None: + _params["sourceId"] = _SERIALIZER.query("source_id", source_id, "str") + if can_fetch_content is not None: + _params["canFetchContent"] = _SERIALIZER.query("can_fetch_content", can_fetch_content, "bool") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, + resource_name: str, + subscription_id: str, + *, + can_fetch_content: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}", + ) + 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 + ), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if can_fetch_content is not None: + _params["canFetchContent"] = _SERIALIZER.query("can_fetch_content", can_fetch_content, "bool") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}", + ) + 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 + ), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + resource_name: str, + subscription_id: str, + *, + source_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}", + ) + 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 + ), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if source_id is not None: + _params["sourceId"] = _SERIALIZER.query("source_id", source_id, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, + resource_name: str, + subscription_id: str, + *, + source_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}", + ) + 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 + ), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if source_id is not None: + _params["sourceId"] = _SERIALIZER.query("source_id", source_id, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_revisions_list_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}/revisions", + ) + 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 + ), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_revision_get_request( + resource_group_name: str, resource_name: str, revision_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/workbooks/{resourceName}/revisions/{revisionId}", + ) + 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 + ), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "revisionId": _SERIALIZER.url("revision_id", revision_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class WorkbooksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.applicationinsights.ApplicationInsightsManagementClient`'s + :attr:`workbooks` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApplicationInsightsManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_subscription( + self, + category: Union[str, _models.CategoryType], + tags: Optional[List[str]] = None, + can_fetch_content: Optional[bool] = None, + **kwargs: Any + ) -> ItemPaged["_models.Workbook"]: + """Get all Workbooks defined within a specified subscription and category. + + :param category: Category of workbook to return. Known values are: "workbook", "TSG", + "performance", and "retention". Required. + :type category: str or ~azure.mgmt.applicationinsights.models.CategoryType + :param tags: Tags presents on each workbook returned. Default value is None. + :type tags: list[str] + :param can_fetch_content: Flag indicating whether or not to return the full content for each + applicable workbook. If false, only return summary content for workbooks. Default value is + None. + :type can_fetch_content: bool + :return: An iterator like instance of either Workbook or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.models.Workbook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01")) + cls: ClsType[_models.WorkbooksListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + category=category, + tags=tags, + can_fetch_content=can_fetch_content, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("WorkbooksListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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.WorkbookError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + category: Union[str, _models.CategoryType], + tags: Optional[List[str]] = None, + source_id: Optional[str] = None, + can_fetch_content: Optional[bool] = None, + **kwargs: Any + ) -> ItemPaged["_models.Workbook"]: + """Get all Workbooks defined within a specified resource group and category. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param category: Category of workbook to return. Known values are: "workbook", "TSG", + "performance", and "retention". Required. + :type category: str or ~azure.mgmt.applicationinsights.models.CategoryType + :param tags: Tags presents on each workbook returned. Default value is None. + :type tags: list[str] + :param source_id: Azure Resource Id that will fetch all linked workbooks. Default value is + None. + :type source_id: str + :param can_fetch_content: Flag indicating whether or not to return the full content for each + applicable workbook. If false, only return summary content for workbooks. Default value is + None. + :type can_fetch_content: bool + :return: An iterator like instance of either Workbook or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.models.Workbook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01")) + cls: ClsType[_models.WorkbooksListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + 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, + category=category, + tags=tags, + source_id=source_id, + can_fetch_content=can_fetch_content, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("WorkbooksListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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.WorkbookError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, resource_group_name: str, resource_name: str, can_fetch_content: Optional[bool] = None, **kwargs: Any + ) -> _models.Workbook: + """Get a single workbook by its resourceName. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the workbook resource. The value must be an UUID. Required. + :type resource_name: str + :param can_fetch_content: Flag indicating whether or not to return the full content for each + applicable workbook. If false, only return summary content for workbooks. Default value is + None. + :type can_fetch_content: bool + :return: Workbook or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.Workbook + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01")) + cls: ClsType[_models.Workbook] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + can_fetch_content=can_fetch_content, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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.WorkbookError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Workbook", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> None: + """Delete a workbook. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the workbook resource. The value must be an UUID. Required. + :type resource_name: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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.WorkbookError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + resource_name: str, + workbook_properties: _models.Workbook, + source_id: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Workbook: + """Create a new workbook. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the workbook resource. The value must be an UUID. Required. + :type resource_name: str + :param workbook_properties: Properties that need to be specified to create a new workbook. + Required. + :type workbook_properties: ~azure.mgmt.applicationinsights.models.Workbook + :param source_id: Azure Resource Id that will fetch all linked workbooks. Default value is + None. + :type source_id: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Workbook or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.Workbook + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + resource_name: str, + workbook_properties: IO[bytes], + source_id: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Workbook: + """Create a new workbook. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the workbook resource. The value must be an UUID. Required. + :type resource_name: str + :param workbook_properties: Properties that need to be specified to create a new workbook. + Required. + :type workbook_properties: IO[bytes] + :param source_id: Azure Resource Id that will fetch all linked workbooks. Default value is + None. + :type source_id: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: Workbook or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.Workbook + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + resource_name: str, + workbook_properties: Union[_models.Workbook, IO[bytes]], + source_id: Optional[str] = None, + **kwargs: Any + ) -> _models.Workbook: + """Create a new workbook. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the workbook resource. The value must be an UUID. Required. + :type resource_name: str + :param workbook_properties: Properties that need to be specified to create a new workbook. Is + either a Workbook type or a IO[bytes] type. Required. + :type workbook_properties: ~azure.mgmt.applicationinsights.models.Workbook or IO[bytes] + :param source_id: Azure Resource Id that will fetch all linked workbooks. Default value is + None. + :type source_id: str + :return: Workbook or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.Workbook + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Workbook] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(workbook_properties, (IOBase, bytes)): + _content = workbook_properties + else: + _json = self._serialize.body(workbook_properties, "Workbook") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + source_id=source_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Workbook", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_group_name: str, + resource_name: str, + source_id: Optional[str] = None, + workbook_update_parameters: Optional[_models.WorkbookUpdateParameters] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Workbook: + """Updates a workbook that has already been added. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the workbook resource. The value must be an UUID. Required. + :type resource_name: str + :param source_id: Azure Resource Id that will fetch all linked workbooks. Default value is + None. + :type source_id: str + :param workbook_update_parameters: Properties that need to be specified to create a new + workbook. Default value is None. + :type workbook_update_parameters: + ~azure.mgmt.applicationinsights.models.WorkbookUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Workbook or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.Workbook + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + resource_name: str, + source_id: Optional[str] = None, + workbook_update_parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Workbook: + """Updates a workbook that has already been added. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the workbook resource. The value must be an UUID. Required. + :type resource_name: str + :param source_id: Azure Resource Id that will fetch all linked workbooks. Default value is + None. + :type source_id: str + :param workbook_update_parameters: Properties that need to be specified to create a new + workbook. Default value is None. + :type workbook_update_parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: Workbook or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.Workbook + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + resource_name: str, + source_id: Optional[str] = None, + workbook_update_parameters: Optional[Union[_models.WorkbookUpdateParameters, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.Workbook: + """Updates a workbook that has already been added. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the workbook resource. The value must be an UUID. Required. + :type resource_name: str + :param source_id: Azure Resource Id that will fetch all linked workbooks. Default value is + None. + :type source_id: str + :param workbook_update_parameters: Properties that need to be specified to create a new + workbook. Is either a WorkbookUpdateParameters type or a IO[bytes] type. Default value is None. + :type workbook_update_parameters: + ~azure.mgmt.applicationinsights.models.WorkbookUpdateParameters or IO[bytes] + :return: Workbook or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.Workbook + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Workbook] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(workbook_update_parameters, (IOBase, bytes)): + _content = workbook_update_parameters + else: + if workbook_update_parameters is not None: + _json = self._serialize.body(workbook_update_parameters, "WorkbookUpdateParameters") + else: + _json = None + + _request = build_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + source_id=source_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.WorkbookError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Workbook", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def revisions_list( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> ItemPaged["_models.Workbook"]: + """Get the revisions for the workbook defined by its resourceName. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the workbook resource. The value must be an UUID. Required. + :type resource_name: str + :return: An iterator like instance of either Workbook or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.applicationinsights.models.Workbook] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01")) + cls: ClsType[_models.WorkbooksListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_revisions_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("WorkbooksListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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.WorkbookError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def revision_get( + self, resource_group_name: str, resource_name: str, revision_id: str, **kwargs: Any + ) -> _models.Workbook: + """Get a single workbook revision defined by its revisionId. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The name of the workbook resource. The value must be an UUID. Required. + :type resource_name: str + :param revision_id: The id of the workbook's revision. Required. + :type revision_id: str + :return: Workbook or the result of cls(response) + :rtype: ~azure.mgmt.applicationinsights.models.Workbook + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01")) + cls: ClsType[_models.Workbook] = kwargs.pop("cls", None) + + _request = build_revision_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + revision_id=revision_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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.WorkbookError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Workbook", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/src/spring/azext_spring/vendored_sdks/applicationinsights/py.typed b/src/spring/azext_spring/vendored_sdks/applicationinsights/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/src/spring/azext_spring/vendored_sdks/applicationinsights/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file