/* generated using openapi-typescript-codegen -- do not edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import type { DevWorkflowExecutionIn } from '../models/DevWorkflowExecutionIn';
import type { WorkflowExecutionIn } from '../models/WorkflowExecutionIn';
import type { WorkflowExecutionOut } from '../models/WorkflowExecutionOut';
import type { WorkflowExecutionStatus } from '../models/WorkflowExecutionStatus';
import type { CancelablePromise } from '../core/CancelablePromise';
import { OpenAPI } from '../core/OpenAPI';
import { request as __request } from '../core/request';
export class WorkflowExecutionService {
    /**
     * Start a new workflow execution
     * Start a new workflow execution. Workflow versions wit status `DEPRECATED` or `DENIED` can't be started.
     *
     * Permission `workflow_execution:start` required if workflow versions status is `PUBLISHED`,
     * otherwise `workflow_execution:start_unpublished` required.
     * @param requestBody
     * @returns WorkflowExecutionOut Successful Response
     * @throws ApiError
     */
    public static workflowExecutionStartWorkflow(
        requestBody: WorkflowExecutionIn,
    ): CancelablePromise<WorkflowExecutionOut> {
        return __request(OpenAPI, {
            method: 'POST',
            url: '/workflow_executions',
            body: requestBody,
            mediaType: 'application/json',
            errors: {
                400: `Error decoding JWT Token`,
                401: `Not authenticated`,
                403: `Not authorized`,
                404: `Entity not Found`,
                422: `Validation Error`,
            },
        });
    }
    /**
     * Get all workflow executions
     * Get all workflow executions.
     *
     * Permission `workflow_execution:list` required, if 'user_id' is the same as the current user,
     * otherwise `workflow_execution:list_all` required.
     * @param executorId Filter for workflow executions by a user. If none, Permission `workflow_execution:read_any` required.
     * @param executionStatus Filter for status of workflow execution
     * @param workflowVersionId Filter for workflow version
     * @returns WorkflowExecutionOut Successful Response
     * @throws ApiError
     */
    public static workflowExecutionListWorkflowExecutions(
        executorId?: string,
        executionStatus?: Array<WorkflowExecutionStatus>,
        workflowVersionId?: string,
    ): CancelablePromise<Array<WorkflowExecutionOut>> {
        return __request(OpenAPI, {
            method: 'GET',
            url: '/workflow_executions',
            query: {
                'executor_id': executorId,
                'execution_status': executionStatus,
                'workflow_version_id': workflowVersionId,
            },
            errors: {
                400: `Error decoding JWT Token`,
                401: `Not authenticated`,
                403: `Not authorized`,
                404: `Entity not Found`,
                422: `Validation Error`,
            },
        });
    }
    /**
     * Start a workflow execution with arbitrary git repository
     * Start a new workflow execution from an arbitrary git repository.
     *
     * Permission `workflow:create` required.
     *
     * For private Gitlab repositories, a Project Access Token with the role Reporter and scope `read_api` is needed.
     *
     * For private GitHub repositories, a Personal Access Token (classic) with scope `repo` is needed.
     * @param requestBody
     * @returns WorkflowExecutionOut Successful Response
     * @throws ApiError
     */
    public static workflowExecutionStartArbitraryWorkflow(
        requestBody: DevWorkflowExecutionIn,
    ): CancelablePromise<WorkflowExecutionOut> {
        return __request(OpenAPI, {
            method: 'POST',
            url: '/workflow_executions/arbitrary',
            body: requestBody,
            mediaType: 'application/json',
            errors: {
                400: `Error decoding JWT Token`,
                401: `Not authenticated`,
                403: `Not authorized`,
                404: `Entity not Found`,
                422: `Validation Error`,
            },
        });
    }
    /**
     * Get a workflow execution
     * Get a specific workflow execution.
     *
     * Permission `workflow_execution:read` required if the current user started the workflow execution,
     * otherwise `workflow_execution:read_any` required.
     * @param eid ID of a workflow execution.
     * @returns WorkflowExecutionOut Successful Response
     * @throws ApiError
     */
    public static workflowExecutionGetWorkflowExecution(
        eid: string,
    ): CancelablePromise<WorkflowExecutionOut> {
        return __request(OpenAPI, {
            method: 'GET',
            url: '/workflow_executions/{eid}',
            path: {
                'eid': eid,
            },
            errors: {
                400: `Error decoding JWT Token`,
                401: `Not authenticated`,
                403: `Not authorized`,
                404: `Entity not Found`,
                422: `Validation Error`,
            },
        });
    }
    /**
     * Delete a workflow execution
     * Delete a specific workflow execution.
     *
     * Permission `workflow_execution:delete` required if the current user started the workflow execution,
     * otherwise `workflow_execution:delete_any` required.
     * @param eid ID of a workflow execution.
     * @returns void
     * @throws ApiError
     */
    public static workflowExecutionDeleteWorkflowExecution(
        eid: string,
    ): CancelablePromise<void> {
        return __request(OpenAPI, {
            method: 'DELETE',
            url: '/workflow_executions/{eid}',
            path: {
                'eid': eid,
            },
            errors: {
                400: `Error decoding JWT Token`,
                401: `Not authenticated`,
                403: `Not authorized`,
                404: `Entity not Found`,
                422: `Validation Error`,
            },
        });
    }
    /**
     * Get the parameters of a workflow execution
     * Get the parameters of a specific workflow execution.
     *
     * Permission `workflow_execution:read` required if the current user started the workflow execution,
     * otherwise `workflow_execution:read_any` required.
     * @param eid ID of a workflow execution.
     * @returns any Successful Response
     * @throws ApiError
     */
    public static workflowExecutionGetWorkflowExecutionParams(
        eid: string,
    ): CancelablePromise<Record<string, any>> {
        return __request(OpenAPI, {
            method: 'GET',
            url: '/workflow_executions/{eid}/params',
            path: {
                'eid': eid,
            },
            errors: {
                400: `Error decoding JWT Token`,
                401: `Not authenticated`,
                403: `Not authorized`,
                404: `Entity not Found`,
                422: `Validation Error`,
            },
        });
    }
    /**
     * Cancel a workflow execution
     * Cancel a running workflow execution.
     *
     * Permission `workflow_execution:cancel` required if the current user started the workflow execution,
     * otherwise `workflow_execution:cancel_any` required.
     * @param eid ID of a workflow execution.
     * @returns void
     * @throws ApiError
     */
    public static workflowExecutionCancelWorkflowExecution(
        eid: string,
    ): CancelablePromise<void> {
        return __request(OpenAPI, {
            method: 'POST',
            url: '/workflow_executions/{eid}/cancel',
            path: {
                'eid': eid,
            },
            errors: {
                400: `Error decoding JWT Token`,
                401: `Not authenticated`,
                403: `Not authorized`,
                404: `Entity not Found`,
                422: `Validation Error`,
            },
        });
    }
}