All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.azure.resourcemanager.billing.implementation.ReservationsClientImpl Maven / Gradle / Ivy

// 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.annotation.BodyParam;
import com.azure.core.annotation.ExpectedResponses;
import com.azure.core.annotation.Get;
import com.azure.core.annotation.HeaderParam;
import com.azure.core.annotation.Headers;
import com.azure.core.annotation.Host;
import com.azure.core.annotation.HostParam;
import com.azure.core.annotation.Patch;
import com.azure.core.annotation.PathParam;
import com.azure.core.annotation.QueryParam;
import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceInterface;
import com.azure.core.annotation.ServiceMethod;
import com.azure.core.annotation.UnexpectedResponseExceptionType;
import com.azure.core.http.rest.PagedFlux;
import com.azure.core.http.rest.PagedIterable;
import com.azure.core.http.rest.PagedResponse;
import com.azure.core.http.rest.PagedResponseBase;
import com.azure.core.http.rest.Response;
import com.azure.core.http.rest.RestProxy;
import com.azure.core.management.exception.ManagementException;
import com.azure.core.management.polling.PollResult;
import com.azure.core.util.Context;
import com.azure.core.util.FluxUtil;
import com.azure.core.util.polling.PollerFlux;
import com.azure.core.util.polling.SyncPoller;
import com.azure.resourcemanager.billing.fluent.ReservationsClient;
import com.azure.resourcemanager.billing.fluent.models.ReservationInner;
import com.azure.resourcemanager.billing.models.PatchModel;
import com.azure.resourcemanager.billing.models.ReservationList;
import com.azure.resourcemanager.billing.models.ReservationsListResult;
import java.nio.ByteBuffer;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

/**
 * An instance of this class provides access to all the operations defined in ReservationsClient.
 */
public final class ReservationsClientImpl implements ReservationsClient {
    /**
     * The proxy service used to perform REST calls.
     */
    private final ReservationsService service;

    /**
     * The service client containing this operation class.
     */
    private final BillingManagementClientImpl client;

    /**
     * Initializes an instance of ReservationsClientImpl.
     * 
     * @param client the instance of the service client containing this operation class.
     */
    ReservationsClientImpl(BillingManagementClientImpl client) {
        this.service
            = RestProxy.create(ReservationsService.class, client.getHttpPipeline(), client.getSerializerAdapter());
        this.client = client;
    }

    /**
     * The interface defining all the services for BillingManagementClientReservations to be used by the proxy service
     * to perform REST calls.
     */
    @Host("{$host}")
    @ServiceInterface(name = "BillingManagementCli")
    public interface ReservationsService {
        @Headers({ "Content-Type: application/json" })
        @Get("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/reservations")
        @ExpectedResponses({ 200 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono> listByBillingAccount(@HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion, @PathParam("billingAccountName") String billingAccountName,
            @QueryParam("filter") String filter, @QueryParam("orderBy") String orderBy,
            @QueryParam("skiptoken") Float skiptoken, @QueryParam("refreshSummary") String refreshSummary,
            @QueryParam("selectedState") String selectedState, @QueryParam("take") Float take,
            @HeaderParam("Accept") String accept, Context context);

        @Headers({ "Content-Type: application/json" })
        @Get("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/reservations")
        @ExpectedResponses({ 200 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono> listByBillingProfile(@HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion, @PathParam("billingAccountName") String billingAccountName,
            @PathParam("billingProfileName") String billingProfileName, @QueryParam("filter") String filter,
            @QueryParam("orderBy") String orderBy, @QueryParam("skiptoken") Float skiptoken,
            @QueryParam("refreshSummary") String refreshSummary, @QueryParam("selectedState") String selectedState,
            @QueryParam("take") Float take, @HeaderParam("Accept") String accept, Context context);

        @Headers({ "Content-Type: application/json" })
        @Get("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/reservationOrders/{reservationOrderId}/reservations/{reservationId}")
        @ExpectedResponses({ 200 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono> getByReservationOrder(@HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion, @PathParam("billingAccountName") String billingAccountName,
            @PathParam("reservationOrderId") String reservationOrderId,
            @PathParam("reservationId") String reservationId, @QueryParam("expand") String expand,
            @HeaderParam("Accept") String accept, Context context);

        @Headers({ "Content-Type: application/json" })
        @Patch("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/reservationOrders/{reservationOrderId}/reservations/{reservationId}")
        @ExpectedResponses({ 200, 202 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono>> updateByBillingAccount(@HostParam("$host") String endpoint,
            @PathParam("billingAccountName") String billingAccountName,
            @PathParam("reservationOrderId") String reservationOrderId,
            @PathParam("reservationId") String reservationId, @QueryParam("api-version") String apiVersion,
            @BodyParam("application/json") PatchModel body, @HeaderParam("Accept") String accept, Context context);

        @Headers({ "Content-Type: application/json" })
        @Get("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/reservationOrders/{reservationOrderId}/reservations")
        @ExpectedResponses({ 200 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono> listByReservationOrder(@HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion, @PathParam("billingAccountName") String billingAccountName,
            @PathParam("reservationOrderId") String reservationOrderId, @HeaderParam("Accept") String accept,
            Context context);

        @Headers({ "Content-Type: application/json" })
        @Get("{nextLink}")
        @ExpectedResponses({ 200 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono> listByBillingAccountNext(
            @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("$host") String endpoint,
            @HeaderParam("Accept") String accept, Context context);

        @Headers({ "Content-Type: application/json" })
        @Get("{nextLink}")
        @ExpectedResponses({ 200 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono> listByBillingProfileNext(
            @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("$host") String endpoint,
            @HeaderParam("Accept") String accept, Context context);

        @Headers({ "Content-Type: application/json" })
        @Get("{nextLink}")
        @ExpectedResponses({ 200 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono> listByReservationOrderNext(
            @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("$host") String endpoint,
            @HeaderParam("Accept") String accept, Context context);
    }

    /**
     * Lists the reservations in the billing account and the roll up counts of reservations group by provisioning
     * states.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param filter The filter query option allows clients to filter a collection of resources that are addressed by a
     * request URL.
     * @param orderBy The orderby query option allows clients to request resources in a particular order.
     * @param skiptoken The number of reservations to skip from the list before returning results.
     * @param refreshSummary To indicate whether to refresh the roll up counts of the reservations group by provisioning
     * states.
     * @param selectedState The selected provisioning state.
     * @param take The number of reservations to return in API response.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the list of reservations and summary of roll out count of reservations in each state along with
     * {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> listByBillingAccountSinglePageAsync(String billingAccountName,
        String filter, String orderBy, Float skiptoken, String refreshSummary, String selectedState, Float take) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (billingAccountName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter billingAccountName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(context -> service.listByBillingAccount(this.client.getEndpoint(), this.client.getApiVersion(),
                billingAccountName, filter, orderBy, skiptoken, refreshSummary, selectedState, take, accept, context))
            .>map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(),
                res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Lists the reservations in the billing account and the roll up counts of reservations group by provisioning
     * states.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param filter The filter query option allows clients to filter a collection of resources that are addressed by a
     * request URL.
     * @param orderBy The orderby query option allows clients to request resources in a particular order.
     * @param skiptoken The number of reservations to skip from the list before returning results.
     * @param refreshSummary To indicate whether to refresh the roll up counts of the reservations group by provisioning
     * states.
     * @param selectedState The selected provisioning state.
     * @param take The number of reservations to return in API response.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the list of reservations and summary of roll out count of reservations in each state along with
     * {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> listByBillingAccountSinglePageAsync(String billingAccountName,
        String filter, String orderBy, Float skiptoken, String refreshSummary, String selectedState, Float take,
        Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (billingAccountName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter billingAccountName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .listByBillingAccount(this.client.getEndpoint(), this.client.getApiVersion(), billingAccountName, filter,
                orderBy, skiptoken, refreshSummary, selectedState, take, accept, context)
            .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(),
                res.getValue().value(), res.getValue().nextLink(), null));
    }

    /**
     * Lists the reservations in the billing account and the roll up counts of reservations group by provisioning
     * states.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param filter The filter query option allows clients to filter a collection of resources that are addressed by a
     * request URL.
     * @param orderBy The orderby query option allows clients to request resources in a particular order.
     * @param skiptoken The number of reservations to skip from the list before returning results.
     * @param refreshSummary To indicate whether to refresh the roll up counts of the reservations group by provisioning
     * states.
     * @param selectedState The selected provisioning state.
     * @param take The number of reservations to return in API response.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the list of reservations and summary of roll out count of reservations in each state as paginated
     * response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux listByBillingAccountAsync(String billingAccountName, String filter,
        String orderBy, Float skiptoken, String refreshSummary, String selectedState, Float take) {
        return new PagedFlux<>(() -> listByBillingAccountSinglePageAsync(billingAccountName, filter, orderBy, skiptoken,
            refreshSummary, selectedState, take), nextLink -> listByBillingAccountNextSinglePageAsync(nextLink));
    }

    /**
     * Lists the reservations in the billing account and the roll up counts of reservations group by provisioning
     * states.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the list of reservations and summary of roll out count of reservations in each state as paginated
     * response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux listByBillingAccountAsync(String billingAccountName) {
        final String filter = null;
        final String orderBy = null;
        final Float skiptoken = null;
        final String refreshSummary = null;
        final String selectedState = null;
        final Float take = null;
        return new PagedFlux<>(() -> listByBillingAccountSinglePageAsync(billingAccountName, filter, orderBy, skiptoken,
            refreshSummary, selectedState, take), nextLink -> listByBillingAccountNextSinglePageAsync(nextLink));
    }

    /**
     * Lists the reservations in the billing account and the roll up counts of reservations group by provisioning
     * states.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param filter The filter query option allows clients to filter a collection of resources that are addressed by a
     * request URL.
     * @param orderBy The orderby query option allows clients to request resources in a particular order.
     * @param skiptoken The number of reservations to skip from the list before returning results.
     * @param refreshSummary To indicate whether to refresh the roll up counts of the reservations group by provisioning
     * states.
     * @param selectedState The selected provisioning state.
     * @param take The number of reservations to return in API response.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the list of reservations and summary of roll out count of reservations in each state as paginated
     * response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux listByBillingAccountAsync(String billingAccountName, String filter,
        String orderBy, Float skiptoken, String refreshSummary, String selectedState, Float take, Context context) {
        return new PagedFlux<>(() -> listByBillingAccountSinglePageAsync(billingAccountName, filter, orderBy, skiptoken,
            refreshSummary, selectedState, take, context),
            nextLink -> listByBillingAccountNextSinglePageAsync(nextLink, context));
    }

    /**
     * Lists the reservations in the billing account and the roll up counts of reservations group by provisioning
     * states.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the list of reservations and summary of roll out count of reservations in each state as paginated
     * response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable listByBillingAccount(String billingAccountName) {
        final String filter = null;
        final String orderBy = null;
        final Float skiptoken = null;
        final String refreshSummary = null;
        final String selectedState = null;
        final Float take = null;
        return new PagedIterable<>(listByBillingAccountAsync(billingAccountName, filter, orderBy, skiptoken,
            refreshSummary, selectedState, take));
    }

    /**
     * Lists the reservations in the billing account and the roll up counts of reservations group by provisioning
     * states.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param filter The filter query option allows clients to filter a collection of resources that are addressed by a
     * request URL.
     * @param orderBy The orderby query option allows clients to request resources in a particular order.
     * @param skiptoken The number of reservations to skip from the list before returning results.
     * @param refreshSummary To indicate whether to refresh the roll up counts of the reservations group by provisioning
     * states.
     * @param selectedState The selected provisioning state.
     * @param take The number of reservations to return in API response.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the list of reservations and summary of roll out count of reservations in each state as paginated
     * response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable listByBillingAccount(String billingAccountName, String filter,
        String orderBy, Float skiptoken, String refreshSummary, String selectedState, Float take, Context context) {
        return new PagedIterable<>(listByBillingAccountAsync(billingAccountName, filter, orderBy, skiptoken,
            refreshSummary, selectedState, take, context));
    }

    /**
     * Lists the reservations for a billing profile and the roll up counts of reservations group by provisioning state.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingProfileName The ID that uniquely identifies a billing profile.
     * @param filter The filter query option allows clients to filter a collection of resources that are addressed by a
     * request URL.
     * @param orderBy The orderby query option allows clients to request resources in a particular order.
     * @param skiptoken The number of reservations to skip from the list before returning results.
     * @param refreshSummary To indicate whether to refresh the roll up counts of the reservations group by provisioning
     * states.
     * @param selectedState The selected provisioning state.
     * @param take The number of reservations to return in API response.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the list of reservations and summary of roll out count of reservations in each state along with
     * {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> listByBillingProfileSinglePageAsync(String billingAccountName,
        String billingProfileName, String filter, String orderBy, Float skiptoken, String refreshSummary,
        String selectedState, Float take) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (billingAccountName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter billingAccountName is required and cannot be null."));
        }
        if (billingProfileName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter billingProfileName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(context -> service.listByBillingProfile(this.client.getEndpoint(), this.client.getApiVersion(),
                billingAccountName, billingProfileName, filter, orderBy, skiptoken, refreshSummary, selectedState, take,
                accept, context))
            .>map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(),
                res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Lists the reservations for a billing profile and the roll up counts of reservations group by provisioning state.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingProfileName The ID that uniquely identifies a billing profile.
     * @param filter The filter query option allows clients to filter a collection of resources that are addressed by a
     * request URL.
     * @param orderBy The orderby query option allows clients to request resources in a particular order.
     * @param skiptoken The number of reservations to skip from the list before returning results.
     * @param refreshSummary To indicate whether to refresh the roll up counts of the reservations group by provisioning
     * states.
     * @param selectedState The selected provisioning state.
     * @param take The number of reservations to return in API response.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the list of reservations and summary of roll out count of reservations in each state along with
     * {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> listByBillingProfileSinglePageAsync(String billingAccountName,
        String billingProfileName, String filter, String orderBy, Float skiptoken, String refreshSummary,
        String selectedState, Float take, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (billingAccountName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter billingAccountName is required and cannot be null."));
        }
        if (billingProfileName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter billingProfileName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .listByBillingProfile(this.client.getEndpoint(), this.client.getApiVersion(), billingAccountName,
                billingProfileName, filter, orderBy, skiptoken, refreshSummary, selectedState, take, accept, context)
            .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(),
                res.getValue().value(), res.getValue().nextLink(), null));
    }

    /**
     * Lists the reservations for a billing profile and the roll up counts of reservations group by provisioning state.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingProfileName The ID that uniquely identifies a billing profile.
     * @param filter The filter query option allows clients to filter a collection of resources that are addressed by a
     * request URL.
     * @param orderBy The orderby query option allows clients to request resources in a particular order.
     * @param skiptoken The number of reservations to skip from the list before returning results.
     * @param refreshSummary To indicate whether to refresh the roll up counts of the reservations group by provisioning
     * states.
     * @param selectedState The selected provisioning state.
     * @param take The number of reservations to return in API response.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the list of reservations and summary of roll out count of reservations in each state as paginated
     * response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux listByBillingProfileAsync(String billingAccountName, String billingProfileName,
        String filter, String orderBy, Float skiptoken, String refreshSummary, String selectedState, Float take) {
        return new PagedFlux<>(
            () -> listByBillingProfileSinglePageAsync(billingAccountName, billingProfileName, filter, orderBy,
                skiptoken, refreshSummary, selectedState, take),
            nextLink -> listByBillingProfileNextSinglePageAsync(nextLink));
    }

    /**
     * Lists the reservations for a billing profile and the roll up counts of reservations group by provisioning state.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingProfileName The ID that uniquely identifies a billing profile.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the list of reservations and summary of roll out count of reservations in each state as paginated
     * response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux listByBillingProfileAsync(String billingAccountName,
        String billingProfileName) {
        final String filter = null;
        final String orderBy = null;
        final Float skiptoken = null;
        final String refreshSummary = null;
        final String selectedState = null;
        final Float take = null;
        return new PagedFlux<>(
            () -> listByBillingProfileSinglePageAsync(billingAccountName, billingProfileName, filter, orderBy,
                skiptoken, refreshSummary, selectedState, take),
            nextLink -> listByBillingProfileNextSinglePageAsync(nextLink));
    }

    /**
     * Lists the reservations for a billing profile and the roll up counts of reservations group by provisioning state.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingProfileName The ID that uniquely identifies a billing profile.
     * @param filter The filter query option allows clients to filter a collection of resources that are addressed by a
     * request URL.
     * @param orderBy The orderby query option allows clients to request resources in a particular order.
     * @param skiptoken The number of reservations to skip from the list before returning results.
     * @param refreshSummary To indicate whether to refresh the roll up counts of the reservations group by provisioning
     * states.
     * @param selectedState The selected provisioning state.
     * @param take The number of reservations to return in API response.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the list of reservations and summary of roll out count of reservations in each state as paginated
     * response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux listByBillingProfileAsync(String billingAccountName, String billingProfileName,
        String filter, String orderBy, Float skiptoken, String refreshSummary, String selectedState, Float take,
        Context context) {
        return new PagedFlux<>(
            () -> listByBillingProfileSinglePageAsync(billingAccountName, billingProfileName, filter, orderBy,
                skiptoken, refreshSummary, selectedState, take, context),
            nextLink -> listByBillingProfileNextSinglePageAsync(nextLink, context));
    }

    /**
     * Lists the reservations for a billing profile and the roll up counts of reservations group by provisioning state.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingProfileName The ID that uniquely identifies a billing profile.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the list of reservations and summary of roll out count of reservations in each state as paginated
     * response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable listByBillingProfile(String billingAccountName, String billingProfileName) {
        final String filter = null;
        final String orderBy = null;
        final Float skiptoken = null;
        final String refreshSummary = null;
        final String selectedState = null;
        final Float take = null;
        return new PagedIterable<>(listByBillingProfileAsync(billingAccountName, billingProfileName, filter, orderBy,
            skiptoken, refreshSummary, selectedState, take));
    }

    /**
     * Lists the reservations for a billing profile and the roll up counts of reservations group by provisioning state.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingProfileName The ID that uniquely identifies a billing profile.
     * @param filter The filter query option allows clients to filter a collection of resources that are addressed by a
     * request URL.
     * @param orderBy The orderby query option allows clients to request resources in a particular order.
     * @param skiptoken The number of reservations to skip from the list before returning results.
     * @param refreshSummary To indicate whether to refresh the roll up counts of the reservations group by provisioning
     * states.
     * @param selectedState The selected provisioning state.
     * @param take The number of reservations to return in API response.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the list of reservations and summary of roll out count of reservations in each state as paginated
     * response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable listByBillingProfile(String billingAccountName, String billingProfileName,
        String filter, String orderBy, Float skiptoken, String refreshSummary, String selectedState, Float take,
        Context context) {
        return new PagedIterable<>(listByBillingProfileAsync(billingAccountName, billingProfileName, filter, orderBy,
            skiptoken, refreshSummary, selectedState, take, context));
    }

    /**
     * Get Reservation details in the billing account.
     * 
     * Get specific Reservation details in the billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param reservationOrderId Order Id of the reservation.
     * @param reservationId Id of the reservation item.
     * @param expand May be used to expand the detail information of some properties.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return specific Reservation details in the billing account along with {@link Response} on successful completion
     * of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> getByReservationOrderWithResponseAsync(String billingAccountName,
        String reservationOrderId, String reservationId, String expand) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (billingAccountName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter billingAccountName is required and cannot be null."));
        }
        if (reservationOrderId == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter reservationOrderId is required and cannot be null."));
        }
        if (reservationId == null) {
            return Mono.error(new IllegalArgumentException("Parameter reservationId is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context -> service.getByReservationOrder(this.client.getEndpoint(), this.client.getApiVersion(),
                    billingAccountName, reservationOrderId, reservationId, expand, accept, context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Get Reservation details in the billing account.
     * 
     * Get specific Reservation details in the billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param reservationOrderId Order Id of the reservation.
     * @param reservationId Id of the reservation item.
     * @param expand May be used to expand the detail information of some properties.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return specific Reservation details in the billing account along with {@link Response} on successful completion
     * of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> getByReservationOrderWithResponseAsync(String billingAccountName,
        String reservationOrderId, String reservationId, String expand, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (billingAccountName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter billingAccountName is required and cannot be null."));
        }
        if (reservationOrderId == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter reservationOrderId is required and cannot be null."));
        }
        if (reservationId == null) {
            return Mono.error(new IllegalArgumentException("Parameter reservationId is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service.getByReservationOrder(this.client.getEndpoint(), this.client.getApiVersion(), billingAccountName,
            reservationOrderId, reservationId, expand, accept, context);
    }

    /**
     * Get Reservation details in the billing account.
     * 
     * Get specific Reservation details in the billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param reservationOrderId Order Id of the reservation.
     * @param reservationId Id of the reservation item.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return specific Reservation details in the billing account on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono getByReservationOrderAsync(String billingAccountName, String reservationOrderId,
        String reservationId) {
        final String expand = null;
        return getByReservationOrderWithResponseAsync(billingAccountName, reservationOrderId, reservationId, expand)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Get Reservation details in the billing account.
     * 
     * Get specific Reservation details in the billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param reservationOrderId Order Id of the reservation.
     * @param reservationId Id of the reservation item.
     * @param expand May be used to expand the detail information of some properties.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return specific Reservation details in the billing account along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response getByReservationOrderWithResponse(String billingAccountName,
        String reservationOrderId, String reservationId, String expand, Context context) {
        return getByReservationOrderWithResponseAsync(billingAccountName, reservationOrderId, reservationId, expand,
            context).block();
    }

    /**
     * Get Reservation details in the billing account.
     * 
     * Get specific Reservation details in the billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param reservationOrderId Order Id of the reservation.
     * @param reservationId Id of the reservation item.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return specific Reservation details in the billing account.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ReservationInner getByReservationOrder(String billingAccountName, String reservationOrderId,
        String reservationId) {
        final String expand = null;
        return getByReservationOrderWithResponse(billingAccountName, reservationOrderId, reservationId, expand,
            Context.NONE).getValue();
    }

    /**
     * Update reservation by billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param reservationOrderId Order Id of the reservation.
     * @param reservationId Id of the reservation item.
     * @param body Request body for patching a reservation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the definition of the reservation along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono>> updateByBillingAccountWithResponseAsync(String billingAccountName,
        String reservationOrderId, String reservationId, PatchModel body) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (billingAccountName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter billingAccountName is required and cannot be null."));
        }
        if (reservationOrderId == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter reservationOrderId is required and cannot be null."));
        }
        if (reservationId == null) {
            return Mono.error(new IllegalArgumentException("Parameter reservationId is required and cannot be null."));
        }
        if (body == null) {
            return Mono.error(new IllegalArgumentException("Parameter body is required and cannot be null."));
        } else {
            body.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(context -> service.updateByBillingAccount(this.client.getEndpoint(), billingAccountName,
                reservationOrderId, reservationId, this.client.getApiVersion(), body, accept, context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Update reservation by billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param reservationOrderId Order Id of the reservation.
     * @param reservationId Id of the reservation item.
     * @param body Request body for patching a reservation.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the definition of the reservation along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono>> updateByBillingAccountWithResponseAsync(String billingAccountName,
        String reservationOrderId, String reservationId, PatchModel body, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (billingAccountName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter billingAccountName is required and cannot be null."));
        }
        if (reservationOrderId == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter reservationOrderId is required and cannot be null."));
        }
        if (reservationId == null) {
            return Mono.error(new IllegalArgumentException("Parameter reservationId is required and cannot be null."));
        }
        if (body == null) {
            return Mono.error(new IllegalArgumentException("Parameter body is required and cannot be null."));
        } else {
            body.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service.updateByBillingAccount(this.client.getEndpoint(), billingAccountName, reservationOrderId,
            reservationId, this.client.getApiVersion(), body, accept, context);
    }

    /**
     * Update reservation by billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param reservationOrderId Order Id of the reservation.
     * @param reservationId Id of the reservation item.
     * @param body Request body for patching a reservation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link PollerFlux} for polling of the definition of the reservation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux, ReservationInner> beginUpdateByBillingAccountAsync(
        String billingAccountName, String reservationOrderId, String reservationId, PatchModel body) {
        Mono>> mono
            = updateByBillingAccountWithResponseAsync(billingAccountName, reservationOrderId, reservationId, body);
        return this.client.getLroResult(mono, this.client.getHttpPipeline(),
            ReservationInner.class, ReservationInner.class, this.client.getContext());
    }

    /**
     * Update reservation by billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param reservationOrderId Order Id of the reservation.
     * @param reservationId Id of the reservation item.
     * @param body Request body for patching a reservation.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link PollerFlux} for polling of the definition of the reservation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux, ReservationInner> beginUpdateByBillingAccountAsync(
        String billingAccountName, String reservationOrderId, String reservationId, PatchModel body, Context context) {
        context = this.client.mergeContext(context);
        Mono>> mono = updateByBillingAccountWithResponseAsync(billingAccountName,
            reservationOrderId, reservationId, body, context);
        return this.client.getLroResult(mono, this.client.getHttpPipeline(),
            ReservationInner.class, ReservationInner.class, context);
    }

    /**
     * Update reservation by billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param reservationOrderId Order Id of the reservation.
     * @param reservationId Id of the reservation item.
     * @param body Request body for patching a reservation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link SyncPoller} for polling of the definition of the reservation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller, ReservationInner> beginUpdateByBillingAccount(
        String billingAccountName, String reservationOrderId, String reservationId, PatchModel body) {
        return this.beginUpdateByBillingAccountAsync(billingAccountName, reservationOrderId, reservationId, body)
            .getSyncPoller();
    }

    /**
     * Update reservation by billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param reservationOrderId Order Id of the reservation.
     * @param reservationId Id of the reservation item.
     * @param body Request body for patching a reservation.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link SyncPoller} for polling of the definition of the reservation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller, ReservationInner> beginUpdateByBillingAccount(
        String billingAccountName, String reservationOrderId, String reservationId, PatchModel body, Context context) {
        return this
            .beginUpdateByBillingAccountAsync(billingAccountName, reservationOrderId, reservationId, body, context)
            .getSyncPoller();
    }

    /**
     * Update reservation by billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param reservationOrderId Order Id of the reservation.
     * @param reservationId Id of the reservation item.
     * @param body Request body for patching a reservation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the definition of the reservation on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono updateByBillingAccountAsync(String billingAccountName, String reservationOrderId,
        String reservationId, PatchModel body) {
        return beginUpdateByBillingAccountAsync(billingAccountName, reservationOrderId, reservationId, body).last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Update reservation by billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param reservationOrderId Order Id of the reservation.
     * @param reservationId Id of the reservation item.
     * @param body Request body for patching a reservation.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the definition of the reservation on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono updateByBillingAccountAsync(String billingAccountName, String reservationOrderId,
        String reservationId, PatchModel body, Context context) {
        return beginUpdateByBillingAccountAsync(billingAccountName, reservationOrderId, reservationId, body, context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Update reservation by billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param reservationOrderId Order Id of the reservation.
     * @param reservationId Id of the reservation item.
     * @param body Request body for patching a reservation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the definition of the reservation.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ReservationInner updateByBillingAccount(String billingAccountName, String reservationOrderId,
        String reservationId, PatchModel body) {
        return updateByBillingAccountAsync(billingAccountName, reservationOrderId, reservationId, body).block();
    }

    /**
     * Update reservation by billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param reservationOrderId Order Id of the reservation.
     * @param reservationId Id of the reservation item.
     * @param body Request body for patching a reservation.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the definition of the reservation.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public ReservationInner updateByBillingAccount(String billingAccountName, String reservationOrderId,
        String reservationId, PatchModel body, Context context) {
        return updateByBillingAccountAsync(billingAccountName, reservationOrderId, reservationId, body, context)
            .block();
    }

    /**
     * Get Reservations in a given reservation Order in the billing account
     * 
     * List Reservations within a single ReservationOrder in the billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param reservationOrderId Order Id of the reservation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return list of `Reservations along with {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> listByReservationOrderSinglePageAsync(String billingAccountName,
        String reservationOrderId) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (billingAccountName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter billingAccountName is required and cannot be null."));
        }
        if (reservationOrderId == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter reservationOrderId is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(context -> service.listByReservationOrder(this.client.getEndpoint(),
                this.client.getApiVersion(), billingAccountName, reservationOrderId, accept, context))
            .>map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(),
                res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Get Reservations in a given reservation Order in the billing account
     * 
     * List Reservations within a single ReservationOrder in the billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param reservationOrderId Order Id of the reservation.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return list of `Reservations along with {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> listByReservationOrderSinglePageAsync(String billingAccountName,
        String reservationOrderId, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (billingAccountName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter billingAccountName is required and cannot be null."));
        }
        if (reservationOrderId == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter reservationOrderId is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .listByReservationOrder(this.client.getEndpoint(), this.client.getApiVersion(), billingAccountName,
                reservationOrderId, accept, context)
            .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(),
                res.getValue().value(), res.getValue().nextLink(), null));
    }

    /**
     * Get Reservations in a given reservation Order in the billing account
     * 
     * List Reservations within a single ReservationOrder in the billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param reservationOrderId Order Id of the reservation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return list of `Reservations as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux listByReservationOrderAsync(String billingAccountName,
        String reservationOrderId) {
        return new PagedFlux<>(() -> listByReservationOrderSinglePageAsync(billingAccountName, reservationOrderId),
            nextLink -> listByReservationOrderNextSinglePageAsync(nextLink));
    }

    /**
     * Get Reservations in a given reservation Order in the billing account
     * 
     * List Reservations within a single ReservationOrder in the billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param reservationOrderId Order Id of the reservation.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return list of `Reservations as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux listByReservationOrderAsync(String billingAccountName,
        String reservationOrderId, Context context) {
        return new PagedFlux<>(
            () -> listByReservationOrderSinglePageAsync(billingAccountName, reservationOrderId, context),
            nextLink -> listByReservationOrderNextSinglePageAsync(nextLink, context));
    }

    /**
     * Get Reservations in a given reservation Order in the billing account
     * 
     * List Reservations within a single ReservationOrder in the billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param reservationOrderId Order Id of the reservation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return list of `Reservations as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable listByReservationOrder(String billingAccountName,
        String reservationOrderId) {
        return new PagedIterable<>(listByReservationOrderAsync(billingAccountName, reservationOrderId));
    }

    /**
     * Get Reservations in a given reservation Order in the billing account
     * 
     * List Reservations within a single ReservationOrder in the billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param reservationOrderId Order Id of the reservation.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return list of `Reservations as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable listByReservationOrder(String billingAccountName, String reservationOrderId,
        Context context) {
        return new PagedIterable<>(listByReservationOrderAsync(billingAccountName, reservationOrderId, context));
    }

    /**
     * Get the next page of items.
     * 
     * @param nextLink The URL to get the next list of items.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the list of reservations and summary of roll out count of reservations in each state along with
     * {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> listByBillingAccountNextSinglePageAsync(String nextLink) {
        if (nextLink == null) {
            return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null."));
        }
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context -> service.listByBillingAccountNext(nextLink, this.client.getEndpoint(), accept, context))
            .>map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(),
                res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Get the next page of items.
     * 
     * @param nextLink The URL to get the next list of items.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the list of reservations and summary of roll out count of reservations in each state along with
     * {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> listByBillingAccountNextSinglePageAsync(String nextLink,
        Context context) {
        if (nextLink == null) {
            return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null."));
        }
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service.listByBillingAccountNext(nextLink, this.client.getEndpoint(), accept, context)
            .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(),
                res.getValue().value(), res.getValue().nextLink(), null));
    }

    /**
     * Get the next page of items.
     * 
     * @param nextLink The URL to get the next list of items.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the list of reservations and summary of roll out count of reservations in each state along with
     * {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> listByBillingProfileNextSinglePageAsync(String nextLink) {
        if (nextLink == null) {
            return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null."));
        }
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context -> service.listByBillingProfileNext(nextLink, this.client.getEndpoint(), accept, context))
            .>map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(),
                res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Get the next page of items.
     * 
     * @param nextLink The URL to get the next list of items.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the list of reservations and summary of roll out count of reservations in each state along with
     * {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> listByBillingProfileNextSinglePageAsync(String nextLink,
        Context context) {
        if (nextLink == null) {
            return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null."));
        }
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service.listByBillingProfileNext(nextLink, this.client.getEndpoint(), accept, context)
            .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(),
                res.getValue().value(), res.getValue().nextLink(), null));
    }

    /**
     * Get the next page of items.
     * 
     * @param nextLink The URL to get the next list of items.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return list of `Reservations along with {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> listByReservationOrderNextSinglePageAsync(String nextLink) {
        if (nextLink == null) {
            return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null."));
        }
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context -> service.listByReservationOrderNext(nextLink, this.client.getEndpoint(), accept, context))
            .>map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(),
                res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Get the next page of items.
     * 
     * @param nextLink The URL to get the next list of items.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return list of `Reservations along with {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> listByReservationOrderNextSinglePageAsync(String nextLink,
        Context context) {
        if (nextLink == null) {
            return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null."));
        }
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service.listByReservationOrderNext(nextLink, this.client.getEndpoint(), accept, context)
            .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(),
                res.getValue().value(), res.getValue().nextLink(), null));
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy