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