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

package com.azure.resourcemanager.netapp.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.netapp.fluent.NetAppResourceQuotaLimitsClient;
import com.azure.resourcemanager.netapp.fluent.models.SubscriptionQuotaItemInner;
import com.azure.resourcemanager.netapp.models.NetAppResourceQuotaLimits;
import com.azure.resourcemanager.netapp.models.SubscriptionQuotaItem;

public final class NetAppResourceQuotaLimitsImpl implements NetAppResourceQuotaLimits {
    private static final ClientLogger LOGGER = new ClientLogger(NetAppResourceQuotaLimitsImpl.class);

    private final NetAppResourceQuotaLimitsClient innerClient;

    private final com.azure.resourcemanager.netapp.NetAppFilesManager serviceManager;

    public NetAppResourceQuotaLimitsImpl(
        NetAppResourceQuotaLimitsClient innerClient,
        com.azure.resourcemanager.netapp.NetAppFilesManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

    public PagedIterable<SubscriptionQuotaItem> list(String location) {
        PagedIterable<SubscriptionQuotaItemInner> inner = this.serviceClient().list(location);
        return Utils.mapPage(inner, inner1 -> new SubscriptionQuotaItemImpl(inner1, this.manager()));
    }

    public PagedIterable<SubscriptionQuotaItem> list(String location, Context context) {
        PagedIterable<SubscriptionQuotaItemInner> inner = this.serviceClient().list(location, context);
        return Utils.mapPage(inner, inner1 -> new SubscriptionQuotaItemImpl(inner1, this.manager()));
    }

    public Response<SubscriptionQuotaItem> getWithResponse(String location, String quotaLimitName, Context context) {
        Response<SubscriptionQuotaItemInner> inner =
            this.serviceClient().getWithResponse(location, quotaLimitName, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new SubscriptionQuotaItemImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public SubscriptionQuotaItem get(String location, String quotaLimitName) {
        SubscriptionQuotaItemInner inner = this.serviceClient().get(location, quotaLimitName);
        if (inner != null) {
            return new SubscriptionQuotaItemImpl(inner, this.manager());
        } else {
            return null;
        }
    }

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

    private com.azure.resourcemanager.netapp.NetAppFilesManager manager() {
        return this.serviceManager;
    }
}
