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

package com.azure.resourcemanager.devspaces.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.devspaces.fluent.ContainerHostMappingsClient;
import com.azure.resourcemanager.devspaces.fluent.models.ContainerHostMappingInner;
import com.azure.resourcemanager.devspaces.models.ContainerHostMapping;
import com.azure.resourcemanager.devspaces.models.ContainerHostMappings;

public final class ContainerHostMappingsImpl implements ContainerHostMappings {
    private static final ClientLogger LOGGER = new ClientLogger(ContainerHostMappingsImpl.class);

    private final ContainerHostMappingsClient innerClient;

    private final com.azure.resourcemanager.devspaces.DevSpacesManager serviceManager;

    public ContainerHostMappingsImpl(
        ContainerHostMappingsClient innerClient, com.azure.resourcemanager.devspaces.DevSpacesManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

    public Response<ContainerHostMapping> getContainerHostMappingWithResponse(
        String resourceGroupName, String location, ContainerHostMappingInner containerHostMapping, Context context) {
        Response<ContainerHostMappingInner> inner =
            this
                .serviceClient()
                .getContainerHostMappingWithResponse(resourceGroupName, location, containerHostMapping, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new ContainerHostMappingImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public ContainerHostMapping getContainerHostMapping(
        String resourceGroupName, String location, ContainerHostMappingInner containerHostMapping) {
        ContainerHostMappingInner inner =
            this.serviceClient().getContainerHostMapping(resourceGroupName, location, containerHostMapping);
        if (inner != null) {
            return new ContainerHostMappingImpl(inner, this.manager());
        } else {
            return null;
        }
    }

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

    private com.azure.resourcemanager.devspaces.DevSpacesManager manager() {
        return this.serviceManager;
    }
}
