|
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 PolicyInsightsClientConfiguration(Configuration): |
| 22 | +class PolicyInsightsClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes |
25 | 23 | """Configuration for PolicyInsightsClient.
|
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: Microsoft Azure subscription ID. |
| 30 | + :param subscription_id: Microsoft Azure subscription ID. Required. |
33 | 31 | :type subscription_id: str
|
34 | 32 | """
|
35 | 33 |
|
36 |
| - def __init__( |
37 |
| - self, |
38 |
| - credential, # type: "TokenCredential" |
39 |
| - subscription_id, # type: str |
40 |
| - **kwargs # type: Any |
41 |
| - ): |
42 |
| - # type: (...) -> None |
| 34 | + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: |
| 35 | + super(PolicyInsightsClientConfiguration, self).__init__(**kwargs) |
43 | 36 | if credential is None:
|
44 | 37 | raise ValueError("Parameter 'credential' must not be None.")
|
45 | 38 | if subscription_id is None:
|
46 | 39 | raise ValueError("Parameter 'subscription_id' must not be None.")
|
47 |
| - super(PolicyInsightsClientConfiguration, self).__init__(**kwargs) |
48 | 40 |
|
49 | 41 | self.credential = credential
|
50 | 42 | self.subscription_id = subscription_id
|
51 |
| - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) |
52 |
| - kwargs.setdefault('sdk_moniker', 'mgmt-policyinsights/{}'.format(VERSION)) |
| 43 | + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) |
| 44 | + kwargs.setdefault("sdk_moniker", "mgmt-policyinsights/{}".format(VERSION)) |
53 | 45 | self._configure(**kwargs)
|
54 | 46 |
|
55 | 47 | def _configure(
|
56 |
| - self, |
57 |
| - **kwargs # type: Any |
| 48 | + self, **kwargs # type: Any |
58 | 49 | ):
|
59 | 50 | # type: (...) -> 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') |
| 51 | + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) |
| 52 | + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) |
| 53 | + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) |
| 54 | + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) |
| 55 | + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) |
| 56 | + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) |
| 57 | + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) |
| 58 | + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) |
| 59 | + self.authentication_policy = kwargs.get("authentication_policy") |
69 | 60 | if self.credential and not self.authentication_policy:
|
70 |
| - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) |
| 61 | + self.authentication_policy = ARMChallengeAuthenticationPolicy( |
| 62 | + self.credential, *self.credential_scopes, **kwargs |
| 63 | + ) |
0 commit comments