Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/spring/HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
Release History
===============
1.28.5
---
* Update Application Insight SDK.

1.28.4
---
* Fix regression issue caused by the SDK change.
Expand Down
2 changes: 1 addition & 1 deletion src/spring/azext_spring/apm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/spring/azext_spring/buildpack_binding.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 2 additions & 3 deletions src/spring/azext_spring/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1589,8 +1589,7 @@ def try_create_application_insights(cmd, resource_group, name, location):
logger.warning(APP_INSIGHTS_CREATION_FAILURE_WARNING)
return None

app_insights_client = get_mgmt_service_client(cmd.cli_ctx, ApplicationInsightsManagementClient,
api_version='2020-02-02-preview')
app_insights_client = get_mgmt_service_client(cmd.cli_ctx, ApplicationInsightsManagementClient)
ai_properties = {
"location": location,
"kind": "web",
Expand Down
Original file line number Diff line number Diff line change
@@ -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()
Original file line number Diff line number Diff line change
@@ -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/")
<HttpRequest [GET], url: 'https://www.example.org/'>
>>> response = client._send_request(request)
<HttpResponse: 200 OK>

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)
Original file line number Diff line number Diff line change
@@ -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
)
Original file line number Diff line number Diff line change
@@ -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
"""
Original file line number Diff line number Diff line change
@@ -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.
# --------------------------------------------------------------------------
Loading
Loading