22# --------------------------------------------------------------------------
33# Copyright (c) Microsoft Corporation. All rights reserved.
44# Licensed under the MIT License. See License.txt in the project root for license information.
5- # Code generated by Microsoft (R) AutoRest Code Generator.
5+ # Code generated by Microsoft (R) Python Code Generator.
66# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77# --------------------------------------------------------------------------
88
99from copy import deepcopy
10+ import sys
1011from typing import Any , Optional , TYPE_CHECKING , cast
11- from typing_extensions import Self
1212
1313from azure .core .pipeline import policies
1414from azure .core .rest import HttpRequest , HttpResponse
1717from azure .mgmt .core .policies import ARMAutoResourceProviderRegistrationPolicy
1818from azure .mgmt .core .tools import get_arm_endpoints
1919
20- from . import models as _models
2120from ._configuration import PolicyInsightsClientConfiguration
2221from ._utils .serialization import Deserializer , Serializer
2322from .operations import (
23+ AttestationsOperations ,
24+ ComponentPolicyStatesOperations ,
2425 Operations ,
2526 PolicyEventsOperations ,
2627 PolicyMetadataOperations ,
3031 RemediationsOperations ,
3132)
3233
34+ if sys .version_info >= (3 , 11 ):
35+ from typing import Self
36+ else :
37+ from typing_extensions import Self # type: ignore
38+
3339if TYPE_CHECKING :
3440 from azure .core import AzureClouds
3541 from azure .core .credentials import TokenCredential
3844class PolicyInsightsClient : # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes
3945 """PolicyInsightsClient.
4046
41- :ivar policy_tracked_resources: PolicyTrackedResourcesOperations operations
42- :vartype policy_tracked_resources:
43- azure.mgmt.policyinsights.operations.PolicyTrackedResourcesOperations
47+ :ivar operations: Operations operations
48+ :vartype operations: azure.mgmt.policyinsights.operations.Operations
4449 :ivar remediations: RemediationsOperations operations
4550 :vartype remediations: azure.mgmt.policyinsights.operations.RemediationsOperations
51+ :ivar attestations: AttestationsOperations operations
52+ :vartype attestations: azure.mgmt.policyinsights.operations.AttestationsOperations
53+ :ivar policy_metadata: PolicyMetadataOperations operations
54+ :vartype policy_metadata: azure.mgmt.policyinsights.operations.PolicyMetadataOperations
4655 :ivar policy_events: PolicyEventsOperations operations
4756 :vartype policy_events: azure.mgmt.policyinsights.operations.PolicyEventsOperations
4857 :ivar policy_states: PolicyStatesOperations operations
4958 :vartype policy_states: azure.mgmt.policyinsights.operations.PolicyStatesOperations
50- :ivar operations: Operations operations
51- :vartype operations: azure.mgmt.policyinsights.operations.Operations
52- :ivar policy_metadata: PolicyMetadataOperations operations
53- :vartype policy_metadata: azure.mgmt.policyinsights.operations.PolicyMetadataOperations
5459 :ivar policy_restrictions: PolicyRestrictionsOperations operations
5560 :vartype policy_restrictions: azure.mgmt.policyinsights.operations.PolicyRestrictionsOperations
56- :param credential: Credential needed for the client to connect to Azure. Required.
61+ :ivar component_policy_states: ComponentPolicyStatesOperations operations
62+ :vartype component_policy_states:
63+ azure.mgmt.policyinsights.operations.ComponentPolicyStatesOperations
64+ :ivar policy_tracked_resources: PolicyTrackedResourcesOperations operations
65+ :vartype policy_tracked_resources:
66+ azure.mgmt.policyinsights.operations.PolicyTrackedResourcesOperations
67+ :param credential: Credential used to authenticate requests to the service. Required.
5768 :type credential: ~azure.core.credentials.TokenCredential
58- :param subscription_id: Microsoft Azure subscription ID . Required.
69+ :param subscription_id: The ID of the target subscription. The value must be an UUID . Required.
5970 :type subscription_id: str
60- :param base_url: Service URL . Default value is None.
71+ :param base_url: Service host . Default value is None.
6172 :type base_url: str
6273 :keyword cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is
6374 None.
@@ -75,6 +86,7 @@ def __init__(
7586 cloud_setting : Optional ["AzureClouds" ] = None ,
7687 ** kwargs : Any
7788 ) -> None :
89+ _endpoint = "{endpoint}"
7890 _cloud = cloud_setting or settings .current .azure_cloud # type: ignore
7991 _endpoints = get_arm_endpoints (_cloud )
8092 if not base_url :
@@ -83,6 +95,7 @@ def __init__(
8395 self ._config = PolicyInsightsClientConfiguration (
8496 credential = credential ,
8597 subscription_id = subscription_id ,
98+ base_url = cast (str , base_url ),
8699 cloud_setting = cloud_setting ,
87100 credential_scopes = credential_scopes ,
88101 ** kwargs
@@ -106,31 +119,34 @@ def __init__(
106119 policies .SensitiveHeaderCleanupPolicy (** kwargs ) if self ._config .redirect_policy else None ,
107120 self ._config .http_logging_policy ,
108121 ]
109- self ._client : ARMPipelineClient = ARMPipelineClient (base_url = cast (str , base_url ), policies = _policies , ** kwargs )
122+ self ._client : ARMPipelineClient = ARMPipelineClient (base_url = cast (str , _endpoint ), policies = _policies , ** kwargs )
110123
111- client_models = {k : v for k , v in _models .__dict__ .items () if isinstance (v , type )}
112- self ._serialize = Serializer (client_models )
113- self ._deserialize = Deserializer (client_models )
124+ self ._serialize = Serializer ()
125+ self ._deserialize = Deserializer ()
114126 self ._serialize .client_side_validation = False
115- self .policy_tracked_resources = PolicyTrackedResourcesOperations (
116- self ._client , self ._config , self ._serialize , self ._deserialize
117- )
127+ self .operations = Operations (self ._client , self ._config , self ._serialize , self ._deserialize )
118128 self .remediations = RemediationsOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
129+ self .attestations = AttestationsOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
130+ self .policy_metadata = PolicyMetadataOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
119131 self .policy_events = PolicyEventsOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
120132 self .policy_states = PolicyStatesOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
121- self .operations = Operations (self ._client , self ._config , self ._serialize , self ._deserialize )
122- self .policy_metadata = PolicyMetadataOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
123133 self .policy_restrictions = PolicyRestrictionsOperations (
124134 self ._client , self ._config , self ._serialize , self ._deserialize
125135 )
136+ self .component_policy_states = ComponentPolicyStatesOperations (
137+ self ._client , self ._config , self ._serialize , self ._deserialize
138+ )
139+ self .policy_tracked_resources = PolicyTrackedResourcesOperations (
140+ self ._client , self ._config , self ._serialize , self ._deserialize
141+ )
126142
127- def _send_request (self , request : HttpRequest , * , stream : bool = False , ** kwargs : Any ) -> HttpResponse :
143+ def send_request (self , request : HttpRequest , * , stream : bool = False , ** kwargs : Any ) -> HttpResponse :
128144 """Runs the network request through the client's chained policies.
129145
130146 >>> from azure.core.rest import HttpRequest
131147 >>> request = HttpRequest("GET", "https://www.example.org/")
132148 <HttpRequest [GET], url: 'https://www.example.org/'>
133- >>> response = client._send_request (request)
149+ >>> response = client.send_request (request)
134150 <HttpResponse: 200 OK>
135151
136152 For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
@@ -143,7 +159,11 @@ def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs:
143159 """
144160
145161 request_copy = deepcopy (request )
146- request_copy .url = self ._client .format_url (request_copy .url )
162+ path_format_arguments = {
163+ "endpoint" : self ._serialize .url ("self._config.base_url" , self ._config .base_url , "str" , skip_quote = True ),
164+ }
165+
166+ request_copy .url = self ._client .format_url (request_copy .url , ** path_format_arguments )
147167 return self ._client .send_request (request_copy , stream = stream , ** kwargs ) # type: ignore
148168
149169 def close (self ) -> None :
0 commit comments