7
7
# --------------------------------------------------------------------------
8
8
9
9
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
11
12
13
+ from azure .core .pipeline import policies
12
14
from azure .core .rest import HttpRequest , HttpResponse
15
+ from azure .core .settings import settings
13
16
from azure .mgmt .core import ARMPipelineClient
17
+ from azure .mgmt .core .policies import ARMAutoResourceProviderRegistrationPolicy
18
+ from azure .mgmt .core .tools import get_arm_endpoints
14
19
15
20
from . import models as _models
16
21
from ._configuration import MigrationDiscoverySapMgmtClientConfiguration
17
22
from ._serialization import Deserializer , Serializer
18
23
from .operations import Operations , SapDiscoverySitesOperations , SapInstancesOperations , ServerInstancesOperations
19
24
20
25
if TYPE_CHECKING :
21
- # pylint: disable=unused-import,ungrouped-imports
22
26
from azure .core .credentials import TokenCredential
23
27
24
28
25
- class MigrationDiscoverySapMgmtClient : # pylint: disable=client-accepts-api-version-keyword
29
+ class MigrationDiscoverySapMgmtClient :
26
30
"""SAP Migration client provides access to various operations for SAP Migration.
27
31
28
32
:ivar sap_discovery_sites: SapDiscoverySitesOperations operations
@@ -39,7 +43,7 @@ class MigrationDiscoverySapMgmtClient: # pylint: disable=client-accepts-api-ver
39
43
:type credential: ~azure.core.credentials.TokenCredential
40
44
:param subscription_id: The ID of the target subscription. Required.
41
45
:type subscription_id: str
42
- :param base_url: Service URL. Default value is "https://management.azure.com" .
46
+ :param base_url: Service URL. Default value is None .
43
47
:type base_url: str
44
48
:keyword api_version: Api Version. Default value is "2023-10-01-preview". Note that overriding
45
49
this default value may result in unsupported behavior.
@@ -49,16 +53,36 @@ class MigrationDiscoverySapMgmtClient: # pylint: disable=client-accepts-api-ver
49
53
"""
50
54
51
55
def __init__ (
52
- self ,
53
- credential : "TokenCredential" ,
54
- subscription_id : str ,
55
- base_url : str = "https://management.azure.com" ,
56
- ** kwargs : Any
56
+ self , credential : "TokenCredential" , subscription_id : str , base_url : Optional [str ] = None , ** kwargs : Any
57
57
) -> None :
58
+ _cloud = kwargs .pop ("cloud_setting" , None ) or settings .current .azure_cloud # type: ignore
59
+ _endpoints = get_arm_endpoints (_cloud )
60
+ if not base_url :
61
+ base_url = _endpoints ["resource_manager" ]
62
+ credential_scopes = kwargs .pop ("credential_scopes" , _endpoints ["credential_scopes" ])
58
63
self ._config = MigrationDiscoverySapMgmtClientConfiguration (
59
- credential = credential , subscription_id = subscription_id , ** kwargs
64
+ credential = credential , subscription_id = subscription_id , credential_scopes = credential_scopes , ** kwargs
60
65
)
61
- self ._client : ARMPipelineClient = ARMPipelineClient (base_url = base_url , config = self ._config , ** kwargs )
66
+
67
+ _policies = kwargs .pop ("policies" , None )
68
+ if _policies is None :
69
+ _policies = [
70
+ policies .RequestIdPolicy (** kwargs ),
71
+ self ._config .headers_policy ,
72
+ self ._config .user_agent_policy ,
73
+ self ._config .proxy_policy ,
74
+ policies .ContentDecodePolicy (** kwargs ),
75
+ ARMAutoResourceProviderRegistrationPolicy (),
76
+ self ._config .redirect_policy ,
77
+ self ._config .retry_policy ,
78
+ self ._config .authentication_policy ,
79
+ self ._config .custom_hook_policy ,
80
+ self ._config .logging_policy ,
81
+ policies .DistributedTracingPolicy (** kwargs ),
82
+ policies .SensitiveHeaderCleanupPolicy (** kwargs ) if self ._config .redirect_policy else None ,
83
+ self ._config .http_logging_policy ,
84
+ ]
85
+ self ._client : ARMPipelineClient = ARMPipelineClient (base_url = cast (str , base_url ), policies = _policies , ** kwargs )
62
86
63
87
client_models = {k : v for k , v in _models .__dict__ .items () if isinstance (v , type )}
64
88
self ._serialize = Serializer (client_models )
@@ -73,7 +97,7 @@ def __init__(
73
97
)
74
98
self .operations = Operations (self ._client , self ._config , self ._serialize , self ._deserialize )
75
99
76
- def _send_request (self , request : HttpRequest , ** kwargs : Any ) -> HttpResponse :
100
+ def _send_request (self , request : HttpRequest , * , stream : bool = False , * *kwargs : Any ) -> HttpResponse :
77
101
"""Runs the network request through the client's chained policies.
78
102
79
103
>>> from azure.core.rest import HttpRequest
@@ -93,12 +117,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
93
117
94
118
request_copy = deepcopy (request )
95
119
request_copy .url = self ._client .format_url (request_copy .url )
96
- return self ._client .send_request (request_copy , ** kwargs )
120
+ return self ._client .send_request (request_copy , stream = stream , ** kwargs ) # type: ignore
97
121
98
122
def close (self ) -> None :
99
123
self ._client .close ()
100
124
101
- def __enter__ (self ) -> "MigrationDiscoverySapMgmtClient" :
125
+ def __enter__ (self ) -> Self :
102
126
self ._client .__enter__ ()
103
127
return self
104
128
0 commit comments