|
6 | 6 | # Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
7 | 7 | # --------------------------------------------------------------------------
|
8 | 8 |
|
9 |
| -from typing import TYPE_CHECKING |
| 9 | +import sys |
| 10 | +from typing import Any, TYPE_CHECKING |
10 | 11 |
|
11 | 12 | from azure.core.configuration import Configuration
|
12 | 13 | from azure.core.pipeline import policies
|
13 |
| -from azure.mgmt.core.policies import ARMHttpLoggingPolicy |
| 14 | +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy |
14 | 15 |
|
15 | 16 | from ._version import VERSION
|
16 | 17 |
|
| 18 | +if sys.version_info >= (3, 8): |
| 19 | + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports |
| 20 | +else: |
| 21 | + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports |
| 22 | + |
17 | 23 | if TYPE_CHECKING:
|
18 | 24 | # pylint: disable=unused-import,ungrouped-imports
|
19 |
| - from typing import Any |
20 |
| - |
21 | 25 | from azure.core.credentials import TokenCredential
|
22 | 26 |
|
23 | 27 |
|
24 |
| -class ServiceFabricManagementClientConfiguration(Configuration): |
| 28 | +class ServiceFabricManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes |
25 | 29 | """Configuration for ServiceFabricManagementClient.
|
26 | 30 |
|
27 | 31 | Note that all parameters used to create this instance are saved as instance
|
28 | 32 | attributes.
|
29 | 33 |
|
30 |
| - :param credential: Credential needed for the client to connect to Azure. |
| 34 | + :param credential: Credential needed for the client to connect to Azure. Required. |
31 | 35 | :type credential: ~azure.core.credentials.TokenCredential
|
32 |
| - :param subscription_id: The customer subscription identifier. |
| 36 | + :param subscription_id: The customer subscription identifier. Required. |
33 | 37 | :type subscription_id: str
|
| 38 | + :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this |
| 39 | + default value may result in unsupported behavior. |
| 40 | + :paramtype api_version: str |
34 | 41 | """
|
35 | 42 |
|
36 |
| - def __init__( |
37 |
| - self, |
38 |
| - credential, # type: "TokenCredential" |
39 |
| - subscription_id, # type: str |
40 |
| - **kwargs # type: Any |
41 |
| - ): |
42 |
| - # type: (...) -> None |
| 43 | + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: |
| 44 | + super(ServiceFabricManagementClientConfiguration, self).__init__(**kwargs) |
| 45 | + api_version = kwargs.pop("api_version", "2021-06-01") # type: Literal["2021-06-01"] |
| 46 | + |
43 | 47 | if credential is None:
|
44 | 48 | raise ValueError("Parameter 'credential' must not be None.")
|
45 | 49 | if subscription_id is None:
|
46 | 50 | raise ValueError("Parameter 'subscription_id' must not be None.")
|
47 |
| - super(ServiceFabricManagementClientConfiguration, self).__init__(**kwargs) |
48 | 51 |
|
49 | 52 | self.credential = credential
|
50 | 53 | self.subscription_id = subscription_id
|
51 |
| - self.api_version = "2021-06-01" |
52 |
| - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) |
53 |
| - kwargs.setdefault('sdk_moniker', 'mgmt-servicefabric/{}'.format(VERSION)) |
| 54 | + self.api_version = api_version |
| 55 | + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) |
| 56 | + kwargs.setdefault("sdk_moniker", "mgmt-servicefabric/{}".format(VERSION)) |
54 | 57 | self._configure(**kwargs)
|
55 | 58 |
|
56 | 59 | def _configure(
|
57 |
| - self, |
58 |
| - **kwargs # type: Any |
| 60 | + self, **kwargs # type: Any |
59 | 61 | ):
|
60 | 62 | # type: (...) -> None
|
61 |
| - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) |
62 |
| - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) |
63 |
| - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) |
64 |
| - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) |
65 |
| - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) |
66 |
| - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) |
67 |
| - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) |
68 |
| - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) |
69 |
| - self.authentication_policy = kwargs.get('authentication_policy') |
| 63 | + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) |
| 64 | + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) |
| 65 | + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) |
| 66 | + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) |
| 67 | + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) |
| 68 | + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) |
| 69 | + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) |
| 70 | + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) |
| 71 | + self.authentication_policy = kwargs.get("authentication_policy") |
70 | 72 | if self.credential and not self.authentication_policy:
|
71 |
| - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) |
| 73 | + self.authentication_policy = ARMChallengeAuthenticationPolicy( |
| 74 | + self.credential, *self.credential_scopes, **kwargs |
| 75 | + ) |
0 commit comments