Skip to content

Commit 5a128e2

Browse files
author
SDKAuto
committed
CodeGen from PR 31320 in Azure/azure-rest-api-specs
Merge 13998c6079a1159305fd190e5e4b99fa000dfaa8 into 533d972b32b91774f13e5b56190ab6573760ee85
1 parent e95bc99 commit 5a128e2

File tree

48 files changed

+2022
-985
lines changed

Some content is hidden

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

48 files changed

+2022
-985
lines changed
Lines changed: 32 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,61 @@
11
# Microsoft Azure SDK for Python
22

33
This is the Microsoft Azure Attestation 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-
## Getting Started
11+
## Getting started
1212

13-
### Prerequsites
14-
```shell
15-
pip install azure-identity
13+
### Prerequisites
14+
15+
- Python 3.8+ is required to use this package.
16+
- [Azure subscription](https://azure.microsoft.com/free/)
17+
18+
### Install the package
19+
20+
```bash
1621
pip install azure-mgmt-attestation
22+
pip install azure-identity
1723
```
18-
19-
Before running the examples, please set the values of the client ID, tenant ID and client secret
20-
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
21-
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
22-
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
2324

25+
### Authentication
2426

25-
### Resources
26-
To learn how to use this package, see the [quickstart guide](https://aka.ms/azsdk/python/mgmt)
27-
28-
For docs and references, see [Python SDK References](https://docs.microsoft.com/python/api/overview/azure/)
29-
Code samples for this package can be found at [Attestation Management](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com.
30-
Additional code samples for different Azure services are available at [Samples Repo](https://aka.ms/azsdk/python/mgmt/samples)
27+
By default, [Azure Active Directory](https://aka.ms/awps/aad) token authentication depends on correct configure of following environment variables.
3128

29+
- `AZURE_CLIENT_ID` for Azure client ID.
30+
- `AZURE_TENANT_ID` for Azure tenant ID.
31+
- `AZURE_CLIENT_SECRET` for Azure client secret.
3232

33-
## Examples
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:
3436

35-
### List Attestation Providers
3637
```python
37-
from azure.core.exceptions import ClientAuthenticationError
3838
from azure.identity import DefaultAzureCredential
3939
from azure.mgmt.attestation import AttestationManagementClient
40+
import os
4041

41-
client = AttestationManagementClient(
42-
credential=DefaultAzureCredential(),
43-
subscription_id="00000000-0000-0000-0000-000000000000",
44-
)
45-
46-
response = client.attestation_providers.list()
47-
print(response)
42+
sub_id = os.getenv("AZURE_SUBSCRIPTION_ID")
43+
client = AttestationManagementClient(credential=DefaultAzureCredential(), subscription_id=sub_id)
4844
```
4945

50-
## Troubleshooting
51-
52-
### CredentialUnavailableError
53-
The CredentialUnavailableError is a specific error type derived from ClientAuthenticationError. This error type is used to indicate that the credential can't authenticate in the current environment, due to missing required configuration or setup. This error is also used as an indication for chained credential types, such as DefaultAzureCredential and ChainedTokenCredential, that the chained credential should continue to attempt other credential types later in the chain.
54-
55-
### Permission issues
56-
Service client calls that result in HttpResponseError with a StatusCode of 401 or 403 often indicate the caller doesn't have sufficient permissions for the specified API. Check the [service documentation](https://learn.microsoft.com/azure/attestation/) to determine which RBAC roles are needed for the specific request, and ensure the authenticated user or service principal have been granted the appropriate roles on the resource.
57-
58-
## Next Steps
59-
60-
If you encounter any bugs or have suggestions, please file an issue in the
61-
[Issues](https://github.com/Azure/azure-sdk-for-python/issues)
62-
section of the project.
46+
## Examples
6347

64-
![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python%2Fazure-mgmt-attestation%2FREADME.png)
48+
Code samples for this package can be found at:
49+
- [Search Attestation 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)
6551

6652

67-
## Contributing
53+
## Troubleshooting
6854

69-
This project welcomes contributions and suggestions. Most contributions require
70-
you to agree to a Contributor License Agreement (CLA) declaring that you have
71-
the right to, and actually do, grant us the rights to use your contribution.
72-
For details, visit [https://cla.microsoft.com](https://cla.microsoft.com).
55+
## Next steps
7356

74-
When you submit a pull request, a CLA-bot will automatically determine whether
75-
you need to provide a CLA and decorate the PR appropriately (e.g., label,
76-
comment). Simply follow the instructions provided by the bot. You will only
77-
need to do this once across all repos using our CLA.
57+
## Provide Feedback
7858

79-
This project has adopted the
80-
[Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
81-
For more information, see the
82-
[Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
83-
or contact [[email protected]](mailto:[email protected]) with any
84-
additional questions or comments.
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": "e82a24def11ffc98cc263884f9f1742c99f2df5e",
2+
"commit": "49fae6febb4eabe6e70630c444b783329fd22db3",
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/attestation/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/attestation/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/attestation/resource-manager/readme.md"
1111
}

sdk/attestation/azure-mgmt-attestation/azure/mgmt/attestation/__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/attestation/azure-mgmt-attestation/azure/mgmt/attestation/_attestation_management_client.py

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,22 @@
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 AttestationManagementClientConfiguration
1720
from ._serialization import Deserializer, Serializer
18-
from .operations import AttestationProvidersOperations, Operations, PrivateEndpointConnectionsOperations
21+
from .operations import (
22+
AttestationProvidersOperations,
23+
Operations,
24+
PrivateEndpointConnectionsOperations,
25+
PrivateLinkResourcesOperations,
26+
)
1927

2028
if TYPE_CHECKING:
2129
# pylint: disable=unused-import,ungrouped-imports
@@ -34,13 +42,16 @@ class AttestationManagementClient: # pylint: disable=client-accepts-api-version
3442
:ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations
3543
:vartype private_endpoint_connections:
3644
azure.mgmt.attestation.operations.PrivateEndpointConnectionsOperations
45+
:ivar private_link_resources: PrivateLinkResourcesOperations operations
46+
:vartype private_link_resources:
47+
azure.mgmt.attestation.operations.PrivateLinkResourcesOperations
3748
:param credential: Credential needed for the client to connect to Azure. Required.
3849
:type credential: ~azure.core.credentials.TokenCredential
3950
:param subscription_id: The ID of the target subscription. Required.
4051
:type subscription_id: str
4152
:param base_url: Service URL. Default value is "https://management.azure.com".
4253
:type base_url: str
43-
:keyword api_version: Api Version. Default value is "2020-10-01". Note that overriding this
54+
:keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this
4455
default value may result in unsupported behavior.
4556
:paramtype api_version: str
4657
"""
@@ -55,9 +66,27 @@ def __init__(
5566
self._config = AttestationManagementClientConfiguration(
5667
credential=credential, subscription_id=subscription_id, **kwargs
5768
)
58-
self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs)
59-
60-
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
69+
_policies = kwargs.pop("policies", None)
70+
if _policies is None:
71+
_policies = [
72+
policies.RequestIdPolicy(**kwargs),
73+
self._config.headers_policy,
74+
self._config.user_agent_policy,
75+
self._config.proxy_policy,
76+
policies.ContentDecodePolicy(**kwargs),
77+
ARMAutoResourceProviderRegistrationPolicy(),
78+
self._config.redirect_policy,
79+
self._config.retry_policy,
80+
self._config.authentication_policy,
81+
self._config.custom_hook_policy,
82+
self._config.logging_policy,
83+
policies.DistributedTracingPolicy(**kwargs),
84+
policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None,
85+
self._config.http_logging_policy,
86+
]
87+
self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs)
88+
89+
client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)}
6190
self._serialize = Serializer(client_models)
6291
self._deserialize = Deserializer(client_models)
6392
self._serialize.client_side_validation = False
@@ -68,8 +97,11 @@ def __init__(
6897
self.private_endpoint_connections = PrivateEndpointConnectionsOperations(
6998
self._client, self._config, self._serialize, self._deserialize
7099
)
100+
self.private_link_resources = PrivateLinkResourcesOperations(
101+
self._client, self._config, self._serialize, self._deserialize
102+
)
71103

72-
def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
104+
def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
73105
"""Runs the network request through the client's chained policies.
74106
75107
>>> from azure.core.rest import HttpRequest
@@ -89,17 +121,14 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
89121

90122
request_copy = deepcopy(request)
91123
request_copy.url = self._client.format_url(request_copy.url)
92-
return self._client.send_request(request_copy, **kwargs)
124+
return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore
93125

94-
def close(self):
95-
# type: () -> None
126+
def close(self) -> None:
96127
self._client.close()
97128

98-
def __enter__(self):
99-
# type: () -> AttestationManagementClient
129+
def __enter__(self) -> Self:
100130
self._client.__enter__()
101131
return self
102132

103-
def __exit__(self, *exc_details):
104-
# type: (Any) -> None
133+
def __exit__(self, *exc_details: Any) -> None:
105134
self._client.__exit__(*exc_details)

sdk/attestation/azure-mgmt-attestation/azure/mgmt/attestation/_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 AttestationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes
21+
class AttestationManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long
2922
"""Configuration for AttestationManagementClient.
3023
3124
Note that all parameters used to create this instance are saved as instance
@@ -35,14 +28,13 @@ class AttestationManagementClientConfiguration(Configuration): # pylint: disabl
3528
:type credential: ~azure.core.credentials.TokenCredential
3629
:param subscription_id: The ID of the target subscription. Required.
3730
:type subscription_id: str
38-
:keyword api_version: Api Version. Default value is "2020-10-01". Note that overriding this
31+
:keyword api_version: Api Version. Default value is "2021-06-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(AttestationManagementClientConfiguration, self).__init__(**kwargs)
45-
api_version = kwargs.pop("api_version", "2020-10-01") # type: Literal["2020-10-01"]
37+
api_version: str = kwargs.pop("api_version", "2021-06-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-attestation/{}".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)