Skip to content

Commit f59941b

Browse files
[AutoRelease] t2-policyinsights-2025-07-05-59782(can only be merged by SDK owner) (#41914)
* code and test * update testcases * Update dev_requirements.txt --------- Co-authored-by: azure-sdk <PythonSdkPipelines> Co-authored-by: ChenxiJiang333 <v-chenjiang@microsoft.com> Co-authored-by: ChenxiJiang333 <119990644+ChenxiJiang333@users.noreply.github.com>
1 parent 0df6784 commit f59941b

File tree

205 files changed

+6981
-4920
lines changed

Some content is hidden

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

205 files changed

+6981
-4920
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
# Release History
22

3+
## 1.1.0b5 (2025-07-21)
4+
5+
### Features Added
6+
7+
- Model `CheckRestrictionsRequest` added property `include_audit_effect`
8+
- Model `FieldRestriction` added property `policy_effect`
9+
- Model `FieldRestriction` added property `reason`
10+
- Enum `FieldRestrictionResult` added member `AUDIT`
11+
- Model `PolicyEvaluationResult` added property `effect_details`
12+
- Model `RemediationFilters` added property `resource_ids`
13+
- Added model `CheckRestrictionEvaluationDetails`
14+
- Added model `PolicyEffectDetails`
15+
316
## 1.1.0b4 (2022-12-29)
417

518
### Features Added

sdk/policyinsights/azure-mgmt-policyinsights/MANIFEST.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
include _meta.json
21
recursive-include tests *.py *.json
32
recursive-include samples *.py *.md
43
include *.md

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Microsoft Azure SDK for Python
22

33
This is the Microsoft Azure Policy Insights Client Library.
4-
This package has been tested with Python 3.7+.
4+
This package has been tested with Python 3.9+.
55
For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all).
66

77
## _Disclaimer_
@@ -12,7 +12,7 @@ _Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For
1212

1313
### Prerequisites
1414

15-
- Python 3.7+ is required to use this package.
15+
- Python 3.9+ is required to use this package.
1616
- [Azure subscription](https://azure.microsoft.com/free/)
1717

1818
### Install the package
@@ -24,7 +24,7 @@ pip install azure-identity
2424

2525
### Authentication
2626

27-
By default, [Azure Active Directory](https://aka.ms/awps/aad) token authentication depends on correct configure of following environment variables.
27+
By default, [Azure Active Directory](https://aka.ms/awps/aad) token authentication depends on correct configuration of the following environment variables.
2828

2929
- `AZURE_CLIENT_ID` for Azure client ID.
3030
- `AZURE_TENANT_ID` for Azure tenant ID.
@@ -45,7 +45,9 @@ client = PolicyInsightsClient(credential=DefaultAzureCredential(), subscription_
4545

4646
## Examples
4747

48-
Code samples for this package can be found at [Policy Insights](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com and [Samples Repo](https://github.com/Azure-Samples/azure-samples-python-management/tree/main/samples/policyinsights)
48+
Code samples for this package can be found at:
49+
- [Search Policy Insights](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)
4951

5052

5153
## Troubleshooting
@@ -57,6 +59,3 @@ Code samples for this package can be found at [Policy Insights](https://docs.mic
5759
If you encounter any bugs or have suggestions, please file an issue in the
5860
[Issues](https://github.com/Azure/azure-sdk-for-python/issues)
5961
section of the project.
60-
61-
62-

sdk/policyinsights/azure-mgmt-policyinsights/_meta.json

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"commit": "6c548b0bd279f5e233661b1c81fb5b61b19965cd",
3+
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
4+
"autorest": "3.10.2",
5+
"use": [
6+
"@autorest/python@6.35.0",
7+
"@autorest/modelerfour@4.27.0"
8+
],
9+
"autorest_command": "autorest specification/policyinsights/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.35.0 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False",
10+
"readme": "specification/policyinsights/resource-manager/readme.md"
11+
}

sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/__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 ._policy_insights_client import PolicyInsightsClient
10+
from typing import TYPE_CHECKING
11+
12+
if TYPE_CHECKING:
13+
from ._patch import * # pylint: disable=unused-wildcard-import
14+
15+
from ._policy_insights_client import PolicyInsightsClient # 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
"PolicyInsightsClient",
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/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_configuration.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,16 @@
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 PolicyInsightsClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes
20+
class PolicyInsightsClientConfiguration: # pylint: disable=too-many-instance-attributes
2321
"""Configuration for PolicyInsightsClient.
2422
2523
Note that all parameters used to create this instance are saved as instance
@@ -32,7 +30,6 @@ class PolicyInsightsClientConfiguration(Configuration): # pylint: disable=too-m
3230
"""
3331

3432
def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None:
35-
super(PolicyInsightsClientConfiguration, self).__init__(**kwargs)
3633
if credential is None:
3734
raise ValueError("Parameter 'credential' must not be None.")
3835
if subscription_id is None:
@@ -42,6 +39,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs
4239
self.subscription_id = subscription_id
4340
self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"])
4441
kwargs.setdefault("sdk_moniker", "mgmt-policyinsights/{}".format(VERSION))
42+
self.polling_interval = kwargs.get("polling_interval", 30)
4543
self._configure(**kwargs)
4644

4745
def _configure(self, **kwargs: Any) -> None:
@@ -50,9 +48,9 @@ def _configure(self, **kwargs: Any) -> None:
5048
self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
5149
self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs)
5250
self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs)
53-
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
5451
self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs)
5552
self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs)
53+
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
5654
self.authentication_policy = kwargs.get("authentication_policy")
5755
if self.credential and not self.authentication_policy:
5856
self.authentication_policy = ARMChallengeAuthenticationPolicy(

sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_policy_insights_client.py

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,19 @@
77
# --------------------------------------------------------------------------
88

99
from copy import deepcopy
10-
from typing import Any, TYPE_CHECKING
10+
from typing import Any, Optional, TYPE_CHECKING, cast
11+
from typing_extensions import Self
1112

13+
from azure.core.pipeline import policies
1214
from azure.core.rest import HttpRequest, HttpResponse
15+
from azure.core.settings import settings
1316
from azure.mgmt.core import ARMPipelineClient
17+
from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy
18+
from azure.mgmt.core.tools import get_arm_endpoints
1419

1520
from . import models as _models
1621
from ._configuration import PolicyInsightsClientConfiguration
17-
from ._serialization import Deserializer, Serializer
22+
from ._utils.serialization import Deserializer, Serializer
1823
from .operations import (
1924
AttestationsOperations,
2025
ComponentPolicyStatesOperations,
@@ -28,7 +33,6 @@
2833
)
2934

3035
if TYPE_CHECKING:
31-
# pylint: disable=unused-import,ungrouped-imports
3236
from azure.core.credentials import TokenCredential
3337

3438

@@ -59,23 +63,43 @@ class PolicyInsightsClient: # pylint: disable=client-accepts-api-version-keywor
5963
:type credential: ~azure.core.credentials.TokenCredential
6064
:param subscription_id: Microsoft Azure subscription ID. Required.
6165
:type subscription_id: str
62-
:param base_url: Service URL. Default value is "https://management.azure.com".
66+
:param base_url: Service URL. Default value is None.
6367
:type base_url: str
6468
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
6569
Retry-After header is present.
6670
"""
6771

6872
def __init__(
69-
self,
70-
credential: "TokenCredential",
71-
subscription_id: str,
72-
base_url: str = "https://management.azure.com",
73-
**kwargs: Any
73+
self, credential: "TokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any
7474
) -> None:
75+
_cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore
76+
_endpoints = get_arm_endpoints(_cloud)
77+
if not base_url:
78+
base_url = _endpoints["resource_manager"]
79+
credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"])
7580
self._config = PolicyInsightsClientConfiguration(
76-
credential=credential, subscription_id=subscription_id, **kwargs
81+
credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs
7782
)
78-
self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs)
83+
84+
_policies = kwargs.pop("policies", None)
85+
if _policies is None:
86+
_policies = [
87+
policies.RequestIdPolicy(**kwargs),
88+
self._config.headers_policy,
89+
self._config.user_agent_policy,
90+
self._config.proxy_policy,
91+
policies.ContentDecodePolicy(**kwargs),
92+
ARMAutoResourceProviderRegistrationPolicy(),
93+
self._config.redirect_policy,
94+
self._config.retry_policy,
95+
self._config.authentication_policy,
96+
self._config.custom_hook_policy,
97+
self._config.logging_policy,
98+
policies.DistributedTracingPolicy(**kwargs),
99+
policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None,
100+
self._config.http_logging_policy,
101+
]
102+
self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, base_url), policies=_policies, **kwargs)
79103

80104
client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)}
81105
self._serialize = Serializer(client_models)
@@ -97,7 +121,7 @@ def __init__(
97121
self.operations = Operations(self._client, self._config, self._serialize, self._deserialize)
98122
self.attestations = AttestationsOperations(self._client, self._config, self._serialize, self._deserialize)
99123

100-
def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
124+
def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
101125
"""Runs the network request through the client's chained policies.
102126
103127
>>> from azure.core.rest import HttpRequest
@@ -117,14 +141,14 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
117141

118142
request_copy = deepcopy(request)
119143
request_copy.url = self._client.format_url(request_copy.url)
120-
return self._client.send_request(request_copy, **kwargs)
144+
return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore
121145

122146
def close(self) -> None:
123147
self._client.close()
124148

125-
def __enter__(self) -> "PolicyInsightsClient":
149+
def __enter__(self) -> Self:
126150
self._client.__enter__()
127151
return self
128152

129-
def __exit__(self, *exc_details) -> None:
153+
def __exit__(self, *exc_details: Any) -> None:
130154
self._client.__exit__(*exc_details)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# --------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
# Code generated by Microsoft (R) AutoRest Code Generator.
5+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
6+
# --------------------------------------------------------------------------

0 commit comments

Comments
 (0)