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
9from typing import Any, TYPE_CHECKING
10
11from azure.core.configuration import Configuration
12from azure.core.pipeline import policies
13from azure.mgmt.core.policies import ARMHttpLoggingPolicy
14
15from .._version import VERSION
16
17if TYPE_CHECKING:
18    # pylint: disable=unused-import,ungrouped-imports
19    from azure.core.credentials_async import AsyncTokenCredential
20
21
22class ComputeManagementClientConfiguration(Configuration):
23    """Configuration for ComputeManagementClient.
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_async.AsyncTokenCredential
30    :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.
31    :type subscription_id: str
32    """
33
34    def __init__(
35        self,
36        credential: "AsyncTokenCredential",
37        subscription_id: str,
38        **kwargs: Any
39    ) -> None:
40        if credential is None:
41            raise ValueError("Parameter 'credential' must not be None.")
42        if subscription_id is None:
43            raise ValueError("Parameter 'subscription_id' must not be None.")
44        super(ComputeManagementClientConfiguration, self).__init__(**kwargs)
45
46        self.credential = credential
47        self.subscription_id = subscription_id
48        self.api_version = "2020-06-30"
49        self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default'])
50        kwargs.setdefault('sdk_moniker', 'mgmt-compute/{}'.format(VERSION))
51        self._configure(**kwargs)
52
53    def _configure(
54        self,
55        **kwargs: Any
56    ) -> None:
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.AsyncRetryPolicy(**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.AsyncRedirectPolicy(**kwargs)
65        self.authentication_policy = kwargs.get('authentication_policy')
66        if self.credential and not self.authentication_policy:
67            self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs)
68