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

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

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

package com.azure.resourcemanager.billing.implementation;

import com.azure.core.annotation.BodyParam;
import com.azure.core.annotation.ExpectedResponses;
import com.azure.core.annotation.Get;
import com.azure.core.annotation.HeaderParam;
import com.azure.core.annotation.Headers;
import com.azure.core.annotation.Host;
import com.azure.core.annotation.HostParam;
import com.azure.core.annotation.PathParam;
import com.azure.core.annotation.Put;
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.Response;
import com.azure.core.http.rest.RestProxy;
import com.azure.core.management.exception.ManagementException;
import com.azure.core.management.polling.PollResult;
import com.azure.core.util.Context;
import com.azure.core.util.FluxUtil;
import com.azure.core.util.polling.PollerFlux;
import com.azure.core.util.polling.SyncPoller;
import com.azure.resourcemanager.billing.fluent.PoliciesClient;
import com.azure.resourcemanager.billing.fluent.models.BillingAccountPolicyInner;
import com.azure.resourcemanager.billing.fluent.models.BillingProfilePolicyInner;
import com.azure.resourcemanager.billing.fluent.models.CustomerPolicyInner;
import com.azure.resourcemanager.billing.fluent.models.SubscriptionPolicyInner;
import com.azure.resourcemanager.billing.models.ServiceDefinedResourceName;
import java.nio.ByteBuffer;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

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

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

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

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

        @Headers({ "Content-Type: application/json" })
        @Put("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/customers/{customerName}/policies/default")
        @ExpectedResponses({ 200, 201 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono>> createOrUpdateByCustomer(@HostParam("$host") String endpoint,
            @PathParam("billingAccountName") String billingAccountName,
            @PathParam("billingProfileName") String billingProfileName, @PathParam("customerName") String customerName,
            @QueryParam("api-version") String apiVersion, @BodyParam("application/json") CustomerPolicyInner parameters,
            @HeaderParam("Accept") String accept, Context context);

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

        @Headers({ "Content-Type: application/json" })
        @Put("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/policies/default")
        @ExpectedResponses({ 200, 201 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono>> createOrUpdateByBillingProfile(@HostParam("$host") String endpoint,
            @PathParam("billingAccountName") String billingAccountName,
            @PathParam("billingProfileName") String billingProfileName, @QueryParam("api-version") String apiVersion,
            @BodyParam("application/json") BillingProfilePolicyInner parameters, @HeaderParam("Accept") String accept,
            Context context);

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

        @Headers({ "Content-Type: application/json" })
        @Put("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}/policies/default")
        @ExpectedResponses({ 200, 201 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono>> createOrUpdateByCustomerAtBillingAccount(@HostParam("$host") String endpoint,
            @PathParam("billingAccountName") String billingAccountName, @PathParam("customerName") String customerName,
            @QueryParam("api-version") String apiVersion, @BodyParam("application/json") CustomerPolicyInner parameters,
            @HeaderParam("Accept") String accept, Context context);

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

        @Headers({ "Content-Type: application/json" })
        @Put("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/policies/default")
        @ExpectedResponses({ 200, 201 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono>> createOrUpdateByBillingAccount(@HostParam("$host") String endpoint,
            @PathParam("billingAccountName") String billingAccountName, @QueryParam("api-version") String apiVersion,
            @BodyParam("application/json") BillingAccountPolicyInner parameters, @HeaderParam("Accept") String accept,
            Context context);

        @Headers({ "Content-Type: application/json" })
        @Get("/subscriptions/{subscriptionId}/providers/Microsoft.Billing/policies/default")
        @ExpectedResponses({ 200 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono> getBySubscription(@HostParam("$host") String endpoint,
            @PathParam("subscriptionId") String subscriptionId, @QueryParam("api-version") String apiVersion,
            @HeaderParam("Accept") String accept, Context context);
    }

    /**
     * Lists the policies for a customer. This operation is supported only for billing accounts with agreement type
     * Microsoft Partner Agreement.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingProfileName The ID that uniquely identifies a billing profile.
     * @param customerName The ID that uniquely identifies a customer.
     * @param policyName Service-defined resource names such as 'default' which are reserved resource names.
     * @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 policy at customer scope along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> getByCustomerWithResponseAsync(String billingAccountName,
        String billingProfileName, String customerName, ServiceDefinedResourceName policyName) {
        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 (customerName == null) {
            return Mono.error(new IllegalArgumentException("Parameter customerName is required and cannot be null."));
        }
        if (policyName == null) {
            return Mono.error(new IllegalArgumentException("Parameter policyName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(context -> service.getByCustomer(this.client.getEndpoint(), billingAccountName,
                billingProfileName, customerName, policyName, this.client.getApiVersion(), accept, context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Lists the policies for a customer. This operation is supported only for billing accounts with agreement type
     * Microsoft Partner Agreement.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingProfileName The ID that uniquely identifies a billing profile.
     * @param customerName The ID that uniquely identifies a customer.
     * @param policyName Service-defined resource names such as 'default' which are reserved resource names.
     * @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 policy at customer scope along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> getByCustomerWithResponseAsync(String billingAccountName,
        String billingProfileName, String customerName, ServiceDefinedResourceName policyName, 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 (customerName == null) {
            return Mono.error(new IllegalArgumentException("Parameter customerName is required and cannot be null."));
        }
        if (policyName == null) {
            return Mono.error(new IllegalArgumentException("Parameter policyName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service.getByCustomer(this.client.getEndpoint(), billingAccountName, billingProfileName, customerName,
            policyName, this.client.getApiVersion(), accept, context);
    }

    /**
     * Lists the policies for a customer. This operation is supported only for billing accounts with agreement type
     * Microsoft Partner Agreement.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingProfileName The ID that uniquely identifies a billing profile.
     * @param customerName The ID that uniquely identifies a customer.
     * @param policyName Service-defined resource names such as 'default' which are reserved resource names.
     * @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 policy at customer scope on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono getByCustomerAsync(String billingAccountName, String billingProfileName,
        String customerName, ServiceDefinedResourceName policyName) {
        return getByCustomerWithResponseAsync(billingAccountName, billingProfileName, customerName, policyName)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Lists the policies for a customer. This operation is supported only for billing accounts with agreement type
     * Microsoft Partner Agreement.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingProfileName The ID that uniquely identifies a billing profile.
     * @param customerName The ID that uniquely identifies a customer.
     * @param policyName Service-defined resource names such as 'default' which are reserved resource names.
     * @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 policy at customer scope along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response getByCustomerWithResponse(String billingAccountName, String billingProfileName,
        String customerName, ServiceDefinedResourceName policyName, Context context) {
        return getByCustomerWithResponseAsync(billingAccountName, billingProfileName, customerName, policyName, context)
            .block();
    }

    /**
     * Lists the policies for a customer. This operation is supported only for billing accounts with agreement type
     * Microsoft Partner Agreement.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingProfileName The ID that uniquely identifies a billing profile.
     * @param customerName The ID that uniquely identifies a customer.
     * @param policyName Service-defined resource names such as 'default' which are reserved resource names.
     * @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 policy at customer scope.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public CustomerPolicyInner getByCustomer(String billingAccountName, String billingProfileName, String customerName,
        ServiceDefinedResourceName policyName) {
        return getByCustomerWithResponse(billingAccountName, billingProfileName, customerName, policyName, Context.NONE)
            .getValue();
    }

    /**
     * Updates the policies for a customer. This operation is supported only for billing accounts with agreement type
     * Microsoft Partner Agreement.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingProfileName The ID that uniquely identifies a billing profile.
     * @param customerName The ID that uniquely identifies a customer.
     * @param parameters A policy at customer scope.
     * @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 policy at customer scope along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono>> createOrUpdateByCustomerWithResponseAsync(String billingAccountName,
        String billingProfileName, String customerName, CustomerPolicyInner parameters) {
        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 (customerName == null) {
            return Mono.error(new IllegalArgumentException("Parameter customerName is required and cannot be null."));
        }
        if (parameters == null) {
            return Mono.error(new IllegalArgumentException("Parameter parameters is required and cannot be null."));
        } else {
            parameters.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(context -> service.createOrUpdateByCustomer(this.client.getEndpoint(), billingAccountName,
                billingProfileName, customerName, this.client.getApiVersion(), parameters, accept, context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Updates the policies for a customer. This operation is supported only for billing accounts with agreement type
     * Microsoft Partner Agreement.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingProfileName The ID that uniquely identifies a billing profile.
     * @param customerName The ID that uniquely identifies a customer.
     * @param parameters A policy at customer scope.
     * @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 policy at customer scope along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono>> createOrUpdateByCustomerWithResponseAsync(String billingAccountName,
        String billingProfileName, String customerName, CustomerPolicyInner parameters, 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 (customerName == null) {
            return Mono.error(new IllegalArgumentException("Parameter customerName is required and cannot be null."));
        }
        if (parameters == null) {
            return Mono.error(new IllegalArgumentException("Parameter parameters is required and cannot be null."));
        } else {
            parameters.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service.createOrUpdateByCustomer(this.client.getEndpoint(), billingAccountName, billingProfileName,
            customerName, this.client.getApiVersion(), parameters, accept, context);
    }

    /**
     * Updates the policies for a customer. This operation is supported only for billing accounts with agreement type
     * Microsoft Partner Agreement.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingProfileName The ID that uniquely identifies a billing profile.
     * @param customerName The ID that uniquely identifies a customer.
     * @param parameters A policy at customer scope.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link PollerFlux} for polling of a policy at customer scope.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux, CustomerPolicyInner> beginCreateOrUpdateByCustomerAsync(
        String billingAccountName, String billingProfileName, String customerName, CustomerPolicyInner parameters) {
        Mono>> mono = createOrUpdateByCustomerWithResponseAsync(billingAccountName,
            billingProfileName, customerName, parameters);
        return this.client.getLroResult(mono, this.client.getHttpPipeline(),
            CustomerPolicyInner.class, CustomerPolicyInner.class, this.client.getContext());
    }

    /**
     * Updates the policies for a customer. This operation is supported only for billing accounts with agreement type
     * Microsoft Partner Agreement.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingProfileName The ID that uniquely identifies a billing profile.
     * @param customerName The ID that uniquely identifies a customer.
     * @param parameters A policy at customer scope.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link PollerFlux} for polling of a policy at customer scope.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux, CustomerPolicyInner> beginCreateOrUpdateByCustomerAsync(
        String billingAccountName, String billingProfileName, String customerName, CustomerPolicyInner parameters,
        Context context) {
        context = this.client.mergeContext(context);
        Mono>> mono = createOrUpdateByCustomerWithResponseAsync(billingAccountName,
            billingProfileName, customerName, parameters, context);
        return this.client.getLroResult(mono, this.client.getHttpPipeline(),
            CustomerPolicyInner.class, CustomerPolicyInner.class, context);
    }

    /**
     * Updates the policies for a customer. This operation is supported only for billing accounts with agreement type
     * Microsoft Partner Agreement.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingProfileName The ID that uniquely identifies a billing profile.
     * @param customerName The ID that uniquely identifies a customer.
     * @param parameters A policy at customer scope.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link SyncPoller} for polling of a policy at customer scope.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller, CustomerPolicyInner> beginCreateOrUpdateByCustomer(
        String billingAccountName, String billingProfileName, String customerName, CustomerPolicyInner parameters) {
        return this.beginCreateOrUpdateByCustomerAsync(billingAccountName, billingProfileName, customerName, parameters)
            .getSyncPoller();
    }

    /**
     * Updates the policies for a customer. This operation is supported only for billing accounts with agreement type
     * Microsoft Partner Agreement.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingProfileName The ID that uniquely identifies a billing profile.
     * @param customerName The ID that uniquely identifies a customer.
     * @param parameters A policy at customer scope.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link SyncPoller} for polling of a policy at customer scope.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller, CustomerPolicyInner> beginCreateOrUpdateByCustomer(
        String billingAccountName, String billingProfileName, String customerName, CustomerPolicyInner parameters,
        Context context) {
        return this
            .beginCreateOrUpdateByCustomerAsync(billingAccountName, billingProfileName, customerName, parameters,
                context)
            .getSyncPoller();
    }

    /**
     * Updates the policies for a customer. This operation is supported only for billing accounts with agreement type
     * Microsoft Partner Agreement.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingProfileName The ID that uniquely identifies a billing profile.
     * @param customerName The ID that uniquely identifies a customer.
     * @param parameters A policy at customer scope.
     * @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 policy at customer scope on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono createOrUpdateByCustomerAsync(String billingAccountName,
        String billingProfileName, String customerName, CustomerPolicyInner parameters) {
        return beginCreateOrUpdateByCustomerAsync(billingAccountName, billingProfileName, customerName, parameters)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Updates the policies for a customer. This operation is supported only for billing accounts with agreement type
     * Microsoft Partner Agreement.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingProfileName The ID that uniquely identifies a billing profile.
     * @param customerName The ID that uniquely identifies a customer.
     * @param parameters A policy at customer scope.
     * @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 policy at customer scope on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono createOrUpdateByCustomerAsync(String billingAccountName,
        String billingProfileName, String customerName, CustomerPolicyInner parameters, Context context) {
        return beginCreateOrUpdateByCustomerAsync(billingAccountName, billingProfileName, customerName, parameters,
            context).last().flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Updates the policies for a customer. This operation is supported only for billing accounts with agreement type
     * Microsoft Partner Agreement.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingProfileName The ID that uniquely identifies a billing profile.
     * @param customerName The ID that uniquely identifies a customer.
     * @param parameters A policy at customer scope.
     * @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 policy at customer scope.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public CustomerPolicyInner createOrUpdateByCustomer(String billingAccountName, String billingProfileName,
        String customerName, CustomerPolicyInner parameters) {
        return createOrUpdateByCustomerAsync(billingAccountName, billingProfileName, customerName, parameters).block();
    }

    /**
     * Updates the policies for a customer. This operation is supported only for billing accounts with agreement type
     * Microsoft Partner Agreement.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param billingProfileName The ID that uniquely identifies a billing profile.
     * @param customerName The ID that uniquely identifies a customer.
     * @param parameters A policy at customer scope.
     * @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 policy at customer scope.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public CustomerPolicyInner createOrUpdateByCustomer(String billingAccountName, String billingProfileName,
        String customerName, CustomerPolicyInner parameters, Context context) {
        return createOrUpdateByCustomerAsync(billingAccountName, billingProfileName, customerName, parameters, context)
            .block();
    }

    /**
     * Lists the policies for a billing profile. This operation is supported only 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 a policy at billing profile scope along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> getByBillingProfileWithResponseAsync(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 accept = "application/json";
        return FluxUtil
            .withContext(context -> service.getByBillingProfile(this.client.getEndpoint(), billingAccountName,
                billingProfileName, this.client.getApiVersion(), accept, context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Lists the policies for a billing profile. This operation is supported only 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 a policy at billing profile scope along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> getByBillingProfileWithResponseAsync(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 accept = "application/json";
        context = this.client.mergeContext(context);
        return service.getByBillingProfile(this.client.getEndpoint(), billingAccountName, billingProfileName,
            this.client.getApiVersion(), accept, context);
    }

    /**
     * Lists the policies for a billing profile. This operation is supported only 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 a policy at billing profile scope on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono getByBillingProfileAsync(String billingAccountName,
        String billingProfileName) {
        return getByBillingProfileWithResponseAsync(billingAccountName, billingProfileName)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Lists the policies for a billing profile. This operation is supported only 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 a policy at billing profile scope along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response getByBillingProfileWithResponse(String billingAccountName,
        String billingProfileName, Context context) {
        return getByBillingProfileWithResponseAsync(billingAccountName, billingProfileName, context).block();
    }

    /**
     * Lists the policies for a billing profile. This operation is supported only 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 a policy at billing profile scope.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public BillingProfilePolicyInner getByBillingProfile(String billingAccountName, String billingProfileName) {
        return getByBillingProfileWithResponse(billingAccountName, billingProfileName, Context.NONE).getValue();
    }

    /**
     * Updates the policies for a billing profile. This operation is supported only 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 parameters A policy at billing profile scope.
     * @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 policy at billing profile scope along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono>> createOrUpdateByBillingProfileWithResponseAsync(String billingAccountName,
        String billingProfileName, BillingProfilePolicyInner parameters) {
        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 (parameters == null) {
            return Mono.error(new IllegalArgumentException("Parameter parameters is required and cannot be null."));
        } else {
            parameters.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(context -> service.createOrUpdateByBillingProfile(this.client.getEndpoint(),
                billingAccountName, billingProfileName, this.client.getApiVersion(), parameters, accept, context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Updates the policies for a billing profile. This operation is supported only 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 parameters A policy at billing profile scope.
     * @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 policy at billing profile scope along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono>> createOrUpdateByBillingProfileWithResponseAsync(String billingAccountName,
        String billingProfileName, BillingProfilePolicyInner parameters, 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 (parameters == null) {
            return Mono.error(new IllegalArgumentException("Parameter parameters is required and cannot be null."));
        } else {
            parameters.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service.createOrUpdateByBillingProfile(this.client.getEndpoint(), billingAccountName, billingProfileName,
            this.client.getApiVersion(), parameters, accept, context);
    }

    /**
     * Updates the policies for a billing profile. This operation is supported only 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 parameters A policy at billing profile scope.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link PollerFlux} for polling of a policy at billing profile scope.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux, BillingProfilePolicyInner>
        beginCreateOrUpdateByBillingProfileAsync(String billingAccountName, String billingProfileName,
            BillingProfilePolicyInner parameters) {
        Mono>> mono
            = createOrUpdateByBillingProfileWithResponseAsync(billingAccountName, billingProfileName, parameters);
        return this.client.getLroResult(mono,
            this.client.getHttpPipeline(), BillingProfilePolicyInner.class, BillingProfilePolicyInner.class,
            this.client.getContext());
    }

    /**
     * Updates the policies for a billing profile. This operation is supported only 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 parameters A policy at billing profile scope.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link PollerFlux} for polling of a policy at billing profile scope.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux, BillingProfilePolicyInner>
        beginCreateOrUpdateByBillingProfileAsync(String billingAccountName, String billingProfileName,
            BillingProfilePolicyInner parameters, Context context) {
        context = this.client.mergeContext(context);
        Mono>> mono = createOrUpdateByBillingProfileWithResponseAsync(billingAccountName,
            billingProfileName, parameters, context);
        return this.client.getLroResult(mono,
            this.client.getHttpPipeline(), BillingProfilePolicyInner.class, BillingProfilePolicyInner.class, context);
    }

    /**
     * Updates the policies for a billing profile. This operation is supported only 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 parameters A policy at billing profile scope.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link SyncPoller} for polling of a policy at billing profile scope.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller, BillingProfilePolicyInner>
        beginCreateOrUpdateByBillingProfile(String billingAccountName, String billingProfileName,
            BillingProfilePolicyInner parameters) {
        return this.beginCreateOrUpdateByBillingProfileAsync(billingAccountName, billingProfileName, parameters)
            .getSyncPoller();
    }

    /**
     * Updates the policies for a billing profile. This operation is supported only 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 parameters A policy at billing profile scope.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link SyncPoller} for polling of a policy at billing profile scope.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller, BillingProfilePolicyInner>
        beginCreateOrUpdateByBillingProfile(String billingAccountName, String billingProfileName,
            BillingProfilePolicyInner parameters, Context context) {
        return this
            .beginCreateOrUpdateByBillingProfileAsync(billingAccountName, billingProfileName, parameters, context)
            .getSyncPoller();
    }

    /**
     * Updates the policies for a billing profile. This operation is supported only 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 parameters A policy at billing profile scope.
     * @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 policy at billing profile scope on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono createOrUpdateByBillingProfileAsync(String billingAccountName,
        String billingProfileName, BillingProfilePolicyInner parameters) {
        return beginCreateOrUpdateByBillingProfileAsync(billingAccountName, billingProfileName, parameters).last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Updates the policies for a billing profile. This operation is supported only 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 parameters A policy at billing profile scope.
     * @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 policy at billing profile scope on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono createOrUpdateByBillingProfileAsync(String billingAccountName,
        String billingProfileName, BillingProfilePolicyInner parameters, Context context) {
        return beginCreateOrUpdateByBillingProfileAsync(billingAccountName, billingProfileName, parameters, context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Updates the policies for a billing profile. This operation is supported only 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 parameters A policy at billing profile scope.
     * @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 policy at billing profile scope.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public BillingProfilePolicyInner createOrUpdateByBillingProfile(String billingAccountName,
        String billingProfileName, BillingProfilePolicyInner parameters) {
        return createOrUpdateByBillingProfileAsync(billingAccountName, billingProfileName, parameters).block();
    }

    /**
     * Updates the policies for a billing profile. This operation is supported only 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 parameters A policy at billing profile scope.
     * @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 policy at billing profile scope.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public BillingProfilePolicyInner createOrUpdateByBillingProfile(String billingAccountName,
        String billingProfileName, BillingProfilePolicyInner parameters, Context context) {
        return createOrUpdateByBillingProfileAsync(billingAccountName, billingProfileName, parameters, context).block();
    }

    /**
     * Lists the policies for a customer at billing account scope. This operation is supported only for billing accounts
     * with agreement type Microsoft Partner Agreement.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param customerName The ID that uniquely identifies a customer.
     * @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 policy at customer scope along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono>
        getByCustomerAtBillingAccountWithResponseAsync(String billingAccountName, String customerName) {
        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 (customerName == null) {
            return Mono.error(new IllegalArgumentException("Parameter customerName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(context -> service.getByCustomerAtBillingAccount(this.client.getEndpoint(), billingAccountName,
                customerName, this.client.getApiVersion(), accept, context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Lists the policies for a customer at billing account scope. This operation is supported only for billing accounts
     * with agreement type Microsoft Partner Agreement.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param customerName The ID that uniquely identifies a customer.
     * @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 policy at customer scope along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> getByCustomerAtBillingAccountWithResponseAsync(
        String billingAccountName, String customerName, 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 (customerName == null) {
            return Mono.error(new IllegalArgumentException("Parameter customerName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service.getByCustomerAtBillingAccount(this.client.getEndpoint(), billingAccountName, customerName,
            this.client.getApiVersion(), accept, context);
    }

    /**
     * Lists the policies for a customer at billing account scope. This operation is supported only for billing accounts
     * with agreement type Microsoft Partner Agreement.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param customerName The ID that uniquely identifies a customer.
     * @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 policy at customer scope on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono getByCustomerAtBillingAccountAsync(String billingAccountName,
        String customerName) {
        return getByCustomerAtBillingAccountWithResponseAsync(billingAccountName, customerName)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Lists the policies for a customer at billing account scope. This operation is supported only for billing accounts
     * with agreement type Microsoft Partner Agreement.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param customerName The ID that uniquely identifies a customer.
     * @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 policy at customer scope along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response getByCustomerAtBillingAccountWithResponse(String billingAccountName,
        String customerName, Context context) {
        return getByCustomerAtBillingAccountWithResponseAsync(billingAccountName, customerName, context).block();
    }

    /**
     * Lists the policies for a customer at billing account scope. This operation is supported only for billing accounts
     * with agreement type Microsoft Partner Agreement.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param customerName The ID that uniquely identifies a customer.
     * @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 policy at customer scope.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public CustomerPolicyInner getByCustomerAtBillingAccount(String billingAccountName, String customerName) {
        return getByCustomerAtBillingAccountWithResponse(billingAccountName, customerName, Context.NONE).getValue();
    }

    /**
     * Updates the policies for a customer at billing account scope. This operation is supported only for billing
     * accounts with agreement type Microsoft Partner Agreement.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param customerName The ID that uniquely identifies a customer.
     * @param parameters A policy at customer scope.
     * @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 policy at customer scope along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono>> createOrUpdateByCustomerAtBillingAccountWithResponseAsync(
        String billingAccountName, String customerName, CustomerPolicyInner parameters) {
        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 (customerName == null) {
            return Mono.error(new IllegalArgumentException("Parameter customerName is required and cannot be null."));
        }
        if (parameters == null) {
            return Mono.error(new IllegalArgumentException("Parameter parameters is required and cannot be null."));
        } else {
            parameters.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(context -> service.createOrUpdateByCustomerAtBillingAccount(this.client.getEndpoint(),
                billingAccountName, customerName, this.client.getApiVersion(), parameters, accept, context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Updates the policies for a customer at billing account scope. This operation is supported only for billing
     * accounts with agreement type Microsoft Partner Agreement.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param customerName The ID that uniquely identifies a customer.
     * @param parameters A policy at customer scope.
     * @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 policy at customer scope along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono>> createOrUpdateByCustomerAtBillingAccountWithResponseAsync(
        String billingAccountName, String customerName, CustomerPolicyInner parameters, 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 (customerName == null) {
            return Mono.error(new IllegalArgumentException("Parameter customerName is required and cannot be null."));
        }
        if (parameters == null) {
            return Mono.error(new IllegalArgumentException("Parameter parameters is required and cannot be null."));
        } else {
            parameters.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service.createOrUpdateByCustomerAtBillingAccount(this.client.getEndpoint(), billingAccountName,
            customerName, this.client.getApiVersion(), parameters, accept, context);
    }

    /**
     * Updates the policies for a customer at billing account scope. This operation is supported only for billing
     * accounts with agreement type Microsoft Partner Agreement.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param customerName The ID that uniquely identifies a customer.
     * @param parameters A policy at customer scope.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link PollerFlux} for polling of a policy at customer scope.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux, CustomerPolicyInner>
        beginCreateOrUpdateByCustomerAtBillingAccountAsync(String billingAccountName, String customerName,
            CustomerPolicyInner parameters) {
        Mono>> mono
            = createOrUpdateByCustomerAtBillingAccountWithResponseAsync(billingAccountName, customerName, parameters);
        return this.client.getLroResult(mono, this.client.getHttpPipeline(),
            CustomerPolicyInner.class, CustomerPolicyInner.class, this.client.getContext());
    }

    /**
     * Updates the policies for a customer at billing account scope. This operation is supported only for billing
     * accounts with agreement type Microsoft Partner Agreement.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param customerName The ID that uniquely identifies a customer.
     * @param parameters A policy at customer scope.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link PollerFlux} for polling of a policy at customer scope.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux, CustomerPolicyInner>
        beginCreateOrUpdateByCustomerAtBillingAccountAsync(String billingAccountName, String customerName,
            CustomerPolicyInner parameters, Context context) {
        context = this.client.mergeContext(context);
        Mono>> mono = createOrUpdateByCustomerAtBillingAccountWithResponseAsync(
            billingAccountName, customerName, parameters, context);
        return this.client.getLroResult(mono, this.client.getHttpPipeline(),
            CustomerPolicyInner.class, CustomerPolicyInner.class, context);
    }

    /**
     * Updates the policies for a customer at billing account scope. This operation is supported only for billing
     * accounts with agreement type Microsoft Partner Agreement.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param customerName The ID that uniquely identifies a customer.
     * @param parameters A policy at customer scope.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link SyncPoller} for polling of a policy at customer scope.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller, CustomerPolicyInner>
        beginCreateOrUpdateByCustomerAtBillingAccount(String billingAccountName, String customerName,
            CustomerPolicyInner parameters) {
        return this.beginCreateOrUpdateByCustomerAtBillingAccountAsync(billingAccountName, customerName, parameters)
            .getSyncPoller();
    }

    /**
     * Updates the policies for a customer at billing account scope. This operation is supported only for billing
     * accounts with agreement type Microsoft Partner Agreement.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param customerName The ID that uniquely identifies a customer.
     * @param parameters A policy at customer scope.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link SyncPoller} for polling of a policy at customer scope.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller, CustomerPolicyInner>
        beginCreateOrUpdateByCustomerAtBillingAccount(String billingAccountName, String customerName,
            CustomerPolicyInner parameters, Context context) {
        return this
            .beginCreateOrUpdateByCustomerAtBillingAccountAsync(billingAccountName, customerName, parameters, context)
            .getSyncPoller();
    }

    /**
     * Updates the policies for a customer at billing account scope. This operation is supported only for billing
     * accounts with agreement type Microsoft Partner Agreement.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param customerName The ID that uniquely identifies a customer.
     * @param parameters A policy at customer scope.
     * @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 policy at customer scope on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono createOrUpdateByCustomerAtBillingAccountAsync(String billingAccountName,
        String customerName, CustomerPolicyInner parameters) {
        return beginCreateOrUpdateByCustomerAtBillingAccountAsync(billingAccountName, customerName, parameters).last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Updates the policies for a customer at billing account scope. This operation is supported only for billing
     * accounts with agreement type Microsoft Partner Agreement.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param customerName The ID that uniquely identifies a customer.
     * @param parameters A policy at customer scope.
     * @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 policy at customer scope on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono createOrUpdateByCustomerAtBillingAccountAsync(String billingAccountName,
        String customerName, CustomerPolicyInner parameters, Context context) {
        return beginCreateOrUpdateByCustomerAtBillingAccountAsync(billingAccountName, customerName, parameters, context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Updates the policies for a customer at billing account scope. This operation is supported only for billing
     * accounts with agreement type Microsoft Partner Agreement.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param customerName The ID that uniquely identifies a customer.
     * @param parameters A policy at customer scope.
     * @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 policy at customer scope.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public CustomerPolicyInner createOrUpdateByCustomerAtBillingAccount(String billingAccountName, String customerName,
        CustomerPolicyInner parameters) {
        return createOrUpdateByCustomerAtBillingAccountAsync(billingAccountName, customerName, parameters).block();
    }

    /**
     * Updates the policies for a customer at billing account scope. This operation is supported only for billing
     * accounts with agreement type Microsoft Partner Agreement.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param customerName The ID that uniquely identifies a customer.
     * @param parameters A policy at customer scope.
     * @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 policy at customer scope.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public CustomerPolicyInner createOrUpdateByCustomerAtBillingAccount(String billingAccountName, String customerName,
        CustomerPolicyInner parameters, Context context) {
        return createOrUpdateByCustomerAtBillingAccountAsync(billingAccountName, customerName, parameters, context)
            .block();
    }

    /**
     * Get the policies for a billing account of Enterprise Agreement type.
     * 
     * @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 policies for a billing account of Enterprise Agreement type along with {@link Response} on successful
     * completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> getByBillingAccountWithResponseAsync(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 accept = "application/json";
        return FluxUtil
            .withContext(context -> service.getByBillingAccount(this.client.getEndpoint(), billingAccountName,
                this.client.getApiVersion(), accept, context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Get the policies for a billing account of Enterprise Agreement type.
     * 
     * @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 policies for a billing account of Enterprise Agreement type along with {@link Response} on successful
     * completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> getByBillingAccountWithResponseAsync(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 accept = "application/json";
        context = this.client.mergeContext(context);
        return service.getByBillingAccount(this.client.getEndpoint(), billingAccountName, this.client.getApiVersion(),
            accept, context);
    }

    /**
     * Get the policies for a billing account of Enterprise Agreement type.
     * 
     * @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 policies for a billing account of Enterprise Agreement type on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono getByBillingAccountAsync(String billingAccountName) {
        return getByBillingAccountWithResponseAsync(billingAccountName)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Get the policies for a billing account of Enterprise Agreement type.
     * 
     * @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 policies for a billing account of Enterprise Agreement type along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response getByBillingAccountWithResponse(String billingAccountName,
        Context context) {
        return getByBillingAccountWithResponseAsync(billingAccountName, context).block();
    }

    /**
     * Get the policies for a billing account of Enterprise Agreement type.
     * 
     * @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 policies for a billing account of Enterprise Agreement type.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public BillingAccountPolicyInner getByBillingAccount(String billingAccountName) {
        return getByBillingAccountWithResponse(billingAccountName, Context.NONE).getValue();
    }

    /**
     * Update the policies for a billing account of Enterprise Agreement type.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param parameters A policy at billing account scope.
     * @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 policy at billing account scope along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono>> createOrUpdateByBillingAccountWithResponseAsync(String billingAccountName,
        BillingAccountPolicyInner parameters) {
        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 (parameters == null) {
            return Mono.error(new IllegalArgumentException("Parameter parameters is required and cannot be null."));
        } else {
            parameters.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(context -> service.createOrUpdateByBillingAccount(this.client.getEndpoint(),
                billingAccountName, this.client.getApiVersion(), parameters, accept, context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Update the policies for a billing account of Enterprise Agreement type.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param parameters A policy at billing account scope.
     * @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 policy at billing account scope along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono>> createOrUpdateByBillingAccountWithResponseAsync(String billingAccountName,
        BillingAccountPolicyInner parameters, 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 (parameters == null) {
            return Mono.error(new IllegalArgumentException("Parameter parameters is required and cannot be null."));
        } else {
            parameters.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service.createOrUpdateByBillingAccount(this.client.getEndpoint(), billingAccountName,
            this.client.getApiVersion(), parameters, accept, context);
    }

    /**
     * Update the policies for a billing account of Enterprise Agreement type.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param parameters A policy at billing account scope.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link PollerFlux} for polling of a policy at billing account scope.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux, BillingAccountPolicyInner>
        beginCreateOrUpdateByBillingAccountAsync(String billingAccountName, BillingAccountPolicyInner parameters) {
        Mono>> mono
            = createOrUpdateByBillingAccountWithResponseAsync(billingAccountName, parameters);
        return this.client.getLroResult(mono,
            this.client.getHttpPipeline(), BillingAccountPolicyInner.class, BillingAccountPolicyInner.class,
            this.client.getContext());
    }

    /**
     * Update the policies for a billing account of Enterprise Agreement type.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param parameters A policy at billing account scope.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link PollerFlux} for polling of a policy at billing account scope.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux, BillingAccountPolicyInner>
        beginCreateOrUpdateByBillingAccountAsync(String billingAccountName, BillingAccountPolicyInner parameters,
            Context context) {
        context = this.client.mergeContext(context);
        Mono>> mono
            = createOrUpdateByBillingAccountWithResponseAsync(billingAccountName, parameters, context);
        return this.client.getLroResult(mono,
            this.client.getHttpPipeline(), BillingAccountPolicyInner.class, BillingAccountPolicyInner.class, context);
    }

    /**
     * Update the policies for a billing account of Enterprise Agreement type.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param parameters A policy at billing account scope.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link SyncPoller} for polling of a policy at billing account scope.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller, BillingAccountPolicyInner>
        beginCreateOrUpdateByBillingAccount(String billingAccountName, BillingAccountPolicyInner parameters) {
        return this.beginCreateOrUpdateByBillingAccountAsync(billingAccountName, parameters).getSyncPoller();
    }

    /**
     * Update the policies for a billing account of Enterprise Agreement type.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param parameters A policy at billing account scope.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link SyncPoller} for polling of a policy at billing account scope.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller, BillingAccountPolicyInner>
        beginCreateOrUpdateByBillingAccount(String billingAccountName, BillingAccountPolicyInner parameters,
            Context context) {
        return this.beginCreateOrUpdateByBillingAccountAsync(billingAccountName, parameters, context).getSyncPoller();
    }

    /**
     * Update the policies for a billing account of Enterprise Agreement type.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param parameters A policy at billing account scope.
     * @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 policy at billing account scope on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono createOrUpdateByBillingAccountAsync(String billingAccountName,
        BillingAccountPolicyInner parameters) {
        return beginCreateOrUpdateByBillingAccountAsync(billingAccountName, parameters).last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Update the policies for a billing account of Enterprise Agreement type.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param parameters A policy at billing account scope.
     * @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 policy at billing account scope on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono createOrUpdateByBillingAccountAsync(String billingAccountName,
        BillingAccountPolicyInner parameters, Context context) {
        return beginCreateOrUpdateByBillingAccountAsync(billingAccountName, parameters, context).last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Update the policies for a billing account of Enterprise Agreement type.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param parameters A policy at billing account scope.
     * @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 policy at billing account scope.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public BillingAccountPolicyInner createOrUpdateByBillingAccount(String billingAccountName,
        BillingAccountPolicyInner parameters) {
        return createOrUpdateByBillingAccountAsync(billingAccountName, parameters).block();
    }

    /**
     * Update the policies for a billing account of Enterprise Agreement type.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param parameters A policy at billing account scope.
     * @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 policy at billing account scope.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public BillingAccountPolicyInner createOrUpdateByBillingAccount(String billingAccountName,
        BillingAccountPolicyInner parameters, Context context) {
        return createOrUpdateByBillingAccountAsync(billingAccountName, parameters, context).block();
    }

    /**
     * Lists the policies that are managed by the Billing Admin for the defined subscriptions. This is supported for
     * Microsoft Online Services Program, Microsoft Customer Agreement and Microsoft Partner Agreement.
     * 
     * @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 policy at subscription scope along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> getBySubscriptionWithResponseAsync() {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono.error(new IllegalArgumentException(
                "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(context -> service.getBySubscription(this.client.getEndpoint(),
                this.client.getSubscriptionId(), this.client.getApiVersion(), accept, context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Lists the policies that are managed by the Billing Admin for the defined subscriptions. This is supported for
     * Microsoft Online Services Program, Microsoft Customer Agreement and Microsoft Partner Agreement.
     * 
     * @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 policy at subscription scope along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> getBySubscriptionWithResponseAsync(Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono.error(new IllegalArgumentException(
                "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service.getBySubscription(this.client.getEndpoint(), this.client.getSubscriptionId(),
            this.client.getApiVersion(), accept, context);
    }

    /**
     * Lists the policies that are managed by the Billing Admin for the defined subscriptions. This is supported for
     * Microsoft Online Services Program, Microsoft Customer Agreement and Microsoft Partner Agreement.
     * 
     * @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 policy at subscription scope on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono getBySubscriptionAsync() {
        return getBySubscriptionWithResponseAsync().flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Lists the policies that are managed by the Billing Admin for the defined subscriptions. This is supported for
     * Microsoft Online Services Program, Microsoft Customer Agreement and Microsoft Partner Agreement.
     * 
     * @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 policy at subscription scope along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response getBySubscriptionWithResponse(Context context) {
        return getBySubscriptionWithResponseAsync(context).block();
    }

    /**
     * Lists the policies that are managed by the Billing Admin for the defined subscriptions. This is supported for
     * Microsoft Online Services Program, Microsoft Customer Agreement and Microsoft Partner Agreement.
     * 
     * @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 policy at subscription scope.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public SubscriptionPolicyInner getBySubscription() {
        return getBySubscriptionWithResponse(Context.NONE).getValue();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy