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

package com.azure.resourcemanager.reservations.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.reservations.fluent.QuotaRequestStatusClient;
import com.azure.resourcemanager.reservations.fluent.models.QuotaRequestDetailsInner;
import com.azure.resourcemanager.reservations.models.QuotaRequestDetails;
import com.azure.resourcemanager.reservations.models.QuotaRequestStatus;

public final class QuotaRequestStatusImpl implements QuotaRequestStatus {
    private static final ClientLogger LOGGER = new ClientLogger(QuotaRequestStatusImpl.class);

    private final QuotaRequestStatusClient innerClient;

    private final com.azure.resourcemanager.reservations.ReservationsManager serviceManager;

    public QuotaRequestStatusImpl(
        QuotaRequestStatusClient innerClient,
        com.azure.resourcemanager.reservations.ReservationsManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

    public Response<QuotaRequestDetails> getWithResponse(
        String subscriptionId, String providerId, String location, String id, Context context) {
        Response<QuotaRequestDetailsInner> inner =
            this.serviceClient().getWithResponse(subscriptionId, providerId, location, id, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new QuotaRequestDetailsImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public QuotaRequestDetails get(String subscriptionId, String providerId, String location, String id) {
        QuotaRequestDetailsInner inner = this.serviceClient().get(subscriptionId, providerId, location, id);
        if (inner != null) {
            return new QuotaRequestDetailsImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public PagedIterable<QuotaRequestDetails> list(String subscriptionId, String providerId, String location) {
        PagedIterable<QuotaRequestDetailsInner> inner = this.serviceClient().list(subscriptionId, providerId, location);
        return Utils.mapPage(inner, inner1 -> new QuotaRequestDetailsImpl(inner1, this.manager()));
    }

    public PagedIterable<QuotaRequestDetails> list(
        String subscriptionId,
        String providerId,
        String location,
        String filter,
        Integer top,
        String skiptoken,
        Context context) {
        PagedIterable<QuotaRequestDetailsInner> inner =
            this.serviceClient().list(subscriptionId, providerId, location, filter, top, skiptoken, context);
        return Utils.mapPage(inner, inner1 -> new QuotaRequestDetailsImpl(inner1, this.manager()));
    }

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

    private com.azure.resourcemanager.reservations.ReservationsManager manager() {
        return this.serviceManager;
    }
}
