|
| 1 | +# coding=utf-8 |
| 2 | +# -------------------------------------------------------------------------- |
| 3 | +# Copyright (c) Microsoft Corporation. All rights reserved. |
| 4 | +# Licensed under the MIT License. See License.txt in the project root for license information. |
| 5 | +# Code generated by Microsoft (R) AutoRest Code Generator. |
| 6 | +# Changes may cause incorrect behavior and will be lost if the code is regenerated. |
| 7 | +# -------------------------------------------------------------------------- |
| 8 | + |
| 9 | +from typing import Any, TYPE_CHECKING |
| 10 | + |
| 11 | +from azure.core.configuration import Configuration |
| 12 | +from azure.core.pipeline import policies |
| 13 | +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy |
| 14 | + |
| 15 | +from ._version import VERSION |
| 16 | + |
| 17 | +if TYPE_CHECKING: |
| 18 | + # pylint: disable=unused-import,ungrouped-imports |
| 19 | + from azure.core.credentials import TokenCredential |
| 20 | + |
| 21 | + |
| 22 | +class WorkloadsClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes |
| 23 | + """Configuration for WorkloadsClient. |
| 24 | +
|
| 25 | + Note that all parameters used to create this instance are saved as instance |
| 26 | + attributes. |
| 27 | +
|
| 28 | + :param credential: Credential needed for the client to connect to Azure. |
| 29 | + :type credential: ~azure.core.credentials.TokenCredential |
| 30 | + :param subscription_id: The ID of the target subscription. |
| 31 | + :type subscription_id: str |
| 32 | + :keyword api_version: Api Version. Default value is "2021-12-01-preview". Note that overriding |
| 33 | + this default value may result in unsupported behavior. |
| 34 | + :paramtype api_version: str |
| 35 | + """ |
| 36 | + |
| 37 | + def __init__( |
| 38 | + self, |
| 39 | + credential: "TokenCredential", |
| 40 | + subscription_id: str, |
| 41 | + **kwargs: Any |
| 42 | + ) -> None: |
| 43 | + super(WorkloadsClientConfiguration, self).__init__(**kwargs) |
| 44 | + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str |
| 45 | + |
| 46 | + if credential is None: |
| 47 | + raise ValueError("Parameter 'credential' must not be None.") |
| 48 | + if subscription_id is None: |
| 49 | + raise ValueError("Parameter 'subscription_id' must not be None.") |
| 50 | + |
| 51 | + self.credential = credential |
| 52 | + self.subscription_id = subscription_id |
| 53 | + self.api_version = api_version |
| 54 | + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) |
| 55 | + kwargs.setdefault('sdk_moniker', 'mgmt-workloads/{}'.format(VERSION)) |
| 56 | + self._configure(**kwargs) |
| 57 | + |
| 58 | + def _configure( |
| 59 | + self, |
| 60 | + **kwargs # type: Any |
| 61 | + ): |
| 62 | + # type: (...) -> None |
| 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') |
| 72 | + if self.credential and not self.authentication_policy: |
| 73 | + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) |
0 commit comments