8
8
# --------------------------------------------------------------------------
9
9
10
10
from copy import deepcopy
11
- from typing import Any , TYPE_CHECKING
11
+ from typing import Any , Optional , TYPE_CHECKING , cast
12
12
from typing_extensions import Self
13
13
14
14
from azure .core .pipeline import policies
15
15
from azure .core .rest import HttpRequest , HttpResponse
16
+ from azure .core .settings import settings
16
17
from azure .mgmt .core import ARMPipelineClient
17
18
from azure .mgmt .core .policies import ARMAutoResourceProviderRegistrationPolicy
19
+ from azure .mgmt .core .tools import get_arm_endpoints
18
20
19
21
from . import models as _models
20
22
from ._configuration import NetworkManagementClientConfiguration
@@ -565,22 +567,24 @@ class NetworkManagementClient(
565
567
:param subscription_id: The subscription credentials which uniquely identify the Microsoft
566
568
Azure subscription. The subscription ID forms part of the URI for every service call. Required.
567
569
:type subscription_id: str
568
- :param base_url: Service URL. Default value is "https://management.azure.com" .
570
+ :param base_url: Service URL. Default value is None .
569
571
:type base_url: str
570
572
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
571
573
Retry-After header is present.
572
574
"""
573
575
574
576
def __init__ (
575
- self ,
576
- credential : "TokenCredential" ,
577
- subscription_id : str ,
578
- base_url : str = "https://management.azure.com" ,
579
- ** kwargs : Any
577
+ self , credential : "TokenCredential" , subscription_id : str , base_url : Optional [str ] = None , ** kwargs : Any
580
578
) -> None :
579
+ _cloud = kwargs .pop ("cloud_setting" , None ) or settings .current .azure_cloud # type: ignore
580
+ _endpoints = get_arm_endpoints (_cloud )
581
+ if not base_url :
582
+ base_url = _endpoints ["resource_manager" ]
583
+ credential_scopes = kwargs .pop ("credential_scopes" , _endpoints ["credential_scopes" ])
581
584
self ._config = NetworkManagementClientConfiguration (
582
- credential = credential , subscription_id = subscription_id , ** kwargs
585
+ credential = credential , subscription_id = subscription_id , credential_scopes = credential_scopes , ** kwargs
583
586
)
587
+
584
588
_policies = kwargs .pop ("policies" , None )
585
589
if _policies is None :
586
590
_policies = [
@@ -599,7 +603,7 @@ def __init__(
599
603
policies .SensitiveHeaderCleanupPolicy (** kwargs ) if self ._config .redirect_policy else None ,
600
604
self ._config .http_logging_policy ,
601
605
]
602
- self ._client : ARMPipelineClient = ARMPipelineClient (base_url = base_url , policies = _policies , ** kwargs )
606
+ self ._client : ARMPipelineClient = ARMPipelineClient (base_url = cast ( str , base_url ) , policies = _policies , ** kwargs )
603
607
604
608
client_models = {k : v for k , v in _models .__dict__ .items () if isinstance (v , type )}
605
609
self ._serialize = Serializer (client_models )
0 commit comments