// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.securityinsights.implementation;

import com.azure.core.http.rest.Response;
import com.azure.core.http.rest.SimpleResponse;
import com.azure.core.util.Context;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.securityinsights.fluent.DomainWhoisClient;
import com.azure.resourcemanager.securityinsights.fluent.models.EnrichmentDomainWhoisInner;
import com.azure.resourcemanager.securityinsights.models.DomainWhois;
import com.azure.resourcemanager.securityinsights.models.EnrichmentDomainWhois;

public final class DomainWhoisImpl implements DomainWhois {
    private static final ClientLogger LOGGER = new ClientLogger(DomainWhoisImpl.class);

    private final DomainWhoisClient innerClient;

    private final com.azure.resourcemanager.securityinsights.SecurityInsightsManager serviceManager;

    public DomainWhoisImpl(
        DomainWhoisClient innerClient,
        com.azure.resourcemanager.securityinsights.SecurityInsightsManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

    public EnrichmentDomainWhois get(String resourceGroupName, String domain) {
        EnrichmentDomainWhoisInner inner = this.serviceClient().get(resourceGroupName, domain);
        if (inner != null) {
            return new EnrichmentDomainWhoisImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public Response<EnrichmentDomainWhois> getWithResponse(String resourceGroupName, String domain, Context context) {
        Response<EnrichmentDomainWhoisInner> inner =
            this.serviceClient().getWithResponse(resourceGroupName, domain, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new EnrichmentDomainWhoisImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    private DomainWhoisClient serviceClient() {
        return this.innerClient;
    }

    private com.azure.resourcemanager.securityinsights.SecurityInsightsManager manager() {
        return this.serviceManager;
    }
}
