Skip to content

Commit 89ea953

Browse files
author
SDKAuto
committed
CodeGen from PR 3517 in test-repo-billy/azure-rest-api-specs
Merge 94ff153d59c635207e94ea130c6e8757651fabbf into 02e500856ce974e6873e205ffdb6523ffdc60bb7
1 parent b2b0c35 commit 89ea953

File tree

63 files changed

+3290
-1116
lines changed

Some content is hidden

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

63 files changed

+3290
-1116
lines changed

sdk/advisor/azure-mgmt-advisor/README.md

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 Advisor 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/advisor)
17-
Code samples for this package can be found at [Advisor](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://github.com/Azure-Samples/azure-samples-python-management/tree/main/samples/advisor)
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-advisor
22+
pip install azure-identity
23+
```
24+
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.advisor import AdvisorManagementClient
40+
import os
41+
42+
sub_id = os.getenv("AZURE_SUBSCRIPTION_ID")
43+
client = AdvisorManagementClient(credential=DefaultAzureCredential(), subscription_id=sub_id)
44+
```
45+
46+
## Examples
47+
48+
Code samples for this package can be found at:
49+
- [Search Advisor](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
2258

2359
If you encounter any bugs or have suggestions, please file an issue in the
2460
[Issues](https://github.com/Azure/azure-sdk-for-python/issues)
2561
section of the project.
26-
27-
28-
![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python%2Fazure-mgmt-advisor%2FREADME.png)
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"commit": "e82a24def11ffc98cc263884f9f1742c99f2df5e",
3-
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
4-
"autorest": "3.9.2",
2+
"commit": "8bda290871718d1b3d8a40fce0afe0c83f16ecc5",
3+
"repository_url": "https://github.com/test-repo-billy/azure-rest-api-specs",
4+
"autorest": "3.10.2",
55
"use": [
6-
"@autorest/python@6.2.1",
7-
"@autorest/modelerfour@4.24.3"
6+
"@autorest/python@6.19.0",
7+
"@autorest/modelerfour@4.27.0"
88
],
9-
"autorest_command": "autorest specification/advisor/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 --tag=package-2020-01 --use=@autorest/python@6.2.1 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False",
9+
"autorest_command": "autorest specification/advisor/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.19.0 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False",
1010
"readme": "specification/advisor/resource-manager/readme.md"
1111
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
try:
1515
from ._patch import __all__ as _patch_all
16-
from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import
16+
from ._patch import * # pylint: disable=unused-wildcard-import
1717
except ImportError:
1818
_patch_all = []
1919
from ._patch import patch_sdk as _patch_sdk

sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/_advisor_management_client.py

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,19 @@
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

15-
from . import models
18+
from . import models as _models
1619
from ._configuration import AdvisorManagementClientConfiguration
1720
from ._serialization import Deserializer, Serializer
1821
from .operations import (
22+
AdvisorManagementClientOperationsMixin,
23+
AdvisorScoresOperations,
1924
ConfigurationsOperations,
2025
Operations,
2126
RecommendationMetadataOperations,
@@ -28,7 +33,9 @@
2833
from azure.core.credentials import TokenCredential
2934

3035

31-
class AdvisorManagementClient: # pylint: disable=client-accepts-api-version-keyword
36+
class AdvisorManagementClient(
37+
AdvisorManagementClientOperationsMixin
38+
): # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes
3239
"""REST APIs for Azure Advisor.
3340
3441
:ivar recommendation_metadata: RecommendationMetadataOperations operations
@@ -42,13 +49,15 @@ class AdvisorManagementClient: # pylint: disable=client-accepts-api-version-key
4249
:vartype operations: azure.mgmt.advisor.operations.Operations
4350
:ivar suppressions: SuppressionsOperations operations
4451
:vartype suppressions: azure.mgmt.advisor.operations.SuppressionsOperations
52+
:ivar advisor_scores: AdvisorScoresOperations operations
53+
:vartype advisor_scores: azure.mgmt.advisor.operations.AdvisorScoresOperations
4554
:param credential: Credential needed for the client to connect to Azure. Required.
4655
:type credential: ~azure.core.credentials.TokenCredential
4756
:param subscription_id: The Azure subscription ID. Required.
4857
:type subscription_id: str
4958
:param base_url: Service URL. Default value is "https://management.azure.com".
5059
:type base_url: str
51-
:keyword api_version: Api Version. Default value is "2020-01-01". Note that overriding this
60+
:keyword api_version: Api Version. Default value is "2023-01-01". Note that overriding this
5261
default value may result in unsupported behavior.
5362
:paramtype api_version: str
5463
"""
@@ -63,9 +72,27 @@ def __init__(
6372
self._config = AdvisorManagementClientConfiguration(
6473
credential=credential, subscription_id=subscription_id, **kwargs
6574
)
66-
self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs)
67-
68-
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
75+
_policies = kwargs.pop("policies", None)
76+
if _policies is None:
77+
_policies = [
78+
policies.RequestIdPolicy(**kwargs),
79+
self._config.headers_policy,
80+
self._config.user_agent_policy,
81+
self._config.proxy_policy,
82+
policies.ContentDecodePolicy(**kwargs),
83+
ARMAutoResourceProviderRegistrationPolicy(),
84+
self._config.redirect_policy,
85+
self._config.retry_policy,
86+
self._config.authentication_policy,
87+
self._config.custom_hook_policy,
88+
self._config.logging_policy,
89+
policies.DistributedTracingPolicy(**kwargs),
90+
policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None,
91+
self._config.http_logging_policy,
92+
]
93+
self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs)
94+
95+
client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)}
6996
self._serialize = Serializer(client_models)
7097
self._deserialize = Deserializer(client_models)
7198
self._serialize.client_side_validation = False
@@ -76,8 +103,9 @@ def __init__(
76103
self.recommendations = RecommendationsOperations(self._client, self._config, self._serialize, self._deserialize)
77104
self.operations = Operations(self._client, self._config, self._serialize, self._deserialize)
78105
self.suppressions = SuppressionsOperations(self._client, self._config, self._serialize, self._deserialize)
106+
self.advisor_scores = AdvisorScoresOperations(self._client, self._config, self._serialize, self._deserialize)
79107

80-
def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
108+
def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
81109
"""Runs the network request through the client's chained policies.
82110
83111
>>> from azure.core.rest import HttpRequest
@@ -97,17 +125,14 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
97125

98126
request_copy = deepcopy(request)
99127
request_copy.url = self._client.format_url(request_copy.url)
100-
return self._client.send_request(request_copy, **kwargs)
128+
return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore
101129

102-
def close(self):
103-
# type: () -> None
130+
def close(self) -> None:
104131
self._client.close()
105132

106-
def __enter__(self):
107-
# type: () -> AdvisorManagementClient
133+
def __enter__(self) -> Self:
108134
self._client.__enter__()
109135
return self
110136

111-
def __exit__(self, *exc_details):
112-
# type: (Any) -> None
137+
def __exit__(self, *exc_details: Any) -> None:
113138
self._client.__exit__(*exc_details)

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

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,19 @@
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
88

9-
import sys
109
from typing import Any, TYPE_CHECKING
1110

12-
from azure.core.configuration import Configuration
1311
from azure.core.pipeline import policies
1412
from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy
1513

1614
from ._version import VERSION
1715

18-
if sys.version_info >= (3, 8):
19-
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
20-
else:
21-
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
22-
2316
if TYPE_CHECKING:
2417
# pylint: disable=unused-import,ungrouped-imports
2518
from azure.core.credentials import TokenCredential
2619

2720

28-
class AdvisorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes
21+
class AdvisorManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long
2922
"""Configuration for AdvisorManagementClient.
3023
3124
Note that all parameters used to create this instance are saved as instance
@@ -35,14 +28,13 @@ class AdvisorManagementClientConfiguration(Configuration): # pylint: disable=to
3528
:type credential: ~azure.core.credentials.TokenCredential
3629
:param subscription_id: The Azure subscription ID. Required.
3730
:type subscription_id: str
38-
:keyword api_version: Api Version. Default value is "2020-01-01". Note that overriding this
31+
:keyword api_version: Api Version. Default value is "2023-01-01". Note that overriding this
3932
default value may result in unsupported behavior.
4033
:paramtype api_version: str
4134
"""
4235

4336
def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None:
44-
super(AdvisorManagementClientConfiguration, self).__init__(**kwargs)
45-
api_version = kwargs.pop("api_version", "2020-01-01") # type: Literal["2020-01-01"]
37+
api_version: str = kwargs.pop("api_version", "2023-01-01")
4638

4739
if credential is None:
4840
raise ValueError("Parameter 'credential' must not be None.")
@@ -54,20 +46,18 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs
5446
self.api_version = api_version
5547
self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"])
5648
kwargs.setdefault("sdk_moniker", "mgmt-advisor/{}".format(VERSION))
49+
self.polling_interval = kwargs.get("polling_interval", 30)
5750
self._configure(**kwargs)
5851

59-
def _configure(
60-
self, **kwargs # type: Any
61-
):
62-
# type: (...) -> None
52+
def _configure(self, **kwargs: Any) -> None:
6353
self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs)
6454
self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs)
6555
self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
6656
self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs)
6757
self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs)
68-
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
6958
self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs)
7059
self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs)
60+
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
7161
self.authentication_policy = kwargs.get("authentication_policy")
7262
if self.credential and not self.authentication_policy:
7363
self.authentication_policy = ARMChallengeAuthenticationPolicy(

0 commit comments

Comments
 (0)