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

package com.azure.resourcemanager.workloads.implementation;

import com.azure.core.annotation.BodyParam;
import com.azure.core.annotation.Delete;
import com.azure.core.annotation.ExpectedResponses;
import com.azure.core.annotation.Get;
import com.azure.core.annotation.HeaderParam;
import com.azure.core.annotation.Headers;
import com.azure.core.annotation.Host;
import com.azure.core.annotation.HostParam;
import com.azure.core.annotation.Patch;
import com.azure.core.annotation.PathParam;
import com.azure.core.annotation.Post;
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.PagedFlux;
import com.azure.core.http.rest.PagedIterable;
import com.azure.core.http.rest.PagedResponse;
import com.azure.core.http.rest.PagedResponseBase;
import com.azure.core.http.rest.Response;
import com.azure.core.http.rest.RestProxy;
import com.azure.core.management.exception.ManagementException;
import com.azure.core.management.polling.PollResult;
import com.azure.core.util.Context;
import com.azure.core.util.FluxUtil;
import com.azure.core.util.polling.PollerFlux;
import com.azure.core.util.polling.SyncPoller;
import com.azure.resourcemanager.workloads.fluent.SapDatabaseInstancesClient;
import com.azure.resourcemanager.workloads.fluent.models.OperationStatusResultInner;
import com.azure.resourcemanager.workloads.fluent.models.SapDatabaseInstanceInner;
import com.azure.resourcemanager.workloads.models.SapDatabaseInstanceList;
import com.azure.resourcemanager.workloads.models.StopRequest;
import com.azure.resourcemanager.workloads.models.UpdateSapDatabaseInstanceRequest;
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 SapDatabaseInstancesClient. */
public final class SapDatabaseInstancesClientImpl implements SapDatabaseInstancesClient {
    /** The proxy service used to perform REST calls. */
    private final SapDatabaseInstancesService service;

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

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

    /**
     * The interface defining all the services for WorkloadsClientSapDatabaseInstances to be used by the proxy service
     * to perform REST calls.
     */
    @Host("{$host}")
    @ServiceInterface(name = "WorkloadsClientSapDa")
    public interface SapDatabaseInstancesService {
        @Headers({"Content-Type: application/json"})
        @Get(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/databaseInstances/{databaseInstanceName}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<SapDatabaseInstanceInner>> get(
            @HostParam("$host") String endpoint,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("sapVirtualInstanceName") String sapVirtualInstanceName,
            @PathParam("databaseInstanceName") String databaseInstanceName,
            @QueryParam("api-version") String apiVersion,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Put(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/databaseInstances/{databaseInstanceName}")
        @ExpectedResponses({200, 201})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<Flux<ByteBuffer>>> create(
            @HostParam("$host") String endpoint,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("sapVirtualInstanceName") String sapVirtualInstanceName,
            @PathParam("databaseInstanceName") String databaseInstanceName,
            @QueryParam("api-version") String apiVersion,
            @BodyParam("application/json") SapDatabaseInstanceInner body,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Patch(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/databaseInstances/{databaseInstanceName}")
        @ExpectedResponses({200, 201})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<Flux<ByteBuffer>>> update(
            @HostParam("$host") String endpoint,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("sapVirtualInstanceName") String sapVirtualInstanceName,
            @PathParam("databaseInstanceName") String databaseInstanceName,
            @QueryParam("api-version") String apiVersion,
            @BodyParam("application/json") UpdateSapDatabaseInstanceRequest body,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Delete(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/databaseInstances/{databaseInstanceName}")
        @ExpectedResponses({200, 202, 204})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<Flux<ByteBuffer>>> delete(
            @HostParam("$host") String endpoint,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("sapVirtualInstanceName") String sapVirtualInstanceName,
            @PathParam("databaseInstanceName") String databaseInstanceName,
            @QueryParam("api-version") String apiVersion,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Get(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/databaseInstances")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<SapDatabaseInstanceList>> list(
            @HostParam("$host") String endpoint,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("sapVirtualInstanceName") String sapVirtualInstanceName,
            @QueryParam("api-version") String apiVersion,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Post(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/databaseInstances/{databaseInstanceName}/start")
        @ExpectedResponses({200, 202})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<Flux<ByteBuffer>>> startInstance(
            @HostParam("$host") String endpoint,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("sapVirtualInstanceName") String sapVirtualInstanceName,
            @PathParam("databaseInstanceName") String databaseInstanceName,
            @QueryParam("api-version") String apiVersion,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Post(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Workloads/sapVirtualInstances/{sapVirtualInstanceName}/databaseInstances/{databaseInstanceName}/stop")
        @ExpectedResponses({200, 202})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<Flux<ByteBuffer>>> stopInstance(
            @HostParam("$host") String endpoint,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @PathParam("sapVirtualInstanceName") String sapVirtualInstanceName,
            @PathParam("databaseInstanceName") String databaseInstanceName,
            @QueryParam("api-version") String apiVersion,
            @BodyParam("application/json") StopRequest body,
            @HeaderParam("Accept") String accept,
            Context context);

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

    /**
     * Gets the SAP Database Instance resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @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 SAP Database Instance resource along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<SapDatabaseInstanceInner>> getWithResponseAsync(
        String resourceGroupName, String sapVirtualInstanceName, String databaseInstanceName) {
        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."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (sapVirtualInstanceName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter sapVirtualInstanceName is required and cannot be null."));
        }
        if (databaseInstanceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter databaseInstanceName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .get(
                            this.client.getEndpoint(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            sapVirtualInstanceName,
                            databaseInstanceName,
                            this.client.getApiVersion(),
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Gets the SAP Database Instance resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @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 SAP Database Instance resource along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<SapDatabaseInstanceInner>> getWithResponseAsync(
        String resourceGroupName, String sapVirtualInstanceName, String databaseInstanceName, 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."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (sapVirtualInstanceName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter sapVirtualInstanceName is required and cannot be null."));
        }
        if (databaseInstanceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter databaseInstanceName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .get(
                this.client.getEndpoint(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                sapVirtualInstanceName,
                databaseInstanceName,
                this.client.getApiVersion(),
                accept,
                context);
    }

    /**
     * Gets the SAP Database Instance resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @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 SAP Database Instance resource on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<SapDatabaseInstanceInner> getAsync(
        String resourceGroupName, String sapVirtualInstanceName, String databaseInstanceName) {
        return getWithResponseAsync(resourceGroupName, sapVirtualInstanceName, databaseInstanceName)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Gets the SAP Database Instance resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @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 SAP Database Instance resource along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<SapDatabaseInstanceInner> getWithResponse(
        String resourceGroupName, String sapVirtualInstanceName, String databaseInstanceName, Context context) {
        return getWithResponseAsync(resourceGroupName, sapVirtualInstanceName, databaseInstanceName, context).block();
    }

    /**
     * Gets the SAP Database Instance resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @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 SAP Database Instance resource.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public SapDatabaseInstanceInner get(
        String resourceGroupName, String sapVirtualInstanceName, String databaseInstanceName) {
        return getWithResponse(resourceGroupName, sapVirtualInstanceName, databaseInstanceName, Context.NONE)
            .getValue();
    }

    /**
     * Creates the Database resource corresponding to the Virtual Instance for SAP solutions resource.
     * &lt;br&gt;&lt;br&gt;This will be used by service only. PUT by end user will return a Bad Request error.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @param body Request body of Database resource of a SAP system.
     * @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 define the Database resource along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> createWithResponseAsync(
        String resourceGroupName,
        String sapVirtualInstanceName,
        String databaseInstanceName,
        SapDatabaseInstanceInner body) {
        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."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (sapVirtualInstanceName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter sapVirtualInstanceName is required and cannot be null."));
        }
        if (databaseInstanceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter databaseInstanceName is required and cannot be null."));
        }
        if (body != null) {
            body.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .create(
                            this.client.getEndpoint(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            sapVirtualInstanceName,
                            databaseInstanceName,
                            this.client.getApiVersion(),
                            body,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Creates the Database resource corresponding to the Virtual Instance for SAP solutions resource.
     * &lt;br&gt;&lt;br&gt;This will be used by service only. PUT by end user will return a Bad Request error.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @param body Request body of Database resource of a SAP system.
     * @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 define the Database resource along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> createWithResponseAsync(
        String resourceGroupName,
        String sapVirtualInstanceName,
        String databaseInstanceName,
        SapDatabaseInstanceInner body,
        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."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (sapVirtualInstanceName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter sapVirtualInstanceName is required and cannot be null."));
        }
        if (databaseInstanceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter databaseInstanceName is required and cannot be null."));
        }
        if (body != null) {
            body.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .create(
                this.client.getEndpoint(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                sapVirtualInstanceName,
                databaseInstanceName,
                this.client.getApiVersion(),
                body,
                accept,
                context);
    }

    /**
     * Creates the Database resource corresponding to the Virtual Instance for SAP solutions resource.
     * &lt;br&gt;&lt;br&gt;This will be used by service only. PUT by end user will return a Bad Request error.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @param body Request body of Database resource of a SAP system.
     * @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 define the Database resource.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<SapDatabaseInstanceInner>, SapDatabaseInstanceInner> beginCreateAsync(
        String resourceGroupName,
        String sapVirtualInstanceName,
        String databaseInstanceName,
        SapDatabaseInstanceInner body) {
        Mono<Response<Flux<ByteBuffer>>> mono =
            createWithResponseAsync(resourceGroupName, sapVirtualInstanceName, databaseInstanceName, body);
        return this
            .client
            .<SapDatabaseInstanceInner, SapDatabaseInstanceInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                SapDatabaseInstanceInner.class,
                SapDatabaseInstanceInner.class,
                this.client.getContext());
    }

    /**
     * Creates the Database resource corresponding to the Virtual Instance for SAP solutions resource.
     * &lt;br&gt;&lt;br&gt;This will be used by service only. PUT by end user will return a Bad Request error.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @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 define the Database resource.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<SapDatabaseInstanceInner>, SapDatabaseInstanceInner> beginCreateAsync(
        String resourceGroupName, String sapVirtualInstanceName, String databaseInstanceName) {
        final SapDatabaseInstanceInner body = null;
        Mono<Response<Flux<ByteBuffer>>> mono =
            createWithResponseAsync(resourceGroupName, sapVirtualInstanceName, databaseInstanceName, body);
        return this
            .client
            .<SapDatabaseInstanceInner, SapDatabaseInstanceInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                SapDatabaseInstanceInner.class,
                SapDatabaseInstanceInner.class,
                this.client.getContext());
    }

    /**
     * Creates the Database resource corresponding to the Virtual Instance for SAP solutions resource.
     * &lt;br&gt;&lt;br&gt;This will be used by service only. PUT by end user will return a Bad Request error.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @param body Request body of Database resource of a SAP system.
     * @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 define the Database resource.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<SapDatabaseInstanceInner>, SapDatabaseInstanceInner> beginCreateAsync(
        String resourceGroupName,
        String sapVirtualInstanceName,
        String databaseInstanceName,
        SapDatabaseInstanceInner body,
        Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono =
            createWithResponseAsync(resourceGroupName, sapVirtualInstanceName, databaseInstanceName, body, context);
        return this
            .client
            .<SapDatabaseInstanceInner, SapDatabaseInstanceInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                SapDatabaseInstanceInner.class,
                SapDatabaseInstanceInner.class,
                context);
    }

    /**
     * Creates the Database resource corresponding to the Virtual Instance for SAP solutions resource.
     * &lt;br&gt;&lt;br&gt;This will be used by service only. PUT by end user will return a Bad Request error.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @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 define the Database resource.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<SapDatabaseInstanceInner>, SapDatabaseInstanceInner> beginCreate(
        String resourceGroupName, String sapVirtualInstanceName, String databaseInstanceName) {
        final SapDatabaseInstanceInner body = null;
        return this
            .beginCreateAsync(resourceGroupName, sapVirtualInstanceName, databaseInstanceName, body)
            .getSyncPoller();
    }

    /**
     * Creates the Database resource corresponding to the Virtual Instance for SAP solutions resource.
     * &lt;br&gt;&lt;br&gt;This will be used by service only. PUT by end user will return a Bad Request error.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @param body Request body of Database resource of a SAP system.
     * @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 define the Database resource.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<SapDatabaseInstanceInner>, SapDatabaseInstanceInner> beginCreate(
        String resourceGroupName,
        String sapVirtualInstanceName,
        String databaseInstanceName,
        SapDatabaseInstanceInner body,
        Context context) {
        return this
            .beginCreateAsync(resourceGroupName, sapVirtualInstanceName, databaseInstanceName, body, context)
            .getSyncPoller();
    }

    /**
     * Creates the Database resource corresponding to the Virtual Instance for SAP solutions resource.
     * &lt;br&gt;&lt;br&gt;This will be used by service only. PUT by end user will return a Bad Request error.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @param body Request body of Database resource of a SAP system.
     * @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 define the Database resource on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<SapDatabaseInstanceInner> createAsync(
        String resourceGroupName,
        String sapVirtualInstanceName,
        String databaseInstanceName,
        SapDatabaseInstanceInner body) {
        return beginCreateAsync(resourceGroupName, sapVirtualInstanceName, databaseInstanceName, body)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Creates the Database resource corresponding to the Virtual Instance for SAP solutions resource.
     * &lt;br&gt;&lt;br&gt;This will be used by service only. PUT by end user will return a Bad Request error.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @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 define the Database resource on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<SapDatabaseInstanceInner> createAsync(
        String resourceGroupName, String sapVirtualInstanceName, String databaseInstanceName) {
        final SapDatabaseInstanceInner body = null;
        return beginCreateAsync(resourceGroupName, sapVirtualInstanceName, databaseInstanceName, body)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Creates the Database resource corresponding to the Virtual Instance for SAP solutions resource.
     * &lt;br&gt;&lt;br&gt;This will be used by service only. PUT by end user will return a Bad Request error.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @param body Request body of Database resource of a SAP system.
     * @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 define the Database resource on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<SapDatabaseInstanceInner> createAsync(
        String resourceGroupName,
        String sapVirtualInstanceName,
        String databaseInstanceName,
        SapDatabaseInstanceInner body,
        Context context) {
        return beginCreateAsync(resourceGroupName, sapVirtualInstanceName, databaseInstanceName, body, context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Creates the Database resource corresponding to the Virtual Instance for SAP solutions resource.
     * &lt;br&gt;&lt;br&gt;This will be used by service only. PUT by end user will return a Bad Request error.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @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 define the Database resource.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public SapDatabaseInstanceInner create(
        String resourceGroupName, String sapVirtualInstanceName, String databaseInstanceName) {
        final SapDatabaseInstanceInner body = null;
        return createAsync(resourceGroupName, sapVirtualInstanceName, databaseInstanceName, body).block();
    }

    /**
     * Creates the Database resource corresponding to the Virtual Instance for SAP solutions resource.
     * &lt;br&gt;&lt;br&gt;This will be used by service only. PUT by end user will return a Bad Request error.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @param body Request body of Database resource of a SAP system.
     * @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 define the Database resource.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public SapDatabaseInstanceInner create(
        String resourceGroupName,
        String sapVirtualInstanceName,
        String databaseInstanceName,
        SapDatabaseInstanceInner body,
        Context context) {
        return createAsync(resourceGroupName, sapVirtualInstanceName, databaseInstanceName, body, context).block();
    }

    /**
     * Updates the Database resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @param body Database resource update request body.
     * @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 define the Database resource along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> updateWithResponseAsync(
        String resourceGroupName,
        String sapVirtualInstanceName,
        String databaseInstanceName,
        UpdateSapDatabaseInstanceRequest body) {
        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."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (sapVirtualInstanceName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter sapVirtualInstanceName is required and cannot be null."));
        }
        if (databaseInstanceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter databaseInstanceName is required and cannot be null."));
        }
        if (body != null) {
            body.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .update(
                            this.client.getEndpoint(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            sapVirtualInstanceName,
                            databaseInstanceName,
                            this.client.getApiVersion(),
                            body,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Updates the Database resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @param body Database resource update request body.
     * @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 define the Database resource along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> updateWithResponseAsync(
        String resourceGroupName,
        String sapVirtualInstanceName,
        String databaseInstanceName,
        UpdateSapDatabaseInstanceRequest body,
        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."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (sapVirtualInstanceName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter sapVirtualInstanceName is required and cannot be null."));
        }
        if (databaseInstanceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter databaseInstanceName is required and cannot be null."));
        }
        if (body != null) {
            body.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .update(
                this.client.getEndpoint(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                sapVirtualInstanceName,
                databaseInstanceName,
                this.client.getApiVersion(),
                body,
                accept,
                context);
    }

    /**
     * Updates the Database resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @param body Database resource update request body.
     * @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 define the Database resource.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<SapDatabaseInstanceInner>, SapDatabaseInstanceInner> beginUpdateAsync(
        String resourceGroupName,
        String sapVirtualInstanceName,
        String databaseInstanceName,
        UpdateSapDatabaseInstanceRequest body) {
        Mono<Response<Flux<ByteBuffer>>> mono =
            updateWithResponseAsync(resourceGroupName, sapVirtualInstanceName, databaseInstanceName, body);
        return this
            .client
            .<SapDatabaseInstanceInner, SapDatabaseInstanceInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                SapDatabaseInstanceInner.class,
                SapDatabaseInstanceInner.class,
                this.client.getContext());
    }

    /**
     * Updates the Database resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @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 define the Database resource.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<SapDatabaseInstanceInner>, SapDatabaseInstanceInner> beginUpdateAsync(
        String resourceGroupName, String sapVirtualInstanceName, String databaseInstanceName) {
        final UpdateSapDatabaseInstanceRequest body = null;
        Mono<Response<Flux<ByteBuffer>>> mono =
            updateWithResponseAsync(resourceGroupName, sapVirtualInstanceName, databaseInstanceName, body);
        return this
            .client
            .<SapDatabaseInstanceInner, SapDatabaseInstanceInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                SapDatabaseInstanceInner.class,
                SapDatabaseInstanceInner.class,
                this.client.getContext());
    }

    /**
     * Updates the Database resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @param body Database resource update request body.
     * @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 define the Database resource.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<SapDatabaseInstanceInner>, SapDatabaseInstanceInner> beginUpdateAsync(
        String resourceGroupName,
        String sapVirtualInstanceName,
        String databaseInstanceName,
        UpdateSapDatabaseInstanceRequest body,
        Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono =
            updateWithResponseAsync(resourceGroupName, sapVirtualInstanceName, databaseInstanceName, body, context);
        return this
            .client
            .<SapDatabaseInstanceInner, SapDatabaseInstanceInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                SapDatabaseInstanceInner.class,
                SapDatabaseInstanceInner.class,
                context);
    }

    /**
     * Updates the Database resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @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 define the Database resource.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<SapDatabaseInstanceInner>, SapDatabaseInstanceInner> beginUpdate(
        String resourceGroupName, String sapVirtualInstanceName, String databaseInstanceName) {
        final UpdateSapDatabaseInstanceRequest body = null;
        return this
            .beginUpdateAsync(resourceGroupName, sapVirtualInstanceName, databaseInstanceName, body)
            .getSyncPoller();
    }

    /**
     * Updates the Database resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @param body Database resource update request body.
     * @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 define the Database resource.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<SapDatabaseInstanceInner>, SapDatabaseInstanceInner> beginUpdate(
        String resourceGroupName,
        String sapVirtualInstanceName,
        String databaseInstanceName,
        UpdateSapDatabaseInstanceRequest body,
        Context context) {
        return this
            .beginUpdateAsync(resourceGroupName, sapVirtualInstanceName, databaseInstanceName, body, context)
            .getSyncPoller();
    }

    /**
     * Updates the Database resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @param body Database resource update request body.
     * @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 define the Database resource on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<SapDatabaseInstanceInner> updateAsync(
        String resourceGroupName,
        String sapVirtualInstanceName,
        String databaseInstanceName,
        UpdateSapDatabaseInstanceRequest body) {
        return beginUpdateAsync(resourceGroupName, sapVirtualInstanceName, databaseInstanceName, body)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Updates the Database resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @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 define the Database resource on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<SapDatabaseInstanceInner> updateAsync(
        String resourceGroupName, String sapVirtualInstanceName, String databaseInstanceName) {
        final UpdateSapDatabaseInstanceRequest body = null;
        return beginUpdateAsync(resourceGroupName, sapVirtualInstanceName, databaseInstanceName, body)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Updates the Database resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @param body Database resource update request body.
     * @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 define the Database resource on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<SapDatabaseInstanceInner> updateAsync(
        String resourceGroupName,
        String sapVirtualInstanceName,
        String databaseInstanceName,
        UpdateSapDatabaseInstanceRequest body,
        Context context) {
        return beginUpdateAsync(resourceGroupName, sapVirtualInstanceName, databaseInstanceName, body, context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Updates the Database resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @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 define the Database resource.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public SapDatabaseInstanceInner update(
        String resourceGroupName, String sapVirtualInstanceName, String databaseInstanceName) {
        final UpdateSapDatabaseInstanceRequest body = null;
        return updateAsync(resourceGroupName, sapVirtualInstanceName, databaseInstanceName, body).block();
    }

    /**
     * Updates the Database resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @param body Database resource update request body.
     * @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 define the Database resource.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public SapDatabaseInstanceInner update(
        String resourceGroupName,
        String sapVirtualInstanceName,
        String databaseInstanceName,
        UpdateSapDatabaseInstanceRequest body,
        Context context) {
        return updateAsync(resourceGroupName, sapVirtualInstanceName, databaseInstanceName, body, context).block();
    }

    /**
     * Deletes the Database resource corresponding to a Virtual Instance for SAP solutions resource.
     * &lt;br&gt;&lt;br&gt;This will be used by service only. Delete by end user will return a Bad Request error.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @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 current status of an async operation along with {@link Response} on successful completion of {@link
     *     Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> deleteWithResponseAsync(
        String resourceGroupName, String sapVirtualInstanceName, String databaseInstanceName) {
        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."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (sapVirtualInstanceName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter sapVirtualInstanceName is required and cannot be null."));
        }
        if (databaseInstanceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter databaseInstanceName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .delete(
                            this.client.getEndpoint(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            sapVirtualInstanceName,
                            databaseInstanceName,
                            this.client.getApiVersion(),
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Deletes the Database resource corresponding to a Virtual Instance for SAP solutions resource.
     * &lt;br&gt;&lt;br&gt;This will be used by service only. Delete by end user will return a Bad Request error.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @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 current status of an async operation along with {@link Response} on successful completion of {@link
     *     Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> deleteWithResponseAsync(
        String resourceGroupName, String sapVirtualInstanceName, String databaseInstanceName, 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."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (sapVirtualInstanceName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter sapVirtualInstanceName is required and cannot be null."));
        }
        if (databaseInstanceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter databaseInstanceName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .delete(
                this.client.getEndpoint(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                sapVirtualInstanceName,
                databaseInstanceName,
                this.client.getApiVersion(),
                accept,
                context);
    }

    /**
     * Deletes the Database resource corresponding to a Virtual Instance for SAP solutions resource.
     * &lt;br&gt;&lt;br&gt;This will be used by service only. Delete by end user will return a Bad Request error.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link PollerFlux} for polling of the current status of an async operation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<OperationStatusResultInner>, OperationStatusResultInner> beginDeleteAsync(
        String resourceGroupName, String sapVirtualInstanceName, String databaseInstanceName) {
        Mono<Response<Flux<ByteBuffer>>> mono =
            deleteWithResponseAsync(resourceGroupName, sapVirtualInstanceName, databaseInstanceName);
        return this
            .client
            .<OperationStatusResultInner, OperationStatusResultInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                OperationStatusResultInner.class,
                OperationStatusResultInner.class,
                this.client.getContext());
    }

    /**
     * Deletes the Database resource corresponding to a Virtual Instance for SAP solutions resource.
     * &lt;br&gt;&lt;br&gt;This will be used by service only. Delete by end user will return a Bad Request error.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link PollerFlux} for polling of the current status of an async operation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<OperationStatusResultInner>, OperationStatusResultInner> beginDeleteAsync(
        String resourceGroupName, String sapVirtualInstanceName, String databaseInstanceName, Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono =
            deleteWithResponseAsync(resourceGroupName, sapVirtualInstanceName, databaseInstanceName, context);
        return this
            .client
            .<OperationStatusResultInner, OperationStatusResultInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                OperationStatusResultInner.class,
                OperationStatusResultInner.class,
                context);
    }

    /**
     * Deletes the Database resource corresponding to a Virtual Instance for SAP solutions resource.
     * &lt;br&gt;&lt;br&gt;This will be used by service only. Delete by end user will return a Bad Request error.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link SyncPoller} for polling of the current status of an async operation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<OperationStatusResultInner>, OperationStatusResultInner> beginDelete(
        String resourceGroupName, String sapVirtualInstanceName, String databaseInstanceName) {
        return this.beginDeleteAsync(resourceGroupName, sapVirtualInstanceName, databaseInstanceName).getSyncPoller();
    }

    /**
     * Deletes the Database resource corresponding to a Virtual Instance for SAP solutions resource.
     * &lt;br&gt;&lt;br&gt;This will be used by service only. Delete by end user will return a Bad Request error.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link SyncPoller} for polling of the current status of an async operation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<OperationStatusResultInner>, OperationStatusResultInner> beginDelete(
        String resourceGroupName, String sapVirtualInstanceName, String databaseInstanceName, Context context) {
        return this
            .beginDeleteAsync(resourceGroupName, sapVirtualInstanceName, databaseInstanceName, context)
            .getSyncPoller();
    }

    /**
     * Deletes the Database resource corresponding to a Virtual Instance for SAP solutions resource.
     * &lt;br&gt;&lt;br&gt;This will be used by service only. Delete by end user will return a Bad Request error.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @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 current status of an async operation on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<OperationStatusResultInner> deleteAsync(
        String resourceGroupName, String sapVirtualInstanceName, String databaseInstanceName) {
        return beginDeleteAsync(resourceGroupName, sapVirtualInstanceName, databaseInstanceName)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Deletes the Database resource corresponding to a Virtual Instance for SAP solutions resource.
     * &lt;br&gt;&lt;br&gt;This will be used by service only. Delete by end user will return a Bad Request error.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @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 current status of an async operation on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<OperationStatusResultInner> deleteAsync(
        String resourceGroupName, String sapVirtualInstanceName, String databaseInstanceName, Context context) {
        return beginDeleteAsync(resourceGroupName, sapVirtualInstanceName, databaseInstanceName, context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Deletes the Database resource corresponding to a Virtual Instance for SAP solutions resource.
     * &lt;br&gt;&lt;br&gt;This will be used by service only. Delete by end user will return a Bad Request error.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @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 current status of an async operation.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public OperationStatusResultInner delete(
        String resourceGroupName, String sapVirtualInstanceName, String databaseInstanceName) {
        return deleteAsync(resourceGroupName, sapVirtualInstanceName, databaseInstanceName).block();
    }

    /**
     * Deletes the Database resource corresponding to a Virtual Instance for SAP solutions resource.
     * &lt;br&gt;&lt;br&gt;This will be used by service only. Delete by end user will return a Bad Request error.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @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 current status of an async operation.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public OperationStatusResultInner delete(
        String resourceGroupName, String sapVirtualInstanceName, String databaseInstanceName, Context context) {
        return deleteAsync(resourceGroupName, sapVirtualInstanceName, databaseInstanceName, context).block();
    }

    /**
     * Lists the Database resources associated with a Virtual Instance for SAP solutions resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @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 defines the collection of SAP Database Instances along with {@link PagedResponse} on successful
     *     completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<SapDatabaseInstanceInner>> listSinglePageAsync(
        String resourceGroupName, String sapVirtualInstanceName) {
        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."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (sapVirtualInstanceName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter sapVirtualInstanceName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .list(
                            this.client.getEndpoint(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            sapVirtualInstanceName,
                            this.client.getApiVersion(),
                            accept,
                            context))
            .<PagedResponse<SapDatabaseInstanceInner>>map(
                res ->
                    new PagedResponseBase<>(
                        res.getRequest(),
                        res.getStatusCode(),
                        res.getHeaders(),
                        res.getValue().value(),
                        res.getValue().nextLink(),
                        null))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Lists the Database resources associated with a Virtual Instance for SAP solutions resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @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 defines the collection of SAP Database Instances along with {@link PagedResponse} on successful
     *     completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<SapDatabaseInstanceInner>> listSinglePageAsync(
        String resourceGroupName, String sapVirtualInstanceName, 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."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (sapVirtualInstanceName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter sapVirtualInstanceName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .list(
                this.client.getEndpoint(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                sapVirtualInstanceName,
                this.client.getApiVersion(),
                accept,
                context)
            .map(
                res ->
                    new PagedResponseBase<>(
                        res.getRequest(),
                        res.getStatusCode(),
                        res.getHeaders(),
                        res.getValue().value(),
                        res.getValue().nextLink(),
                        null));
    }

    /**
     * Lists the Database resources associated with a Virtual Instance for SAP solutions resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @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 defines the collection of SAP Database Instances as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<SapDatabaseInstanceInner> listAsync(String resourceGroupName, String sapVirtualInstanceName) {
        return new PagedFlux<>(
            () -> listSinglePageAsync(resourceGroupName, sapVirtualInstanceName),
            nextLink -> listNextSinglePageAsync(nextLink));
    }

    /**
     * Lists the Database resources associated with a Virtual Instance for SAP solutions resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @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 defines the collection of SAP Database Instances as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<SapDatabaseInstanceInner> listAsync(
        String resourceGroupName, String sapVirtualInstanceName, Context context) {
        return new PagedFlux<>(
            () -> listSinglePageAsync(resourceGroupName, sapVirtualInstanceName, context),
            nextLink -> listNextSinglePageAsync(nextLink, context));
    }

    /**
     * Lists the Database resources associated with a Virtual Instance for SAP solutions resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @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 defines the collection of SAP Database Instances as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<SapDatabaseInstanceInner> list(String resourceGroupName, String sapVirtualInstanceName) {
        return new PagedIterable<>(listAsync(resourceGroupName, sapVirtualInstanceName));
    }

    /**
     * Lists the Database resources associated with a Virtual Instance for SAP solutions resource.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @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 defines the collection of SAP Database Instances as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<SapDatabaseInstanceInner> list(
        String resourceGroupName, String sapVirtualInstanceName, Context context) {
        return new PagedIterable<>(listAsync(resourceGroupName, sapVirtualInstanceName, context));
    }

    /**
     * Starts the database instance of the SAP system.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @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 current status of an async operation along with {@link Response} on successful completion of {@link
     *     Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> startInstanceWithResponseAsync(
        String resourceGroupName, String sapVirtualInstanceName, String databaseInstanceName) {
        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."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (sapVirtualInstanceName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter sapVirtualInstanceName is required and cannot be null."));
        }
        if (databaseInstanceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter databaseInstanceName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .startInstance(
                            this.client.getEndpoint(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            sapVirtualInstanceName,
                            databaseInstanceName,
                            this.client.getApiVersion(),
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Starts the database instance of the SAP system.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @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 current status of an async operation along with {@link Response} on successful completion of {@link
     *     Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> startInstanceWithResponseAsync(
        String resourceGroupName, String sapVirtualInstanceName, String databaseInstanceName, 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."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (sapVirtualInstanceName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter sapVirtualInstanceName is required and cannot be null."));
        }
        if (databaseInstanceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter databaseInstanceName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .startInstance(
                this.client.getEndpoint(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                sapVirtualInstanceName,
                databaseInstanceName,
                this.client.getApiVersion(),
                accept,
                context);
    }

    /**
     * Starts the database instance of the SAP system.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link PollerFlux} for polling of the current status of an async operation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<OperationStatusResultInner>, OperationStatusResultInner> beginStartInstanceAsync(
        String resourceGroupName, String sapVirtualInstanceName, String databaseInstanceName) {
        Mono<Response<Flux<ByteBuffer>>> mono =
            startInstanceWithResponseAsync(resourceGroupName, sapVirtualInstanceName, databaseInstanceName);
        return this
            .client
            .<OperationStatusResultInner, OperationStatusResultInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                OperationStatusResultInner.class,
                OperationStatusResultInner.class,
                this.client.getContext());
    }

    /**
     * Starts the database instance of the SAP system.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link PollerFlux} for polling of the current status of an async operation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<OperationStatusResultInner>, OperationStatusResultInner> beginStartInstanceAsync(
        String resourceGroupName, String sapVirtualInstanceName, String databaseInstanceName, Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono =
            startInstanceWithResponseAsync(resourceGroupName, sapVirtualInstanceName, databaseInstanceName, context);
        return this
            .client
            .<OperationStatusResultInner, OperationStatusResultInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                OperationStatusResultInner.class,
                OperationStatusResultInner.class,
                context);
    }

    /**
     * Starts the database instance of the SAP system.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link SyncPoller} for polling of the current status of an async operation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<OperationStatusResultInner>, OperationStatusResultInner> beginStartInstance(
        String resourceGroupName, String sapVirtualInstanceName, String databaseInstanceName) {
        return this
            .beginStartInstanceAsync(resourceGroupName, sapVirtualInstanceName, databaseInstanceName)
            .getSyncPoller();
    }

    /**
     * Starts the database instance of the SAP system.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link SyncPoller} for polling of the current status of an async operation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<OperationStatusResultInner>, OperationStatusResultInner> beginStartInstance(
        String resourceGroupName, String sapVirtualInstanceName, String databaseInstanceName, Context context) {
        return this
            .beginStartInstanceAsync(resourceGroupName, sapVirtualInstanceName, databaseInstanceName, context)
            .getSyncPoller();
    }

    /**
     * Starts the database instance of the SAP system.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @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 current status of an async operation on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<OperationStatusResultInner> startInstanceAsync(
        String resourceGroupName, String sapVirtualInstanceName, String databaseInstanceName) {
        return beginStartInstanceAsync(resourceGroupName, sapVirtualInstanceName, databaseInstanceName)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Starts the database instance of the SAP system.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @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 current status of an async operation on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<OperationStatusResultInner> startInstanceAsync(
        String resourceGroupName, String sapVirtualInstanceName, String databaseInstanceName, Context context) {
        return beginStartInstanceAsync(resourceGroupName, sapVirtualInstanceName, databaseInstanceName, context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Starts the database instance of the SAP system.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @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 current status of an async operation.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public OperationStatusResultInner startInstance(
        String resourceGroupName, String sapVirtualInstanceName, String databaseInstanceName) {
        return startInstanceAsync(resourceGroupName, sapVirtualInstanceName, databaseInstanceName).block();
    }

    /**
     * Starts the database instance of the SAP system.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @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 current status of an async operation.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public OperationStatusResultInner startInstance(
        String resourceGroupName, String sapVirtualInstanceName, String databaseInstanceName, Context context) {
        return startInstanceAsync(resourceGroupName, sapVirtualInstanceName, databaseInstanceName, context).block();
    }

    /**
     * Stops the database instance of the SAP system.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @param body Stop request for the database instance of the SAP system.
     * @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 current status of an async operation along with {@link Response} on successful completion of {@link
     *     Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> stopInstanceWithResponseAsync(
        String resourceGroupName, String sapVirtualInstanceName, String databaseInstanceName, StopRequest body) {
        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."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (sapVirtualInstanceName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter sapVirtualInstanceName is required and cannot be null."));
        }
        if (databaseInstanceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter databaseInstanceName is required and cannot be null."));
        }
        if (body != null) {
            body.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .stopInstance(
                            this.client.getEndpoint(),
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            sapVirtualInstanceName,
                            databaseInstanceName,
                            this.client.getApiVersion(),
                            body,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Stops the database instance of the SAP system.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @param body Stop request for the database instance of the SAP system.
     * @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 current status of an async operation along with {@link Response} on successful completion of {@link
     *     Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> stopInstanceWithResponseAsync(
        String resourceGroupName,
        String sapVirtualInstanceName,
        String databaseInstanceName,
        StopRequest body,
        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."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (sapVirtualInstanceName == null) {
            return Mono
                .error(
                    new IllegalArgumentException("Parameter sapVirtualInstanceName is required and cannot be null."));
        }
        if (databaseInstanceName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter databaseInstanceName is required and cannot be null."));
        }
        if (body != null) {
            body.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .stopInstance(
                this.client.getEndpoint(),
                this.client.getSubscriptionId(),
                resourceGroupName,
                sapVirtualInstanceName,
                databaseInstanceName,
                this.client.getApiVersion(),
                body,
                accept,
                context);
    }

    /**
     * Stops the database instance of the SAP system.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @param body Stop request for the database instance of the SAP system.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link PollerFlux} for polling of the current status of an async operation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<OperationStatusResultInner>, OperationStatusResultInner> beginStopInstanceAsync(
        String resourceGroupName, String sapVirtualInstanceName, String databaseInstanceName, StopRequest body) {
        Mono<Response<Flux<ByteBuffer>>> mono =
            stopInstanceWithResponseAsync(resourceGroupName, sapVirtualInstanceName, databaseInstanceName, body);
        return this
            .client
            .<OperationStatusResultInner, OperationStatusResultInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                OperationStatusResultInner.class,
                OperationStatusResultInner.class,
                this.client.getContext());
    }

    /**
     * Stops the database instance of the SAP system.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link PollerFlux} for polling of the current status of an async operation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<OperationStatusResultInner>, OperationStatusResultInner> beginStopInstanceAsync(
        String resourceGroupName, String sapVirtualInstanceName, String databaseInstanceName) {
        final StopRequest body = null;
        Mono<Response<Flux<ByteBuffer>>> mono =
            stopInstanceWithResponseAsync(resourceGroupName, sapVirtualInstanceName, databaseInstanceName, body);
        return this
            .client
            .<OperationStatusResultInner, OperationStatusResultInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                OperationStatusResultInner.class,
                OperationStatusResultInner.class,
                this.client.getContext());
    }

    /**
     * Stops the database instance of the SAP system.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @param body Stop request for the database instance of the SAP system.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link PollerFlux} for polling of the current status of an async operation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<OperationStatusResultInner>, OperationStatusResultInner> beginStopInstanceAsync(
        String resourceGroupName,
        String sapVirtualInstanceName,
        String databaseInstanceName,
        StopRequest body,
        Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono =
            stopInstanceWithResponseAsync(
                resourceGroupName, sapVirtualInstanceName, databaseInstanceName, body, context);
        return this
            .client
            .<OperationStatusResultInner, OperationStatusResultInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                OperationStatusResultInner.class,
                OperationStatusResultInner.class,
                context);
    }

    /**
     * Stops the database instance of the SAP system.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link SyncPoller} for polling of the current status of an async operation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<OperationStatusResultInner>, OperationStatusResultInner> beginStopInstance(
        String resourceGroupName, String sapVirtualInstanceName, String databaseInstanceName) {
        final StopRequest body = null;
        return this
            .beginStopInstanceAsync(resourceGroupName, sapVirtualInstanceName, databaseInstanceName, body)
            .getSyncPoller();
    }

    /**
     * Stops the database instance of the SAP system.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @param body Stop request for the database instance of the SAP system.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link SyncPoller} for polling of the current status of an async operation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<OperationStatusResultInner>, OperationStatusResultInner> beginStopInstance(
        String resourceGroupName,
        String sapVirtualInstanceName,
        String databaseInstanceName,
        StopRequest body,
        Context context) {
        return this
            .beginStopInstanceAsync(resourceGroupName, sapVirtualInstanceName, databaseInstanceName, body, context)
            .getSyncPoller();
    }

    /**
     * Stops the database instance of the SAP system.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @param body Stop request for the database instance of the SAP system.
     * @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 current status of an async operation on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<OperationStatusResultInner> stopInstanceAsync(
        String resourceGroupName, String sapVirtualInstanceName, String databaseInstanceName, StopRequest body) {
        return beginStopInstanceAsync(resourceGroupName, sapVirtualInstanceName, databaseInstanceName, body)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Stops the database instance of the SAP system.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @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 current status of an async operation on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<OperationStatusResultInner> stopInstanceAsync(
        String resourceGroupName, String sapVirtualInstanceName, String databaseInstanceName) {
        final StopRequest body = null;
        return beginStopInstanceAsync(resourceGroupName, sapVirtualInstanceName, databaseInstanceName, body)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Stops the database instance of the SAP system.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @param body Stop request for the database instance of the SAP system.
     * @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 current status of an async operation on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<OperationStatusResultInner> stopInstanceAsync(
        String resourceGroupName,
        String sapVirtualInstanceName,
        String databaseInstanceName,
        StopRequest body,
        Context context) {
        return beginStopInstanceAsync(resourceGroupName, sapVirtualInstanceName, databaseInstanceName, body, context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Stops the database instance of the SAP system.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @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 current status of an async operation.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public OperationStatusResultInner stopInstance(
        String resourceGroupName, String sapVirtualInstanceName, String databaseInstanceName) {
        final StopRequest body = null;
        return stopInstanceAsync(resourceGroupName, sapVirtualInstanceName, databaseInstanceName, body).block();
    }

    /**
     * Stops the database instance of the SAP system.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param sapVirtualInstanceName The name of the Virtual Instances for SAP solutions resource.
     * @param databaseInstanceName Database resource name string modeled as parameter for auto generation to work
     *     correctly.
     * @param body Stop request for the database instance of the SAP system.
     * @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 current status of an async operation.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public OperationStatusResultInner stopInstance(
        String resourceGroupName,
        String sapVirtualInstanceName,
        String databaseInstanceName,
        StopRequest body,
        Context context) {
        return stopInstanceAsync(resourceGroupName, sapVirtualInstanceName, databaseInstanceName, body, context)
            .block();
    }

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

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