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

package com.azure.resourcemanager.managednetworkfabric.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.managednetworkfabric.fluent.NetworkFabricSkusClient;
import com.azure.resourcemanager.managednetworkfabric.fluent.models.NetworkFabricSkuInner;
import com.azure.resourcemanager.managednetworkfabric.models.NetworkFabricSku;
import com.azure.resourcemanager.managednetworkfabric.models.NetworkFabricSkus;

public final class NetworkFabricSkusImpl implements NetworkFabricSkus {
    private static final ClientLogger LOGGER = new ClientLogger(NetworkFabricSkusImpl.class);

    private final NetworkFabricSkusClient innerClient;

    private final com.azure.resourcemanager.managednetworkfabric.ManagedNetworkFabricManager serviceManager;

    public NetworkFabricSkusImpl(
        NetworkFabricSkusClient innerClient,
        com.azure.resourcemanager.managednetworkfabric.ManagedNetworkFabricManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

    public Response<NetworkFabricSku> getWithResponse(String networkFabricSkuName, Context context) {
        Response<NetworkFabricSkuInner> inner = this.serviceClient().getWithResponse(networkFabricSkuName, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new NetworkFabricSkuImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public NetworkFabricSku get(String networkFabricSkuName) {
        NetworkFabricSkuInner inner = this.serviceClient().get(networkFabricSkuName);
        if (inner != null) {
            return new NetworkFabricSkuImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public PagedIterable<NetworkFabricSku> list() {
        PagedIterable<NetworkFabricSkuInner> inner = this.serviceClient().list();
        return Utils.mapPage(inner, inner1 -> new NetworkFabricSkuImpl(inner1, this.manager()));
    }

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

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

    private com.azure.resourcemanager.managednetworkfabric.ManagedNetworkFabricManager manager() {
        return this.serviceManager;
    }
}
