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

package com.azure.resourcemanager.networkcloud.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.networkcloud.fluent.RackSkusClient;
import com.azure.resourcemanager.networkcloud.fluent.models.RackSkuInner;
import com.azure.resourcemanager.networkcloud.models.RackSku;
import com.azure.resourcemanager.networkcloud.models.RackSkus;

public final class RackSkusImpl implements RackSkus {
    private static final ClientLogger LOGGER = new ClientLogger(RackSkusImpl.class);

    private final RackSkusClient innerClient;

    private final com.azure.resourcemanager.networkcloud.NetworkCloudManager serviceManager;

    public RackSkusImpl(
        RackSkusClient innerClient, com.azure.resourcemanager.networkcloud.NetworkCloudManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

    public PagedIterable<RackSku> list() {
        PagedIterable<RackSkuInner> inner = this.serviceClient().list();
        return Utils.mapPage(inner, inner1 -> new RackSkuImpl(inner1, this.manager()));
    }

    public PagedIterable<RackSku> list(Context context) {
        PagedIterable<RackSkuInner> inner = this.serviceClient().list(context);
        return Utils.mapPage(inner, inner1 -> new RackSkuImpl(inner1, this.manager()));
    }

    public Response<RackSku> getWithResponse(String rackSkuName, Context context) {
        Response<RackSkuInner> inner = this.serviceClient().getWithResponse(rackSkuName, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new RackSkuImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public RackSku get(String rackSkuName) {
        RackSkuInner inner = this.serviceClient().get(rackSkuName);
        if (inner != null) {
            return new RackSkuImpl(inner, this.manager());
        } else {
            return null;
        }
    }

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

    private com.azure.resourcemanager.networkcloud.NetworkCloudManager manager() {
        return this.serviceManager;
    }
}
