Skip to content

Commit 1617122

Browse files
author
SDKAuto
committed
CodeGen from PR 31229 in Azure/azure-rest-api-specs
Merge 71da838c454623fe0d1053cd78276c922c46d77c into 92e45eacb58f010293254e88a2bf1160c9a25478
1 parent 77d7e0d commit 1617122

File tree

396 files changed

+15754
-8577
lines changed

Some content is hidden

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

396 files changed

+15754
-8577
lines changed

sdk/automation/azure-mgmt-automation/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 Automation 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 [Automation](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-automation
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.automation import AutomationClient
40+
import os
41+
42+
sub_id = os.getenv("AZURE_SUBSCRIPTION_ID")
43+
client = AutomationClient(credential=DefaultAzureCredential(), subscription_id=sub_id)
44+
```
45+
46+
## Examples
47+
48+
Code samples for this package can be found at:
49+
- [Search Automation](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-automation%2FREADME.png)
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"commit": "23b62d4e4dab07dccda851cfe50f6c6afb705a3b",
2+
"commit": "74c2a41f29b9bae56c4291f7a561f137aa987822",
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.19.0",
7+
"@autorest/modelerfour@4.27.0"
88
],
9-
"autorest_command": "autorest specification/automation/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/automation/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/automation/resource-manager/readme.md"
1111
}

sdk/automation/azure-mgmt-automation/azure/mgmt/automation/_automation_client.py

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@
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 AutomationClientConfiguration
@@ -43,6 +46,7 @@
4346
NodeReportsOperations,
4447
ObjectDataTypesOperations,
4548
Operations,
49+
PowerShell72ModuleOperations,
4650
PrivateEndpointConnectionsOperations,
4751
PrivateLinkResourcesOperations,
4852
Python2PackageOperations,
@@ -149,6 +153,8 @@ class AutomationClient(
149153
:vartype object_data_types: azure.mgmt.automation.operations.ObjectDataTypesOperations
150154
:ivar fields: FieldsOperations operations
151155
:vartype fields: azure.mgmt.automation.operations.FieldsOperations
156+
:ivar power_shell72_module: PowerShell72ModuleOperations operations
157+
:vartype power_shell72_module: azure.mgmt.automation.operations.PowerShell72ModuleOperations
152158
:ivar operations: Operations operations
153159
:vartype operations: azure.mgmt.automation.operations.Operations
154160
:ivar python2_package: Python2PackageOperations operations
@@ -201,7 +207,25 @@ def __init__(
201207
**kwargs: Any
202208
) -> None:
203209
self._config = AutomationClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs)
204-
self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs)
210+
_policies = kwargs.pop("policies", None)
211+
if _policies is None:
212+
_policies = [
213+
policies.RequestIdPolicy(**kwargs),
214+
self._config.headers_policy,
215+
self._config.user_agent_policy,
216+
self._config.proxy_policy,
217+
policies.ContentDecodePolicy(**kwargs),
218+
ARMAutoResourceProviderRegistrationPolicy(),
219+
self._config.redirect_policy,
220+
self._config.retry_policy,
221+
self._config.authentication_policy,
222+
self._config.custom_hook_policy,
223+
self._config.logging_policy,
224+
policies.DistributedTracingPolicy(**kwargs),
225+
policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None,
226+
self._config.http_logging_policy,
227+
]
228+
self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs)
205229

206230
client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)}
207231
self._serialize = Serializer(client_models)
@@ -269,6 +293,9 @@ def __init__(
269293
self._client, self._config, self._serialize, self._deserialize
270294
)
271295
self.fields = FieldsOperations(self._client, self._config, self._serialize, self._deserialize)
296+
self.power_shell72_module = PowerShell72ModuleOperations(
297+
self._client, self._config, self._serialize, self._deserialize
298+
)
272299
self.operations = Operations(self._client, self._config, self._serialize, self._deserialize)
273300
self.python2_package = Python2PackageOperations(self._client, self._config, self._serialize, self._deserialize)
274301
self.python3_package = Python3PackageOperations(self._client, self._config, self._serialize, self._deserialize)
@@ -292,7 +319,7 @@ def __init__(
292319
)
293320
self.variable = VariableOperations(self._client, self._config, self._serialize, self._deserialize)
294321

295-
def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
322+
def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
296323
"""Runs the network request through the client's chained policies.
297324
298325
>>> from azure.core.rest import HttpRequest
@@ -312,14 +339,14 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
312339

313340
request_copy = deepcopy(request)
314341
request_copy.url = self._client.format_url(request_copy.url)
315-
return self._client.send_request(request_copy, **kwargs)
342+
return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore
316343

317344
def close(self) -> None:
318345
self._client.close()
319346

320-
def __enter__(self) -> "AutomationClient":
347+
def __enter__(self) -> Self:
321348
self._client.__enter__()
322349
return self
323350

324-
def __exit__(self, *exc_details) -> None:
351+
def __exit__(self, *exc_details: Any) -> None:
325352
self._client.__exit__(*exc_details)

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
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

@@ -19,7 +18,7 @@
1918
from azure.core.credentials import TokenCredential
2019

2120

22-
class AutomationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes
21+
class AutomationClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long
2322
"""Configuration for AutomationClient.
2423
2524
Note that all parameters used to create this instance are saved as instance
@@ -33,7 +32,6 @@ class AutomationClientConfiguration(Configuration): # pylint: disable=too-many-
3332
"""
3433

3534
def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None:
36-
super(AutomationClientConfiguration, self).__init__(**kwargs)
3735
if credential is None:
3836
raise ValueError("Parameter 'credential' must not be None.")
3937
if subscription_id is None:
@@ -43,6 +41,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs
4341
self.subscription_id = subscription_id
4442
self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"])
4543
kwargs.setdefault("sdk_moniker", "mgmt-automation/{}".format(VERSION))
44+
self.polling_interval = kwargs.get("polling_interval", 30)
4645
self._configure(**kwargs)
4746

4847
def _configure(self, **kwargs: Any) -> None:
@@ -51,9 +50,9 @@ def _configure(self, **kwargs: Any) -> None:
5150
self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
5251
self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs)
5352
self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs)
54-
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
5553
self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs)
5654
self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs)
55+
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
5756
self.authentication_policy = kwargs.get("authentication_policy")
5857
if self.credential and not self.authentication_policy:
5958
self.authentication_policy = ARMChallengeAuthenticationPolicy(

0 commit comments

Comments
 (0)