Skip to content

Commit 5f7536b

Browse files
author
SDKAuto
committed
CodeGen from PR 32650 in Azure/azure-rest-api-specs
Merge d61fba6ef132610f4395e2cffc9427d3049650d5 into d77a060fb0e738586212fe393cf5215fd90d097c
1 parent db582b1 commit 5f7536b

File tree

83 files changed

+6460
-2006
lines changed

Some content is hidden

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

83 files changed

+6460
-2006
lines changed
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.8+.
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.8+ 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 configure of 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.
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"commit": "e37a57df67daaa82f9c3758fc450bc8655812a08",
2+
"commit": "80888c83384e5d38a47dbc282ca9c9d67d2aa30f",
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.27.4",
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.27.4 --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

+9-3
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

+43-13
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,35 @@
88

99
from copy import deepcopy
1010
from typing import Any, TYPE_CHECKING
11+
from typing_extensions import Self
1112

13+
from azure.core.pipeline import policies
1214
from azure.core.rest import HttpRequest, HttpResponse
1315
from azure.mgmt.core import ARMPipelineClient
16+
from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy
1417

1518
from . import models as _models
1619
from ._configuration import AlertsManagementClientConfiguration
1720
from ._serialization import Deserializer, Serializer
1821
from .operations import (
1922
AlertProcessingRulesOperations,
23+
AlertRuleRecommendationsOperations,
24+
AlertsManagementClientOperationsMixin,
2025
AlertsOperations,
2126
Operations,
2227
PrometheusRuleGroupsOperations,
2328
SmartGroupsOperations,
2429
)
2530

2631
if TYPE_CHECKING:
27-
# pylint: disable=unused-import,ungrouped-imports
2832
from azure.core.credentials import TokenCredential
2933

3034

31-
class AlertsManagementClient: # pylint: disable=client-accepts-api-version-keyword
35+
class AlertsManagementClient(
36+
AlertsManagementClientOperationsMixin
37+
): # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes
3238
"""AlertsManagement Client.
3339
34-
:ivar alert_processing_rules: AlertProcessingRulesOperations operations
35-
:vartype alert_processing_rules:
36-
azure.mgmt.alertsmanagement.operations.AlertProcessingRulesOperations
3740
:ivar prometheus_rule_groups: PrometheusRuleGroupsOperations operations
3841
:vartype prometheus_rule_groups:
3942
azure.mgmt.alertsmanagement.operations.PrometheusRuleGroupsOperations
@@ -43,6 +46,12 @@ class AlertsManagementClient: # pylint: disable=client-accepts-api-version-keyw
4346
:vartype alerts: azure.mgmt.alertsmanagement.operations.AlertsOperations
4447
:ivar smart_groups: SmartGroupsOperations operations
4548
:vartype smart_groups: azure.mgmt.alertsmanagement.operations.SmartGroupsOperations
49+
:ivar alert_rule_recommendations: AlertRuleRecommendationsOperations operations
50+
:vartype alert_rule_recommendations:
51+
azure.mgmt.alertsmanagement.operations.AlertRuleRecommendationsOperations
52+
:ivar alert_processing_rules: AlertProcessingRulesOperations operations
53+
:vartype alert_processing_rules:
54+
azure.mgmt.alertsmanagement.operations.AlertProcessingRulesOperations
4655
:param credential: Credential needed for the client to connect to Azure. Required.
4756
:type credential: ~azure.core.credentials.TokenCredential
4857
:param subscription_id: The ID of the target subscription. Required.
@@ -61,23 +70,44 @@ def __init__(
6170
self._config = AlertsManagementClientConfiguration(
6271
credential=credential, subscription_id=subscription_id, **kwargs
6372
)
64-
self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs)
73+
_policies = kwargs.pop("policies", None)
74+
if _policies is None:
75+
_policies = [
76+
policies.RequestIdPolicy(**kwargs),
77+
self._config.headers_policy,
78+
self._config.user_agent_policy,
79+
self._config.proxy_policy,
80+
policies.ContentDecodePolicy(**kwargs),
81+
ARMAutoResourceProviderRegistrationPolicy(),
82+
self._config.redirect_policy,
83+
self._config.retry_policy,
84+
self._config.authentication_policy,
85+
self._config.custom_hook_policy,
86+
self._config.logging_policy,
87+
policies.DistributedTracingPolicy(**kwargs),
88+
policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None,
89+
self._config.http_logging_policy,
90+
]
91+
self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs)
6592

6693
client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)}
6794
self._serialize = Serializer(client_models)
6895
self._deserialize = Deserializer(client_models)
6996
self._serialize.client_side_validation = False
70-
self.alert_processing_rules = AlertProcessingRulesOperations(
71-
self._client, self._config, self._serialize, self._deserialize
72-
)
7397
self.prometheus_rule_groups = PrometheusRuleGroupsOperations(
7498
self._client, self._config, self._serialize, self._deserialize
7599
)
76100
self.operations = Operations(self._client, self._config, self._serialize, self._deserialize)
77101
self.alerts = AlertsOperations(self._client, self._config, self._serialize, self._deserialize)
78102
self.smart_groups = SmartGroupsOperations(self._client, self._config, self._serialize, self._deserialize)
103+
self.alert_rule_recommendations = AlertRuleRecommendationsOperations(
104+
self._client, self._config, self._serialize, self._deserialize
105+
)
106+
self.alert_processing_rules = AlertProcessingRulesOperations(
107+
self._client, self._config, self._serialize, self._deserialize
108+
)
79109

80-
def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
110+
def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
81111
"""Runs the network request through the client's chained policies.
82112
83113
>>> from azure.core.rest import HttpRequest
@@ -97,14 +127,14 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
97127

98128
request_copy = deepcopy(request)
99129
request_copy.url = self._client.format_url(request_copy.url)
100-
return self._client.send_request(request_copy, **kwargs)
130+
return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore
101131

102132
def close(self) -> None:
103133
self._client.close()
104134

105-
def __enter__(self) -> "AlertsManagementClient":
135+
def __enter__(self) -> Self:
106136
self._client.__enter__()
107137
return self
108138

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

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

+3-5
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)