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

com.azure.resourcemanager.billing.implementation.SavingsPlansClientImpl 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.Post;
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.SavingsPlansClient;
import com.azure.resourcemanager.billing.fluent.models.SavingsPlanModelInner;
import com.azure.resourcemanager.billing.fluent.models.SavingsPlanValidateResponseInner;
import com.azure.resourcemanager.billing.models.SavingsPlanModelList;
import com.azure.resourcemanager.billing.models.SavingsPlanModelListResult;
import com.azure.resourcemanager.billing.models.SavingsPlanUpdateRequest;
import com.azure.resourcemanager.billing.models.SavingsPlanUpdateValidateRequest;
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 SavingsPlansClient.
 */
public final class SavingsPlansClientImpl implements SavingsPlansClient {
    /**
     * The proxy service used to perform REST calls.
     */
    private final SavingsPlansService service;

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

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

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

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

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

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

        @Headers({ "Content-Type: application/json" })
        @Post("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/savingsPlanOrders/{savingsPlanOrderId}/savingsPlans/{savingsPlanId}/validate")
        @ExpectedResponses({ 200 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono> validateUpdateByBillingAccount(
            @HostParam("$host") String endpoint, @PathParam("billingAccountName") String billingAccountName,
            @PathParam("savingsPlanOrderId") String savingsPlanOrderId,
            @PathParam("savingsPlanId") String savingsPlanId, @QueryParam("api-version") String apiVersion,
            @BodyParam("application/json") SavingsPlanUpdateValidateRequest body, @HeaderParam("Accept") String accept,
            Context context);

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

    /**
     * List savings plans in an order by billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param savingsPlanOrderId Order ID of the savings plan.
     * @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 savings plans along with {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> listBySavingsPlanOrderSinglePageAsync(String billingAccountName,
        String savingsPlanOrderId) {
        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 (savingsPlanOrderId == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter savingsPlanOrderId is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(context -> service.listBySavingsPlanOrder(this.client.getEndpoint(), billingAccountName,
                savingsPlanOrderId, this.client.getApiVersion(), 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()));
    }

    /**
     * List savings plans in an order by billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param savingsPlanOrderId Order ID of the savings plan.
     * @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 savings plans along with {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> listBySavingsPlanOrderSinglePageAsync(String billingAccountName,
        String savingsPlanOrderId, 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 (savingsPlanOrderId == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter savingsPlanOrderId is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .listBySavingsPlanOrder(this.client.getEndpoint(), billingAccountName, savingsPlanOrderId,
                this.client.getApiVersion(), accept, context)
            .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(),
                res.getValue().value(), res.getValue().nextLink(), null));
    }

    /**
     * List savings plans in an order by billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param savingsPlanOrderId Order ID of the savings plan.
     * @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 savings plans as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux listBySavingsPlanOrderAsync(String billingAccountName,
        String savingsPlanOrderId) {
        return new PagedFlux<>(() -> listBySavingsPlanOrderSinglePageAsync(billingAccountName, savingsPlanOrderId),
            nextLink -> listBySavingsPlanOrderNextSinglePageAsync(nextLink));
    }

    /**
     * List savings plans in an order by billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param savingsPlanOrderId Order ID of the savings plan.
     * @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 savings plans as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux listBySavingsPlanOrderAsync(String billingAccountName,
        String savingsPlanOrderId, Context context) {
        return new PagedFlux<>(
            () -> listBySavingsPlanOrderSinglePageAsync(billingAccountName, savingsPlanOrderId, context),
            nextLink -> listBySavingsPlanOrderNextSinglePageAsync(nextLink, context));
    }

    /**
     * List savings plans in an order by billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param savingsPlanOrderId Order ID of the savings plan.
     * @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 savings plans as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable listBySavingsPlanOrder(String billingAccountName,
        String savingsPlanOrderId) {
        return new PagedIterable<>(listBySavingsPlanOrderAsync(billingAccountName, savingsPlanOrderId));
    }

    /**
     * List savings plans in an order by billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param savingsPlanOrderId Order ID of the savings plan.
     * @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 savings plans as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable listBySavingsPlanOrder(String billingAccountName,
        String savingsPlanOrderId, Context context) {
        return new PagedIterable<>(listBySavingsPlanOrderAsync(billingAccountName, savingsPlanOrderId, context));
    }

    /**
     * List savings plans by billing account.
     * 
     * @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 savings plans to skip from the list before returning results.
     * @param take The number of savings plans to return.
     * @param selectedState The selected provisioning state.
     * @param refreshSummary To indicate whether to refresh the roll up counts of the savings plans group by
     * provisioning states.
     * @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 savings plans 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, Float take, String selectedState, String refreshSummary) {
        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(), billingAccountName,
                this.client.getApiVersion(), filter, orderBy, skiptoken, take, selectedState, refreshSummary, 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()));
    }

    /**
     * List savings plans by billing account.
     * 
     * @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 savings plans to skip from the list before returning results.
     * @param take The number of savings plans to return.
     * @param selectedState The selected provisioning state.
     * @param refreshSummary To indicate whether to refresh the roll up counts of the savings plans group by
     * provisioning states.
     * @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 savings plans 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, Float take, String selectedState, String refreshSummary,
        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(), billingAccountName, this.client.getApiVersion(), filter,
                orderBy, skiptoken, take, selectedState, refreshSummary, accept, context)
            .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(),
                res.getValue().value(), res.getValue().nextLink(), null));
    }

    /**
     * List savings plans by billing account.
     * 
     * @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 savings plans to skip from the list before returning results.
     * @param take The number of savings plans to return.
     * @param selectedState The selected provisioning state.
     * @param refreshSummary To indicate whether to refresh the roll up counts of the savings plans group by
     * provisioning states.
     * @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 savings plans as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux listByBillingAccountAsync(String billingAccountName, String filter,
        String orderBy, Float skiptoken, Float take, String selectedState, String refreshSummary) {
        return new PagedFlux<>(() -> listByBillingAccountSinglePageAsync(billingAccountName, filter, orderBy, skiptoken,
            take, selectedState, refreshSummary), nextLink -> listByBillingAccountNextSinglePageAsync(nextLink));
    }

    /**
     * List savings plans by billing account.
     * 
     * @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 list of savings plans 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 Float take = null;
        final String selectedState = null;
        final String refreshSummary = null;
        return new PagedFlux<>(() -> listByBillingAccountSinglePageAsync(billingAccountName, filter, orderBy, skiptoken,
            take, selectedState, refreshSummary), nextLink -> listByBillingAccountNextSinglePageAsync(nextLink));
    }

    /**
     * List savings plans by billing account.
     * 
     * @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 savings plans to skip from the list before returning results.
     * @param take The number of savings plans to return.
     * @param selectedState The selected provisioning state.
     * @param refreshSummary To indicate whether to refresh the roll up counts of the savings plans group by
     * provisioning states.
     * @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 savings plans as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux listByBillingAccountAsync(String billingAccountName, String filter,
        String orderBy, Float skiptoken, Float take, String selectedState, String refreshSummary, Context context) {
        return new PagedFlux<>(
            () -> listByBillingAccountSinglePageAsync(billingAccountName, filter, orderBy, skiptoken, take,
                selectedState, refreshSummary, context),
            nextLink -> listByBillingAccountNextSinglePageAsync(nextLink, context));
    }

    /**
     * List savings plans by billing account.
     * 
     * @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 list of savings plans 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 Float take = null;
        final String selectedState = null;
        final String refreshSummary = null;
        return new PagedIterable<>(listByBillingAccountAsync(billingAccountName, filter, orderBy, skiptoken, take,
            selectedState, refreshSummary));
    }

    /**
     * List savings plans by billing account.
     * 
     * @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 savings plans to skip from the list before returning results.
     * @param take The number of savings plans to return.
     * @param selectedState The selected provisioning state.
     * @param refreshSummary To indicate whether to refresh the roll up counts of the savings plans group by
     * provisioning states.
     * @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 savings plans as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable listByBillingAccount(String billingAccountName, String filter,
        String orderBy, Float skiptoken, Float take, String selectedState, String refreshSummary, Context context) {
        return new PagedIterable<>(listByBillingAccountAsync(billingAccountName, filter, orderBy, skiptoken, take,
            selectedState, refreshSummary, context));
    }

    /**
     * Get savings plan by billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param savingsPlanOrderId Order ID of the savings plan.
     * @param savingsPlanId ID of the savings plan.
     * @param expand May be used to expand the planInformation.
     * @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 savings plan by billing account along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> getByBillingAccountWithResponseAsync(String billingAccountName,
        String savingsPlanOrderId, String savingsPlanId, 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 (savingsPlanOrderId == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter savingsPlanOrderId is required and cannot be null."));
        }
        if (savingsPlanId == null) {
            return Mono.error(new IllegalArgumentException("Parameter savingsPlanId is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(context -> service.getByBillingAccount(this.client.getEndpoint(), billingAccountName,
                savingsPlanOrderId, savingsPlanId, this.client.getApiVersion(), expand, accept, context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Get savings plan by billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param savingsPlanOrderId Order ID of the savings plan.
     * @param savingsPlanId ID of the savings plan.
     * @param expand May be used to expand the planInformation.
     * @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 savings plan by billing account along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> getByBillingAccountWithResponseAsync(String billingAccountName,
        String savingsPlanOrderId, String savingsPlanId, 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 (savingsPlanOrderId == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter savingsPlanOrderId is required and cannot be null."));
        }
        if (savingsPlanId == null) {
            return Mono.error(new IllegalArgumentException("Parameter savingsPlanId is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service.getByBillingAccount(this.client.getEndpoint(), billingAccountName, savingsPlanOrderId,
            savingsPlanId, this.client.getApiVersion(), expand, accept, context);
    }

    /**
     * Get savings plan by billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param savingsPlanOrderId Order ID of the savings plan.
     * @param savingsPlanId ID of the savings plan.
     * @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 savings plan by billing account on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono getByBillingAccountAsync(String billingAccountName, String savingsPlanOrderId,
        String savingsPlanId) {
        final String expand = null;
        return getByBillingAccountWithResponseAsync(billingAccountName, savingsPlanOrderId, savingsPlanId, expand)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Get savings plan by billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param savingsPlanOrderId Order ID of the savings plan.
     * @param savingsPlanId ID of the savings plan.
     * @param expand May be used to expand the planInformation.
     * @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 savings plan by billing account along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response getByBillingAccountWithResponse(String billingAccountName,
        String savingsPlanOrderId, String savingsPlanId, String expand, Context context) {
        return getByBillingAccountWithResponseAsync(billingAccountName, savingsPlanOrderId, savingsPlanId, expand,
            context).block();
    }

    /**
     * Get savings plan by billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param savingsPlanOrderId Order ID of the savings plan.
     * @param savingsPlanId ID of the savings plan.
     * @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 savings plan by billing account.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public SavingsPlanModelInner getByBillingAccount(String billingAccountName, String savingsPlanOrderId,
        String savingsPlanId) {
        final String expand = null;
        return getByBillingAccountWithResponse(billingAccountName, savingsPlanOrderId, savingsPlanId, expand,
            Context.NONE).getValue();
    }

    /**
     * Update savings plan by billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param savingsPlanOrderId Order ID of the savings plan.
     * @param savingsPlanId ID of the savings plan.
     * @param body Request body for patching a savings plan order alias.
     * @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 savings plan along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono>> updateByBillingAccountWithResponseAsync(String billingAccountName,
        String savingsPlanOrderId, String savingsPlanId, SavingsPlanUpdateRequest 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 (savingsPlanOrderId == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter savingsPlanOrderId is required and cannot be null."));
        }
        if (savingsPlanId == null) {
            return Mono.error(new IllegalArgumentException("Parameter savingsPlanId 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,
                savingsPlanOrderId, savingsPlanId, this.client.getApiVersion(), body, accept, context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Update savings plan by billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param savingsPlanOrderId Order ID of the savings plan.
     * @param savingsPlanId ID of the savings plan.
     * @param body Request body for patching a savings plan order alias.
     * @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 savings plan along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono>> updateByBillingAccountWithResponseAsync(String billingAccountName,
        String savingsPlanOrderId, String savingsPlanId, SavingsPlanUpdateRequest 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 (savingsPlanOrderId == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter savingsPlanOrderId is required and cannot be null."));
        }
        if (savingsPlanId == null) {
            return Mono.error(new IllegalArgumentException("Parameter savingsPlanId 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, savingsPlanOrderId,
            savingsPlanId, this.client.getApiVersion(), body, accept, context);
    }

    /**
     * Update savings plan by billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param savingsPlanOrderId Order ID of the savings plan.
     * @param savingsPlanId ID of the savings plan.
     * @param body Request body for patching a savings plan order alias.
     * @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 savings plan.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux, SavingsPlanModelInner> beginUpdateByBillingAccountAsync(
        String billingAccountName, String savingsPlanOrderId, String savingsPlanId, SavingsPlanUpdateRequest body) {
        Mono>> mono
            = updateByBillingAccountWithResponseAsync(billingAccountName, savingsPlanOrderId, savingsPlanId, body);
        return this.client.getLroResult(mono,
            this.client.getHttpPipeline(), SavingsPlanModelInner.class, SavingsPlanModelInner.class,
            this.client.getContext());
    }

    /**
     * Update savings plan by billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param savingsPlanOrderId Order ID of the savings plan.
     * @param savingsPlanId ID of the savings plan.
     * @param body Request body for patching a savings plan order alias.
     * @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 savings plan.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux, SavingsPlanModelInner> beginUpdateByBillingAccountAsync(
        String billingAccountName, String savingsPlanOrderId, String savingsPlanId, SavingsPlanUpdateRequest body,
        Context context) {
        context = this.client.mergeContext(context);
        Mono>> mono = updateByBillingAccountWithResponseAsync(billingAccountName,
            savingsPlanOrderId, savingsPlanId, body, context);
        return this.client.getLroResult(mono,
            this.client.getHttpPipeline(), SavingsPlanModelInner.class, SavingsPlanModelInner.class, context);
    }

    /**
     * Update savings plan by billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param savingsPlanOrderId Order ID of the savings plan.
     * @param savingsPlanId ID of the savings plan.
     * @param body Request body for patching a savings plan order alias.
     * @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 savings plan.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller, SavingsPlanModelInner> beginUpdateByBillingAccount(
        String billingAccountName, String savingsPlanOrderId, String savingsPlanId, SavingsPlanUpdateRequest body) {
        return this.beginUpdateByBillingAccountAsync(billingAccountName, savingsPlanOrderId, savingsPlanId, body)
            .getSyncPoller();
    }

    /**
     * Update savings plan by billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param savingsPlanOrderId Order ID of the savings plan.
     * @param savingsPlanId ID of the savings plan.
     * @param body Request body for patching a savings plan order alias.
     * @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 savings plan.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller, SavingsPlanModelInner> beginUpdateByBillingAccount(
        String billingAccountName, String savingsPlanOrderId, String savingsPlanId, SavingsPlanUpdateRequest body,
        Context context) {
        return this
            .beginUpdateByBillingAccountAsync(billingAccountName, savingsPlanOrderId, savingsPlanId, body, context)
            .getSyncPoller();
    }

    /**
     * Update savings plan by billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param savingsPlanOrderId Order ID of the savings plan.
     * @param savingsPlanId ID of the savings plan.
     * @param body Request body for patching a savings plan order alias.
     * @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 savings plan on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono updateByBillingAccountAsync(String billingAccountName,
        String savingsPlanOrderId, String savingsPlanId, SavingsPlanUpdateRequest body) {
        return beginUpdateByBillingAccountAsync(billingAccountName, savingsPlanOrderId, savingsPlanId, body).last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Update savings plan by billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param savingsPlanOrderId Order ID of the savings plan.
     * @param savingsPlanId ID of the savings plan.
     * @param body Request body for patching a savings plan order alias.
     * @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 savings plan on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono updateByBillingAccountAsync(String billingAccountName,
        String savingsPlanOrderId, String savingsPlanId, SavingsPlanUpdateRequest body, Context context) {
        return beginUpdateByBillingAccountAsync(billingAccountName, savingsPlanOrderId, savingsPlanId, body, context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Update savings plan by billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param savingsPlanOrderId Order ID of the savings plan.
     * @param savingsPlanId ID of the savings plan.
     * @param body Request body for patching a savings plan order alias.
     * @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 savings plan.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public SavingsPlanModelInner updateByBillingAccount(String billingAccountName, String savingsPlanOrderId,
        String savingsPlanId, SavingsPlanUpdateRequest body) {
        return updateByBillingAccountAsync(billingAccountName, savingsPlanOrderId, savingsPlanId, body).block();
    }

    /**
     * Update savings plan by billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param savingsPlanOrderId Order ID of the savings plan.
     * @param savingsPlanId ID of the savings plan.
     * @param body Request body for patching a savings plan order alias.
     * @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 savings plan.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public SavingsPlanModelInner updateByBillingAccount(String billingAccountName, String savingsPlanOrderId,
        String savingsPlanId, SavingsPlanUpdateRequest body, Context context) {
        return updateByBillingAccountAsync(billingAccountName, savingsPlanOrderId, savingsPlanId, body, context)
            .block();
    }

    /**
     * Validate savings plan patch by billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param savingsPlanOrderId Order ID of the savings plan.
     * @param savingsPlanId ID of the savings plan.
     * @param body Request body for patching a savings plan order alias.
     * @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 savings plan update validate response along with {@link Response} on successful completion of
     * {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> validateUpdateByBillingAccountWithResponseAsync(
        String billingAccountName, String savingsPlanOrderId, String savingsPlanId,
        SavingsPlanUpdateValidateRequest 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 (savingsPlanOrderId == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter savingsPlanOrderId is required and cannot be null."));
        }
        if (savingsPlanId == null) {
            return Mono.error(new IllegalArgumentException("Parameter savingsPlanId 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.validateUpdateByBillingAccount(this.client.getEndpoint(), billingAccountName,
                    savingsPlanOrderId, savingsPlanId, this.client.getApiVersion(), body, accept, context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Validate savings plan patch by billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param savingsPlanOrderId Order ID of the savings plan.
     * @param savingsPlanId ID of the savings plan.
     * @param body Request body for patching a savings plan order alias.
     * @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 savings plan update validate response along with {@link Response} on successful completion of
     * {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> validateUpdateByBillingAccountWithResponseAsync(
        String billingAccountName, String savingsPlanOrderId, String savingsPlanId,
        SavingsPlanUpdateValidateRequest 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 (savingsPlanOrderId == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter savingsPlanOrderId is required and cannot be null."));
        }
        if (savingsPlanId == null) {
            return Mono.error(new IllegalArgumentException("Parameter savingsPlanId 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.validateUpdateByBillingAccount(this.client.getEndpoint(), billingAccountName, savingsPlanOrderId,
            savingsPlanId, this.client.getApiVersion(), body, accept, context);
    }

    /**
     * Validate savings plan patch by billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param savingsPlanOrderId Order ID of the savings plan.
     * @param savingsPlanId ID of the savings plan.
     * @param body Request body for patching a savings plan order alias.
     * @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 savings plan update validate response on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono validateUpdateByBillingAccountAsync(String billingAccountName,
        String savingsPlanOrderId, String savingsPlanId, SavingsPlanUpdateValidateRequest body) {
        return validateUpdateByBillingAccountWithResponseAsync(billingAccountName, savingsPlanOrderId, savingsPlanId,
            body).flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Validate savings plan patch by billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param savingsPlanOrderId Order ID of the savings plan.
     * @param savingsPlanId ID of the savings plan.
     * @param body Request body for patching a savings plan order alias.
     * @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 savings plan update validate response along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response validateUpdateByBillingAccountWithResponse(
        String billingAccountName, String savingsPlanOrderId, String savingsPlanId,
        SavingsPlanUpdateValidateRequest body, Context context) {
        return validateUpdateByBillingAccountWithResponseAsync(billingAccountName, savingsPlanOrderId, savingsPlanId,
            body, context).block();
    }

    /**
     * Validate savings plan patch by billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param savingsPlanOrderId Order ID of the savings plan.
     * @param savingsPlanId ID of the savings plan.
     * @param body Request body for patching a savings plan order alias.
     * @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 savings plan update validate response.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public SavingsPlanValidateResponseInner validateUpdateByBillingAccount(String billingAccountName,
        String savingsPlanOrderId, String savingsPlanId, SavingsPlanUpdateValidateRequest body) {
        return validateUpdateByBillingAccountWithResponse(billingAccountName, savingsPlanOrderId, savingsPlanId, body,
            Context.NONE).getValue();
    }

    /**
     * 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 savings plans along with {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> listBySavingsPlanOrderNextSinglePageAsync(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.listBySavingsPlanOrderNext(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 savings plans along with {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> listBySavingsPlanOrderNextSinglePageAsync(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.listBySavingsPlanOrderNext(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 savings plans 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 list of savings plans 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));
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy