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