// 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.Delete;
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.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.util.Context;
import com.azure.core.util.FluxUtil;
import com.azure.resourcemanager.billing.fluent.BillingRoleAssignmentsClient;
import com.azure.resourcemanager.billing.fluent.models.BillingRoleAssignmentInner;
import com.azure.resourcemanager.billing.models.BillingRoleAssignmentListResult;
import reactor.core.publisher.Mono;

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

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

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

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

        @Headers({"Content-Type: application/json"})
        @Delete(
            "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleAssignments"
                + "/{billingRoleAssignmentName}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<BillingRoleAssignmentInner>> deleteByBillingAccount(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("billingAccountName") String billingAccountName,
            @PathParam("billingRoleAssignmentName") String billingRoleAssignmentName,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Get(
            "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}"
                + "/invoiceSections/{invoiceSectionName}/billingRoleAssignments/{billingRoleAssignmentName}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<BillingRoleAssignmentInner>> getByInvoiceSection(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("billingAccountName") String billingAccountName,
            @PathParam("billingProfileName") String billingProfileName,
            @PathParam("invoiceSectionName") String invoiceSectionName,
            @PathParam("billingRoleAssignmentName") String billingRoleAssignmentName,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Delete(
            "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}"
                + "/invoiceSections/{invoiceSectionName}/billingRoleAssignments/{billingRoleAssignmentName}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<BillingRoleAssignmentInner>> deleteByInvoiceSection(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("billingAccountName") String billingAccountName,
            @PathParam("billingProfileName") String billingProfileName,
            @PathParam("invoiceSectionName") String invoiceSectionName,
            @PathParam("billingRoleAssignmentName") String billingRoleAssignmentName,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Get(
            "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}"
                + "/billingRoleAssignments/{billingRoleAssignmentName}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<BillingRoleAssignmentInner>> getByBillingProfile(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("billingAccountName") String billingAccountName,
            @PathParam("billingProfileName") String billingProfileName,
            @PathParam("billingRoleAssignmentName") String billingRoleAssignmentName,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Delete(
            "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}"
                + "/billingRoleAssignments/{billingRoleAssignmentName}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<BillingRoleAssignmentInner>> deleteByBillingProfile(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("billingAccountName") String billingAccountName,
            @PathParam("billingProfileName") String billingProfileName,
            @PathParam("billingRoleAssignmentName") String billingRoleAssignmentName,
            @HeaderParam("Accept") String accept,
            Context context);

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

        @Headers({"Content-Type: application/json"})
        @Get(
            "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}"
                + "/invoiceSections/{invoiceSectionName}/billingRoleAssignments")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<BillingRoleAssignmentListResult>> listByInvoiceSection(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("billingAccountName") String billingAccountName,
            @PathParam("billingProfileName") String billingProfileName,
            @PathParam("invoiceSectionName") String invoiceSectionName,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Get(
            "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}"
                + "/billingRoleAssignments")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<BillingRoleAssignmentListResult>> listByBillingProfile(
            @HostParam("$host") String endpoint,
            @QueryParam("api-version") String apiVersion,
            @PathParam("billingAccountName") String billingAccountName,
            @PathParam("billingProfileName") String billingProfileName,
            @HeaderParam("Accept") String accept,
            Context context);

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

    /**
     * Gets a role assignment for the caller on a billing account. The operation is supported for billing accounts with
     * agreement type Microsoft Partner Agreement or Microsoft Customer Agreement.
     *
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingRoleAssignmentName The ID that uniquely identifies a role assignment.
     * @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 a role assignment for the caller on a billing account along with {@link Response} on successful
     *     completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<BillingRoleAssignmentInner>> getByBillingAccountWithResponseAsync(
        String billingAccountName, String billingRoleAssignmentName) {
        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 (billingRoleAssignmentName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter billingRoleAssignmentName is required and cannot be null."));
        }
        final String apiVersion = "2020-05-01";
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .getByBillingAccount(
                            this.client.getEndpoint(),
                            apiVersion,
                            billingAccountName,
                            billingRoleAssignmentName,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Gets a role assignment for the caller on a billing account. The operation is supported for billing accounts with
     * agreement type Microsoft Partner Agreement or Microsoft Customer Agreement.
     *
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingRoleAssignmentName The ID that uniquely identifies a role assignment.
     * @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 a role assignment for the caller on a billing account along with {@link Response} on successful
     *     completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<BillingRoleAssignmentInner>> getByBillingAccountWithResponseAsync(
        String billingAccountName, String billingRoleAssignmentName, 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 (billingRoleAssignmentName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter billingRoleAssignmentName is required and cannot be null."));
        }
        final String apiVersion = "2020-05-01";
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .getByBillingAccount(
                this.client.getEndpoint(), apiVersion, billingAccountName, billingRoleAssignmentName, accept, context);
    }

    /**
     * Gets a role assignment for the caller on a billing account. The operation is supported for billing accounts with
     * agreement type Microsoft Partner Agreement or Microsoft Customer Agreement.
     *
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingRoleAssignmentName The ID that uniquely identifies a role assignment.
     * @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 a role assignment for the caller on a billing account on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<BillingRoleAssignmentInner> getByBillingAccountAsync(
        String billingAccountName, String billingRoleAssignmentName) {
        return getByBillingAccountWithResponseAsync(billingAccountName, billingRoleAssignmentName)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Gets a role assignment for the caller on a billing account. The operation is supported for billing accounts with
     * agreement type Microsoft Partner Agreement or Microsoft Customer Agreement.
     *
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingRoleAssignmentName The ID that uniquely identifies a role assignment.
     * @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 a role assignment for the caller on a billing account along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<BillingRoleAssignmentInner> getByBillingAccountWithResponse(
        String billingAccountName, String billingRoleAssignmentName, Context context) {
        return getByBillingAccountWithResponseAsync(billingAccountName, billingRoleAssignmentName, context).block();
    }

    /**
     * Gets a role assignment for the caller on a billing account. The operation is supported for billing accounts with
     * agreement type Microsoft Partner Agreement or Microsoft Customer Agreement.
     *
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingRoleAssignmentName The ID that uniquely identifies a role assignment.
     * @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 a role assignment for the caller on a billing account.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public BillingRoleAssignmentInner getByBillingAccount(String billingAccountName, String billingRoleAssignmentName) {
        return getByBillingAccountWithResponse(billingAccountName, billingRoleAssignmentName, Context.NONE).getValue();
    }

    /**
     * Deletes a role assignment for the caller on a billing account. The operation is supported for billing accounts
     * with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement.
     *
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingRoleAssignmentName The ID that uniquely identifies a role assignment.
     * @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 role assignment along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<BillingRoleAssignmentInner>> deleteByBillingAccountWithResponseAsync(
        String billingAccountName, String billingRoleAssignmentName) {
        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 (billingRoleAssignmentName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter billingRoleAssignmentName is required and cannot be null."));
        }
        final String apiVersion = "2020-05-01";
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .deleteByBillingAccount(
                            this.client.getEndpoint(),
                            apiVersion,
                            billingAccountName,
                            billingRoleAssignmentName,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Deletes a role assignment for the caller on a billing account. The operation is supported for billing accounts
     * with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement.
     *
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingRoleAssignmentName The ID that uniquely identifies a role assignment.
     * @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 role assignment along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<BillingRoleAssignmentInner>> deleteByBillingAccountWithResponseAsync(
        String billingAccountName, String billingRoleAssignmentName, 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 (billingRoleAssignmentName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter billingRoleAssignmentName is required and cannot be null."));
        }
        final String apiVersion = "2020-05-01";
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .deleteByBillingAccount(
                this.client.getEndpoint(), apiVersion, billingAccountName, billingRoleAssignmentName, accept, context);
    }

    /**
     * Deletes a role assignment for the caller on a billing account. The operation is supported for billing accounts
     * with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement.
     *
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingRoleAssignmentName The ID that uniquely identifies a role assignment.
     * @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 role assignment on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<BillingRoleAssignmentInner> deleteByBillingAccountAsync(
        String billingAccountName, String billingRoleAssignmentName) {
        return deleteByBillingAccountWithResponseAsync(billingAccountName, billingRoleAssignmentName)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Deletes a role assignment for the caller on a billing account. The operation is supported for billing accounts
     * with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement.
     *
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingRoleAssignmentName The ID that uniquely identifies a role assignment.
     * @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 role assignment along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<BillingRoleAssignmentInner> deleteByBillingAccountWithResponse(
        String billingAccountName, String billingRoleAssignmentName, Context context) {
        return deleteByBillingAccountWithResponseAsync(billingAccountName, billingRoleAssignmentName, context).block();
    }

    /**
     * Deletes a role assignment for the caller on a billing account. The operation is supported for billing accounts
     * with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement.
     *
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingRoleAssignmentName The ID that uniquely identifies a role assignment.
     * @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 role assignment.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public BillingRoleAssignmentInner deleteByBillingAccount(
        String billingAccountName, String billingRoleAssignmentName) {
        return deleteByBillingAccountWithResponse(billingAccountName, billingRoleAssignmentName, Context.NONE)
            .getValue();
    }

    /**
     * Gets a role assignment for the caller on an invoice section. The operation is supported for billing accounts with
     * agreement type Microsoft Customer Agreement.
     *
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingProfileName The ID that uniquely identifies a billing profile.
     * @param invoiceSectionName The ID that uniquely identifies an invoice section.
     * @param billingRoleAssignmentName The ID that uniquely identifies a role assignment.
     * @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 a role assignment for the caller on an invoice section along with {@link Response} on successful
     *     completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<BillingRoleAssignmentInner>> getByInvoiceSectionWithResponseAsync(
        String billingAccountName,
        String billingProfileName,
        String invoiceSectionName,
        String billingRoleAssignmentName) {
        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."));
        }
        if (invoiceSectionName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter invoiceSectionName is required and cannot be null."));
        }
        if (billingRoleAssignmentName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter billingRoleAssignmentName is required and cannot be null."));
        }
        final String apiVersion = "2020-05-01";
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .getByInvoiceSection(
                            this.client.getEndpoint(),
                            apiVersion,
                            billingAccountName,
                            billingProfileName,
                            invoiceSectionName,
                            billingRoleAssignmentName,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Gets a role assignment for the caller on an invoice section. The operation is supported for billing accounts with
     * agreement type Microsoft Customer Agreement.
     *
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingProfileName The ID that uniquely identifies a billing profile.
     * @param invoiceSectionName The ID that uniquely identifies an invoice section.
     * @param billingRoleAssignmentName The ID that uniquely identifies a role assignment.
     * @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 a role assignment for the caller on an invoice section along with {@link Response} on successful
     *     completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<BillingRoleAssignmentInner>> getByInvoiceSectionWithResponseAsync(
        String billingAccountName,
        String billingProfileName,
        String invoiceSectionName,
        String billingRoleAssignmentName,
        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."));
        }
        if (invoiceSectionName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter invoiceSectionName is required and cannot be null."));
        }
        if (billingRoleAssignmentName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter billingRoleAssignmentName is required and cannot be null."));
        }
        final String apiVersion = "2020-05-01";
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .getByInvoiceSection(
                this.client.getEndpoint(),
                apiVersion,
                billingAccountName,
                billingProfileName,
                invoiceSectionName,
                billingRoleAssignmentName,
                accept,
                context);
    }

    /**
     * Gets a role assignment for the caller on an invoice section. The operation is supported for billing accounts with
     * agreement type Microsoft Customer Agreement.
     *
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingProfileName The ID that uniquely identifies a billing profile.
     * @param invoiceSectionName The ID that uniquely identifies an invoice section.
     * @param billingRoleAssignmentName The ID that uniquely identifies a role assignment.
     * @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 a role assignment for the caller on an invoice section on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<BillingRoleAssignmentInner> getByInvoiceSectionAsync(
        String billingAccountName,
        String billingProfileName,
        String invoiceSectionName,
        String billingRoleAssignmentName) {
        return getByInvoiceSectionWithResponseAsync(
                billingAccountName, billingProfileName, invoiceSectionName, billingRoleAssignmentName)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Gets a role assignment for the caller on an invoice section. The operation is supported for billing accounts with
     * agreement type Microsoft Customer Agreement.
     *
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingProfileName The ID that uniquely identifies a billing profile.
     * @param invoiceSectionName The ID that uniquely identifies an invoice section.
     * @param billingRoleAssignmentName The ID that uniquely identifies a role assignment.
     * @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 a role assignment for the caller on an invoice section along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<BillingRoleAssignmentInner> getByInvoiceSectionWithResponse(
        String billingAccountName,
        String billingProfileName,
        String invoiceSectionName,
        String billingRoleAssignmentName,
        Context context) {
        return getByInvoiceSectionWithResponseAsync(
                billingAccountName, billingProfileName, invoiceSectionName, billingRoleAssignmentName, context)
            .block();
    }

    /**
     * Gets a role assignment for the caller on an invoice section. The operation is supported for billing accounts with
     * agreement type Microsoft Customer Agreement.
     *
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingProfileName The ID that uniquely identifies a billing profile.
     * @param invoiceSectionName The ID that uniquely identifies an invoice section.
     * @param billingRoleAssignmentName The ID that uniquely identifies a role assignment.
     * @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 a role assignment for the caller on an invoice section.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public BillingRoleAssignmentInner getByInvoiceSection(
        String billingAccountName,
        String billingProfileName,
        String invoiceSectionName,
        String billingRoleAssignmentName) {
        return getByInvoiceSectionWithResponse(
                billingAccountName, billingProfileName, invoiceSectionName, billingRoleAssignmentName, Context.NONE)
            .getValue();
    }

    /**
     * Deletes a role assignment for the caller on an invoice section. The operation is supported for billing accounts
     * with agreement type Microsoft Customer Agreement.
     *
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingProfileName The ID that uniquely identifies a billing profile.
     * @param invoiceSectionName The ID that uniquely identifies an invoice section.
     * @param billingRoleAssignmentName The ID that uniquely identifies a role assignment.
     * @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 role assignment along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<BillingRoleAssignmentInner>> deleteByInvoiceSectionWithResponseAsync(
        String billingAccountName,
        String billingProfileName,
        String invoiceSectionName,
        String billingRoleAssignmentName) {
        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."));
        }
        if (invoiceSectionName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter invoiceSectionName is required and cannot be null."));
        }
        if (billingRoleAssignmentName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter billingRoleAssignmentName is required and cannot be null."));
        }
        final String apiVersion = "2020-05-01";
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .deleteByInvoiceSection(
                            this.client.getEndpoint(),
                            apiVersion,
                            billingAccountName,
                            billingProfileName,
                            invoiceSectionName,
                            billingRoleAssignmentName,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Deletes a role assignment for the caller on an invoice section. The operation is supported for billing accounts
     * with agreement type Microsoft Customer Agreement.
     *
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingProfileName The ID that uniquely identifies a billing profile.
     * @param invoiceSectionName The ID that uniquely identifies an invoice section.
     * @param billingRoleAssignmentName The ID that uniquely identifies a role assignment.
     * @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 role assignment along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<BillingRoleAssignmentInner>> deleteByInvoiceSectionWithResponseAsync(
        String billingAccountName,
        String billingProfileName,
        String invoiceSectionName,
        String billingRoleAssignmentName,
        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."));
        }
        if (invoiceSectionName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter invoiceSectionName is required and cannot be null."));
        }
        if (billingRoleAssignmentName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter billingRoleAssignmentName is required and cannot be null."));
        }
        final String apiVersion = "2020-05-01";
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .deleteByInvoiceSection(
                this.client.getEndpoint(),
                apiVersion,
                billingAccountName,
                billingProfileName,
                invoiceSectionName,
                billingRoleAssignmentName,
                accept,
                context);
    }

    /**
     * Deletes a role assignment for the caller on an invoice section. The operation is supported for billing accounts
     * with agreement type Microsoft Customer Agreement.
     *
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingProfileName The ID that uniquely identifies a billing profile.
     * @param invoiceSectionName The ID that uniquely identifies an invoice section.
     * @param billingRoleAssignmentName The ID that uniquely identifies a role assignment.
     * @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 role assignment on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<BillingRoleAssignmentInner> deleteByInvoiceSectionAsync(
        String billingAccountName,
        String billingProfileName,
        String invoiceSectionName,
        String billingRoleAssignmentName) {
        return deleteByInvoiceSectionWithResponseAsync(
                billingAccountName, billingProfileName, invoiceSectionName, billingRoleAssignmentName)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Deletes a role assignment for the caller on an invoice section. The operation is supported for billing accounts
     * with agreement type Microsoft Customer Agreement.
     *
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingProfileName The ID that uniquely identifies a billing profile.
     * @param invoiceSectionName The ID that uniquely identifies an invoice section.
     * @param billingRoleAssignmentName The ID that uniquely identifies a role assignment.
     * @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 role assignment along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<BillingRoleAssignmentInner> deleteByInvoiceSectionWithResponse(
        String billingAccountName,
        String billingProfileName,
        String invoiceSectionName,
        String billingRoleAssignmentName,
        Context context) {
        return deleteByInvoiceSectionWithResponseAsync(
                billingAccountName, billingProfileName, invoiceSectionName, billingRoleAssignmentName, context)
            .block();
    }

    /**
     * Deletes a role assignment for the caller on an invoice section. The operation is supported for billing accounts
     * with agreement type Microsoft Customer Agreement.
     *
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingProfileName The ID that uniquely identifies a billing profile.
     * @param invoiceSectionName The ID that uniquely identifies an invoice section.
     * @param billingRoleAssignmentName The ID that uniquely identifies a role assignment.
     * @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 role assignment.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public BillingRoleAssignmentInner deleteByInvoiceSection(
        String billingAccountName,
        String billingProfileName,
        String invoiceSectionName,
        String billingRoleAssignmentName) {
        return deleteByInvoiceSectionWithResponse(
                billingAccountName, billingProfileName, invoiceSectionName, billingRoleAssignmentName, Context.NONE)
            .getValue();
    }

    /**
     * Gets a role assignment for the caller on a billing profile. The operation is supported for billing accounts with
     * agreement type Microsoft Partner Agreement or Microsoft Customer Agreement.
     *
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingProfileName The ID that uniquely identifies a billing profile.
     * @param billingRoleAssignmentName The ID that uniquely identifies a role assignment.
     * @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 a role assignment for the caller on a billing profile along with {@link Response} on successful
     *     completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<BillingRoleAssignmentInner>> getByBillingProfileWithResponseAsync(
        String billingAccountName, String billingProfileName, String billingRoleAssignmentName) {
        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."));
        }
        if (billingRoleAssignmentName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter billingRoleAssignmentName is required and cannot be null."));
        }
        final String apiVersion = "2020-05-01";
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .getByBillingProfile(
                            this.client.getEndpoint(),
                            apiVersion,
                            billingAccountName,
                            billingProfileName,
                            billingRoleAssignmentName,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Gets a role assignment for the caller on a billing profile. The operation is supported for billing accounts with
     * agreement type Microsoft Partner Agreement or Microsoft Customer Agreement.
     *
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingProfileName The ID that uniquely identifies a billing profile.
     * @param billingRoleAssignmentName The ID that uniquely identifies a role assignment.
     * @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 a role assignment for the caller on a billing profile along with {@link Response} on successful
     *     completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<BillingRoleAssignmentInner>> getByBillingProfileWithResponseAsync(
        String billingAccountName, String billingProfileName, String billingRoleAssignmentName, 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."));
        }
        if (billingRoleAssignmentName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter billingRoleAssignmentName is required and cannot be null."));
        }
        final String apiVersion = "2020-05-01";
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .getByBillingProfile(
                this.client.getEndpoint(),
                apiVersion,
                billingAccountName,
                billingProfileName,
                billingRoleAssignmentName,
                accept,
                context);
    }

    /**
     * Gets a role assignment for the caller on a billing profile. The operation is supported for billing accounts with
     * agreement type Microsoft Partner Agreement or Microsoft Customer Agreement.
     *
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingProfileName The ID that uniquely identifies a billing profile.
     * @param billingRoleAssignmentName The ID that uniquely identifies a role assignment.
     * @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 a role assignment for the caller on a billing profile on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<BillingRoleAssignmentInner> getByBillingProfileAsync(
        String billingAccountName, String billingProfileName, String billingRoleAssignmentName) {
        return getByBillingProfileWithResponseAsync(billingAccountName, billingProfileName, billingRoleAssignmentName)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Gets a role assignment for the caller on a billing profile. The operation is supported for billing accounts with
     * agreement type Microsoft Partner Agreement or Microsoft Customer Agreement.
     *
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingProfileName The ID that uniquely identifies a billing profile.
     * @param billingRoleAssignmentName The ID that uniquely identifies a role assignment.
     * @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 a role assignment for the caller on a billing profile along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<BillingRoleAssignmentInner> getByBillingProfileWithResponse(
        String billingAccountName, String billingProfileName, String billingRoleAssignmentName, Context context) {
        return getByBillingProfileWithResponseAsync(
                billingAccountName, billingProfileName, billingRoleAssignmentName, context)
            .block();
    }

    /**
     * Gets a role assignment for the caller on a billing profile. The operation is supported for billing accounts with
     * agreement type Microsoft Partner Agreement or Microsoft Customer Agreement.
     *
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingProfileName The ID that uniquely identifies a billing profile.
     * @param billingRoleAssignmentName The ID that uniquely identifies a role assignment.
     * @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 a role assignment for the caller on a billing profile.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public BillingRoleAssignmentInner getByBillingProfile(
        String billingAccountName, String billingProfileName, String billingRoleAssignmentName) {
        return getByBillingProfileWithResponse(
                billingAccountName, billingProfileName, billingRoleAssignmentName, Context.NONE)
            .getValue();
    }

    /**
     * Deletes a role assignment for the caller on a billing profile. The operation is supported for billing accounts
     * with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement.
     *
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingProfileName The ID that uniquely identifies a billing profile.
     * @param billingRoleAssignmentName The ID that uniquely identifies a role assignment.
     * @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 role assignment along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<BillingRoleAssignmentInner>> deleteByBillingProfileWithResponseAsync(
        String billingAccountName, String billingProfileName, String billingRoleAssignmentName) {
        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."));
        }
        if (billingRoleAssignmentName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter billingRoleAssignmentName is required and cannot be null."));
        }
        final String apiVersion = "2020-05-01";
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .deleteByBillingProfile(
                            this.client.getEndpoint(),
                            apiVersion,
                            billingAccountName,
                            billingProfileName,
                            billingRoleAssignmentName,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Deletes a role assignment for the caller on a billing profile. The operation is supported for billing accounts
     * with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement.
     *
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingProfileName The ID that uniquely identifies a billing profile.
     * @param billingRoleAssignmentName The ID that uniquely identifies a role assignment.
     * @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 role assignment along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<BillingRoleAssignmentInner>> deleteByBillingProfileWithResponseAsync(
        String billingAccountName, String billingProfileName, String billingRoleAssignmentName, 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."));
        }
        if (billingRoleAssignmentName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter billingRoleAssignmentName is required and cannot be null."));
        }
        final String apiVersion = "2020-05-01";
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .deleteByBillingProfile(
                this.client.getEndpoint(),
                apiVersion,
                billingAccountName,
                billingProfileName,
                billingRoleAssignmentName,
                accept,
                context);
    }

    /**
     * Deletes a role assignment for the caller on a billing profile. The operation is supported for billing accounts
     * with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement.
     *
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingProfileName The ID that uniquely identifies a billing profile.
     * @param billingRoleAssignmentName The ID that uniquely identifies a role assignment.
     * @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 role assignment on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<BillingRoleAssignmentInner> deleteByBillingProfileAsync(
        String billingAccountName, String billingProfileName, String billingRoleAssignmentName) {
        return deleteByBillingProfileWithResponseAsync(
                billingAccountName, billingProfileName, billingRoleAssignmentName)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Deletes a role assignment for the caller on a billing profile. The operation is supported for billing accounts
     * with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement.
     *
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingProfileName The ID that uniquely identifies a billing profile.
     * @param billingRoleAssignmentName The ID that uniquely identifies a role assignment.
     * @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 role assignment along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<BillingRoleAssignmentInner> deleteByBillingProfileWithResponse(
        String billingAccountName, String billingProfileName, String billingRoleAssignmentName, Context context) {
        return deleteByBillingProfileWithResponseAsync(
                billingAccountName, billingProfileName, billingRoleAssignmentName, context)
            .block();
    }

    /**
     * Deletes a role assignment for the caller on a billing profile. The operation is supported for billing accounts
     * with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement.
     *
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingProfileName The ID that uniquely identifies a billing profile.
     * @param billingRoleAssignmentName The ID that uniquely identifies a role assignment.
     * @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 role assignment.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public BillingRoleAssignmentInner deleteByBillingProfile(
        String billingAccountName, String billingProfileName, String billingRoleAssignmentName) {
        return deleteByBillingProfileWithResponse(
                billingAccountName, billingProfileName, billingRoleAssignmentName, Context.NONE)
            .getValue();
    }

    /**
     * Lists the role assignments for the caller on a billing account. The operation is supported for billing accounts
     * with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement.
     *
     * @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 role assignments along with {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<BillingRoleAssignmentInner>> listByBillingAccountSinglePageAsync(
        String billingAccountName) {
        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 apiVersion = "2020-05-01";
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .listByBillingAccount(
                            this.client.getEndpoint(), apiVersion, billingAccountName, accept, context))
            .<PagedResponse<BillingRoleAssignmentInner>>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 role assignments for the caller on a billing account. The operation is supported for billing accounts
     * with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement.
     *
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @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 role assignments along with {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<BillingRoleAssignmentInner>> listByBillingAccountSinglePageAsync(
        String billingAccountName, 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 apiVersion = "2020-05-01";
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .listByBillingAccount(this.client.getEndpoint(), apiVersion, billingAccountName, accept, context)
            .map(
                res ->
                    new PagedResponseBase<>(
                        res.getRequest(),
                        res.getStatusCode(),
                        res.getHeaders(),
                        res.getValue().value(),
                        res.getValue().nextLink(),
                        null));
    }

    /**
     * Lists the role assignments for the caller on a billing account. The operation is supported for billing accounts
     * with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement.
     *
     * @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 role assignments as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<BillingRoleAssignmentInner> listByBillingAccountAsync(String billingAccountName) {
        return new PagedFlux<>(
            () -> listByBillingAccountSinglePageAsync(billingAccountName),
            nextLink -> listByBillingAccountNextSinglePageAsync(nextLink));
    }

    /**
     * Lists the role assignments for the caller on a billing account. The operation is supported for billing accounts
     * with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement.
     *
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @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 role assignments as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<BillingRoleAssignmentInner> listByBillingAccountAsync(
        String billingAccountName, Context context) {
        return new PagedFlux<>(
            () -> listByBillingAccountSinglePageAsync(billingAccountName, context),
            nextLink -> listByBillingAccountNextSinglePageAsync(nextLink, context));
    }

    /**
     * Lists the role assignments for the caller on a billing account. The operation is supported for billing accounts
     * with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement.
     *
     * @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 role assignments as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<BillingRoleAssignmentInner> listByBillingAccount(String billingAccountName) {
        return new PagedIterable<>(listByBillingAccountAsync(billingAccountName));
    }

    /**
     * Lists the role assignments for the caller on a billing account. The operation is supported for billing accounts
     * with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement.
     *
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @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 role assignments as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<BillingRoleAssignmentInner> listByBillingAccount(String billingAccountName, Context context) {
        return new PagedIterable<>(listByBillingAccountAsync(billingAccountName, context));
    }

    /**
     * Lists the role assignments for the caller on an invoice section. The operation is supported for billing accounts
     * with agreement type Microsoft Customer Agreement.
     *
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingProfileName The ID that uniquely identifies a billing profile.
     * @param invoiceSectionName The ID that uniquely identifies an invoice section.
     * @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 role assignments along with {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<BillingRoleAssignmentInner>> listByInvoiceSectionSinglePageAsync(
        String billingAccountName, String billingProfileName, String invoiceSectionName) {
        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."));
        }
        if (invoiceSectionName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter invoiceSectionName is required and cannot be null."));
        }
        final String apiVersion = "2020-05-01";
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .listByInvoiceSection(
                            this.client.getEndpoint(),
                            apiVersion,
                            billingAccountName,
                            billingProfileName,
                            invoiceSectionName,
                            accept,
                            context))
            .<PagedResponse<BillingRoleAssignmentInner>>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 role assignments for the caller on an invoice section. The operation is supported for billing accounts
     * with agreement type Microsoft Customer Agreement.
     *
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingProfileName The ID that uniquely identifies a billing profile.
     * @param invoiceSectionName The ID that uniquely identifies an invoice section.
     * @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 role assignments along with {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<BillingRoleAssignmentInner>> listByInvoiceSectionSinglePageAsync(
        String billingAccountName, String billingProfileName, String invoiceSectionName, 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."));
        }
        if (invoiceSectionName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter invoiceSectionName is required and cannot be null."));
        }
        final String apiVersion = "2020-05-01";
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .listByInvoiceSection(
                this.client.getEndpoint(),
                apiVersion,
                billingAccountName,
                billingProfileName,
                invoiceSectionName,
                accept,
                context)
            .map(
                res ->
                    new PagedResponseBase<>(
                        res.getRequest(),
                        res.getStatusCode(),
                        res.getHeaders(),
                        res.getValue().value(),
                        res.getValue().nextLink(),
                        null));
    }

    /**
     * Lists the role assignments for the caller on an invoice section. The operation is supported for billing accounts
     * with agreement type Microsoft Customer Agreement.
     *
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingProfileName The ID that uniquely identifies a billing profile.
     * @param invoiceSectionName The ID that uniquely identifies an invoice section.
     * @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 role assignments as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<BillingRoleAssignmentInner> listByInvoiceSectionAsync(
        String billingAccountName, String billingProfileName, String invoiceSectionName) {
        return new PagedFlux<>(
            () -> listByInvoiceSectionSinglePageAsync(billingAccountName, billingProfileName, invoiceSectionName),
            nextLink -> listByInvoiceSectionNextSinglePageAsync(nextLink));
    }

    /**
     * Lists the role assignments for the caller on an invoice section. The operation is supported for billing accounts
     * with agreement type Microsoft Customer Agreement.
     *
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingProfileName The ID that uniquely identifies a billing profile.
     * @param invoiceSectionName The ID that uniquely identifies an invoice section.
     * @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 role assignments as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<BillingRoleAssignmentInner> listByInvoiceSectionAsync(
        String billingAccountName, String billingProfileName, String invoiceSectionName, Context context) {
        return new PagedFlux<>(
            () ->
                listByInvoiceSectionSinglePageAsync(
                    billingAccountName, billingProfileName, invoiceSectionName, context),
            nextLink -> listByInvoiceSectionNextSinglePageAsync(nextLink, context));
    }

    /**
     * Lists the role assignments for the caller on an invoice section. The operation is supported for billing accounts
     * with agreement type Microsoft Customer Agreement.
     *
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingProfileName The ID that uniquely identifies a billing profile.
     * @param invoiceSectionName The ID that uniquely identifies an invoice section.
     * @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 role assignments as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<BillingRoleAssignmentInner> listByInvoiceSection(
        String billingAccountName, String billingProfileName, String invoiceSectionName) {
        return new PagedIterable<>(
            listByInvoiceSectionAsync(billingAccountName, billingProfileName, invoiceSectionName));
    }

    /**
     * Lists the role assignments for the caller on an invoice section. The operation is supported for billing accounts
     * with agreement type Microsoft Customer Agreement.
     *
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingProfileName The ID that uniquely identifies a billing profile.
     * @param invoiceSectionName The ID that uniquely identifies an invoice section.
     * @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 role assignments as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<BillingRoleAssignmentInner> listByInvoiceSection(
        String billingAccountName, String billingProfileName, String invoiceSectionName, Context context) {
        return new PagedIterable<>(
            listByInvoiceSectionAsync(billingAccountName, billingProfileName, invoiceSectionName, context));
    }

    /**
     * Lists the role assignments for the caller on a billing profile. The operation is supported for billing accounts
     * with agreement type Microsoft Customer Agreement.
     *
     * @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 role assignments along with {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<BillingRoleAssignmentInner>> listByBillingProfileSinglePageAsync(
        String billingAccountName, String billingProfileName) {
        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 apiVersion = "2020-05-01";
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .listByBillingProfile(
                            this.client.getEndpoint(),
                            apiVersion,
                            billingAccountName,
                            billingProfileName,
                            accept,
                            context))
            .<PagedResponse<BillingRoleAssignmentInner>>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 role assignments for the caller on a billing profile. The operation is supported for billing accounts
     * with agreement type Microsoft Customer Agreement.
     *
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingProfileName The ID that uniquely identifies a billing profile.
     * @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 role assignments along with {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<BillingRoleAssignmentInner>> listByBillingProfileSinglePageAsync(
        String billingAccountName, String billingProfileName, 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 apiVersion = "2020-05-01";
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .listByBillingProfile(
                this.client.getEndpoint(), apiVersion, billingAccountName, billingProfileName, accept, context)
            .map(
                res ->
                    new PagedResponseBase<>(
                        res.getRequest(),
                        res.getStatusCode(),
                        res.getHeaders(),
                        res.getValue().value(),
                        res.getValue().nextLink(),
                        null));
    }

    /**
     * Lists the role assignments for the caller on a billing profile. The operation is supported for billing accounts
     * with agreement type Microsoft Customer Agreement.
     *
     * @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 role assignments as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<BillingRoleAssignmentInner> listByBillingProfileAsync(
        String billingAccountName, String billingProfileName) {
        return new PagedFlux<>(
            () -> listByBillingProfileSinglePageAsync(billingAccountName, billingProfileName),
            nextLink -> listByBillingProfileNextSinglePageAsync(nextLink));
    }

    /**
     * Lists the role assignments for the caller on a billing profile. The operation is supported for billing accounts
     * with agreement type Microsoft Customer Agreement.
     *
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingProfileName The ID that uniquely identifies a billing profile.
     * @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 role assignments as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<BillingRoleAssignmentInner> listByBillingProfileAsync(
        String billingAccountName, String billingProfileName, Context context) {
        return new PagedFlux<>(
            () -> listByBillingProfileSinglePageAsync(billingAccountName, billingProfileName, context),
            nextLink -> listByBillingProfileNextSinglePageAsync(nextLink, context));
    }

    /**
     * Lists the role assignments for the caller on a billing profile. The operation is supported for billing accounts
     * with agreement type Microsoft Customer Agreement.
     *
     * @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 role assignments as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<BillingRoleAssignmentInner> listByBillingProfile(
        String billingAccountName, String billingProfileName) {
        return new PagedIterable<>(listByBillingProfileAsync(billingAccountName, billingProfileName));
    }

    /**
     * Lists the role assignments for the caller on a billing profile. The operation is supported for billing accounts
     * with agreement type Microsoft Customer Agreement.
     *
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingProfileName The ID that uniquely identifies a billing profile.
     * @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 role assignments as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<BillingRoleAssignmentInner> listByBillingProfile(
        String billingAccountName, String billingProfileName, Context context) {
        return new PagedIterable<>(listByBillingProfileAsync(billingAccountName, billingProfileName, context));
    }

    /**
     * Get the next page of items.
     *
     * @param nextLink The URL to get the next list of items
     *     <p>The nextLink parameter.
     * @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 role assignments along with {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<BillingRoleAssignmentInner>> 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))
            .<PagedResponse<BillingRoleAssignmentInner>>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
     *     <p>The nextLink parameter.
     * @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 role assignments along with {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<BillingRoleAssignmentInner>> 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
     *     <p>The nextLink parameter.
     * @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 role assignments along with {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<BillingRoleAssignmentInner>> listByInvoiceSectionNextSinglePageAsync(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.listByInvoiceSectionNext(nextLink, this.client.getEndpoint(), accept, context))
            .<PagedResponse<BillingRoleAssignmentInner>>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
     *     <p>The nextLink parameter.
     * @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 role assignments along with {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<BillingRoleAssignmentInner>> listByInvoiceSectionNextSinglePageAsync(
        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
            .listByInvoiceSectionNext(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
     *     <p>The nextLink parameter.
     * @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 role assignments along with {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<BillingRoleAssignmentInner>> 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))
            .<PagedResponse<BillingRoleAssignmentInner>>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
     *     <p>The nextLink parameter.
     * @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 role assignments along with {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<BillingRoleAssignmentInner>> 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));
    }
}
