// 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.TriggerRunsImpl;
import com.azure.analytics.synapse.artifacts.models.CloudErrorException;
import com.azure.analytics.synapse.artifacts.models.RunFilterParameters;
import com.azure.analytics.synapse.artifacts.models.TriggerRunsQueryResponse;
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 TriggerRunAsyncClient {
    @Generated private final TriggerRunsImpl serviceClient;

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

    /**
     * Rerun single trigger instance by runId.
     *
     * @param triggerName The trigger name.
     * @param runId The pipeline run identifier.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorException 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>> rerunTriggerInstanceWithResponse(String triggerName, String runId) {
        return this.serviceClient.rerunTriggerInstanceWithResponseAsync(triggerName, runId);
    }

    /**
     * Rerun single trigger instance by runId.
     *
     * @param triggerName The trigger name.
     * @param runId The pipeline run identifier.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorException 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> rerunTriggerInstance(String triggerName, String runId) {
        return this.serviceClient.rerunTriggerInstanceAsync(triggerName, runId);
    }

    /**
     * Cancel single trigger instance by runId.
     *
     * @param triggerName The trigger name.
     * @param runId The pipeline run identifier.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorException 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>> cancelTriggerInstanceWithResponse(String triggerName, String runId) {
        return this.serviceClient.cancelTriggerInstanceWithResponseAsync(triggerName, runId);
    }

    /**
     * Cancel single trigger instance by runId.
     *
     * @param triggerName The trigger name.
     * @param runId The pipeline run identifier.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorException 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> cancelTriggerInstance(String triggerName, String runId) {
        return this.serviceClient.cancelTriggerInstanceAsync(triggerName, runId);
    }

    /**
     * Query trigger runs.
     *
     * @param filterParameters Parameters to filter the pipeline run.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of trigger runs along with {@link Response} on successful completion of {@link Mono}.
     */
    @Generated
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<TriggerRunsQueryResponse>> queryTriggerRunsByWorkspaceWithResponse(
            RunFilterParameters filterParameters) {
        return this.serviceClient.queryTriggerRunsByWorkspaceWithResponseAsync(filterParameters);
    }

    /**
     * Query trigger runs.
     *
     * @param filterParameters Parameters to filter the pipeline run.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CloudErrorException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a list of trigger runs on successful completion of {@link Mono}.
     */
    @Generated
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<TriggerRunsQueryResponse> queryTriggerRunsByWorkspace(RunFilterParameters filterParameters) {
        return this.serviceClient.queryTriggerRunsByWorkspaceAsync(filterParameters);
    }
}
