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

package com.azure.resourcemanager.vmwarecloudsimple.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.vmwarecloudsimple.fluent.ResourcePoolsClient;
import com.azure.resourcemanager.vmwarecloudsimple.fluent.models.ResourcePoolInner;
import com.azure.resourcemanager.vmwarecloudsimple.models.ResourcePool;
import com.azure.resourcemanager.vmwarecloudsimple.models.ResourcePools;

public final class ResourcePoolsImpl implements ResourcePools {
    private static final ClientLogger LOGGER = new ClientLogger(ResourcePoolsImpl.class);

    private final ResourcePoolsClient innerClient;

    private final com.azure.resourcemanager.vmwarecloudsimple.VMwareCloudSimpleManager serviceManager;

    public ResourcePoolsImpl(
        ResourcePoolsClient innerClient,
        com.azure.resourcemanager.vmwarecloudsimple.VMwareCloudSimpleManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

    public PagedIterable<ResourcePool> list(String regionId, String pcName) {
        PagedIterable<ResourcePoolInner> inner = this.serviceClient().list(regionId, pcName);
        return Utils.mapPage(inner, inner1 -> new ResourcePoolImpl(inner1, this.manager()));
    }

    public PagedIterable<ResourcePool> list(String regionId, String pcName, Context context) {
        PagedIterable<ResourcePoolInner> inner = this.serviceClient().list(regionId, pcName, context);
        return Utils.mapPage(inner, inner1 -> new ResourcePoolImpl(inner1, this.manager()));
    }

    public Response<ResourcePool> getWithResponse(
        String regionId, String pcName, String resourcePoolName, Context context) {
        Response<ResourcePoolInner> inner =
            this.serviceClient().getWithResponse(regionId, pcName, resourcePoolName, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new ResourcePoolImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public ResourcePool get(String regionId, String pcName, String resourcePoolName) {
        ResourcePoolInner inner = this.serviceClient().get(regionId, pcName, resourcePoolName);
        if (inner != null) {
            return new ResourcePoolImpl(inner, this.manager());
        } else {
            return null;
        }
    }

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

    private com.azure.resourcemanager.vmwarecloudsimple.VMwareCloudSimpleManager manager() {
        return this.serviceManager;
    }
}
