Skip to content

Commit 249d7bf

Browse files
azure-sdkChenxiJiang333
authored andcommitted
[AutoRelease] t2-managedservices-2024-11-04-44075(can only be merged by SDK owner) (Azure#38287)
* code and test * update-testcase --------- Co-authored-by: azure-sdk <PythonSdkPipelines> Co-authored-by: ChenxiJiang333 <[email protected]>
1 parent 9b27efe commit 249d7bf

File tree

68 files changed

+2088
-1221
lines changed

Some content is hidden

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

68 files changed

+2088
-1221
lines changed

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

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Release History
22

3+
## 7.0.0b2 (2024-11-05)
4+
5+
### Other Changes
6+
7+
- Update dependencies
8+
39
## 7.0.0b1 (2022-10-31)
410

511
### Features Added

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

+44-11
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 Managed Services 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 [Managed Services](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-managedservices
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.managedservices import ManagedServicesClient
40+
import os
41+
42+
sub_id = os.getenv("AZURE_SUBSCRIPTION_ID")
43+
client = ManagedServicesClient(credential=DefaultAzureCredential(), subscription_id=sub_id)
44+
```
45+
46+
## Examples
47+
48+
Code samples for this package can be found at:
49+
- [Search Managed Services](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-managedservices%2FREADME.png)
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"commit": "5fc05d0f0b15cbf16de942cadce464b495c66a58",
2+
"commit": "cc6315290ff14f03f0c18904a109f82afac4a899",
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.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/managedservices/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.1 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False",
9+
"autorest_command": "autorest specification/managedservices/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/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/managedservices/resource-manager/readme.md"
1111
}

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

+1-1
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/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/_configuration.py

+5-15
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 ManagedServicesClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes
21+
class ManagedServicesClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long
2922
"""Configuration for ManagedServicesClient.
3023
3124
Note that all parameters used to create this instance are saved as instance
@@ -39,8 +32,7 @@ class ManagedServicesClientConfiguration(Configuration): # pylint: disable=too-
3932
"""
4033

4134
def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None:
42-
super(ManagedServicesClientConfiguration, self).__init__(**kwargs)
43-
api_version = kwargs.pop("api_version", "2022-10-01") # type: Literal["2022-10-01"]
35+
api_version: str = kwargs.pop("api_version", "2022-10-01")
4436

4537
if credential is None:
4638
raise ValueError("Parameter 'credential' must not be None.")
@@ -49,20 +41,18 @@ def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None:
4941
self.api_version = api_version
5042
self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"])
5143
kwargs.setdefault("sdk_moniker", "mgmt-managedservices/{}".format(VERSION))
44+
self.polling_interval = kwargs.get("polling_interval", 30)
5245
self._configure(**kwargs)
5346

54-
def _configure(
55-
self, **kwargs # type: Any
56-
):
57-
# type: (...) -> None
47+
def _configure(self, **kwargs: Any) -> None:
5848
self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs)
5949
self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs)
6050
self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
6151
self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs)
6252
self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs)
63-
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
6453
self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs)
6554
self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs)
55+
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
6656
self.authentication_policy = kwargs.get("authentication_policy")
6757
if self.credential and not self.authentication_policy:
6858
self.authentication_policy = ARMChallengeAuthenticationPolicy(

sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/_managed_services_client.py

+30-12
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@
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 ManagedServicesClientConfiguration
1720
from ._serialization import Deserializer, Serializer
1821
from .operations import (
@@ -66,9 +69,27 @@ def __init__(
6669
self, credential: "TokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any
6770
) -> None:
6871
self._config = ManagedServicesClientConfiguration(credential=credential, **kwargs)
69-
self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs)
70-
71-
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
72+
_policies = kwargs.pop("policies", None)
73+
if _policies is None:
74+
_policies = [
75+
policies.RequestIdPolicy(**kwargs),
76+
self._config.headers_policy,
77+
self._config.user_agent_policy,
78+
self._config.proxy_policy,
79+
policies.ContentDecodePolicy(**kwargs),
80+
ARMAutoResourceProviderRegistrationPolicy(),
81+
self._config.redirect_policy,
82+
self._config.retry_policy,
83+
self._config.authentication_policy,
84+
self._config.custom_hook_policy,
85+
self._config.logging_policy,
86+
policies.DistributedTracingPolicy(**kwargs),
87+
policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None,
88+
self._config.http_logging_policy,
89+
]
90+
self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs)
91+
92+
client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)}
7293
self._serialize = Serializer(client_models)
7394
self._deserialize = Deserializer(client_models)
7495
self._serialize.client_side_validation = False
@@ -91,7 +112,7 @@ def __init__(
91112
self._client, self._config, self._serialize, self._deserialize
92113
)
93114

94-
def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
115+
def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
95116
"""Runs the network request through the client's chained policies.
96117
97118
>>> from azure.core.rest import HttpRequest
@@ -111,17 +132,14 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
111132

112133
request_copy = deepcopy(request)
113134
request_copy.url = self._client.format_url(request_copy.url)
114-
return self._client.send_request(request_copy, **kwargs)
135+
return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore
115136

116-
def close(self):
117-
# type: () -> None
137+
def close(self) -> None:
118138
self._client.close()
119139

120-
def __enter__(self):
121-
# type: () -> ManagedServicesClient
140+
def __enter__(self) -> Self:
122141
self._client.__enter__()
123142
return self
124143

125-
def __exit__(self, *exc_details):
126-
# type: (Any) -> None
144+
def __exit__(self, *exc_details: Any) -> None:
127145
self._client.__exit__(*exc_details)

0 commit comments

Comments
 (0)