|
1 | 1 | # coding=utf-8 |
2 | 2 | # -------------------------------------------------------------------------- |
3 | 3 | # Copyright (c) Microsoft Corporation. All rights reserved. |
4 | | -# Licensed under the MIT License. See License.txt in the project root for |
5 | | -# license information. |
6 | | -# |
| 4 | +# Licensed under the MIT License. See License.txt in the project root for license information. |
7 | 5 | # Code generated by Microsoft (R) AutoRest Code Generator. |
8 | | -# Changes may cause incorrect behavior and will be lost if the code is |
9 | | -# regenerated. |
| 6 | +# Changes may cause incorrect behavior and will be lost if the code is regenerated. |
10 | 7 | # -------------------------------------------------------------------------- |
11 | | -from msrestazure import AzureConfiguration |
12 | 8 |
|
13 | | -from .version import VERSION |
| 9 | +from typing import TYPE_CHECKING |
14 | 10 |
|
| 11 | +from azure.core.configuration import Configuration |
| 12 | +from azure.core.pipeline import policies |
| 13 | +from azure.mgmt.core.policies import ARMHttpLoggingPolicy |
| 14 | + |
| 15 | +from ._version import VERSION |
| 16 | + |
| 17 | +if TYPE_CHECKING: |
| 18 | + # pylint: disable=unused-import,ungrouped-imports |
| 19 | + from typing import Any |
| 20 | + |
| 21 | + from azure.core.credentials import TokenCredential |
| 22 | + |
| 23 | + |
| 24 | +class OperationalInsightsManagementClientConfiguration(Configuration): |
| 25 | + """Configuration for OperationalInsightsManagementClient. |
15 | 26 |
|
16 | | -class LogAnalyticsManagementClientConfiguration(AzureConfiguration): |
17 | | - """Configuration for LogAnalyticsManagementClient |
18 | 27 | Note that all parameters used to create this instance are saved as instance |
19 | 28 | attributes. |
20 | 29 |
|
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>` |
| 30 | + :param credential: Credential needed for the client to connect to Azure. |
| 31 | + :type credential: ~azure.core.credentials.TokenCredential |
24 | 32 | :param subscription_id: The ID of the target subscription. |
25 | 33 | :type subscription_id: str |
26 | | - :param str base_url: Service URL |
27 | 34 | """ |
28 | 35 |
|
29 | 36 | def __init__( |
30 | | - self, credentials, subscription_id, base_url=None): |
31 | | - |
32 | | - if credentials is None: |
33 | | - raise ValueError("Parameter 'credentials' must not be None.") |
| 37 | + self, |
| 38 | + credential, # type: "TokenCredential" |
| 39 | + subscription_id, # type: str |
| 40 | + **kwargs # type: Any |
| 41 | + ): |
| 42 | + # type: (...) -> None |
| 43 | + if credential is None: |
| 44 | + raise ValueError("Parameter 'credential' must not be None.") |
34 | 45 | if subscription_id is None: |
35 | 46 | raise ValueError("Parameter 'subscription_id' must not be None.") |
36 | | - if not base_url: |
37 | | - base_url = 'https://management.azure.com' |
38 | | - |
39 | | - super(LogAnalyticsManagementClientConfiguration, self).__init__(base_url) |
40 | | - |
41 | | - # Starting Autorest.Python 4.0.64, make connection pool activated by default |
42 | | - self.keep_alive = True |
| 47 | + super(OperationalInsightsManagementClientConfiguration, self).__init__(**kwargs) |
43 | 48 |
|
44 | | - self.add_user_agent('azure-mgmt-loganalytics/{}'.format(VERSION)) |
45 | | - self.add_user_agent('Azure-SDK-For-Python') |
46 | | - |
47 | | - self.credentials = credentials |
| 49 | + self.credential = credential |
48 | 50 | self.subscription_id = subscription_id |
| 51 | + self.api_version = "2020-08-01" |
| 52 | + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) |
| 53 | + kwargs.setdefault('sdk_moniker', 'mgmt-loganalytics/{}'.format(VERSION)) |
| 54 | + self._configure(**kwargs) |
| 55 | + |
| 56 | + def _configure( |
| 57 | + self, |
| 58 | + **kwargs # type: Any |
| 59 | + ): |
| 60 | + # 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') |
| 70 | + if self.credential and not self.authentication_policy: |
| 71 | + self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) |
0 commit comments