Skip to content

Commit 289c547

Browse files
author
SDKAuto
committed
CodeGen from PR 33988 in Azure/azure-rest-api-specs
Merge f5e13c30c10989d1081f6f1ec22fee85bd444bef into 5b798125a6aa7d5152fe0e3dd595d8a76dcfa568
1 parent acc0d4a commit 289c547

File tree

78 files changed

+5037
-2168
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+5037
-2168
lines changed

sdk/alertsmanagement/azure-mgmt-alertsmanagement/CHANGELOG.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,56 @@
11
# Release History
22

3+
## 2.0.0b3 (2025-04-21)
4+
5+
### Features Added
6+
7+
- Client `AlertsManagementClient` added operation group `alert_rule_recommendations`
8+
- Model `Essentials` added property `has_enrichments`
9+
- Model `Essentials` added property `is_stateful_alert`
10+
- Model `Essentials` added property `correlation_details`
11+
- Enum `MonitorService` added member `RESOURCE_HEALTH`
12+
- Model `Resource` added property `system_data`
13+
- Added model `AlertEnrichmentItem`
14+
- Added model `AlertEnrichmentProperties`
15+
- Added model `AlertEnrichmentResponse`
16+
- Added model `AlertEnrichmentsList`
17+
- Added model `AlertRuleRecommendationResource`
18+
- Added model `AlertRuleRecommendationsListResponse`
19+
- Added model `CorrelationDetails`
20+
- Added model `ErrorDetailAutoGenerated`
21+
- Added model `ErrorResponseAutoGenerated4`
22+
- Added enum `MetricAlertsDisplayUnit`
23+
- Added model `PrometheusEnrichmentItem`
24+
- Added model `PrometheusInstantQuery`
25+
- Added model `PrometheusRangeQuery`
26+
- Added model `PrometheusRuleGroupResourcePatchParameters`
27+
- Added model `ProxyResource`
28+
- Added model `ResourceAutoGenerated2`
29+
- Added model `RuleArmTemplate`
30+
- Added enum `Status`
31+
- Added enum `Type`
32+
- Model `AlertsOperations` added method `get_enrichments`
33+
- Model `AlertsOperations` added method `list_enrichments`
34+
- Added model `AlertRuleRecommendationsOperations`
35+
- Method `AlertProcessingRulesOperations.create_or_update` has a new overload `def create_or_update(self: None, resource_group_name: str, alert_processing_rule_name: str, alert_processing_rule: IO[bytes], content_type: str)`
36+
- Method `AlertProcessingRulesOperations.update` has a new overload `def update(self: None, resource_group_name: str, alert_processing_rule_name: str, alert_processing_rule_patch: IO[bytes], content_type: str)`
37+
- Method `AlertsOperations.change_state` has a new overload `def change_state(self: None, scope: str, alert_id: str, new_state: Union[str, AlertState], comment: Optional[Comments], content_type: str)`
38+
- Method `AlertsOperations.change_state` has a new overload `def change_state(self: None, scope: str, alert_id: str, new_state: Union[str, AlertState], comment: Optional[IO[bytes]], content_type: str)`
39+
- Method `PrometheusRuleGroupsOperations.create_or_update` has a new overload `def create_or_update(self: None, resource_group_name: str, rule_group_name: str, parameters: IO[bytes], content_type: str)`
40+
- Method `PrometheusRuleGroupsOperations.update` has a new overload `def update(self: None, resource_group_name: str, rule_group_name: str, parameters: PrometheusRuleGroupResourcePatchParameters, content_type: str)`
41+
- Method `PrometheusRuleGroupsOperations.update` has a new overload `def update(self: None, resource_group_name: str, rule_group_name: str, parameters: IO[bytes], content_type: str)`
42+
43+
### Breaking Changes
44+
45+
- Model `ResourceAutoGenerated` deleted or renamed its instance variable `system_data`
46+
- Deleted or renamed model `PrometheusRuleGroupResourcePatch`
47+
- Deleted or renamed model `PrometheusRuleGroupResourcePatchProperties`
48+
- Method `AlertsOperations.change_state` inserted a `positional_or_keyword` parameter `scope`
49+
- Method `AlertsOperations.get_all` inserted a `positional_or_keyword` parameter `scope`
50+
- Method `AlertsOperations.get_by_id` inserted a `positional_or_keyword` parameter `scope`
51+
- Method `AlertsOperations.get_history` inserted a `positional_or_keyword` parameter `scope`
52+
- Method `AlertsOperations.get_summary` inserted a `positional_or_keyword` parameter `scope`
53+
354
## 2.0.0b2 (2022-12-26)
455

556
### Features Added
Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,61 @@
11
# Microsoft Azure SDK for Python
22

33
This is the Microsoft Azure Alerts Management Client Library.
4-
This package has been tested with Python 3.7+.
4+
This package has been tested with Python 3.9+.
55
For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all).
66

77
## _Disclaimer_
88

99
_Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For more information and questions, please refer to https://github.com/Azure/azure-sdk-for-python/issues/20691_
1010

11-
# Usage
11+
## Getting started
1212

13+
### Prerequisites
1314

14-
To learn how to use this package, see the [quickstart guide](https://aka.ms/azsdk/python/mgmt)
15-
16-
For docs and references, see [Python SDK References](https://docs.microsoft.com/python/api/overview/azure/)
17-
Code samples for this package can be found at [Alerts Management](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com.
18-
Additional code samples for different Azure services are available at [Samples Repo](https://aka.ms/azsdk/python/mgmt/samples)
15+
- Python 3.9+ is required to use this package.
16+
- [Azure subscription](https://azure.microsoft.com/free/)
1917

18+
### Install the package
2019

21-
# Provide Feedback
20+
```bash
21+
pip install azure-mgmt-alertsmanagement
22+
pip install azure-identity
23+
```
2224

23-
If you encounter any bugs or have suggestions, please file an issue in the
24-
[Issues](https://github.com/Azure/azure-sdk-for-python/issues)
25-
section of the project.
25+
### Authentication
26+
27+
By default, [Azure Active Directory](https://aka.ms/awps/aad) token authentication depends on correct configuration of the following environment variables.
28+
29+
- `AZURE_CLIENT_ID` for Azure client ID.
30+
- `AZURE_TENANT_ID` for Azure tenant ID.
31+
- `AZURE_CLIENT_SECRET` for Azure client secret.
32+
33+
In addition, Azure subscription ID can be configured via environment variable `AZURE_SUBSCRIPTION_ID`.
34+
35+
With above configuration, client can be authenticated by following code:
36+
37+
```python
38+
from azure.identity import DefaultAzureCredential
39+
from azure.mgmt.alertsmanagement import AlertsManagementClient
40+
import os
2641

42+
sub_id = os.getenv("AZURE_SUBSCRIPTION_ID")
43+
client = AlertsManagementClient(credential=DefaultAzureCredential(), subscription_id=sub_id)
44+
```
2745

46+
## Examples
2847

48+
Code samples for this package can be found at:
49+
- [Search Alerts Management](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com
50+
- [Azure Python Mgmt SDK Samples Repo](https://aka.ms/azsdk/python/mgmt/samples)
51+
52+
53+
## Troubleshooting
54+
55+
## Next steps
56+
57+
## Provide Feedback
58+
59+
If you encounter any bugs or have suggestions, please file an issue in the
60+
[Issues](https://github.com/Azure/azure-sdk-for-python/issues)
61+
section of the project.
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"commit": "e37a57df67daaa82f9c3758fc450bc8655812a08",
2+
"commit": "e18a444f27b006d9f2afa23af78e3191f74e1579",
33
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
4-
"autorest": "3.9.2",
4+
"autorest": "3.10.2",
55
"use": [
6-
"@autorest/python@6.2.7",
7-
"@autorest/modelerfour@4.24.3"
6+
"@autorest/python@6.33.0",
7+
"@autorest/modelerfour@4.27.0"
88
],
9-
"autorest_command": "autorest specification/alertsmanagement/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.2.7 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False",
9+
"autorest_command": "autorest specification/alertsmanagement/resource-manager/readme.md --generate-sample=True --generate-test=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.33.0 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False",
1010
"readme": "specification/alertsmanagement/resource-manager/readme.md"
1111
}

sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/__init__.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,28 @@
55
# Code generated by Microsoft (R) AutoRest Code Generator.
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
8+
# pylint: disable=wrong-import-position
89

9-
from ._alerts_management_client import AlertsManagementClient
10+
from typing import TYPE_CHECKING
11+
12+
if TYPE_CHECKING:
13+
from ._patch import * # pylint: disable=unused-wildcard-import
14+
15+
from ._alerts_management_client import AlertsManagementClient # type: ignore
1016
from ._version import VERSION
1117

1218
__version__ = VERSION
1319

1420
try:
1521
from ._patch import __all__ as _patch_all
16-
from ._patch import * # pylint: disable=unused-wildcard-import
22+
from ._patch import *
1723
except ImportError:
1824
_patch_all = []
1925
from ._patch import patch_sdk as _patch_sdk
2026

2127
__all__ = [
2228
"AlertsManagementClient",
2329
]
24-
__all__.extend([p for p in _patch_all if p not in __all__])
30+
__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore
2531

2632
_patch_sdk()

sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/_alerts_management_client.py

Lines changed: 51 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,35 @@
77
# --------------------------------------------------------------------------
88

99
from copy import deepcopy
10-
from typing import Any, TYPE_CHECKING
10+
from typing import Any, Optional, TYPE_CHECKING, cast
11+
from typing_extensions import Self
1112

13+
from azure.core.pipeline import policies
1214
from azure.core.rest import HttpRequest, HttpResponse
15+
from azure.core.settings import settings
1316
from azure.mgmt.core import ARMPipelineClient
17+
from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy
18+
from azure.mgmt.core.tools import get_arm_endpoints
1419

1520
from . import models as _models
1621
from ._configuration import AlertsManagementClientConfiguration
1722
from ._serialization import Deserializer, Serializer
1823
from .operations import (
1924
AlertProcessingRulesOperations,
25+
AlertRuleRecommendationsOperations,
2026
AlertsOperations,
2127
Operations,
2228
PrometheusRuleGroupsOperations,
2329
SmartGroupsOperations,
2430
)
2531

2632
if TYPE_CHECKING:
27-
# pylint: disable=unused-import,ungrouped-imports
2833
from azure.core.credentials import TokenCredential
2934

3035

3136
class AlertsManagementClient: # pylint: disable=client-accepts-api-version-keyword
3237
"""AlertsManagement Client.
3338
34-
:ivar alert_processing_rules: AlertProcessingRulesOperations operations
35-
:vartype alert_processing_rules:
36-
azure.mgmt.alertsmanagement.operations.AlertProcessingRulesOperations
3739
:ivar prometheus_rule_groups: PrometheusRuleGroupsOperations operations
3840
:vartype prometheus_rule_groups:
3941
azure.mgmt.alertsmanagement.operations.PrometheusRuleGroupsOperations
@@ -43,41 +45,70 @@ class AlertsManagementClient: # pylint: disable=client-accepts-api-version-keyw
4345
:vartype alerts: azure.mgmt.alertsmanagement.operations.AlertsOperations
4446
:ivar smart_groups: SmartGroupsOperations operations
4547
:vartype smart_groups: azure.mgmt.alertsmanagement.operations.SmartGroupsOperations
48+
:ivar alert_rule_recommendations: AlertRuleRecommendationsOperations operations
49+
:vartype alert_rule_recommendations:
50+
azure.mgmt.alertsmanagement.operations.AlertRuleRecommendationsOperations
51+
:ivar alert_processing_rules: AlertProcessingRulesOperations operations
52+
:vartype alert_processing_rules:
53+
azure.mgmt.alertsmanagement.operations.AlertProcessingRulesOperations
4654
:param credential: Credential needed for the client to connect to Azure. Required.
4755
:type credential: ~azure.core.credentials.TokenCredential
4856
:param subscription_id: The ID of the target subscription. Required.
4957
:type subscription_id: str
50-
:param base_url: Service URL. Default value is "https://management.azure.com".
58+
:param base_url: Service URL. Default value is None.
5159
:type base_url: str
5260
"""
5361

5462
def __init__(
55-
self,
56-
credential: "TokenCredential",
57-
subscription_id: str,
58-
base_url: str = "https://management.azure.com",
59-
**kwargs: Any
63+
self, credential: "TokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any
6064
) -> None:
65+
_cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore
66+
_endpoints = get_arm_endpoints(_cloud)
67+
if not base_url:
68+
base_url = _endpoints["resource_manager"]
69+
credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"])
6170
self._config = AlertsManagementClientConfiguration(
62-
credential=credential, subscription_id=subscription_id, **kwargs
71+
credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs
6372
)
64-
self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs)
73+
74+
_policies = kwargs.pop("policies", None)
75+
if _policies is None:
76+
_policies = [
77+
policies.RequestIdPolicy(**kwargs),
78+
self._config.headers_policy,
79+
self._config.user_agent_policy,
80+
self._config.proxy_policy,
81+
policies.ContentDecodePolicy(**kwargs),
82+
ARMAutoResourceProviderRegistrationPolicy(),
83+
self._config.redirect_policy,
84+
self._config.retry_policy,
85+
self._config.authentication_policy,
86+
self._config.custom_hook_policy,
87+
self._config.logging_policy,
88+
policies.DistributedTracingPolicy(**kwargs),
89+
policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None,
90+
self._config.http_logging_policy,
91+
]
92+
self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, base_url), policies=_policies, **kwargs)
6593

6694
client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)}
6795
self._serialize = Serializer(client_models)
6896
self._deserialize = Deserializer(client_models)
6997
self._serialize.client_side_validation = False
70-
self.alert_processing_rules = AlertProcessingRulesOperations(
71-
self._client, self._config, self._serialize, self._deserialize
72-
)
7398
self.prometheus_rule_groups = PrometheusRuleGroupsOperations(
7499
self._client, self._config, self._serialize, self._deserialize
75100
)
76101
self.operations = Operations(self._client, self._config, self._serialize, self._deserialize)
77102
self.alerts = AlertsOperations(self._client, self._config, self._serialize, self._deserialize)
78103
self.smart_groups = SmartGroupsOperations(self._client, self._config, self._serialize, self._deserialize)
104+
self.alert_rule_recommendations = AlertRuleRecommendationsOperations(
105+
self._client, self._config, self._serialize, self._deserialize
106+
)
107+
self.alert_processing_rules = AlertProcessingRulesOperations(
108+
self._client, self._config, self._serialize, self._deserialize
109+
)
79110

80-
def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
111+
def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
81112
"""Runs the network request through the client's chained policies.
82113
83114
>>> from azure.core.rest import HttpRequest
@@ -97,14 +128,14 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
97128

98129
request_copy = deepcopy(request)
99130
request_copy.url = self._client.format_url(request_copy.url)
100-
return self._client.send_request(request_copy, **kwargs)
131+
return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore
101132

102133
def close(self) -> None:
103134
self._client.close()
104135

105-
def __enter__(self) -> "AlertsManagementClient":
136+
def __enter__(self) -> Self:
106137
self._client.__enter__()
107138
return self
108139

109-
def __exit__(self, *exc_details) -> None:
140+
def __exit__(self, *exc_details: Any) -> None:
110141
self._client.__exit__(*exc_details)

sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/_configuration.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,16 @@
88

99
from typing import Any, TYPE_CHECKING
1010

11-
from azure.core.configuration import Configuration
1211
from azure.core.pipeline import policies
1312
from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy
1413

1514
from ._version import VERSION
1615

1716
if TYPE_CHECKING:
18-
# pylint: disable=unused-import,ungrouped-imports
1917
from azure.core.credentials import TokenCredential
2018

2119

22-
class AlertsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes
20+
class AlertsManagementClientConfiguration: # pylint: disable=too-many-instance-attributes
2321
"""Configuration for AlertsManagementClient.
2422
2523
Note that all parameters used to create this instance are saved as instance
@@ -32,7 +30,6 @@ class AlertsManagementClientConfiguration(Configuration): # pylint: disable=too
3230
"""
3331

3432
def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None:
35-
super(AlertsManagementClientConfiguration, self).__init__(**kwargs)
3633
if credential is None:
3734
raise ValueError("Parameter 'credential' must not be None.")
3835
if subscription_id is None:
@@ -42,6 +39,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs
4239
self.subscription_id = subscription_id
4340
self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"])
4441
kwargs.setdefault("sdk_moniker", "mgmt-alertsmanagement/{}".format(VERSION))
42+
self.polling_interval = kwargs.get("polling_interval", 30)
4543
self._configure(**kwargs)
4644

4745
def _configure(self, **kwargs: Any) -> None:
@@ -50,9 +48,9 @@ def _configure(self, **kwargs: Any) -> None:
5048
self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
5149
self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs)
5250
self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs)
53-
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
5451
self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs)
5552
self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs)
53+
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
5654
self.authentication_policy = kwargs.get("authentication_policy")
5755
if self.credential and not self.authentication_policy:
5856
self.authentication_policy = ARMChallengeAuthenticationPolicy(

0 commit comments

Comments
 (0)