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

package com.azure.resourcemanager.synapse.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.PathParam;
import com.azure.core.annotation.Put;
import com.azure.core.annotation.QueryParam;
import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceInterface;
import com.azure.core.annotation.ServiceMethod;
import com.azure.core.annotation.UnexpectedResponseExceptionType;
import com.azure.core.http.rest.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.synapse.fluent.KustoPoolAttachedDatabaseConfigurationsClient;
import com.azure.resourcemanager.synapse.fluent.models.AttachedDatabaseConfigurationInner;
import com.azure.resourcemanager.synapse.models.AttachedDatabaseConfigurationListResult;
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
 * KustoPoolAttachedDatabaseConfigurationsClient.
 */
public final class KustoPoolAttachedDatabaseConfigurationsClientImpl
    implements KustoPoolAttachedDatabaseConfigurationsClient {
    /** The proxy service used to perform REST calls. */
    private final KustoPoolAttachedDatabaseConfigurationsService service;

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

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

    /**
     * The interface defining all the services for SynapseManagementClientKustoPoolAttachedDatabaseConfigurations to be
     * used by the proxy service to perform REST calls.
     */
    @Host("{$host}")
    @ServiceInterface(name = "SynapseManagementCli")
    public interface KustoPoolAttachedDatabaseConfigurationsService {
        @Headers({"Content-Type: application/json"})
        @Get(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces"
                + "/{workspaceName}/kustoPools/{kustoPoolName}/attachedDatabaseConfigurations")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<AttachedDatabaseConfigurationListResult>> listByKustoPool(
            @HostParam("$host") String endpoint,
            @PathParam("workspaceName") String workspaceName,
            @PathParam("kustoPoolName") String kustoPoolName,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @QueryParam("api-version") String apiVersion,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Get(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces"
                + "/{workspaceName}/kustoPools/{kustoPoolName}/attachedDatabaseConfigurations"
                + "/{attachedDatabaseConfigurationName}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<AttachedDatabaseConfigurationInner>> get(
            @HostParam("$host") String endpoint,
            @PathParam("workspaceName") String workspaceName,
            @PathParam("kustoPoolName") String kustoPoolName,
            @PathParam("attachedDatabaseConfigurationName") String attachedDatabaseConfigurationName,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @QueryParam("api-version") String apiVersion,
            @HeaderParam("Accept") String accept,
            Context context);

        @Headers({"Content-Type: application/json"})
        @Put(
            "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces"
                + "/{workspaceName}/kustoPools/{kustoPoolName}/attachedDatabaseConfigurations"
                + "/{attachedDatabaseConfigurationName}")
        @ExpectedResponses({200, 201, 202})
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono<Response<Flux<ByteBuffer>>> createOrUpdate(
            @HostParam("$host") String endpoint,
            @PathParam("workspaceName") String workspaceName,
            @PathParam("kustoPoolName") String kustoPoolName,
            @PathParam("attachedDatabaseConfigurationName") String attachedDatabaseConfigurationName,
            @PathParam("subscriptionId") String subscriptionId,
            @PathParam("resourceGroupName") String resourceGroupName,
            @QueryParam("api-version") String apiVersion,
            @BodyParam("application/json") AttachedDatabaseConfigurationInner parameters,
            @HeaderParam("Accept") String accept,
            Context context);

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

    /**
     * Returns the list of attached database configurations of the given Kusto Pool.
     *
     * @param workspaceName The name of the workspace.
     * @param kustoPoolName The name of the Kusto pool.
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the list attached database configurations operation response along with {@link PagedResponse} on
     *     successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<AttachedDatabaseConfigurationInner>> listByKustoPoolSinglePageAsync(
        String workspaceName, String kustoPoolName, String resourceGroupName) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (workspaceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter workspaceName is required and cannot be null."));
        }
        if (kustoPoolName == null) {
            return Mono.error(new IllegalArgumentException("Parameter kustoPoolName 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."));
        }
        final String apiVersion = "2021-06-01-preview";
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .listByKustoPool(
                            this.client.getEndpoint(),
                            workspaceName,
                            kustoPoolName,
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            apiVersion,
                            accept,
                            context))
            .<PagedResponse<AttachedDatabaseConfigurationInner>>map(
                res ->
                    new PagedResponseBase<>(
                        res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), null, null))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Returns the list of attached database configurations of the given Kusto Pool.
     *
     * @param workspaceName The name of the workspace.
     * @param kustoPoolName The name of the Kusto pool.
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the list attached database configurations operation response along with {@link PagedResponse} on
     *     successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<AttachedDatabaseConfigurationInner>> listByKustoPoolSinglePageAsync(
        String workspaceName, String kustoPoolName, String resourceGroupName, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (workspaceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter workspaceName is required and cannot be null."));
        }
        if (kustoPoolName == null) {
            return Mono.error(new IllegalArgumentException("Parameter kustoPoolName 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."));
        }
        final String apiVersion = "2021-06-01-preview";
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .listByKustoPool(
                this.client.getEndpoint(),
                workspaceName,
                kustoPoolName,
                this.client.getSubscriptionId(),
                resourceGroupName,
                apiVersion,
                accept,
                context)
            .map(
                res ->
                    new PagedResponseBase<>(
                        res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), null, null));
    }

    /**
     * Returns the list of attached database configurations of the given Kusto Pool.
     *
     * @param workspaceName The name of the workspace.
     * @param kustoPoolName The name of the Kusto pool.
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the list attached database configurations operation response as paginated response with {@link
     *     PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<AttachedDatabaseConfigurationInner> listByKustoPoolAsync(
        String workspaceName, String kustoPoolName, String resourceGroupName) {
        return new PagedFlux<>(() -> listByKustoPoolSinglePageAsync(workspaceName, kustoPoolName, resourceGroupName));
    }

    /**
     * Returns the list of attached database configurations of the given Kusto Pool.
     *
     * @param workspaceName The name of the workspace.
     * @param kustoPoolName The name of the Kusto pool.
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the list attached database configurations operation response as paginated response with {@link
     *     PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux<AttachedDatabaseConfigurationInner> listByKustoPoolAsync(
        String workspaceName, String kustoPoolName, String resourceGroupName, Context context) {
        return new PagedFlux<>(
            () -> listByKustoPoolSinglePageAsync(workspaceName, kustoPoolName, resourceGroupName, context));
    }

    /**
     * Returns the list of attached database configurations of the given Kusto Pool.
     *
     * @param workspaceName The name of the workspace.
     * @param kustoPoolName The name of the Kusto pool.
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the list attached database configurations operation response as paginated response with {@link
     *     PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<AttachedDatabaseConfigurationInner> listByKustoPool(
        String workspaceName, String kustoPoolName, String resourceGroupName) {
        return new PagedIterable<>(listByKustoPoolAsync(workspaceName, kustoPoolName, resourceGroupName));
    }

    /**
     * Returns the list of attached database configurations of the given Kusto Pool.
     *
     * @param workspaceName The name of the workspace.
     * @param kustoPoolName The name of the Kusto pool.
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the list attached database configurations operation response as paginated response with {@link
     *     PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<AttachedDatabaseConfigurationInner> listByKustoPool(
        String workspaceName, String kustoPoolName, String resourceGroupName, Context context) {
        return new PagedIterable<>(listByKustoPoolAsync(workspaceName, kustoPoolName, resourceGroupName, context));
    }

    /**
     * Returns an attached database configuration.
     *
     * @param workspaceName The name of the workspace.
     * @param kustoPoolName The name of the Kusto pool.
     * @param attachedDatabaseConfigurationName The name of the attached database configuration.
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return class representing an attached database configuration along with {@link Response} on successful
     *     completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<AttachedDatabaseConfigurationInner>> getWithResponseAsync(
        String workspaceName,
        String kustoPoolName,
        String attachedDatabaseConfigurationName,
        String resourceGroupName) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (workspaceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter workspaceName is required and cannot be null."));
        }
        if (kustoPoolName == null) {
            return Mono.error(new IllegalArgumentException("Parameter kustoPoolName is required and cannot be null."));
        }
        if (attachedDatabaseConfigurationName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter attachedDatabaseConfigurationName 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."));
        }
        final String apiVersion = "2021-06-01-preview";
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .get(
                            this.client.getEndpoint(),
                            workspaceName,
                            kustoPoolName,
                            attachedDatabaseConfigurationName,
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            apiVersion,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Returns an attached database configuration.
     *
     * @param workspaceName The name of the workspace.
     * @param kustoPoolName The name of the Kusto pool.
     * @param attachedDatabaseConfigurationName The name of the attached database configuration.
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @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 class representing an attached database configuration along with {@link Response} on successful
     *     completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<AttachedDatabaseConfigurationInner>> getWithResponseAsync(
        String workspaceName,
        String kustoPoolName,
        String attachedDatabaseConfigurationName,
        String resourceGroupName,
        Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (workspaceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter workspaceName is required and cannot be null."));
        }
        if (kustoPoolName == null) {
            return Mono.error(new IllegalArgumentException("Parameter kustoPoolName is required and cannot be null."));
        }
        if (attachedDatabaseConfigurationName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter attachedDatabaseConfigurationName 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."));
        }
        final String apiVersion = "2021-06-01-preview";
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .get(
                this.client.getEndpoint(),
                workspaceName,
                kustoPoolName,
                attachedDatabaseConfigurationName,
                this.client.getSubscriptionId(),
                resourceGroupName,
                apiVersion,
                accept,
                context);
    }

    /**
     * Returns an attached database configuration.
     *
     * @param workspaceName The name of the workspace.
     * @param kustoPoolName The name of the Kusto pool.
     * @param attachedDatabaseConfigurationName The name of the attached database configuration.
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return class representing an attached database configuration on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<AttachedDatabaseConfigurationInner> getAsync(
        String workspaceName,
        String kustoPoolName,
        String attachedDatabaseConfigurationName,
        String resourceGroupName) {
        return getWithResponseAsync(workspaceName, kustoPoolName, attachedDatabaseConfigurationName, resourceGroupName)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Returns an attached database configuration.
     *
     * @param workspaceName The name of the workspace.
     * @param kustoPoolName The name of the Kusto pool.
     * @param attachedDatabaseConfigurationName The name of the attached database configuration.
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @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 class representing an attached database configuration along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<AttachedDatabaseConfigurationInner> getWithResponse(
        String workspaceName,
        String kustoPoolName,
        String attachedDatabaseConfigurationName,
        String resourceGroupName,
        Context context) {
        return getWithResponseAsync(
                workspaceName, kustoPoolName, attachedDatabaseConfigurationName, resourceGroupName, context)
            .block();
    }

    /**
     * Returns an attached database configuration.
     *
     * @param workspaceName The name of the workspace.
     * @param kustoPoolName The name of the Kusto pool.
     * @param attachedDatabaseConfigurationName The name of the attached database configuration.
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return class representing an attached database configuration.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public AttachedDatabaseConfigurationInner get(
        String workspaceName,
        String kustoPoolName,
        String attachedDatabaseConfigurationName,
        String resourceGroupName) {
        return getWithResponse(
                workspaceName, kustoPoolName, attachedDatabaseConfigurationName, resourceGroupName, Context.NONE)
            .getValue();
    }

    /**
     * Creates or updates an attached database configuration.
     *
     * @param workspaceName The name of the workspace.
     * @param kustoPoolName The name of the Kusto pool.
     * @param attachedDatabaseConfigurationName The name of the attached database configuration.
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param parameters The database parameters supplied to the CreateOrUpdate 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 class representing an attached database configuration along with {@link Response} on successful
     *     completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> createOrUpdateWithResponseAsync(
        String workspaceName,
        String kustoPoolName,
        String attachedDatabaseConfigurationName,
        String resourceGroupName,
        AttachedDatabaseConfigurationInner parameters) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (workspaceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter workspaceName is required and cannot be null."));
        }
        if (kustoPoolName == null) {
            return Mono.error(new IllegalArgumentException("Parameter kustoPoolName is required and cannot be null."));
        }
        if (attachedDatabaseConfigurationName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter attachedDatabaseConfigurationName 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 (parameters == null) {
            return Mono.error(new IllegalArgumentException("Parameter parameters is required and cannot be null."));
        } else {
            parameters.validate();
        }
        final String apiVersion = "2021-06-01-preview";
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .createOrUpdate(
                            this.client.getEndpoint(),
                            workspaceName,
                            kustoPoolName,
                            attachedDatabaseConfigurationName,
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            apiVersion,
                            parameters,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Creates or updates an attached database configuration.
     *
     * @param workspaceName The name of the workspace.
     * @param kustoPoolName The name of the Kusto pool.
     * @param attachedDatabaseConfigurationName The name of the attached database configuration.
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param parameters The database parameters supplied to the CreateOrUpdate operation.
     * @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 class representing an attached database configuration along with {@link Response} on successful
     *     completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> createOrUpdateWithResponseAsync(
        String workspaceName,
        String kustoPoolName,
        String attachedDatabaseConfigurationName,
        String resourceGroupName,
        AttachedDatabaseConfigurationInner parameters,
        Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (workspaceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter workspaceName is required and cannot be null."));
        }
        if (kustoPoolName == null) {
            return Mono.error(new IllegalArgumentException("Parameter kustoPoolName is required and cannot be null."));
        }
        if (attachedDatabaseConfigurationName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter attachedDatabaseConfigurationName 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 (parameters == null) {
            return Mono.error(new IllegalArgumentException("Parameter parameters is required and cannot be null."));
        } else {
            parameters.validate();
        }
        final String apiVersion = "2021-06-01-preview";
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .createOrUpdate(
                this.client.getEndpoint(),
                workspaceName,
                kustoPoolName,
                attachedDatabaseConfigurationName,
                this.client.getSubscriptionId(),
                resourceGroupName,
                apiVersion,
                parameters,
                accept,
                context);
    }

    /**
     * Creates or updates an attached database configuration.
     *
     * @param workspaceName The name of the workspace.
     * @param kustoPoolName The name of the Kusto pool.
     * @param attachedDatabaseConfigurationName The name of the attached database configuration.
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param parameters The database parameters supplied to the CreateOrUpdate 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 class representing an attached database configuration.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<AttachedDatabaseConfigurationInner>, AttachedDatabaseConfigurationInner>
        beginCreateOrUpdateAsync(
            String workspaceName,
            String kustoPoolName,
            String attachedDatabaseConfigurationName,
            String resourceGroupName,
            AttachedDatabaseConfigurationInner parameters) {
        Mono<Response<Flux<ByteBuffer>>> mono =
            createOrUpdateWithResponseAsync(
                workspaceName, kustoPoolName, attachedDatabaseConfigurationName, resourceGroupName, parameters);
        return this
            .client
            .<AttachedDatabaseConfigurationInner, AttachedDatabaseConfigurationInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                AttachedDatabaseConfigurationInner.class,
                AttachedDatabaseConfigurationInner.class,
                this.client.getContext());
    }

    /**
     * Creates or updates an attached database configuration.
     *
     * @param workspaceName The name of the workspace.
     * @param kustoPoolName The name of the Kusto pool.
     * @param attachedDatabaseConfigurationName The name of the attached database configuration.
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param parameters The database parameters supplied to the CreateOrUpdate operation.
     * @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 class representing an attached database configuration.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<AttachedDatabaseConfigurationInner>, AttachedDatabaseConfigurationInner>
        beginCreateOrUpdateAsync(
            String workspaceName,
            String kustoPoolName,
            String attachedDatabaseConfigurationName,
            String resourceGroupName,
            AttachedDatabaseConfigurationInner parameters,
            Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono =
            createOrUpdateWithResponseAsync(
                workspaceName,
                kustoPoolName,
                attachedDatabaseConfigurationName,
                resourceGroupName,
                parameters,
                context);
        return this
            .client
            .<AttachedDatabaseConfigurationInner, AttachedDatabaseConfigurationInner>getLroResult(
                mono,
                this.client.getHttpPipeline(),
                AttachedDatabaseConfigurationInner.class,
                AttachedDatabaseConfigurationInner.class,
                context);
    }

    /**
     * Creates or updates an attached database configuration.
     *
     * @param workspaceName The name of the workspace.
     * @param kustoPoolName The name of the Kusto pool.
     * @param attachedDatabaseConfigurationName The name of the attached database configuration.
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param parameters The database parameters supplied to the CreateOrUpdate 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 class representing an attached database configuration.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<AttachedDatabaseConfigurationInner>, AttachedDatabaseConfigurationInner>
        beginCreateOrUpdate(
            String workspaceName,
            String kustoPoolName,
            String attachedDatabaseConfigurationName,
            String resourceGroupName,
            AttachedDatabaseConfigurationInner parameters) {
        return this
            .beginCreateOrUpdateAsync(
                workspaceName, kustoPoolName, attachedDatabaseConfigurationName, resourceGroupName, parameters)
            .getSyncPoller();
    }

    /**
     * Creates or updates an attached database configuration.
     *
     * @param workspaceName The name of the workspace.
     * @param kustoPoolName The name of the Kusto pool.
     * @param attachedDatabaseConfigurationName The name of the attached database configuration.
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param parameters The database parameters supplied to the CreateOrUpdate operation.
     * @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 class representing an attached database configuration.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<AttachedDatabaseConfigurationInner>, AttachedDatabaseConfigurationInner>
        beginCreateOrUpdate(
            String workspaceName,
            String kustoPoolName,
            String attachedDatabaseConfigurationName,
            String resourceGroupName,
            AttachedDatabaseConfigurationInner parameters,
            Context context) {
        return this
            .beginCreateOrUpdateAsync(
                workspaceName, kustoPoolName, attachedDatabaseConfigurationName, resourceGroupName, parameters, context)
            .getSyncPoller();
    }

    /**
     * Creates or updates an attached database configuration.
     *
     * @param workspaceName The name of the workspace.
     * @param kustoPoolName The name of the Kusto pool.
     * @param attachedDatabaseConfigurationName The name of the attached database configuration.
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param parameters The database parameters supplied to the CreateOrUpdate 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 class representing an attached database configuration on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<AttachedDatabaseConfigurationInner> createOrUpdateAsync(
        String workspaceName,
        String kustoPoolName,
        String attachedDatabaseConfigurationName,
        String resourceGroupName,
        AttachedDatabaseConfigurationInner parameters) {
        return beginCreateOrUpdateAsync(
                workspaceName, kustoPoolName, attachedDatabaseConfigurationName, resourceGroupName, parameters)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Creates or updates an attached database configuration.
     *
     * @param workspaceName The name of the workspace.
     * @param kustoPoolName The name of the Kusto pool.
     * @param attachedDatabaseConfigurationName The name of the attached database configuration.
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param parameters The database parameters supplied to the CreateOrUpdate operation.
     * @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 class representing an attached database configuration on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<AttachedDatabaseConfigurationInner> createOrUpdateAsync(
        String workspaceName,
        String kustoPoolName,
        String attachedDatabaseConfigurationName,
        String resourceGroupName,
        AttachedDatabaseConfigurationInner parameters,
        Context context) {
        return beginCreateOrUpdateAsync(
                workspaceName, kustoPoolName, attachedDatabaseConfigurationName, resourceGroupName, parameters, context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Creates or updates an attached database configuration.
     *
     * @param workspaceName The name of the workspace.
     * @param kustoPoolName The name of the Kusto pool.
     * @param attachedDatabaseConfigurationName The name of the attached database configuration.
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param parameters The database parameters supplied to the CreateOrUpdate 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 class representing an attached database configuration.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public AttachedDatabaseConfigurationInner createOrUpdate(
        String workspaceName,
        String kustoPoolName,
        String attachedDatabaseConfigurationName,
        String resourceGroupName,
        AttachedDatabaseConfigurationInner parameters) {
        return createOrUpdateAsync(
                workspaceName, kustoPoolName, attachedDatabaseConfigurationName, resourceGroupName, parameters)
            .block();
    }

    /**
     * Creates or updates an attached database configuration.
     *
     * @param workspaceName The name of the workspace.
     * @param kustoPoolName The name of the Kusto pool.
     * @param attachedDatabaseConfigurationName The name of the attached database configuration.
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param parameters The database parameters supplied to the CreateOrUpdate operation.
     * @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 class representing an attached database configuration.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public AttachedDatabaseConfigurationInner createOrUpdate(
        String workspaceName,
        String kustoPoolName,
        String attachedDatabaseConfigurationName,
        String resourceGroupName,
        AttachedDatabaseConfigurationInner parameters,
        Context context) {
        return createOrUpdateAsync(
                workspaceName, kustoPoolName, attachedDatabaseConfigurationName, resourceGroupName, parameters, context)
            .block();
    }

    /**
     * Deletes the attached database configuration with the given name.
     *
     * @param workspaceName The name of the workspace.
     * @param kustoPoolName The name of the Kusto pool.
     * @param attachedDatabaseConfigurationName The name of the attached database configuration.
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws 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 Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> deleteWithResponseAsync(
        String workspaceName,
        String kustoPoolName,
        String attachedDatabaseConfigurationName,
        String resourceGroupName) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (workspaceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter workspaceName is required and cannot be null."));
        }
        if (kustoPoolName == null) {
            return Mono.error(new IllegalArgumentException("Parameter kustoPoolName is required and cannot be null."));
        }
        if (attachedDatabaseConfigurationName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter attachedDatabaseConfigurationName 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."));
        }
        final String apiVersion = "2021-06-01-preview";
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context ->
                    service
                        .delete(
                            this.client.getEndpoint(),
                            workspaceName,
                            kustoPoolName,
                            attachedDatabaseConfigurationName,
                            this.client.getSubscriptionId(),
                            resourceGroupName,
                            apiVersion,
                            accept,
                            context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Deletes the attached database configuration with the given name.
     *
     * @param workspaceName The name of the workspace.
     * @param kustoPoolName The name of the Kusto pool.
     * @param attachedDatabaseConfigurationName The name of the attached database configuration.
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @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 Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Response<Flux<ByteBuffer>>> deleteWithResponseAsync(
        String workspaceName,
        String kustoPoolName,
        String attachedDatabaseConfigurationName,
        String resourceGroupName,
        Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (workspaceName == null) {
            return Mono.error(new IllegalArgumentException("Parameter workspaceName is required and cannot be null."));
        }
        if (kustoPoolName == null) {
            return Mono.error(new IllegalArgumentException("Parameter kustoPoolName is required and cannot be null."));
        }
        if (attachedDatabaseConfigurationName == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter attachedDatabaseConfigurationName 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."));
        }
        final String apiVersion = "2021-06-01-preview";
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .delete(
                this.client.getEndpoint(),
                workspaceName,
                kustoPoolName,
                attachedDatabaseConfigurationName,
                this.client.getSubscriptionId(),
                resourceGroupName,
                apiVersion,
                accept,
                context);
    }

    /**
     * Deletes the attached database configuration with the given name.
     *
     * @param workspaceName The name of the workspace.
     * @param kustoPoolName The name of the Kusto pool.
     * @param attachedDatabaseConfigurationName The name of the attached database configuration.
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws 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 long-running operation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<Void>, Void> beginDeleteAsync(
        String workspaceName,
        String kustoPoolName,
        String attachedDatabaseConfigurationName,
        String resourceGroupName) {
        Mono<Response<Flux<ByteBuffer>>> mono =
            deleteWithResponseAsync(workspaceName, kustoPoolName, attachedDatabaseConfigurationName, resourceGroupName);
        return this
            .client
            .<Void, Void>getLroResult(
                mono, this.client.getHttpPipeline(), Void.class, Void.class, this.client.getContext());
    }

    /**
     * Deletes the attached database configuration with the given name.
     *
     * @param workspaceName The name of the workspace.
     * @param kustoPoolName The name of the Kusto pool.
     * @param attachedDatabaseConfigurationName The name of the attached database configuration.
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @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 long-running operation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux<PollResult<Void>, Void> beginDeleteAsync(
        String workspaceName,
        String kustoPoolName,
        String attachedDatabaseConfigurationName,
        String resourceGroupName,
        Context context) {
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono =
            deleteWithResponseAsync(
                workspaceName, kustoPoolName, attachedDatabaseConfigurationName, resourceGroupName, context);
        return this
            .client
            .<Void, Void>getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, context);
    }

    /**
     * Deletes the attached database configuration with the given name.
     *
     * @param workspaceName The name of the workspace.
     * @param kustoPoolName The name of the Kusto pool.
     * @param attachedDatabaseConfigurationName The name of the attached database configuration.
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws 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 long-running operation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<Void>, Void> beginDelete(
        String workspaceName,
        String kustoPoolName,
        String attachedDatabaseConfigurationName,
        String resourceGroupName) {
        return this
            .beginDeleteAsync(workspaceName, kustoPoolName, attachedDatabaseConfigurationName, resourceGroupName)
            .getSyncPoller();
    }

    /**
     * Deletes the attached database configuration with the given name.
     *
     * @param workspaceName The name of the workspace.
     * @param kustoPoolName The name of the Kusto pool.
     * @param attachedDatabaseConfigurationName The name of the attached database configuration.
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @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 long-running operation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<PollResult<Void>, Void> beginDelete(
        String workspaceName,
        String kustoPoolName,
        String attachedDatabaseConfigurationName,
        String resourceGroupName,
        Context context) {
        return this
            .beginDeleteAsync(
                workspaceName, kustoPoolName, attachedDatabaseConfigurationName, resourceGroupName, context)
            .getSyncPoller();
    }

    /**
     * Deletes the attached database configuration with the given name.
     *
     * @param workspaceName The name of the workspace.
     * @param kustoPoolName The name of the Kusto pool.
     * @param attachedDatabaseConfigurationName The name of the attached database configuration.
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return A {@link Mono} that completes when a successful response is received.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Void> deleteAsync(
        String workspaceName,
        String kustoPoolName,
        String attachedDatabaseConfigurationName,
        String resourceGroupName) {
        return beginDeleteAsync(workspaceName, kustoPoolName, attachedDatabaseConfigurationName, resourceGroupName)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Deletes the attached database configuration with the given name.
     *
     * @param workspaceName The name of the workspace.
     * @param kustoPoolName The name of the Kusto pool.
     * @param attachedDatabaseConfigurationName The name of the attached database configuration.
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return A {@link Mono} that completes when a successful response is received.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<Void> deleteAsync(
        String workspaceName,
        String kustoPoolName,
        String attachedDatabaseConfigurationName,
        String resourceGroupName,
        Context context) {
        return beginDeleteAsync(
                workspaceName, kustoPoolName, attachedDatabaseConfigurationName, resourceGroupName, context)
            .last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Deletes the attached database configuration with the given name.
     *
     * @param workspaceName The name of the workspace.
     * @param kustoPoolName The name of the Kusto pool.
     * @param attachedDatabaseConfigurationName The name of the attached database configuration.
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public void delete(
        String workspaceName,
        String kustoPoolName,
        String attachedDatabaseConfigurationName,
        String resourceGroupName) {
        deleteAsync(workspaceName, kustoPoolName, attachedDatabaseConfigurationName, resourceGroupName).block();
    }

    /**
     * Deletes the attached database configuration with the given name.
     *
     * @param workspaceName The name of the workspace.
     * @param kustoPoolName The name of the Kusto pool.
     * @param attachedDatabaseConfigurationName The name of the attached database configuration.
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @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.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public void delete(
        String workspaceName,
        String kustoPoolName,
        String attachedDatabaseConfigurationName,
        String resourceGroupName,
        Context context) {
        deleteAsync(workspaceName, kustoPoolName, attachedDatabaseConfigurationName, resourceGroupName, context)
            .block();
    }
}
