Skip to content

Commit 50104bd

Browse files
author
SDKAuto
committed
CodeGen from PR 33449 in Azure/azure-rest-api-specs
Merge a7da4e66908908f0c6203d58990711e34c056069 into e0ef299f475a972c2856175014bf4f1e9873dda0
1 parent 7656cf2 commit 50104bd

File tree

92 files changed

+9678
-2046
lines changed

Some content is hidden

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

92 files changed

+9678
-2046
lines changed
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.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.
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"commit": "e37a57df67daaa82f9c3758fc450bc8655812a08",
2+
"commit": "d60259e0cb76b27d45a16dcee4a7a280c083d640",
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

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: 48 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,33 @@
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,
2024
AlertsOperations,
25+
IssueOperations,
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: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes
3236
"""AlertsManagement Client.
3337
34-
:ivar alert_processing_rules: AlertProcessingRulesOperations operations
35-
:vartype alert_processing_rules:
36-
azure.mgmt.alertsmanagement.operations.AlertProcessingRulesOperations
3738
:ivar prometheus_rule_groups: PrometheusRuleGroupsOperations operations
3839
:vartype prometheus_rule_groups:
3940
azure.mgmt.alertsmanagement.operations.PrometheusRuleGroupsOperations
@@ -43,8 +44,18 @@ class AlertsManagementClient: # pylint: disable=client-accepts-api-version-keyw
4344
:vartype alerts: azure.mgmt.alertsmanagement.operations.AlertsOperations
4445
:ivar smart_groups: SmartGroupsOperations operations
4546
:vartype smart_groups: azure.mgmt.alertsmanagement.operations.SmartGroupsOperations
47+
:ivar alert_rule_recommendations: AlertRuleRecommendationsOperations operations
48+
:vartype alert_rule_recommendations:
49+
azure.mgmt.alertsmanagement.operations.AlertRuleRecommendationsOperations
50+
:ivar alert_processing_rules: AlertProcessingRulesOperations operations
51+
:vartype alert_processing_rules:
52+
azure.mgmt.alertsmanagement.operations.AlertProcessingRulesOperations
53+
:ivar issue: IssueOperations operations
54+
:vartype issue: azure.mgmt.alertsmanagement.operations.IssueOperations
4655
:param credential: Credential needed for the client to connect to Azure. Required.
4756
:type credential: ~azure.core.credentials.TokenCredential
57+
:param issue_name: The name of the IssueResource. Required.
58+
:type issue_name: str
4859
:param subscription_id: The ID of the target subscription. Required.
4960
:type subscription_id: str
5061
:param base_url: Service URL. Default value is "https://management.azure.com".
@@ -54,30 +65,53 @@ class AlertsManagementClient: # pylint: disable=client-accepts-api-version-keyw
5465
def __init__(
5566
self,
5667
credential: "TokenCredential",
68+
issue_name: str,
5769
subscription_id: str,
5870
base_url: str = "https://management.azure.com",
5971
**kwargs: Any
6072
) -> None:
6173
self._config = AlertsManagementClientConfiguration(
62-
credential=credential, subscription_id=subscription_id, **kwargs
74+
credential=credential, issue_name=issue_name, subscription_id=subscription_id, **kwargs
6375
)
64-
self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs)
76+
_policies = kwargs.pop("policies", None)
77+
if _policies is None:
78+
_policies = [
79+
policies.RequestIdPolicy(**kwargs),
80+
self._config.headers_policy,
81+
self._config.user_agent_policy,
82+
self._config.proxy_policy,
83+
policies.ContentDecodePolicy(**kwargs),
84+
ARMAutoResourceProviderRegistrationPolicy(),
85+
self._config.redirect_policy,
86+
self._config.retry_policy,
87+
self._config.authentication_policy,
88+
self._config.custom_hook_policy,
89+
self._config.logging_policy,
90+
policies.DistributedTracingPolicy(**kwargs),
91+
policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None,
92+
self._config.http_logging_policy,
93+
]
94+
self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs)
6595

6696
client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)}
6797
self._serialize = Serializer(client_models)
6898
self._deserialize = Deserializer(client_models)
6999
self._serialize.client_side_validation = False
70-
self.alert_processing_rules = AlertProcessingRulesOperations(
71-
self._client, self._config, self._serialize, self._deserialize
72-
)
73100
self.prometheus_rule_groups = PrometheusRuleGroupsOperations(
74101
self._client, self._config, self._serialize, self._deserialize
75102
)
76103
self.operations = Operations(self._client, self._config, self._serialize, self._deserialize)
77104
self.alerts = AlertsOperations(self._client, self._config, self._serialize, self._deserialize)
78105
self.smart_groups = SmartGroupsOperations(self._client, self._config, self._serialize, self._deserialize)
106+
self.alert_rule_recommendations = AlertRuleRecommendationsOperations(
107+
self._client, self._config, self._serialize, self._deserialize
108+
)
109+
self.alert_processing_rules = AlertProcessingRulesOperations(
110+
self._client, self._config, self._serialize, self._deserialize
111+
)
112+
self.issue = IssueOperations(self._client, self._config, self._serialize, self._deserialize)
79113

80-
def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
114+
def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
81115
"""Runs the network request through the client's chained policies.
82116
83117
>>> from azure.core.rest import HttpRequest
@@ -97,14 +131,14 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
97131

98132
request_copy = deepcopy(request)
99133
request_copy.url = self._client.format_url(request_copy.url)
100-
return self._client.send_request(request_copy, **kwargs)
134+
return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore
101135

102136
def close(self) -> None:
103137
self._client.close()
104138

105-
def __enter__(self) -> "AlertsManagementClient":
139+
def __enter__(self) -> Self:
106140
self._client.__enter__()
107141
return self
108142

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

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,40 +8,43 @@
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
2624
attributes.
2725
2826
:param credential: Credential needed for the client to connect to Azure. Required.
2927
:type credential: ~azure.core.credentials.TokenCredential
28+
:param issue_name: The name of the IssueResource. Required.
29+
:type issue_name: str
3030
:param subscription_id: The ID of the target subscription. Required.
3131
:type subscription_id: str
3232
"""
3333

34-
def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None:
35-
super(AlertsManagementClientConfiguration, self).__init__(**kwargs)
34+
def __init__(self, credential: "TokenCredential", issue_name: str, subscription_id: str, **kwargs: Any) -> None:
3635
if credential is None:
3736
raise ValueError("Parameter 'credential' must not be None.")
37+
if issue_name is None:
38+
raise ValueError("Parameter 'issue_name' must not be None.")
3839
if subscription_id is None:
3940
raise ValueError("Parameter 'subscription_id' must not be None.")
4041

4142
self.credential = credential
43+
self.issue_name = issue_name
4244
self.subscription_id = subscription_id
4345
self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"])
4446
kwargs.setdefault("sdk_moniker", "mgmt-alertsmanagement/{}".format(VERSION))
47+
self.polling_interval = kwargs.get("polling_interval", 30)
4548
self._configure(**kwargs)
4649

4750
def _configure(self, **kwargs: Any) -> None:
@@ -50,9 +53,9 @@ def _configure(self, **kwargs: Any) -> None:
5053
self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
5154
self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs)
5255
self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs)
53-
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
5456
self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs)
5557
self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs)
58+
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
5659
self.authentication_policy = kwargs.get("authentication_policy")
5760
if self.credential and not self.authentication_policy:
5861
self.authentication_policy = ARMChallengeAuthenticationPolicy(

0 commit comments

Comments
 (0)