# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from typing import Any, Optional, TYPE_CHECKING

from azure.mgmt.core import AsyncARMPipelineClient
from msrest import Deserializer, Serializer

if TYPE_CHECKING:
    # pylint: disable=unused-import,ungrouped-imports
    from azure.core.credentials_async import AsyncTokenCredential

from ._configuration_async import MicrosoftDatadogClientConfiguration
from .operations_async import ApiKeyOperations
from .operations_async import HostOperations
from .operations_async import LinkedResourceOperations
from .operations_async import MonitoredResourceOperations
from .operations_async import OperationOperations
from .operations_async import MonitorOperations
from .operations_async import RefreshSetPasswordOperations
from .operations_async import TagRuleOperations
from .operations_async import SingleSignOnConfigurationOperations
from .. import models


class MicrosoftDatadogClient(object):
    """MicrosoftDatadogClient.

    :ivar api_key: ApiKeyOperations operations
    :vartype api_key: microsoft_datadog_client.aio.operations_async.ApiKeyOperations
    :ivar host: HostOperations operations
    :vartype host: microsoft_datadog_client.aio.operations_async.HostOperations
    :ivar linked_resource: LinkedResourceOperations operations
    :vartype linked_resource: microsoft_datadog_client.aio.operations_async.LinkedResourceOperations
    :ivar monitored_resource: MonitoredResourceOperations operations
    :vartype monitored_resource: microsoft_datadog_client.aio.operations_async.MonitoredResourceOperations
    :ivar operation: OperationOperations operations
    :vartype operation: microsoft_datadog_client.aio.operations_async.OperationOperations
    :ivar monitor: MonitorOperations operations
    :vartype monitor: microsoft_datadog_client.aio.operations_async.MonitorOperations
    :ivar refresh_set_password: RefreshSetPasswordOperations operations
    :vartype refresh_set_password: microsoft_datadog_client.aio.operations_async.RefreshSetPasswordOperations
    :ivar tag_rule: TagRuleOperations operations
    :vartype tag_rule: microsoft_datadog_client.aio.operations_async.TagRuleOperations
    :ivar single_sign_on_configuration: SingleSignOnConfigurationOperations operations
    :vartype single_sign_on_configuration: microsoft_datadog_client.aio.operations_async.SingleSignOnConfigurationOperations
    :param credential: Credential needed for the client to connect to Azure.
    :type credential: ~azure.core.credentials_async.AsyncTokenCredential
    :param subscription_id: The Microsoft Azure subscription ID.
    :type subscription_id: str
    :param str base_url: Service URL
    :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
    """

    def __init__(
        self,
        credential: "AsyncTokenCredential",
        subscription_id: str,
        base_url: Optional[str] = None,
        **kwargs: Any
    ) -> None:
        if not base_url:
            base_url = 'https://management.azure.com'
        self._config = MicrosoftDatadogClientConfiguration(credential, subscription_id, **kwargs)
        self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs)

        client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)

        self.api_key = ApiKeyOperations(
            self._client, self._config, self._serialize, self._deserialize)
        self.host = HostOperations(
            self._client, self._config, self._serialize, self._deserialize)
        self.linked_resource = LinkedResourceOperations(
            self._client, self._config, self._serialize, self._deserialize)
        self.monitored_resource = MonitoredResourceOperations(
            self._client, self._config, self._serialize, self._deserialize)
        self.operation = OperationOperations(
            self._client, self._config, self._serialize, self._deserialize)
        self.monitor = MonitorOperations(
            self._client, self._config, self._serialize, self._deserialize)
        self.refresh_set_password = RefreshSetPasswordOperations(
            self._client, self._config, self._serialize, self._deserialize)
        self.tag_rule = TagRuleOperations(
            self._client, self._config, self._serialize, self._deserialize)
        self.single_sign_on_configuration = SingleSignOnConfigurationOperations(
            self._client, self._config, self._serialize, self._deserialize)

    async def close(self) -> None:
        await self._client.close()

    async def __aenter__(self) -> "MicrosoftDatadogClient":
        await self._client.__aenter__()
        return self

    async def __aexit__(self, *exc_details) -> None:
        await self._client.__aexit__(*exc_details)
