Skip to content

Commit 106234a

Browse files
author
SDKAuto
committed
CodeGen from PR 33428 in Azure/azure-rest-api-specs
Merge 8dd9cfbec0d103448b6a4c4f10f28214a936b523 into 25524506300a020e51f5c95bc770aeb6f0c73f74
1 parent 7656cf2 commit 106234a

File tree

117 files changed

+15666
-2474
lines changed

Some content is hidden

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

117 files changed

+15666
-2474
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": "fd7c3d3350853543f90f76a68c01dd9f3fb9f345",
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: 71 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,36 @@
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,
26+
MigrateFromSmartDetectionOperations,
2127
Operations,
2228
PrometheusRuleGroupsOperations,
29+
SmartDetectorAlertRulesOperations,
2330
SmartGroupsOperations,
31+
TenantActivityLogAlertsOperations,
2432
)
2533

2634
if TYPE_CHECKING:
27-
# pylint: disable=unused-import,ungrouped-imports
2835
from azure.core.credentials import TokenCredential
2936

3037

31-
class AlertsManagementClient: # pylint: disable=client-accepts-api-version-keyword
38+
class AlertsManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes
3239
"""AlertsManagement Client.
3340
34-
:ivar alert_processing_rules: AlertProcessingRulesOperations operations
35-
:vartype alert_processing_rules:
36-
azure.mgmt.alertsmanagement.operations.AlertProcessingRulesOperations
3741
:ivar prometheus_rule_groups: PrometheusRuleGroupsOperations operations
3842
:vartype prometheus_rule_groups:
3943
azure.mgmt.alertsmanagement.operations.PrometheusRuleGroupsOperations
@@ -43,41 +47,94 @@ class AlertsManagementClient: # pylint: disable=client-accepts-api-version-keyw
4347
:vartype alerts: azure.mgmt.alertsmanagement.operations.AlertsOperations
4448
:ivar smart_groups: SmartGroupsOperations operations
4549
:vartype smart_groups: azure.mgmt.alertsmanagement.operations.SmartGroupsOperations
50+
:ivar alert_rule_recommendations: AlertRuleRecommendationsOperations operations
51+
:vartype alert_rule_recommendations:
52+
azure.mgmt.alertsmanagement.operations.AlertRuleRecommendationsOperations
53+
:ivar alert_processing_rules: AlertProcessingRulesOperations operations
54+
:vartype alert_processing_rules:
55+
azure.mgmt.alertsmanagement.operations.AlertProcessingRulesOperations
56+
:ivar smart_detector_alert_rules: SmartDetectorAlertRulesOperations operations
57+
:vartype smart_detector_alert_rules:
58+
azure.mgmt.alertsmanagement.operations.SmartDetectorAlertRulesOperations
59+
:ivar migrate_from_smart_detection: MigrateFromSmartDetectionOperations operations
60+
:vartype migrate_from_smart_detection:
61+
azure.mgmt.alertsmanagement.operations.MigrateFromSmartDetectionOperations
62+
:ivar tenant_activity_log_alerts: TenantActivityLogAlertsOperations operations
63+
:vartype tenant_activity_log_alerts:
64+
azure.mgmt.alertsmanagement.operations.TenantActivityLogAlertsOperations
65+
:ivar issue: IssueOperations operations
66+
:vartype issue: azure.mgmt.alertsmanagement.operations.IssueOperations
4667
:param credential: Credential needed for the client to connect to Azure. Required.
4768
:type credential: ~azure.core.credentials.TokenCredential
69+
:param issue_name: The name of the IssueResource. Required.
70+
:type issue_name: str
4871
:param subscription_id: The ID of the target subscription. Required.
4972
:type subscription_id: str
5073
:param base_url: Service URL. Default value is "https://management.azure.com".
5174
:type base_url: str
75+
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
76+
Retry-After header is present.
5277
"""
5378

5479
def __init__(
5580
self,
5681
credential: "TokenCredential",
82+
issue_name: str,
5783
subscription_id: str,
5884
base_url: str = "https://management.azure.com",
5985
**kwargs: Any
6086
) -> None:
6187
self._config = AlertsManagementClientConfiguration(
62-
credential=credential, subscription_id=subscription_id, **kwargs
88+
credential=credential, issue_name=issue_name, subscription_id=subscription_id, **kwargs
6389
)
64-
self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs)
90+
_policies = kwargs.pop("policies", None)
91+
if _policies is None:
92+
_policies = [
93+
policies.RequestIdPolicy(**kwargs),
94+
self._config.headers_policy,
95+
self._config.user_agent_policy,
96+
self._config.proxy_policy,
97+
policies.ContentDecodePolicy(**kwargs),
98+
ARMAutoResourceProviderRegistrationPolicy(),
99+
self._config.redirect_policy,
100+
self._config.retry_policy,
101+
self._config.authentication_policy,
102+
self._config.custom_hook_policy,
103+
self._config.logging_policy,
104+
policies.DistributedTracingPolicy(**kwargs),
105+
policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None,
106+
self._config.http_logging_policy,
107+
]
108+
self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs)
65109

66110
client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)}
67111
self._serialize = Serializer(client_models)
68112
self._deserialize = Deserializer(client_models)
69113
self._serialize.client_side_validation = False
70-
self.alert_processing_rules = AlertProcessingRulesOperations(
71-
self._client, self._config, self._serialize, self._deserialize
72-
)
73114
self.prometheus_rule_groups = PrometheusRuleGroupsOperations(
74115
self._client, self._config, self._serialize, self._deserialize
75116
)
76117
self.operations = Operations(self._client, self._config, self._serialize, self._deserialize)
77118
self.alerts = AlertsOperations(self._client, self._config, self._serialize, self._deserialize)
78119
self.smart_groups = SmartGroupsOperations(self._client, self._config, self._serialize, self._deserialize)
120+
self.alert_rule_recommendations = AlertRuleRecommendationsOperations(
121+
self._client, self._config, self._serialize, self._deserialize
122+
)
123+
self.alert_processing_rules = AlertProcessingRulesOperations(
124+
self._client, self._config, self._serialize, self._deserialize
125+
)
126+
self.smart_detector_alert_rules = SmartDetectorAlertRulesOperations(
127+
self._client, self._config, self._serialize, self._deserialize
128+
)
129+
self.migrate_from_smart_detection = MigrateFromSmartDetectionOperations(
130+
self._client, self._config, self._serialize, self._deserialize
131+
)
132+
self.tenant_activity_log_alerts = TenantActivityLogAlertsOperations(
133+
self._client, self._config, self._serialize, self._deserialize
134+
)
135+
self.issue = IssueOperations(self._client, self._config, self._serialize, self._deserialize)
79136

80-
def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
137+
def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
81138
"""Runs the network request through the client's chained policies.
82139
83140
>>> from azure.core.rest import HttpRequest
@@ -97,14 +154,14 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
97154

98155
request_copy = deepcopy(request)
99156
request_copy.url = self._client.format_url(request_copy.url)
100-
return self._client.send_request(request_copy, **kwargs)
157+
return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore
101158

102159
def close(self) -> None:
103160
self._client.close()
104161

105-
def __enter__(self) -> "AlertsManagementClient":
162+
def __enter__(self) -> Self:
106163
self._client.__enter__()
107164
return self
108165

109-
def __exit__(self, *exc_details) -> None:
166+
def __exit__(self, *exc_details: Any) -> None:
110167
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)