|
8 | 8 | # Changes may cause incorrect behavior and will be lost if the code is
|
9 | 9 | # regenerated.
|
10 | 10 | # --------------------------------------------------------------------------
|
11 |
| -from msrestazure import AzureConfiguration |
| 11 | +from typing import Any |
12 | 12 |
|
13 |
| -from .version import VERSION |
| 13 | +from azure.core.configuration import Configuration |
| 14 | +from azure.core.pipeline import policies |
14 | 15 |
|
| 16 | +from ._version import VERSION |
| 17 | + |
| 18 | + |
| 19 | +class NetworkManagementClientConfiguration(Configuration): |
| 20 | + """Configuration for NetworkManagementClient. |
15 | 21 |
|
16 |
| -class NetworkManagementClientConfiguration(AzureConfiguration): |
17 |
| - """Configuration for NetworkManagementClient |
18 | 22 | Note that all parameters used to create this instance are saved as instance
|
19 | 23 | attributes.
|
20 | 24 |
|
21 |
| - :param credentials: Credentials needed for the client to connect to Azure. |
22 |
| - :type credentials: :mod:`A msrestazure Credentials |
23 |
| - object<msrestazure.azure_active_directory>` |
24 |
| - :param subscription_id: The subscription credentials which uniquely |
25 |
| - identify the Microsoft Azure subscription. The subscription ID forms part |
26 |
| - of the URI for every service call. |
| 25 | + :param credential: Credential needed for the client to connect to Azure. |
| 26 | + :type credential: ~azure.core.credentials.TokenCredential |
| 27 | + :param subscription_id: The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. |
27 | 28 | :type subscription_id: str
|
28 |
| - :param str base_url: Service URL |
29 | 29 | """
|
30 | 30 |
|
31 | 31 | def __init__(
|
32 |
| - self, credentials, subscription_id, base_url=None): |
33 |
| - |
34 |
| - if credentials is None: |
35 |
| - raise ValueError("Parameter 'credentials' must not be None.") |
| 32 | + self, |
| 33 | + credential, # type: "TokenCredential" |
| 34 | + subscription_id, # type: str |
| 35 | + **kwargs # type: Any |
| 36 | + ): |
| 37 | + # type: (...) -> None |
| 38 | + if credential is None: |
| 39 | + raise ValueError("Parameter 'credential' must not be None.") |
36 | 40 | if subscription_id is None:
|
37 | 41 | raise ValueError("Parameter 'subscription_id' must not be None.")
|
38 |
| - if not base_url: |
39 |
| - base_url = 'https://management.azure.com' |
40 |
| - |
41 |
| - super(NetworkManagementClientConfiguration, self).__init__(base_url) |
| 42 | + super(NetworkManagementClientConfiguration, self).__init__(**kwargs) |
42 | 43 |
|
43 |
| - # Starting Autorest.Python 4.0.64, make connection pool activated by default |
44 |
| - self.keep_alive = True |
45 |
| - |
46 |
| - self.add_user_agent('azure-mgmt-network/{}'.format(VERSION)) |
47 |
| - self.add_user_agent('Azure-SDK-For-Python') |
48 |
| - |
49 |
| - self.credentials = credentials |
| 44 | + self.credential = credential |
50 | 45 | self.subscription_id = subscription_id
|
| 46 | + self.credential_scopes = ['https://management.azure.com/.default'] |
| 47 | + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) |
| 48 | + kwargs.setdefault('sdk_moniker', 'azure-mgmt-network/{}'.format(VERSION)) |
| 49 | + self._configure(**kwargs) |
| 50 | + |
| 51 | + def _configure( |
| 52 | + self, |
| 53 | + **kwargs # type: Any |
| 54 | + ): |
| 55 | + # type: (...) -> None |
| 56 | + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) |
| 57 | + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) |
| 58 | + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) |
| 59 | + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) |
| 60 | + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) |
| 61 | + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) |
| 62 | + self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) |
| 63 | + self.authentication_policy = kwargs.get('authentication_policy') |
| 64 | + if self.credential and not self.authentication_policy: |
| 65 | + self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) |
0 commit comments