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

package com.azure.analytics.purview.workflow.implementation;

import com.azure.analytics.purview.workflow.PurviewWorkflowServiceVersion;
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.Host;
import com.azure.core.annotation.HostParam;
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.exception.ClientAuthenticationException;
import com.azure.core.exception.HttpResponseException;
import com.azure.core.exception.ResourceModifiedException;
import com.azure.core.exception.ResourceNotFoundException;
import com.azure.core.http.HttpPipeline;
import com.azure.core.http.HttpPipelineBuilder;
import com.azure.core.http.policy.CookiePolicy;
import com.azure.core.http.policy.RetryPolicy;
import com.azure.core.http.policy.UserAgentPolicy;
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.RequestOptions;
import com.azure.core.http.rest.Response;
import com.azure.core.http.rest.RestProxy;
import com.azure.core.util.BinaryData;
import com.azure.core.util.Context;
import com.azure.core.util.FluxUtil;
import com.azure.core.util.serializer.JacksonAdapter;
import com.azure.core.util.serializer.SerializerAdapter;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import reactor.core.publisher.Mono;

/** Initializes a new instance of the PurviewWorkflowClient type. */
public final class PurviewWorkflowClientImpl {
    /** The proxy service used to perform REST calls. */
    private final PurviewWorkflowClientService service;

    /** The account endpoint of your Purview account. Example: https://{accountName}.purview.azure.com/. */
    private final String endpoint;

    /**
     * Gets The account endpoint of your Purview account. Example: https://{accountName}.purview.azure.com/.
     *
     * @return the endpoint value.
     */
    public String getEndpoint() {
        return this.endpoint;
    }

    /** Service version. */
    private final PurviewWorkflowServiceVersion serviceVersion;

    /**
     * Gets Service version.
     *
     * @return the serviceVersion value.
     */
    public PurviewWorkflowServiceVersion getServiceVersion() {
        return this.serviceVersion;
    }

    /** The HTTP pipeline to send requests through. */
    private final HttpPipeline httpPipeline;

    /**
     * Gets The HTTP pipeline to send requests through.
     *
     * @return the httpPipeline value.
     */
    public HttpPipeline getHttpPipeline() {
        return this.httpPipeline;
    }

    /** The serializer to serialize an object into a string. */
    private final SerializerAdapter serializerAdapter;

    /**
     * Gets The serializer to serialize an object into a string.
     *
     * @return the serializerAdapter value.
     */
    public SerializerAdapter getSerializerAdapter() {
        return this.serializerAdapter;
    }

    /**
     * Initializes an instance of PurviewWorkflowClient client.
     *
     * @param endpoint The account endpoint of your Purview account. Example: https://{accountName}.purview.azure.com/.
     * @param serviceVersion Service version.
     */
    public PurviewWorkflowClientImpl(String endpoint, PurviewWorkflowServiceVersion serviceVersion) {
        this(
                new HttpPipelineBuilder()
                        .policies(new UserAgentPolicy(), new RetryPolicy(), new CookiePolicy())
                        .build(),
                JacksonAdapter.createDefaultSerializerAdapter(),
                endpoint,
                serviceVersion);
    }

    /**
     * Initializes an instance of PurviewWorkflowClient client.
     *
     * @param httpPipeline The HTTP pipeline to send requests through.
     * @param endpoint The account endpoint of your Purview account. Example: https://{accountName}.purview.azure.com/.
     * @param serviceVersion Service version.
     */
    public PurviewWorkflowClientImpl(
            HttpPipeline httpPipeline, String endpoint, PurviewWorkflowServiceVersion serviceVersion) {
        this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion);
    }

    /**
     * Initializes an instance of PurviewWorkflowClient client.
     *
     * @param httpPipeline The HTTP pipeline to send requests through.
     * @param serializerAdapter The serializer to serialize an object into a string.
     * @param endpoint The account endpoint of your Purview account. Example: https://{accountName}.purview.azure.com/.
     * @param serviceVersion Service version.
     */
    public PurviewWorkflowClientImpl(
            HttpPipeline httpPipeline,
            SerializerAdapter serializerAdapter,
            String endpoint,
            PurviewWorkflowServiceVersion serviceVersion) {
        this.httpPipeline = httpPipeline;
        this.serializerAdapter = serializerAdapter;
        this.endpoint = endpoint;
        this.serviceVersion = serviceVersion;
        this.service =
                RestProxy.create(PurviewWorkflowClientService.class, this.httpPipeline, this.getSerializerAdapter());
    }

    /**
     * The interface defining all the services for PurviewWorkflowClient to be used by the proxy service to perform REST
     * calls.
     */
    @Host("{endpoint}/workflow")
    @ServiceInterface(name = "PurviewWorkflowClien")
    public interface PurviewWorkflowClientService {
        @Get("/workflows")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Mono<Response<BinaryData>> listWorkflows(
                @HostParam("endpoint") String endpoint,
                @QueryParam("api-version") String apiVersion,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Get("/workflows")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Response<BinaryData> listWorkflowsSync(
                @HostParam("endpoint") String endpoint,
                @QueryParam("api-version") String apiVersion,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Get("/workflows/{workflowId}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Mono<Response<BinaryData>> getWorkflow(
                @HostParam("endpoint") String endpoint,
                @PathParam("workflowId") String workflowId,
                @QueryParam("api-version") String apiVersion,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Get("/workflows/{workflowId}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Response<BinaryData> getWorkflowSync(
                @HostParam("endpoint") String endpoint,
                @PathParam("workflowId") String workflowId,
                @QueryParam("api-version") String apiVersion,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Put("/workflows/{workflowId}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Mono<Response<BinaryData>> createOrReplaceWorkflow(
                @HostParam("endpoint") String endpoint,
                @PathParam("workflowId") String workflowId,
                @QueryParam("api-version") String apiVersion,
                @BodyParam("application/json") BinaryData workflowCreateOrUpdateCommand,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Put("/workflows/{workflowId}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Response<BinaryData> createOrReplaceWorkflowSync(
                @HostParam("endpoint") String endpoint,
                @PathParam("workflowId") String workflowId,
                @QueryParam("api-version") String apiVersion,
                @BodyParam("application/json") BinaryData workflowCreateOrUpdateCommand,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Delete("/workflows/{workflowId}")
        @ExpectedResponses({204})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Mono<Response<Void>> deleteWorkflow(
                @HostParam("endpoint") String endpoint,
                @PathParam("workflowId") String workflowId,
                @QueryParam("api-version") String apiVersion,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Delete("/workflows/{workflowId}")
        @ExpectedResponses({204})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Response<Void> deleteWorkflowSync(
                @HostParam("endpoint") String endpoint,
                @PathParam("workflowId") String workflowId,
                @QueryParam("api-version") String apiVersion,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Post("/userrequests")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Mono<Response<BinaryData>> submitUserRequests(
                @HostParam("endpoint") String endpoint,
                @QueryParam("api-version") String apiVersion,
                @BodyParam("application/json") BinaryData userRequestsPayload,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Post("/userrequests")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Response<BinaryData> submitUserRequestsSync(
                @HostParam("endpoint") String endpoint,
                @QueryParam("api-version") String apiVersion,
                @BodyParam("application/json") BinaryData userRequestsPayload,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Get("/workflowruns")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Mono<Response<BinaryData>> listWorkflowRuns(
                @HostParam("endpoint") String endpoint,
                @QueryParam("api-version") String apiVersion,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Get("/workflowruns")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Response<BinaryData> listWorkflowRunsSync(
                @HostParam("endpoint") String endpoint,
                @QueryParam("api-version") String apiVersion,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Get("/workflowruns/{workflowRunId}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Mono<Response<BinaryData>> getWorkflowRun(
                @HostParam("endpoint") String endpoint,
                @QueryParam("api-version") String apiVersion,
                @PathParam("workflowRunId") String workflowRunId,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Get("/workflowruns/{workflowRunId}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Response<BinaryData> getWorkflowRunSync(
                @HostParam("endpoint") String endpoint,
                @QueryParam("api-version") String apiVersion,
                @PathParam("workflowRunId") String workflowRunId,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Post("/workflowruns/{workflowRunId}/cancel")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Mono<Response<Void>> cancelWorkflowRun(
                @HostParam("endpoint") String endpoint,
                @QueryParam("api-version") String apiVersion,
                @PathParam("workflowRunId") String workflowRunId,
                @BodyParam("application/json") BinaryData runCancelReply,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Post("/workflowruns/{workflowRunId}/cancel")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Response<Void> cancelWorkflowRunSync(
                @HostParam("endpoint") String endpoint,
                @QueryParam("api-version") String apiVersion,
                @PathParam("workflowRunId") String workflowRunId,
                @BodyParam("application/json") BinaryData runCancelReply,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Get("/workflowtasks")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Mono<Response<BinaryData>> listWorkflowTasks(
                @HostParam("endpoint") String endpoint,
                @QueryParam("api-version") String apiVersion,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Get("/workflowtasks")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Response<BinaryData> listWorkflowTasksSync(
                @HostParam("endpoint") String endpoint,
                @QueryParam("api-version") String apiVersion,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Get("/workflowtasks/{taskId}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Mono<Response<BinaryData>> getWorkflowTask(
                @HostParam("endpoint") String endpoint,
                @PathParam("taskId") String taskId,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Get("/workflowtasks/{taskId}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Response<BinaryData> getWorkflowTaskSync(
                @HostParam("endpoint") String endpoint,
                @PathParam("taskId") String taskId,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Post("/workflowtasks/{taskId}/approve-approval")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Mono<Response<Void>> approveApprovalTask(
                @HostParam("endpoint") String endpoint,
                @PathParam("taskId") String taskId,
                @QueryParam("api-version") String apiVersion,
                @BodyParam("application/json") BinaryData approvalResponseComment,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Post("/workflowtasks/{taskId}/approve-approval")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Response<Void> approveApprovalTaskSync(
                @HostParam("endpoint") String endpoint,
                @PathParam("taskId") String taskId,
                @QueryParam("api-version") String apiVersion,
                @BodyParam("application/json") BinaryData approvalResponseComment,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Post("/workflowtasks/{taskId}/reject-approval")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Mono<Response<Void>> rejectApprovalTask(
                @HostParam("endpoint") String endpoint,
                @PathParam("taskId") String taskId,
                @QueryParam("api-version") String apiVersion,
                @BodyParam("application/json") BinaryData approvalResponseComment,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Post("/workflowtasks/{taskId}/reject-approval")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Response<Void> rejectApprovalTaskSync(
                @HostParam("endpoint") String endpoint,
                @PathParam("taskId") String taskId,
                @QueryParam("api-version") String apiVersion,
                @BodyParam("application/json") BinaryData approvalResponseComment,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Post("/workflowtasks/{taskId}/reassign")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Mono<Response<Void>> reassignWorkflowTask(
                @HostParam("endpoint") String endpoint,
                @PathParam("taskId") String taskId,
                @QueryParam("api-version") String apiVersion,
                @BodyParam("application/json") BinaryData reassignCommand,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Post("/workflowtasks/{taskId}/reassign")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Response<Void> reassignWorkflowTaskSync(
                @HostParam("endpoint") String endpoint,
                @PathParam("taskId") String taskId,
                @QueryParam("api-version") String apiVersion,
                @BodyParam("application/json") BinaryData reassignCommand,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Post("/workflowtasks/{taskId}/change-task-status")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Mono<Response<Void>> updateTaskStatus(
                @HostParam("endpoint") String endpoint,
                @PathParam("taskId") String taskId,
                @QueryParam("api-version") String apiVersion,
                @BodyParam("application/json") BinaryData taskUpdateCommand,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Post("/workflowtasks/{taskId}/change-task-status")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Response<Void> updateTaskStatusSync(
                @HostParam("endpoint") String endpoint,
                @PathParam("taskId") String taskId,
                @QueryParam("api-version") String apiVersion,
                @BodyParam("application/json") BinaryData taskUpdateCommand,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Get("{nextLink}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Mono<Response<BinaryData>> listWorkflowsNext(
                @PathParam(value = "nextLink", encoded = true) String nextLink,
                @HostParam("endpoint") String endpoint,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Get("{nextLink}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Response<BinaryData> listWorkflowsNextSync(
                @PathParam(value = "nextLink", encoded = true) String nextLink,
                @HostParam("endpoint") String endpoint,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Get("{nextLink}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Mono<Response<BinaryData>> listWorkflowRunsNext(
                @PathParam(value = "nextLink", encoded = true) String nextLink,
                @HostParam("endpoint") String endpoint,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Get("{nextLink}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Response<BinaryData> listWorkflowRunsNextSync(
                @PathParam(value = "nextLink", encoded = true) String nextLink,
                @HostParam("endpoint") String endpoint,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Get("{nextLink}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Mono<Response<BinaryData>> listWorkflowTasksNext(
                @PathParam(value = "nextLink", encoded = true) String nextLink,
                @HostParam("endpoint") String endpoint,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);

        @Get("{nextLink}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(
                value = ClientAuthenticationException.class,
                code = {401})
        @UnexpectedResponseExceptionType(
                value = ResourceNotFoundException.class,
                code = {404})
        @UnexpectedResponseExceptionType(
                value = ResourceModifiedException.class,
                code = {409})
        @UnexpectedResponseExceptionType(HttpResponseException.class)
        Response<BinaryData> listWorkflowTasksNextSync(
                @PathParam(value = "nextLink", encoded = true) String nextLink,
                @HostParam("endpoint") String endpoint,
                @HeaderParam("Accept") String accept,
                RequestOptions requestOptions,
                Context context);
    }

    /**
     * List all workflows.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     id: String (Required)
     *     triggers (Required): [
     *          (Required){
     *             type: String(when_term_creation_is_requested/when_term_deletion_is_requested/when_term_update_is_requested/when_terms_import_is_requested/when_data_access_grant_is_requested/when_asset_update_is_requested) (Required)
     *             underGlossaryHierarchy: String (Optional)
     *             underCollection: String (Optional)
     *             underGlossary: String (Optional)
     *         }
     *     ]
     *     createdTime: OffsetDateTime (Optional)
     *     createdBy: String (Optional)
     *     lastUpdateTime: OffsetDateTime (Optional)
     *     updatedBy: String (Optional)
     *     name: String (Required)
     *     isEnabled: boolean (Required)
     *     description: String (Required)
     * }
     * }</pre>
     *
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return the workflow list along with {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<BinaryData>> listWorkflowsSinglePageAsync(RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                        context ->
                                service.listWorkflows(
                                        this.getEndpoint(),
                                        this.getServiceVersion().getVersion(),
                                        accept,
                                        requestOptions,
                                        context))
                .map(
                        res ->
                                new PagedResponseBase<>(
                                        res.getRequest(),
                                        res.getStatusCode(),
                                        res.getHeaders(),
                                        getValues(res.getValue(), "value"),
                                        getNextLink(res.getValue(), "nextLink"),
                                        null));
    }

    /**
     * List all workflows.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     id: String (Required)
     *     triggers (Required): [
     *          (Required){
     *             type: String(when_term_creation_is_requested/when_term_deletion_is_requested/when_term_update_is_requested/when_terms_import_is_requested/when_data_access_grant_is_requested/when_asset_update_is_requested) (Required)
     *             underGlossaryHierarchy: String (Optional)
     *             underCollection: String (Optional)
     *             underGlossary: String (Optional)
     *         }
     *     ]
     *     createdTime: OffsetDateTime (Optional)
     *     createdBy: String (Optional)
     *     lastUpdateTime: OffsetDateTime (Optional)
     *     updatedBy: String (Optional)
     *     name: String (Required)
     *     isEnabled: boolean (Required)
     *     description: String (Required)
     * }
     * }</pre>
     *
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return the workflow list as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedFlux<BinaryData> listWorkflowsAsync(RequestOptions requestOptions) {
        RequestOptions requestOptionsForNextPage = new RequestOptions();
        requestOptionsForNextPage.setContext(
                requestOptions != null && requestOptions.getContext() != null
                        ? requestOptions.getContext()
                        : Context.NONE);
        return new PagedFlux<>(
                () -> listWorkflowsSinglePageAsync(requestOptions),
                nextLink -> listWorkflowsNextSinglePageAsync(nextLink, requestOptionsForNextPage));
    }

    /**
     * List all workflows.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     id: String (Required)
     *     triggers (Required): [
     *          (Required){
     *             type: String(when_term_creation_is_requested/when_term_deletion_is_requested/when_term_update_is_requested/when_terms_import_is_requested/when_data_access_grant_is_requested/when_asset_update_is_requested) (Required)
     *             underGlossaryHierarchy: String (Optional)
     *             underCollection: String (Optional)
     *             underGlossary: String (Optional)
     *         }
     *     ]
     *     createdTime: OffsetDateTime (Optional)
     *     createdBy: String (Optional)
     *     lastUpdateTime: OffsetDateTime (Optional)
     *     updatedBy: String (Optional)
     *     name: String (Required)
     *     isEnabled: boolean (Required)
     *     description: String (Required)
     * }
     * }</pre>
     *
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return the workflow list along with {@link PagedResponse}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private PagedResponse<BinaryData> listWorkflowsSinglePage(RequestOptions requestOptions) {
        final String accept = "application/json";
        Response<BinaryData> res =
                service.listWorkflowsSync(
                        this.getEndpoint(),
                        this.getServiceVersion().getVersion(),
                        accept,
                        requestOptions,
                        Context.NONE);
        return new PagedResponseBase<>(
                res.getRequest(),
                res.getStatusCode(),
                res.getHeaders(),
                getValues(res.getValue(), "value"),
                getNextLink(res.getValue(), "nextLink"),
                null);
    }

    /**
     * List all workflows.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     id: String (Required)
     *     triggers (Required): [
     *          (Required){
     *             type: String(when_term_creation_is_requested/when_term_deletion_is_requested/when_term_update_is_requested/when_terms_import_is_requested/when_data_access_grant_is_requested/when_asset_update_is_requested) (Required)
     *             underGlossaryHierarchy: String (Optional)
     *             underCollection: String (Optional)
     *             underGlossary: String (Optional)
     *         }
     *     ]
     *     createdTime: OffsetDateTime (Optional)
     *     createdBy: String (Optional)
     *     lastUpdateTime: OffsetDateTime (Optional)
     *     updatedBy: String (Optional)
     *     name: String (Required)
     *     isEnabled: boolean (Required)
     *     description: String (Required)
     * }
     * }</pre>
     *
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return the workflow list as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<BinaryData> listWorkflows(RequestOptions requestOptions) {
        RequestOptions requestOptionsForNextPage = new RequestOptions();
        requestOptionsForNextPage.setContext(
                requestOptions != null && requestOptions.getContext() != null
                        ? requestOptions.getContext()
                        : Context.NONE);
        return new PagedIterable<>(
                () -> listWorkflowsSinglePage(requestOptions),
                nextLink -> listWorkflowsNextSinglePage(nextLink, requestOptionsForNextPage));
    }

    /**
     * Get a specific workflow.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     id: String (Required)
     *     triggers (Required): [
     *          (Required){
     *             type: String(when_term_creation_is_requested/when_term_deletion_is_requested/when_term_update_is_requested/when_terms_import_is_requested/when_data_access_grant_is_requested/when_asset_update_is_requested) (Required)
     *             underGlossaryHierarchy: String (Optional)
     *             underCollection: String (Optional)
     *             underGlossary: String (Optional)
     *         }
     *     ]
     *     createdTime: OffsetDateTime (Optional)
     *     createdBy: String (Optional)
     *     lastUpdateTime: OffsetDateTime (Optional)
     *     updatedBy: String (Optional)
     *     name: String (Required)
     *     isEnabled: boolean (Required)
     *     description: String (Required)
     *     actionDag: Object (Required)
     * }
     * }</pre>
     *
     * @param workflowId The workflow id.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return a specific workflow along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<BinaryData>> getWorkflowWithResponseAsync(String workflowId, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.getWorkflow(
                                this.getEndpoint(),
                                workflowId,
                                this.getServiceVersion().getVersion(),
                                accept,
                                requestOptions,
                                context));
    }

    /**
     * Get a specific workflow.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     id: String (Required)
     *     triggers (Required): [
     *          (Required){
     *             type: String(when_term_creation_is_requested/when_term_deletion_is_requested/when_term_update_is_requested/when_terms_import_is_requested/when_data_access_grant_is_requested/when_asset_update_is_requested) (Required)
     *             underGlossaryHierarchy: String (Optional)
     *             underCollection: String (Optional)
     *             underGlossary: String (Optional)
     *         }
     *     ]
     *     createdTime: OffsetDateTime (Optional)
     *     createdBy: String (Optional)
     *     lastUpdateTime: OffsetDateTime (Optional)
     *     updatedBy: String (Optional)
     *     name: String (Required)
     *     isEnabled: boolean (Required)
     *     description: String (Required)
     *     actionDag: Object (Required)
     * }
     * }</pre>
     *
     * @param workflowId The workflow id.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return a specific workflow along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<BinaryData> getWorkflowWithResponse(String workflowId, RequestOptions requestOptions) {
        final String accept = "application/json";
        return service.getWorkflowSync(
                this.getEndpoint(),
                workflowId,
                this.getServiceVersion().getVersion(),
                accept,
                requestOptions,
                Context.NONE);
    }

    /**
     * Create or replace a workflow.
     *
     * <p><strong>Request Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     triggers (Required): [
     *          (Required){
     *             type: String(when_term_creation_is_requested/when_term_deletion_is_requested/when_term_update_is_requested/when_terms_import_is_requested/when_data_access_grant_is_requested/when_asset_update_is_requested) (Required)
     *             underGlossaryHierarchy: String (Optional)
     *             underCollection: String (Optional)
     *             underGlossary: String (Optional)
     *         }
     *     ]
     *     name: String (Required)
     *     isEnabled: boolean (Required)
     *     description: String (Required)
     *     actionDag: Object (Optional)
     * }
     * }</pre>
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     id: String (Required)
     *     triggers (Required): [
     *          (Required){
     *             type: String(when_term_creation_is_requested/when_term_deletion_is_requested/when_term_update_is_requested/when_terms_import_is_requested/when_data_access_grant_is_requested/when_asset_update_is_requested) (Required)
     *             underGlossaryHierarchy: String (Optional)
     *             underCollection: String (Optional)
     *             underGlossary: String (Optional)
     *         }
     *     ]
     *     createdTime: OffsetDateTime (Optional)
     *     createdBy: String (Optional)
     *     lastUpdateTime: OffsetDateTime (Optional)
     *     updatedBy: String (Optional)
     *     name: String (Required)
     *     isEnabled: boolean (Required)
     *     description: String (Required)
     *     actionDag: Object (Required)
     * }
     * }</pre>
     *
     * @param workflowId The workflow id.
     * @param workflowCreateOrUpdateCommand Create or update workflow payload.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return the workflow properties along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<BinaryData>> createOrReplaceWorkflowWithResponseAsync(
            String workflowId, BinaryData workflowCreateOrUpdateCommand, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.createOrReplaceWorkflow(
                                this.getEndpoint(),
                                workflowId,
                                this.getServiceVersion().getVersion(),
                                workflowCreateOrUpdateCommand,
                                accept,
                                requestOptions,
                                context));
    }

    /**
     * Create or replace a workflow.
     *
     * <p><strong>Request Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     triggers (Required): [
     *          (Required){
     *             type: String(when_term_creation_is_requested/when_term_deletion_is_requested/when_term_update_is_requested/when_terms_import_is_requested/when_data_access_grant_is_requested/when_asset_update_is_requested) (Required)
     *             underGlossaryHierarchy: String (Optional)
     *             underCollection: String (Optional)
     *             underGlossary: String (Optional)
     *         }
     *     ]
     *     name: String (Required)
     *     isEnabled: boolean (Required)
     *     description: String (Required)
     *     actionDag: Object (Optional)
     * }
     * }</pre>
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     id: String (Required)
     *     triggers (Required): [
     *          (Required){
     *             type: String(when_term_creation_is_requested/when_term_deletion_is_requested/when_term_update_is_requested/when_terms_import_is_requested/when_data_access_grant_is_requested/when_asset_update_is_requested) (Required)
     *             underGlossaryHierarchy: String (Optional)
     *             underCollection: String (Optional)
     *             underGlossary: String (Optional)
     *         }
     *     ]
     *     createdTime: OffsetDateTime (Optional)
     *     createdBy: String (Optional)
     *     lastUpdateTime: OffsetDateTime (Optional)
     *     updatedBy: String (Optional)
     *     name: String (Required)
     *     isEnabled: boolean (Required)
     *     description: String (Required)
     *     actionDag: Object (Required)
     * }
     * }</pre>
     *
     * @param workflowId The workflow id.
     * @param workflowCreateOrUpdateCommand Create or update workflow payload.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return the workflow properties along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<BinaryData> createOrReplaceWorkflowWithResponse(
            String workflowId, BinaryData workflowCreateOrUpdateCommand, RequestOptions requestOptions) {
        final String accept = "application/json";
        return service.createOrReplaceWorkflowSync(
                this.getEndpoint(),
                workflowId,
                this.getServiceVersion().getVersion(),
                workflowCreateOrUpdateCommand,
                accept,
                requestOptions,
                Context.NONE);
    }

    /**
     * Delete a workflow.
     *
     * @param workflowId The workflow id.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return the {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<Void>> deleteWorkflowWithResponseAsync(String workflowId, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.deleteWorkflow(
                                this.getEndpoint(),
                                workflowId,
                                this.getServiceVersion().getVersion(),
                                accept,
                                requestOptions,
                                context));
    }

    /**
     * Delete a workflow.
     *
     * @param workflowId The workflow id.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return the {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<Void> deleteWorkflowWithResponse(String workflowId, RequestOptions requestOptions) {
        final String accept = "application/json";
        return service.deleteWorkflowSync(
                this.getEndpoint(),
                workflowId,
                this.getServiceVersion().getVersion(),
                accept,
                requestOptions,
                Context.NONE);
    }

    /**
     * Submit a user request for requestor, a user request describes user ask to do operation(s) on Purview. If any
     * workflow's trigger matches with an operation in request, a run of the workflow is created.
     *
     * <p><strong>Request Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     operations (Required): [
     *          (Required){
     *             type: String(CreateTerm/UpdateTerm/DeleteTerm/ImportTerms/UpdateAsset/GrantDataAccess) (Required)
     *             payload: Object (Required)
     *         }
     *     ]
     *     comment: String (Optional)
     * }
     * }</pre>
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     requestId: String (Required)
     *     requestor: String (Required)
     *     operations (Required): [
     *          (Required){
     *             type: String(CreateTerm/UpdateTerm/DeleteTerm/ImportTerms/UpdateAsset/GrantDataAccess) (Required)
     *             payload: Object (Required)
     *             workflowRunIds (Optional): [
     *                 String (Optional)
     *             ]
     *         }
     *     ]
     *     comment: String (Optional)
     *     status: String(NotStarted/InProgress/Failed/Completed/Canceling/CancellationFailed/Canceled) (Required)
     * }
     * }</pre>
     *
     * @param userRequestsPayload The payload of submitting a user request.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return describes user ask to do operation(s) on Purview along with {@link Response} on successful completion of
     *     {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<BinaryData>> submitUserRequestsWithResponseAsync(
            BinaryData userRequestsPayload, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.submitUserRequests(
                                this.getEndpoint(),
                                this.getServiceVersion().getVersion(),
                                userRequestsPayload,
                                accept,
                                requestOptions,
                                context));
    }

    /**
     * Submit a user request for requestor, a user request describes user ask to do operation(s) on Purview. If any
     * workflow's trigger matches with an operation in request, a run of the workflow is created.
     *
     * <p><strong>Request Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     operations (Required): [
     *          (Required){
     *             type: String(CreateTerm/UpdateTerm/DeleteTerm/ImportTerms/UpdateAsset/GrantDataAccess) (Required)
     *             payload: Object (Required)
     *         }
     *     ]
     *     comment: String (Optional)
     * }
     * }</pre>
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     requestId: String (Required)
     *     requestor: String (Required)
     *     operations (Required): [
     *          (Required){
     *             type: String(CreateTerm/UpdateTerm/DeleteTerm/ImportTerms/UpdateAsset/GrantDataAccess) (Required)
     *             payload: Object (Required)
     *             workflowRunIds (Optional): [
     *                 String (Optional)
     *             ]
     *         }
     *     ]
     *     comment: String (Optional)
     *     status: String(NotStarted/InProgress/Failed/Completed/Canceling/CancellationFailed/Canceled) (Required)
     * }
     * }</pre>
     *
     * @param userRequestsPayload The payload of submitting a user request.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return describes user ask to do operation(s) on Purview along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<BinaryData> submitUserRequestsWithResponse(
            BinaryData userRequestsPayload, RequestOptions requestOptions) {
        final String accept = "application/json";
        return service.submitUserRequestsSync(
                this.getEndpoint(),
                this.getServiceVersion().getVersion(),
                userRequestsPayload,
                accept,
                requestOptions,
                Context.NONE);
    }

    /**
     * List workflow runs.
     *
     * <p><strong>Query Parameters</strong>
     *
     * <table border="1">
     *     <caption>Query Parameters</caption>
     *     <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
     *     <tr><td>timeWindow</td><td>String</td><td>No</td><td>Time window of filtering items. Allowed values: "1d", "7d", "30d", "90d".</td></tr>
     *     <tr><td>orderby</td><td>String</td><td>No</td><td>The key word which used to sort the results. Allowed values: "status desc", "status asc", "requestor desc", "requestor asc", "startTime desc", "startTime asc", "createdTime desc", "createdTime asc".</td></tr>
     *     <tr><td>runStatuses</td><td>List&lt;String&gt;</td><td>No</td><td>Filter workflow runs by workflow run status. In the form of "," separated string.</td></tr>
     *     <tr><td>workflowIds</td><td>List&lt;String&gt;</td><td>No</td><td>Filter items by workflow id list. In the form of "," separated string.</td></tr>
     *     <tr><td>maxpagesize</td><td>Integer</td><td>No</td><td>The maximum page size to get the items at one time.</td></tr>
     * </table>
     *
     * You can add these to a request with {@link RequestOptions#addQueryParam}
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     id: String (Required)
     *     workflowId: String (Required)
     *     startTime: OffsetDateTime (Required)
     *     requestor: String (Required)
     *     userRequestId: String (Optional)
     *     runPayload (Required): {
     *         type: String(CreateTerm/UpdateTerm/DeleteTerm/ImportTerms/UpdateAsset/GrantDataAccess) (Required)
     *         targetValue: String (Required)
     *     }
     *     status: String(NotStarted/InProgress/Failed/Completed/Canceling/CancellationFailed/Canceled) (Required)
     *     endTime: OffsetDateTime (Optional)
     *     cancelTime: OffsetDateTime (Optional)
     *     cancelComment: String (Optional)
     * }
     * }</pre>
     *
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return the response body along with {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<BinaryData>> listWorkflowRunsSinglePageAsync(RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                        context ->
                                service.listWorkflowRuns(
                                        this.getEndpoint(),
                                        this.getServiceVersion().getVersion(),
                                        accept,
                                        requestOptions,
                                        context))
                .map(
                        res ->
                                new PagedResponseBase<>(
                                        res.getRequest(),
                                        res.getStatusCode(),
                                        res.getHeaders(),
                                        getValues(res.getValue(), "value"),
                                        getNextLink(res.getValue(), "nextLink"),
                                        null));
    }

    /**
     * List workflow runs.
     *
     * <p><strong>Query Parameters</strong>
     *
     * <table border="1">
     *     <caption>Query Parameters</caption>
     *     <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
     *     <tr><td>timeWindow</td><td>String</td><td>No</td><td>Time window of filtering items. Allowed values: "1d", "7d", "30d", "90d".</td></tr>
     *     <tr><td>orderby</td><td>String</td><td>No</td><td>The key word which used to sort the results. Allowed values: "status desc", "status asc", "requestor desc", "requestor asc", "startTime desc", "startTime asc", "createdTime desc", "createdTime asc".</td></tr>
     *     <tr><td>runStatuses</td><td>List&lt;String&gt;</td><td>No</td><td>Filter workflow runs by workflow run status. In the form of "," separated string.</td></tr>
     *     <tr><td>workflowIds</td><td>List&lt;String&gt;</td><td>No</td><td>Filter items by workflow id list. In the form of "," separated string.</td></tr>
     *     <tr><td>maxpagesize</td><td>Integer</td><td>No</td><td>The maximum page size to get the items at one time.</td></tr>
     * </table>
     *
     * You can add these to a request with {@link RequestOptions#addQueryParam}
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     id: String (Required)
     *     workflowId: String (Required)
     *     startTime: OffsetDateTime (Required)
     *     requestor: String (Required)
     *     userRequestId: String (Optional)
     *     runPayload (Required): {
     *         type: String(CreateTerm/UpdateTerm/DeleteTerm/ImportTerms/UpdateAsset/GrantDataAccess) (Required)
     *         targetValue: String (Required)
     *     }
     *     status: String(NotStarted/InProgress/Failed/Completed/Canceling/CancellationFailed/Canceled) (Required)
     *     endTime: OffsetDateTime (Optional)
     *     cancelTime: OffsetDateTime (Optional)
     *     cancelComment: String (Optional)
     * }
     * }</pre>
     *
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return the paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedFlux<BinaryData> listWorkflowRunsAsync(RequestOptions requestOptions) {
        RequestOptions requestOptionsForNextPage = new RequestOptions();
        requestOptionsForNextPage.setContext(
                requestOptions != null && requestOptions.getContext() != null
                        ? requestOptions.getContext()
                        : Context.NONE);
        return new PagedFlux<>(
                () -> listWorkflowRunsSinglePageAsync(requestOptions),
                nextLink -> listWorkflowRunsNextSinglePageAsync(nextLink, requestOptionsForNextPage));
    }

    /**
     * List workflow runs.
     *
     * <p><strong>Query Parameters</strong>
     *
     * <table border="1">
     *     <caption>Query Parameters</caption>
     *     <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
     *     <tr><td>timeWindow</td><td>String</td><td>No</td><td>Time window of filtering items. Allowed values: "1d", "7d", "30d", "90d".</td></tr>
     *     <tr><td>orderby</td><td>String</td><td>No</td><td>The key word which used to sort the results. Allowed values: "status desc", "status asc", "requestor desc", "requestor asc", "startTime desc", "startTime asc", "createdTime desc", "createdTime asc".</td></tr>
     *     <tr><td>runStatuses</td><td>List&lt;String&gt;</td><td>No</td><td>Filter workflow runs by workflow run status. In the form of "," separated string.</td></tr>
     *     <tr><td>workflowIds</td><td>List&lt;String&gt;</td><td>No</td><td>Filter items by workflow id list. In the form of "," separated string.</td></tr>
     *     <tr><td>maxpagesize</td><td>Integer</td><td>No</td><td>The maximum page size to get the items at one time.</td></tr>
     * </table>
     *
     * You can add these to a request with {@link RequestOptions#addQueryParam}
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     id: String (Required)
     *     workflowId: String (Required)
     *     startTime: OffsetDateTime (Required)
     *     requestor: String (Required)
     *     userRequestId: String (Optional)
     *     runPayload (Required): {
     *         type: String(CreateTerm/UpdateTerm/DeleteTerm/ImportTerms/UpdateAsset/GrantDataAccess) (Required)
     *         targetValue: String (Required)
     *     }
     *     status: String(NotStarted/InProgress/Failed/Completed/Canceling/CancellationFailed/Canceled) (Required)
     *     endTime: OffsetDateTime (Optional)
     *     cancelTime: OffsetDateTime (Optional)
     *     cancelComment: String (Optional)
     * }
     * }</pre>
     *
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return the response body along with {@link PagedResponse}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private PagedResponse<BinaryData> listWorkflowRunsSinglePage(RequestOptions requestOptions) {
        final String accept = "application/json";
        Response<BinaryData> res =
                service.listWorkflowRunsSync(
                        this.getEndpoint(),
                        this.getServiceVersion().getVersion(),
                        accept,
                        requestOptions,
                        Context.NONE);
        return new PagedResponseBase<>(
                res.getRequest(),
                res.getStatusCode(),
                res.getHeaders(),
                getValues(res.getValue(), "value"),
                getNextLink(res.getValue(), "nextLink"),
                null);
    }

    /**
     * List workflow runs.
     *
     * <p><strong>Query Parameters</strong>
     *
     * <table border="1">
     *     <caption>Query Parameters</caption>
     *     <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
     *     <tr><td>timeWindow</td><td>String</td><td>No</td><td>Time window of filtering items. Allowed values: "1d", "7d", "30d", "90d".</td></tr>
     *     <tr><td>orderby</td><td>String</td><td>No</td><td>The key word which used to sort the results. Allowed values: "status desc", "status asc", "requestor desc", "requestor asc", "startTime desc", "startTime asc", "createdTime desc", "createdTime asc".</td></tr>
     *     <tr><td>runStatuses</td><td>List&lt;String&gt;</td><td>No</td><td>Filter workflow runs by workflow run status. In the form of "," separated string.</td></tr>
     *     <tr><td>workflowIds</td><td>List&lt;String&gt;</td><td>No</td><td>Filter items by workflow id list. In the form of "," separated string.</td></tr>
     *     <tr><td>maxpagesize</td><td>Integer</td><td>No</td><td>The maximum page size to get the items at one time.</td></tr>
     * </table>
     *
     * You can add these to a request with {@link RequestOptions#addQueryParam}
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     id: String (Required)
     *     workflowId: String (Required)
     *     startTime: OffsetDateTime (Required)
     *     requestor: String (Required)
     *     userRequestId: String (Optional)
     *     runPayload (Required): {
     *         type: String(CreateTerm/UpdateTerm/DeleteTerm/ImportTerms/UpdateAsset/GrantDataAccess) (Required)
     *         targetValue: String (Required)
     *     }
     *     status: String(NotStarted/InProgress/Failed/Completed/Canceling/CancellationFailed/Canceled) (Required)
     *     endTime: OffsetDateTime (Optional)
     *     cancelTime: OffsetDateTime (Optional)
     *     cancelComment: String (Optional)
     * }
     * }</pre>
     *
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return the paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<BinaryData> listWorkflowRuns(RequestOptions requestOptions) {
        RequestOptions requestOptionsForNextPage = new RequestOptions();
        requestOptionsForNextPage.setContext(
                requestOptions != null && requestOptions.getContext() != null
                        ? requestOptions.getContext()
                        : Context.NONE);
        return new PagedIterable<>(
                () -> listWorkflowRunsSinglePage(requestOptions),
                nextLink -> listWorkflowRunsNextSinglePage(nextLink, requestOptionsForNextPage));
    }

    /**
     * Get a workflow run.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     id: String (Optional)
     *     workflowId: String (Optional)
     *     startTime: OffsetDateTime (Optional)
     *     requestor: String (Optional)
     *     userRequestId: String (Optional)
     *     runPayload (Optional): {
     *         type: String(CreateTerm/UpdateTerm/DeleteTerm/ImportTerms/UpdateAsset/GrantDataAccess) (Required)
     *         targetValue: String (Required)
     *         payload: Object (Required)
     *     }
     *     status: String(NotStarted/InProgress/Failed/Completed/Canceling/CancellationFailed/Canceled) (Optional)
     *     endTime: OffsetDateTime (Optional)
     *     cancelTime: OffsetDateTime (Optional)
     *     cancelComment: String (Optional)
     *     actionDag: Object (Required)
     *     detail (Required): {
     *         runInput: Object (Required)
     *         actions: Object (Required)
     *     }
     * }
     * }</pre>
     *
     * @param workflowRunId The workflow run id.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return a workflow run along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<BinaryData>> getWorkflowRunWithResponseAsync(
            String workflowRunId, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.getWorkflowRun(
                                this.getEndpoint(),
                                this.getServiceVersion().getVersion(),
                                workflowRunId,
                                accept,
                                requestOptions,
                                context));
    }

    /**
     * Get a workflow run.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     id: String (Optional)
     *     workflowId: String (Optional)
     *     startTime: OffsetDateTime (Optional)
     *     requestor: String (Optional)
     *     userRequestId: String (Optional)
     *     runPayload (Optional): {
     *         type: String(CreateTerm/UpdateTerm/DeleteTerm/ImportTerms/UpdateAsset/GrantDataAccess) (Required)
     *         targetValue: String (Required)
     *         payload: Object (Required)
     *     }
     *     status: String(NotStarted/InProgress/Failed/Completed/Canceling/CancellationFailed/Canceled) (Optional)
     *     endTime: OffsetDateTime (Optional)
     *     cancelTime: OffsetDateTime (Optional)
     *     cancelComment: String (Optional)
     *     actionDag: Object (Required)
     *     detail (Required): {
     *         runInput: Object (Required)
     *         actions: Object (Required)
     *     }
     * }
     * }</pre>
     *
     * @param workflowRunId The workflow run id.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return a workflow run along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<BinaryData> getWorkflowRunWithResponse(String workflowRunId, RequestOptions requestOptions) {
        final String accept = "application/json";
        return service.getWorkflowRunSync(
                this.getEndpoint(),
                this.getServiceVersion().getVersion(),
                workflowRunId,
                accept,
                requestOptions,
                Context.NONE);
    }

    /**
     * Cancel a workflow run.
     *
     * <p><strong>Request Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     comment: String (Optional)
     * }
     * }</pre>
     *
     * @param workflowRunId The workflow run id.
     * @param runCancelReply Reply of canceling a workflow run.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return the {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<Void>> cancelWorkflowRunWithResponseAsync(
            String workflowRunId, BinaryData runCancelReply, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.cancelWorkflowRun(
                                this.getEndpoint(),
                                this.getServiceVersion().getVersion(),
                                workflowRunId,
                                runCancelReply,
                                accept,
                                requestOptions,
                                context));
    }

    /**
     * Cancel a workflow run.
     *
     * <p><strong>Request Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     comment: String (Optional)
     * }
     * }</pre>
     *
     * @param workflowRunId The workflow run id.
     * @param runCancelReply Reply of canceling a workflow run.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return the {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<Void> cancelWorkflowRunWithResponse(
            String workflowRunId, BinaryData runCancelReply, RequestOptions requestOptions) {
        final String accept = "application/json";
        return service.cancelWorkflowRunSync(
                this.getEndpoint(),
                this.getServiceVersion().getVersion(),
                workflowRunId,
                runCancelReply,
                accept,
                requestOptions,
                Context.NONE);
    }

    /**
     * Get all workflow tasks.
     *
     * <p><strong>Query Parameters</strong>
     *
     * <table border="1">
     *     <caption>Query Parameters</caption>
     *     <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
     *     <tr><td>viewMode</td><td>String</td><td>No</td><td>To filter user's sent, received or history workflow tasks.</td></tr>
     *     <tr><td>workflowIds</td><td>List&lt;String&gt;</td><td>No</td><td>Filter items by workflow id list. In the form of "," separated string.</td></tr>
     *     <tr><td>timeWindow</td><td>String</td><td>No</td><td>Time window of filtering items. Allowed values: "1d", "7d", "30d", "90d".</td></tr>
     *     <tr><td>maxpagesize</td><td>Integer</td><td>No</td><td>The maximum page size to get the items at one time.</td></tr>
     *     <tr><td>orderby</td><td>String</td><td>No</td><td>The key word which used to sort the results. Allowed values: "status desc", "status asc", "requestor desc", "requestor asc", "startTime desc", "startTime asc", "createdTime desc", "createdTime asc".</td></tr>
     *     <tr><td>taskTypes</td><td>List&lt;String&gt;</td><td>No</td><td>Filter items by workflow task type. In the form of "," separated string.</td></tr>
     *     <tr><td>taskStatuses</td><td>List&lt;String&gt;</td><td>No</td><td>Filter workflow tasks by status. In the form of "," separated string.</td></tr>
     *     <tr><td>workflowNameKeyword</td><td>String</td><td>No</td><td>The key word which could used to filter workflow item with related workflow.</td></tr>
     * </table>
     *
     * You can add these to a request with {@link RequestOptions#addQueryParam}
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     id: String (Required)
     *     title: String (Optional)
     *     workflowRunId: String (Required)
     *     workflowId: String (Required)
     *     requestor: String (Required)
     *     createdTime: OffsetDateTime (Required)
     *     lastUpdateTime: OffsetDateTime (Required)
     *     payload (Required): {
     *         type: String(CreateTerm/UpdateTerm/DeleteTerm/ImportTerms/UpdateAsset/GrantDataAccess) (Required)
     *         targetValue: String (Required)
     *         payload: Object (Optional)
     *     }
     *     reminderInfo (Optional): {
     *         lastRemindTime: OffsetDateTime (Optional)
     *         nextRemindTime: OffsetDateTime (Required)
     *         reminderSettings: Object (Required)
     *     }
     *     expiryInfo (Optional): {
     *         lastExpiryNotificationTime: OffsetDateTime (Optional)
     *         nextExpiryNotificationTime: OffsetDateTime (Required)
     *         expiryTime: OffsetDateTime (Required)
     *         expirySettings (Required): {
     *             expireAfter: Object (Required)
     *             notifyOnExpiration (Optional): [
     *                 String (Optional)
     *             ]
     *         }
     *     }
     * }
     * }</pre>
     *
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return all workflow tasks along with {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<BinaryData>> listWorkflowTasksSinglePageAsync(RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                        context ->
                                service.listWorkflowTasks(
                                        this.getEndpoint(),
                                        this.getServiceVersion().getVersion(),
                                        accept,
                                        requestOptions,
                                        context))
                .map(
                        res ->
                                new PagedResponseBase<>(
                                        res.getRequest(),
                                        res.getStatusCode(),
                                        res.getHeaders(),
                                        getValues(res.getValue(), "value"),
                                        getNextLink(res.getValue(), "nextLink"),
                                        null));
    }

    /**
     * Get all workflow tasks.
     *
     * <p><strong>Query Parameters</strong>
     *
     * <table border="1">
     *     <caption>Query Parameters</caption>
     *     <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
     *     <tr><td>viewMode</td><td>String</td><td>No</td><td>To filter user's sent, received or history workflow tasks.</td></tr>
     *     <tr><td>workflowIds</td><td>List&lt;String&gt;</td><td>No</td><td>Filter items by workflow id list. In the form of "," separated string.</td></tr>
     *     <tr><td>timeWindow</td><td>String</td><td>No</td><td>Time window of filtering items. Allowed values: "1d", "7d", "30d", "90d".</td></tr>
     *     <tr><td>maxpagesize</td><td>Integer</td><td>No</td><td>The maximum page size to get the items at one time.</td></tr>
     *     <tr><td>orderby</td><td>String</td><td>No</td><td>The key word which used to sort the results. Allowed values: "status desc", "status asc", "requestor desc", "requestor asc", "startTime desc", "startTime asc", "createdTime desc", "createdTime asc".</td></tr>
     *     <tr><td>taskTypes</td><td>List&lt;String&gt;</td><td>No</td><td>Filter items by workflow task type. In the form of "," separated string.</td></tr>
     *     <tr><td>taskStatuses</td><td>List&lt;String&gt;</td><td>No</td><td>Filter workflow tasks by status. In the form of "," separated string.</td></tr>
     *     <tr><td>workflowNameKeyword</td><td>String</td><td>No</td><td>The key word which could used to filter workflow item with related workflow.</td></tr>
     * </table>
     *
     * You can add these to a request with {@link RequestOptions#addQueryParam}
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     id: String (Required)
     *     title: String (Optional)
     *     workflowRunId: String (Required)
     *     workflowId: String (Required)
     *     requestor: String (Required)
     *     createdTime: OffsetDateTime (Required)
     *     lastUpdateTime: OffsetDateTime (Required)
     *     payload (Required): {
     *         type: String(CreateTerm/UpdateTerm/DeleteTerm/ImportTerms/UpdateAsset/GrantDataAccess) (Required)
     *         targetValue: String (Required)
     *         payload: Object (Optional)
     *     }
     *     reminderInfo (Optional): {
     *         lastRemindTime: OffsetDateTime (Optional)
     *         nextRemindTime: OffsetDateTime (Required)
     *         reminderSettings: Object (Required)
     *     }
     *     expiryInfo (Optional): {
     *         lastExpiryNotificationTime: OffsetDateTime (Optional)
     *         nextExpiryNotificationTime: OffsetDateTime (Required)
     *         expiryTime: OffsetDateTime (Required)
     *         expirySettings (Required): {
     *             expireAfter: Object (Required)
     *             notifyOnExpiration (Optional): [
     *                 String (Optional)
     *             ]
     *         }
     *     }
     * }
     * }</pre>
     *
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return all workflow tasks as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedFlux<BinaryData> listWorkflowTasksAsync(RequestOptions requestOptions) {
        RequestOptions requestOptionsForNextPage = new RequestOptions();
        requestOptionsForNextPage.setContext(
                requestOptions != null && requestOptions.getContext() != null
                        ? requestOptions.getContext()
                        : Context.NONE);
        return new PagedFlux<>(
                () -> listWorkflowTasksSinglePageAsync(requestOptions),
                nextLink -> listWorkflowTasksNextSinglePageAsync(nextLink, requestOptionsForNextPage));
    }

    /**
     * Get all workflow tasks.
     *
     * <p><strong>Query Parameters</strong>
     *
     * <table border="1">
     *     <caption>Query Parameters</caption>
     *     <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
     *     <tr><td>viewMode</td><td>String</td><td>No</td><td>To filter user's sent, received or history workflow tasks.</td></tr>
     *     <tr><td>workflowIds</td><td>List&lt;String&gt;</td><td>No</td><td>Filter items by workflow id list. In the form of "," separated string.</td></tr>
     *     <tr><td>timeWindow</td><td>String</td><td>No</td><td>Time window of filtering items. Allowed values: "1d", "7d", "30d", "90d".</td></tr>
     *     <tr><td>maxpagesize</td><td>Integer</td><td>No</td><td>The maximum page size to get the items at one time.</td></tr>
     *     <tr><td>orderby</td><td>String</td><td>No</td><td>The key word which used to sort the results. Allowed values: "status desc", "status asc", "requestor desc", "requestor asc", "startTime desc", "startTime asc", "createdTime desc", "createdTime asc".</td></tr>
     *     <tr><td>taskTypes</td><td>List&lt;String&gt;</td><td>No</td><td>Filter items by workflow task type. In the form of "," separated string.</td></tr>
     *     <tr><td>taskStatuses</td><td>List&lt;String&gt;</td><td>No</td><td>Filter workflow tasks by status. In the form of "," separated string.</td></tr>
     *     <tr><td>workflowNameKeyword</td><td>String</td><td>No</td><td>The key word which could used to filter workflow item with related workflow.</td></tr>
     * </table>
     *
     * You can add these to a request with {@link RequestOptions#addQueryParam}
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     id: String (Required)
     *     title: String (Optional)
     *     workflowRunId: String (Required)
     *     workflowId: String (Required)
     *     requestor: String (Required)
     *     createdTime: OffsetDateTime (Required)
     *     lastUpdateTime: OffsetDateTime (Required)
     *     payload (Required): {
     *         type: String(CreateTerm/UpdateTerm/DeleteTerm/ImportTerms/UpdateAsset/GrantDataAccess) (Required)
     *         targetValue: String (Required)
     *         payload: Object (Optional)
     *     }
     *     reminderInfo (Optional): {
     *         lastRemindTime: OffsetDateTime (Optional)
     *         nextRemindTime: OffsetDateTime (Required)
     *         reminderSettings: Object (Required)
     *     }
     *     expiryInfo (Optional): {
     *         lastExpiryNotificationTime: OffsetDateTime (Optional)
     *         nextExpiryNotificationTime: OffsetDateTime (Required)
     *         expiryTime: OffsetDateTime (Required)
     *         expirySettings (Required): {
     *             expireAfter: Object (Required)
     *             notifyOnExpiration (Optional): [
     *                 String (Optional)
     *             ]
     *         }
     *     }
     * }
     * }</pre>
     *
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return all workflow tasks along with {@link PagedResponse}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private PagedResponse<BinaryData> listWorkflowTasksSinglePage(RequestOptions requestOptions) {
        final String accept = "application/json";
        Response<BinaryData> res =
                service.listWorkflowTasksSync(
                        this.getEndpoint(),
                        this.getServiceVersion().getVersion(),
                        accept,
                        requestOptions,
                        Context.NONE);
        return new PagedResponseBase<>(
                res.getRequest(),
                res.getStatusCode(),
                res.getHeaders(),
                getValues(res.getValue(), "value"),
                getNextLink(res.getValue(), "nextLink"),
                null);
    }

    /**
     * Get all workflow tasks.
     *
     * <p><strong>Query Parameters</strong>
     *
     * <table border="1">
     *     <caption>Query Parameters</caption>
     *     <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
     *     <tr><td>viewMode</td><td>String</td><td>No</td><td>To filter user's sent, received or history workflow tasks.</td></tr>
     *     <tr><td>workflowIds</td><td>List&lt;String&gt;</td><td>No</td><td>Filter items by workflow id list. In the form of "," separated string.</td></tr>
     *     <tr><td>timeWindow</td><td>String</td><td>No</td><td>Time window of filtering items. Allowed values: "1d", "7d", "30d", "90d".</td></tr>
     *     <tr><td>maxpagesize</td><td>Integer</td><td>No</td><td>The maximum page size to get the items at one time.</td></tr>
     *     <tr><td>orderby</td><td>String</td><td>No</td><td>The key word which used to sort the results. Allowed values: "status desc", "status asc", "requestor desc", "requestor asc", "startTime desc", "startTime asc", "createdTime desc", "createdTime asc".</td></tr>
     *     <tr><td>taskTypes</td><td>List&lt;String&gt;</td><td>No</td><td>Filter items by workflow task type. In the form of "," separated string.</td></tr>
     *     <tr><td>taskStatuses</td><td>List&lt;String&gt;</td><td>No</td><td>Filter workflow tasks by status. In the form of "," separated string.</td></tr>
     *     <tr><td>workflowNameKeyword</td><td>String</td><td>No</td><td>The key word which could used to filter workflow item with related workflow.</td></tr>
     * </table>
     *
     * You can add these to a request with {@link RequestOptions#addQueryParam}
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     id: String (Required)
     *     title: String (Optional)
     *     workflowRunId: String (Required)
     *     workflowId: String (Required)
     *     requestor: String (Required)
     *     createdTime: OffsetDateTime (Required)
     *     lastUpdateTime: OffsetDateTime (Required)
     *     payload (Required): {
     *         type: String(CreateTerm/UpdateTerm/DeleteTerm/ImportTerms/UpdateAsset/GrantDataAccess) (Required)
     *         targetValue: String (Required)
     *         payload: Object (Optional)
     *     }
     *     reminderInfo (Optional): {
     *         lastRemindTime: OffsetDateTime (Optional)
     *         nextRemindTime: OffsetDateTime (Required)
     *         reminderSettings: Object (Required)
     *     }
     *     expiryInfo (Optional): {
     *         lastExpiryNotificationTime: OffsetDateTime (Optional)
     *         nextExpiryNotificationTime: OffsetDateTime (Required)
     *         expiryTime: OffsetDateTime (Required)
     *         expirySettings (Required): {
     *             expireAfter: Object (Required)
     *             notifyOnExpiration (Optional): [
     *                 String (Optional)
     *             ]
     *         }
     *     }
     * }
     * }</pre>
     *
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return all workflow tasks as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<BinaryData> listWorkflowTasks(RequestOptions requestOptions) {
        RequestOptions requestOptionsForNextPage = new RequestOptions();
        requestOptionsForNextPage.setContext(
                requestOptions != null && requestOptions.getContext() != null
                        ? requestOptions.getContext()
                        : Context.NONE);
        return new PagedIterable<>(
                () -> listWorkflowTasksSinglePage(requestOptions),
                nextLink -> listWorkflowTasksNextSinglePage(nextLink, requestOptionsForNextPage));
    }

    /**
     * Get a workflow task.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     id: String (Required)
     *     title: String (Optional)
     *     workflowRunId: String (Required)
     *     workflowId: String (Required)
     *     requestor: String (Required)
     *     createdTime: OffsetDateTime (Required)
     *     lastUpdateTime: OffsetDateTime (Required)
     *     payload (Required): {
     *         type: String(CreateTerm/UpdateTerm/DeleteTerm/ImportTerms/UpdateAsset/GrantDataAccess) (Required)
     *         targetValue: String (Required)
     *         payload: Object (Optional)
     *     }
     *     reminderInfo (Optional): {
     *         lastRemindTime: OffsetDateTime (Optional)
     *         nextRemindTime: OffsetDateTime (Required)
     *         reminderSettings: Object (Required)
     *     }
     *     expiryInfo (Optional): {
     *         lastExpiryNotificationTime: OffsetDateTime (Optional)
     *         nextExpiryNotificationTime: OffsetDateTime (Required)
     *         expiryTime: OffsetDateTime (Required)
     *         expirySettings (Required): {
     *             expireAfter: Object (Required)
     *             notifyOnExpiration (Optional): [
     *                 String (Optional)
     *             ]
     *         }
     *     }
     * }
     * }</pre>
     *
     * @param taskId The task id.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return a workflow task along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<BinaryData>> getWorkflowTaskWithResponseAsync(String taskId, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                context -> service.getWorkflowTask(this.getEndpoint(), taskId, accept, requestOptions, context));
    }

    /**
     * Get a workflow task.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     id: String (Required)
     *     title: String (Optional)
     *     workflowRunId: String (Required)
     *     workflowId: String (Required)
     *     requestor: String (Required)
     *     createdTime: OffsetDateTime (Required)
     *     lastUpdateTime: OffsetDateTime (Required)
     *     payload (Required): {
     *         type: String(CreateTerm/UpdateTerm/DeleteTerm/ImportTerms/UpdateAsset/GrantDataAccess) (Required)
     *         targetValue: String (Required)
     *         payload: Object (Optional)
     *     }
     *     reminderInfo (Optional): {
     *         lastRemindTime: OffsetDateTime (Optional)
     *         nextRemindTime: OffsetDateTime (Required)
     *         reminderSettings: Object (Required)
     *     }
     *     expiryInfo (Optional): {
     *         lastExpiryNotificationTime: OffsetDateTime (Optional)
     *         nextExpiryNotificationTime: OffsetDateTime (Required)
     *         expiryTime: OffsetDateTime (Required)
     *         expirySettings (Required): {
     *             expireAfter: Object (Required)
     *             notifyOnExpiration (Optional): [
     *                 String (Optional)
     *             ]
     *         }
     *     }
     * }
     * }</pre>
     *
     * @param taskId The task id.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return a workflow task along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<BinaryData> getWorkflowTaskWithResponse(String taskId, RequestOptions requestOptions) {
        final String accept = "application/json";
        return service.getWorkflowTaskSync(this.getEndpoint(), taskId, accept, requestOptions, Context.NONE);
    }

    /**
     * Approve an approval task.
     *
     * <p><strong>Request Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     comment: String (Optional)
     * }
     * }</pre>
     *
     * @param taskId The task id.
     * @param approvalResponseComment The request body of approving an approval request.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return the {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<Void>> approveApprovalTaskWithResponseAsync(
            String taskId, BinaryData approvalResponseComment, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.approveApprovalTask(
                                this.getEndpoint(),
                                taskId,
                                this.getServiceVersion().getVersion(),
                                approvalResponseComment,
                                accept,
                                requestOptions,
                                context));
    }

    /**
     * Approve an approval task.
     *
     * <p><strong>Request Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     comment: String (Optional)
     * }
     * }</pre>
     *
     * @param taskId The task id.
     * @param approvalResponseComment The request body of approving an approval request.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return the {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<Void> approveApprovalTaskWithResponse(
            String taskId, BinaryData approvalResponseComment, RequestOptions requestOptions) {
        final String accept = "application/json";
        return service.approveApprovalTaskSync(
                this.getEndpoint(),
                taskId,
                this.getServiceVersion().getVersion(),
                approvalResponseComment,
                accept,
                requestOptions,
                Context.NONE);
    }

    /**
     * Reject an approval task.
     *
     * <p><strong>Request Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     comment: String (Optional)
     * }
     * }</pre>
     *
     * @param taskId The task id.
     * @param approvalResponseComment The request body of rejecting an approval request.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return the {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<Void>> rejectApprovalTaskWithResponseAsync(
            String taskId, BinaryData approvalResponseComment, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.rejectApprovalTask(
                                this.getEndpoint(),
                                taskId,
                                this.getServiceVersion().getVersion(),
                                approvalResponseComment,
                                accept,
                                requestOptions,
                                context));
    }

    /**
     * Reject an approval task.
     *
     * <p><strong>Request Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     comment: String (Optional)
     * }
     * }</pre>
     *
     * @param taskId The task id.
     * @param approvalResponseComment The request body of rejecting an approval request.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return the {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<Void> rejectApprovalTaskWithResponse(
            String taskId, BinaryData approvalResponseComment, RequestOptions requestOptions) {
        final String accept = "application/json";
        return service.rejectApprovalTaskSync(
                this.getEndpoint(),
                taskId,
                this.getServiceVersion().getVersion(),
                approvalResponseComment,
                accept,
                requestOptions,
                Context.NONE);
    }

    /**
     * Reassign a workflow task.
     *
     * <p><strong>Request Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     reassignments (Optional): [
     *          (Optional){
     *             reassignFrom: String (Required)
     *             reassignTo: String (Required)
     *         }
     *     ]
     * }
     * }</pre>
     *
     * @param taskId The task id.
     * @param reassignCommand The request body of reassigning a workflow task.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return the {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<Void>> reassignWorkflowTaskWithResponseAsync(
            String taskId, BinaryData reassignCommand, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.reassignWorkflowTask(
                                this.getEndpoint(),
                                taskId,
                                this.getServiceVersion().getVersion(),
                                reassignCommand,
                                accept,
                                requestOptions,
                                context));
    }

    /**
     * Reassign a workflow task.
     *
     * <p><strong>Request Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     reassignments (Optional): [
     *          (Optional){
     *             reassignFrom: String (Required)
     *             reassignTo: String (Required)
     *         }
     *     ]
     * }
     * }</pre>
     *
     * @param taskId The task id.
     * @param reassignCommand The request body of reassigning a workflow task.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return the {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<Void> reassignWorkflowTaskWithResponse(
            String taskId, BinaryData reassignCommand, RequestOptions requestOptions) {
        final String accept = "application/json";
        return service.reassignWorkflowTaskSync(
                this.getEndpoint(),
                taskId,
                this.getServiceVersion().getVersion(),
                reassignCommand,
                accept,
                requestOptions,
                Context.NONE);
    }

    /**
     * Update the status of a workflow task request.
     *
     * <p><strong>Request Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     newStatus: String(NotStarted/InProgress/Completed/Canceled) (Required)
     *     comment: String (Optional)
     * }
     * }</pre>
     *
     * @param taskId The task id.
     * @param taskUpdateCommand Request body of updating workflow task request.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return the {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<Void>> updateTaskStatusWithResponseAsync(
            String taskId, BinaryData taskUpdateCommand, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.updateTaskStatus(
                                this.getEndpoint(),
                                taskId,
                                this.getServiceVersion().getVersion(),
                                taskUpdateCommand,
                                accept,
                                requestOptions,
                                context));
    }

    /**
     * Update the status of a workflow task request.
     *
     * <p><strong>Request Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     newStatus: String(NotStarted/InProgress/Completed/Canceled) (Required)
     *     comment: String (Optional)
     * }
     * }</pre>
     *
     * @param taskId The task id.
     * @param taskUpdateCommand Request body of updating workflow task request.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return the {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<Void> updateTaskStatusWithResponse(
            String taskId, BinaryData taskUpdateCommand, RequestOptions requestOptions) {
        final String accept = "application/json";
        return service.updateTaskStatusSync(
                this.getEndpoint(),
                taskId,
                this.getServiceVersion().getVersion(),
                taskUpdateCommand,
                accept,
                requestOptions,
                Context.NONE);
    }

    /**
     * Get the next page of items.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     id: String (Required)
     *     triggers (Required): [
     *          (Required){
     *             type: String(when_term_creation_is_requested/when_term_deletion_is_requested/when_term_update_is_requested/when_terms_import_is_requested/when_data_access_grant_is_requested/when_asset_update_is_requested) (Required)
     *             underGlossaryHierarchy: String (Optional)
     *             underCollection: String (Optional)
     *             underGlossary: String (Optional)
     *         }
     *     ]
     *     createdTime: OffsetDateTime (Optional)
     *     createdBy: String (Optional)
     *     lastUpdateTime: OffsetDateTime (Optional)
     *     updatedBy: String (Optional)
     *     name: String (Required)
     *     isEnabled: boolean (Required)
     *     description: String (Required)
     * }
     * }</pre>
     *
     * @param nextLink The URL to get the next list of items
     *     <p>The nextLink parameter.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return the workflow list along with {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<BinaryData>> listWorkflowsNextSinglePageAsync(
            String nextLink, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                        context ->
                                service.listWorkflowsNext(
                                        nextLink, this.getEndpoint(), accept, requestOptions, context))
                .map(
                        res ->
                                new PagedResponseBase<>(
                                        res.getRequest(),
                                        res.getStatusCode(),
                                        res.getHeaders(),
                                        getValues(res.getValue(), "value"),
                                        getNextLink(res.getValue(), "nextLink"),
                                        null));
    }

    /**
     * Get the next page of items.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     id: String (Required)
     *     triggers (Required): [
     *          (Required){
     *             type: String(when_term_creation_is_requested/when_term_deletion_is_requested/when_term_update_is_requested/when_terms_import_is_requested/when_data_access_grant_is_requested/when_asset_update_is_requested) (Required)
     *             underGlossaryHierarchy: String (Optional)
     *             underCollection: String (Optional)
     *             underGlossary: String (Optional)
     *         }
     *     ]
     *     createdTime: OffsetDateTime (Optional)
     *     createdBy: String (Optional)
     *     lastUpdateTime: OffsetDateTime (Optional)
     *     updatedBy: String (Optional)
     *     name: String (Required)
     *     isEnabled: boolean (Required)
     *     description: String (Required)
     * }
     * }</pre>
     *
     * @param nextLink The URL to get the next list of items
     *     <p>The nextLink parameter.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return the workflow list along with {@link PagedResponse}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private PagedResponse<BinaryData> listWorkflowsNextSinglePage(String nextLink, RequestOptions requestOptions) {
        final String accept = "application/json";
        Response<BinaryData> res =
                service.listWorkflowsNextSync(nextLink, this.getEndpoint(), accept, requestOptions, Context.NONE);
        return new PagedResponseBase<>(
                res.getRequest(),
                res.getStatusCode(),
                res.getHeaders(),
                getValues(res.getValue(), "value"),
                getNextLink(res.getValue(), "nextLink"),
                null);
    }

    /**
     * Get the next page of items.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     id: String (Required)
     *     workflowId: String (Required)
     *     startTime: OffsetDateTime (Required)
     *     requestor: String (Required)
     *     userRequestId: String (Optional)
     *     runPayload (Required): {
     *         type: String(CreateTerm/UpdateTerm/DeleteTerm/ImportTerms/UpdateAsset/GrantDataAccess) (Required)
     *         targetValue: String (Required)
     *     }
     *     status: String(NotStarted/InProgress/Failed/Completed/Canceling/CancellationFailed/Canceled) (Required)
     *     endTime: OffsetDateTime (Optional)
     *     cancelTime: OffsetDateTime (Optional)
     *     cancelComment: String (Optional)
     * }
     * }</pre>
     *
     * @param nextLink The URL to get the next list of items
     *     <p>The nextLink parameter.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return the response body along with {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<BinaryData>> listWorkflowRunsNextSinglePageAsync(
            String nextLink, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                        context ->
                                service.listWorkflowRunsNext(
                                        nextLink, this.getEndpoint(), accept, requestOptions, context))
                .map(
                        res ->
                                new PagedResponseBase<>(
                                        res.getRequest(),
                                        res.getStatusCode(),
                                        res.getHeaders(),
                                        getValues(res.getValue(), "value"),
                                        getNextLink(res.getValue(), "nextLink"),
                                        null));
    }

    /**
     * Get the next page of items.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     id: String (Required)
     *     workflowId: String (Required)
     *     startTime: OffsetDateTime (Required)
     *     requestor: String (Required)
     *     userRequestId: String (Optional)
     *     runPayload (Required): {
     *         type: String(CreateTerm/UpdateTerm/DeleteTerm/ImportTerms/UpdateAsset/GrantDataAccess) (Required)
     *         targetValue: String (Required)
     *     }
     *     status: String(NotStarted/InProgress/Failed/Completed/Canceling/CancellationFailed/Canceled) (Required)
     *     endTime: OffsetDateTime (Optional)
     *     cancelTime: OffsetDateTime (Optional)
     *     cancelComment: String (Optional)
     * }
     * }</pre>
     *
     * @param nextLink The URL to get the next list of items
     *     <p>The nextLink parameter.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return the response body along with {@link PagedResponse}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private PagedResponse<BinaryData> listWorkflowRunsNextSinglePage(String nextLink, RequestOptions requestOptions) {
        final String accept = "application/json";
        Response<BinaryData> res =
                service.listWorkflowRunsNextSync(nextLink, this.getEndpoint(), accept, requestOptions, Context.NONE);
        return new PagedResponseBase<>(
                res.getRequest(),
                res.getStatusCode(),
                res.getHeaders(),
                getValues(res.getValue(), "value"),
                getNextLink(res.getValue(), "nextLink"),
                null);
    }

    /**
     * Get the next page of items.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     id: String (Required)
     *     title: String (Optional)
     *     workflowRunId: String (Required)
     *     workflowId: String (Required)
     *     requestor: String (Required)
     *     createdTime: OffsetDateTime (Required)
     *     lastUpdateTime: OffsetDateTime (Required)
     *     payload (Required): {
     *         type: String(CreateTerm/UpdateTerm/DeleteTerm/ImportTerms/UpdateAsset/GrantDataAccess) (Required)
     *         targetValue: String (Required)
     *         payload: Object (Optional)
     *     }
     *     reminderInfo (Optional): {
     *         lastRemindTime: OffsetDateTime (Optional)
     *         nextRemindTime: OffsetDateTime (Required)
     *         reminderSettings: Object (Required)
     *     }
     *     expiryInfo (Optional): {
     *         lastExpiryNotificationTime: OffsetDateTime (Optional)
     *         nextExpiryNotificationTime: OffsetDateTime (Required)
     *         expiryTime: OffsetDateTime (Required)
     *         expirySettings (Required): {
     *             expireAfter: Object (Required)
     *             notifyOnExpiration (Optional): [
     *                 String (Optional)
     *             ]
     *         }
     *     }
     * }
     * }</pre>
     *
     * @param nextLink The URL to get the next list of items
     *     <p>The nextLink parameter.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return the response body along with {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono<PagedResponse<BinaryData>> listWorkflowTasksNextSinglePageAsync(
            String nextLink, RequestOptions requestOptions) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                        context ->
                                service.listWorkflowTasksNext(
                                        nextLink, this.getEndpoint(), accept, requestOptions, context))
                .map(
                        res ->
                                new PagedResponseBase<>(
                                        res.getRequest(),
                                        res.getStatusCode(),
                                        res.getHeaders(),
                                        getValues(res.getValue(), "value"),
                                        getNextLink(res.getValue(), "nextLink"),
                                        null));
    }

    /**
     * Get the next page of items.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     id: String (Required)
     *     title: String (Optional)
     *     workflowRunId: String (Required)
     *     workflowId: String (Required)
     *     requestor: String (Required)
     *     createdTime: OffsetDateTime (Required)
     *     lastUpdateTime: OffsetDateTime (Required)
     *     payload (Required): {
     *         type: String(CreateTerm/UpdateTerm/DeleteTerm/ImportTerms/UpdateAsset/GrantDataAccess) (Required)
     *         targetValue: String (Required)
     *         payload: Object (Optional)
     *     }
     *     reminderInfo (Optional): {
     *         lastRemindTime: OffsetDateTime (Optional)
     *         nextRemindTime: OffsetDateTime (Required)
     *         reminderSettings: Object (Required)
     *     }
     *     expiryInfo (Optional): {
     *         lastExpiryNotificationTime: OffsetDateTime (Optional)
     *         nextExpiryNotificationTime: OffsetDateTime (Required)
     *         expiryTime: OffsetDateTime (Required)
     *         expirySettings (Required): {
     *             expireAfter: Object (Required)
     *             notifyOnExpiration (Optional): [
     *                 String (Optional)
     *             ]
     *         }
     *     }
     * }
     * }</pre>
     *
     * @param nextLink The URL to get the next list of items
     *     <p>The nextLink parameter.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return the response body along with {@link PagedResponse}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private PagedResponse<BinaryData> listWorkflowTasksNextSinglePage(String nextLink, RequestOptions requestOptions) {
        final String accept = "application/json";
        Response<BinaryData> res =
                service.listWorkflowTasksNextSync(nextLink, this.getEndpoint(), accept, requestOptions, Context.NONE);
        return new PagedResponseBase<>(
                res.getRequest(),
                res.getStatusCode(),
                res.getHeaders(),
                getValues(res.getValue(), "value"),
                getNextLink(res.getValue(), "nextLink"),
                null);
    }

    private List<BinaryData> getValues(BinaryData binaryData, String path) {
        try {
            Map<?, ?> obj = binaryData.toObject(Map.class);
            List<?> values = (List<?>) obj.get(path);
            return values.stream().map(BinaryData::fromObject).collect(Collectors.toList());
        } catch (RuntimeException e) {
            return null;
        }
    }

    private String getNextLink(BinaryData binaryData, String path) {
        try {
            Map<?, ?> obj = binaryData.toObject(Map.class);
            return (String) obj.get(path);
        } catch (RuntimeException e) {
            return null;
        }
    }
}
