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

package com.azure.resourcemanager.fluidrelay.implementation;

import com.azure.core.http.rest.PagedIterable;
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.fluidrelay.fluent.FluidRelayContainersClient;
import com.azure.resourcemanager.fluidrelay.fluent.models.FluidRelayContainerInner;
import com.azure.resourcemanager.fluidrelay.models.FluidRelayContainer;
import com.azure.resourcemanager.fluidrelay.models.FluidRelayContainers;

public final class FluidRelayContainersImpl implements FluidRelayContainers {
    private static final ClientLogger LOGGER = new ClientLogger(FluidRelayContainersImpl.class);

    private final FluidRelayContainersClient innerClient;

    private final com.azure.resourcemanager.fluidrelay.FluidRelayManager serviceManager;

    public FluidRelayContainersImpl(
        FluidRelayContainersClient innerClient, com.azure.resourcemanager.fluidrelay.FluidRelayManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

    public FluidRelayContainer get(String resourceGroup, String fluidRelayServerName, String fluidRelayContainerName) {
        FluidRelayContainerInner inner =
            this.serviceClient().get(resourceGroup, fluidRelayServerName, fluidRelayContainerName);
        if (inner != null) {
            return new FluidRelayContainerImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public Response<FluidRelayContainer> getWithResponse(
        String resourceGroup, String fluidRelayServerName, String fluidRelayContainerName, Context context) {
        Response<FluidRelayContainerInner> inner =
            this.serviceClient().getWithResponse(resourceGroup, fluidRelayServerName, fluidRelayContainerName, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new FluidRelayContainerImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public void delete(String resourceGroup, String fluidRelayServerName, String fluidRelayContainerName) {
        this.serviceClient().delete(resourceGroup, fluidRelayServerName, fluidRelayContainerName);
    }

    public Response<Void> deleteWithResponse(
        String resourceGroup, String fluidRelayServerName, String fluidRelayContainerName, Context context) {
        return this
            .serviceClient()
            .deleteWithResponse(resourceGroup, fluidRelayServerName, fluidRelayContainerName, context);
    }

    public PagedIterable<FluidRelayContainer> listByFluidRelayServers(
        String resourceGroup, String fluidRelayServerName) {
        PagedIterable<FluidRelayContainerInner> inner =
            this.serviceClient().listByFluidRelayServers(resourceGroup, fluidRelayServerName);
        return Utils.mapPage(inner, inner1 -> new FluidRelayContainerImpl(inner1, this.manager()));
    }

    public PagedIterable<FluidRelayContainer> listByFluidRelayServers(
        String resourceGroup, String fluidRelayServerName, Context context) {
        PagedIterable<FluidRelayContainerInner> inner =
            this.serviceClient().listByFluidRelayServers(resourceGroup, fluidRelayServerName, context);
        return Utils.mapPage(inner, inner1 -> new FluidRelayContainerImpl(inner1, this.manager()));
    }

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

    private com.azure.resourcemanager.fluidrelay.FluidRelayManager manager() {
        return this.serviceManager;
    }
}
