// 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.IpGeodatasClient;
import com.azure.resourcemanager.securityinsights.fluent.models.EnrichmentIpGeodataInner;
import com.azure.resourcemanager.securityinsights.models.EnrichmentIpGeodata;
import com.azure.resourcemanager.securityinsights.models.IpGeodatas;

public final class IpGeodatasImpl implements IpGeodatas {
    private static final ClientLogger LOGGER = new ClientLogger(IpGeodatasImpl.class);

    private final IpGeodatasClient innerClient;

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

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

    public EnrichmentIpGeodata get(String resourceGroupName, String ipAddress) {
        EnrichmentIpGeodataInner inner = this.serviceClient().get(resourceGroupName, ipAddress);
        if (inner != null) {
            return new EnrichmentIpGeodataImpl(inner, this.manager());
        } else {
            return null;
        }
    }

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

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

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