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

package com.azure.analytics.synapse.artifacts;

import com.azure.analytics.synapse.artifacts.implementation.KqlScriptsOperationsImpl;
import com.azure.analytics.synapse.artifacts.models.ArtifactRenameRequest;
import com.azure.analytics.synapse.artifacts.models.ErrorContractException;
import com.azure.analytics.synapse.artifacts.models.KqlScriptResource;
import com.azure.core.annotation.Generated;
import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceClient;
import com.azure.core.annotation.ServiceMethod;
import com.azure.core.http.rest.Response;
import reactor.core.publisher.Mono;

/** Initializes a new instance of the asynchronous ArtifactsClient type. */
@ServiceClient(builder = ArtifactsClientBuilder.class, isAsync = true)
public final class KqlScriptAsyncClient {
    @Generated private final KqlScriptsOperationsImpl serviceClient;

    /**
     * Initializes an instance of KqlScriptAsyncClient class.
     *
     * @param serviceClient the service client implementation.
     */
    @Generated
    KqlScriptAsyncClient(KqlScriptsOperationsImpl serviceClient) {
        this.serviceClient = serviceClient;
    }

    /**
     * Creates or updates a KQL Script.
     *
     * @param kqlScriptName KQL script name.
     * @param kqlScript KQL script.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorContractException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the response body along with {@link Response} on successful completion of {@link Mono}.
     */
    @Generated
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<KqlScriptResource>> createOrUpdateWithResponse(
            String kqlScriptName, KqlScriptResource kqlScript) {
        return this.serviceClient.createOrUpdateWithResponseAsync(kqlScriptName, kqlScript);
    }

    /**
     * Creates or updates a KQL Script.
     *
     * @param kqlScriptName KQL script name.
     * @param kqlScript KQL script.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorContractException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the response body on successful completion of {@link Mono}.
     */
    @Generated
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<KqlScriptResource> createOrUpdate(String kqlScriptName, KqlScriptResource kqlScript) {
        return this.serviceClient.createOrUpdateAsync(kqlScriptName, kqlScript);
    }

    /**
     * Get KQL script by name.
     *
     * @param kqlScriptName KQL script name.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorContractException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return kQL script by name along with {@link Response} on successful completion of {@link Mono}.
     */
    @Generated
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<KqlScriptResource>> getByNameWithResponse(String kqlScriptName) {
        return this.serviceClient.getByNameWithResponseAsync(kqlScriptName);
    }

    /**
     * Get KQL script by name.
     *
     * @param kqlScriptName KQL script name.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorContractException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return kQL script by name on successful completion of {@link Mono}.
     */
    @Generated
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<KqlScriptResource> getByName(String kqlScriptName) {
        return this.serviceClient.getByNameAsync(kqlScriptName);
    }

    /**
     * Delete KQL script by name.
     *
     * @param kqlScriptName KQL script name.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorContractException 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}.
     */
    @Generated
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<Void>> deleteByNameWithResponse(String kqlScriptName) {
        return this.serviceClient.deleteByNameWithResponseAsync(kqlScriptName);
    }

    /**
     * Delete KQL script by name.
     *
     * @param kqlScriptName KQL script name.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorContractException 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.
     */
    @Generated
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Void> deleteByName(String kqlScriptName) {
        return this.serviceClient.deleteByNameAsync(kqlScriptName);
    }

    /**
     * Rename KQL script.
     *
     * @param kqlScriptName KQL script name.
     * @param renameRequest Rename request.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorContractException 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}.
     */
    @Generated
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<Void>> renameWithResponse(String kqlScriptName, ArtifactRenameRequest renameRequest) {
        return this.serviceClient.renameWithResponseAsync(kqlScriptName, renameRequest);
    }

    /**
     * Rename KQL script.
     *
     * @param kqlScriptName KQL script name.
     * @param renameRequest Rename request.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorContractException 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.
     */
    @Generated
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Void> rename(String kqlScriptName, ArtifactRenameRequest renameRequest) {
        return this.serviceClient.renameAsync(kqlScriptName, renameRequest);
    }
}
