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

package com.azure.resourcemanager.billing.implementation;

import com.azure.core.http.rest.PagedIterable;
import com.azure.core.util.Context;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.billing.fluent.ReservationsClient;
import com.azure.resourcemanager.billing.fluent.models.ReservationInner;
import com.azure.resourcemanager.billing.models.Reservation;
import com.azure.resourcemanager.billing.models.Reservations;

public final class ReservationsImpl implements Reservations {
    private static final ClientLogger LOGGER = new ClientLogger(ReservationsImpl.class);

    private final ReservationsClient innerClient;

    private final com.azure.resourcemanager.billing.BillingManager serviceManager;

    public ReservationsImpl(
        ReservationsClient innerClient, com.azure.resourcemanager.billing.BillingManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

    public PagedIterable<Reservation> listByBillingAccount(String billingAccountName) {
        PagedIterable<ReservationInner> inner = this.serviceClient().listByBillingAccount(billingAccountName);
        return Utils.mapPage(inner, inner1 -> new ReservationImpl(inner1, this.manager()));
    }

    public PagedIterable<Reservation> listByBillingAccount(
        String billingAccountName,
        String filter,
        String orderby,
        String refreshSummary,
        String selectedState,
        Context context) {
        PagedIterable<ReservationInner> inner =
            this
                .serviceClient()
                .listByBillingAccount(billingAccountName, filter, orderby, refreshSummary, selectedState, context);
        return Utils.mapPage(inner, inner1 -> new ReservationImpl(inner1, this.manager()));
    }

    public PagedIterable<Reservation> listByBillingProfile(String billingAccountName, String billingProfileName) {
        PagedIterable<ReservationInner> inner =
            this.serviceClient().listByBillingProfile(billingAccountName, billingProfileName);
        return Utils.mapPage(inner, inner1 -> new ReservationImpl(inner1, this.manager()));
    }

    public PagedIterable<Reservation> listByBillingProfile(
        String billingAccountName,
        String billingProfileName,
        String filter,
        String orderby,
        String refreshSummary,
        String selectedState,
        Context context) {
        PagedIterable<ReservationInner> inner =
            this
                .serviceClient()
                .listByBillingProfile(
                    billingAccountName, billingProfileName, filter, orderby, refreshSummary, selectedState, context);
        return Utils.mapPage(inner, inner1 -> new ReservationImpl(inner1, this.manager()));
    }

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

    private com.azure.resourcemanager.billing.BillingManager manager() {
        return this.serviceManager;
    }
}
