/* tslint:disable */
/* eslint-disable */
/**
 * authentik
 * Making authentication simple.
 *
 * The version of the OpenAPI document: 2026.5.0-rc1
 * Contact: hello@goauthentik.io
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */

import type {
    Cache,
    ChallengeTypes,
    DeniedActionEnum,
    Flow,
    FlowChallengeResponseRequest,
    FlowDesignationEnum,
    FlowDiagram,
    FlowInspection,
    FlowRequest,
    FlowStageBinding,
    FlowStageBindingRequest,
    InvalidResponseActionEnum,
    Link,
    PaginatedFlowList,
    PaginatedFlowStageBindingList,
    PatchedFlowRequest,
    PatchedFlowStageBindingRequest,
    PolicyEngineMode,
    UsedBy,
} from "../models/index";
import {
    CacheFromJSON,
    ChallengeTypesFromJSON,
    FlowChallengeResponseRequestToJSON,
    FlowDiagramFromJSON,
    FlowFromJSON,
    FlowInspectionFromJSON,
    FlowRequestToJSON,
    FlowStageBindingFromJSON,
    FlowStageBindingRequestToJSON,
    LinkFromJSON,
    PaginatedFlowListFromJSON,
    PaginatedFlowStageBindingListFromJSON,
    PatchedFlowRequestToJSON,
    PatchedFlowStageBindingRequestToJSON,
    UsedByFromJSON,
} from "../models/index";
import * as runtime from "../runtime";

export interface FlowsBindingsCreateRequest {
    flowStageBindingRequest: FlowStageBindingRequest;
}

export interface FlowsBindingsDestroyRequest {
    fsbUuid: string;
}

export interface FlowsBindingsListRequest {
    evaluateOnPlan?: boolean;
    fsbUuid?: string;
    invalidResponseAction?: InvalidResponseActionEnum;
    order?: number;
    ordering?: string;
    page?: number;
    pageSize?: number;
    pbmUuid?: string;
    policies?: Array<string>;
    policyEngineMode?: PolicyEngineMode;
    reEvaluatePolicies?: boolean;
    search?: string;
    stage?: string;
    target?: string;
}

export interface FlowsBindingsPartialUpdateRequest {
    fsbUuid: string;
    patchedFlowStageBindingRequest?: PatchedFlowStageBindingRequest;
}

export interface FlowsBindingsRetrieveRequest {
    fsbUuid: string;
}

export interface FlowsBindingsUpdateRequest {
    fsbUuid: string;
    flowStageBindingRequest: FlowStageBindingRequest;
}

export interface FlowsBindingsUsedByListRequest {
    fsbUuid: string;
}

export interface FlowsExecutorGetRequest {
    flowSlug: string;
    query: string;
}

export interface FlowsExecutorSolveRequest {
    flowSlug: string;
    query: string;
    flowChallengeResponseRequest?: FlowChallengeResponseRequest;
}

export interface FlowsInspectorGetRequest {
    flowSlug: string;
}

export interface FlowsInstancesCreateRequest {
    flowRequest: FlowRequest;
}

export interface FlowsInstancesDestroyRequest {
    slug: string;
}

export interface FlowsInstancesDiagramRetrieveRequest {
    slug: string;
}

export interface FlowsInstancesExecuteRetrieveRequest {
    slug: string;
}

export interface FlowsInstancesExportRetrieveRequest {
    slug: string;
}

export interface FlowsInstancesListRequest {
    deniedAction?: DeniedActionEnum;
    designation?: FlowDesignationEnum;
    flowUuid?: string;
    name?: string;
    ordering?: string;
    page?: number;
    pageSize?: number;
    search?: string;
    slug?: string;
}

export interface FlowsInstancesPartialUpdateRequest {
    slug: string;
    patchedFlowRequest?: PatchedFlowRequest;
}

export interface FlowsInstancesRetrieveRequest {
    slug: string;
}

export interface FlowsInstancesUpdateRequest {
    slug: string;
    flowRequest: FlowRequest;
}

export interface FlowsInstancesUsedByListRequest {
    slug: string;
}

/**
 *
 */
export class FlowsApi extends runtime.BaseAPI {
    /**
     * Creates request options for flowsBindingsCreate without sending the request
     */
    async flowsBindingsCreateRequestOpts(
        requestParameters: FlowsBindingsCreateRequest,
    ): Promise<runtime.RequestOpts> {
        if (requestParameters["flowStageBindingRequest"] == null) {
            throw new runtime.RequiredError(
                "flowStageBindingRequest",
                'Required parameter "flowStageBindingRequest" was null or undefined when calling flowsBindingsCreate().',
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        headerParameters["Content-Type"] = "application/json";

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("authentik", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/flows/bindings/`;

        return {
            path: urlPath,
            method: "POST",
            headers: headerParameters,
            query: queryParameters,
            body: FlowStageBindingRequestToJSON(requestParameters["flowStageBindingRequest"]),
        };
    }

    /**
     * FlowStageBinding Viewset
     */
    async flowsBindingsCreateRaw(
        requestParameters: FlowsBindingsCreateRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<FlowStageBinding>> {
        const requestOptions = await this.flowsBindingsCreateRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) =>
            FlowStageBindingFromJSON(jsonValue),
        );
    }

    /**
     * FlowStageBinding Viewset
     */
    async flowsBindingsCreate(
        requestParameters: FlowsBindingsCreateRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<FlowStageBinding> {
        const response = await this.flowsBindingsCreateRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Creates request options for flowsBindingsDestroy without sending the request
     */
    async flowsBindingsDestroyRequestOpts(
        requestParameters: FlowsBindingsDestroyRequest,
    ): Promise<runtime.RequestOpts> {
        if (requestParameters["fsbUuid"] == null) {
            throw new runtime.RequiredError(
                "fsbUuid",
                'Required parameter "fsbUuid" was null or undefined when calling flowsBindingsDestroy().',
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("authentik", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/flows/bindings/{fsb_uuid}/`;
        urlPath = urlPath.replace(
            `{${"fsb_uuid"}}`,
            encodeURIComponent(String(requestParameters["fsbUuid"])),
        );

        return {
            path: urlPath,
            method: "DELETE",
            headers: headerParameters,
            query: queryParameters,
        };
    }

    /**
     * FlowStageBinding Viewset
     */
    async flowsBindingsDestroyRaw(
        requestParameters: FlowsBindingsDestroyRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<void>> {
        const requestOptions = await this.flowsBindingsDestroyRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * FlowStageBinding Viewset
     */
    async flowsBindingsDestroy(
        requestParameters: FlowsBindingsDestroyRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<void> {
        await this.flowsBindingsDestroyRaw(requestParameters, initOverrides);
    }

    /**
     * Creates request options for flowsBindingsList without sending the request
     */
    async flowsBindingsListRequestOpts(
        requestParameters: FlowsBindingsListRequest,
    ): Promise<runtime.RequestOpts> {
        const queryParameters: any = {};

        if (requestParameters["evaluateOnPlan"] != null) {
            queryParameters["evaluate_on_plan"] = requestParameters["evaluateOnPlan"];
        }

        if (requestParameters["fsbUuid"] != null) {
            queryParameters["fsb_uuid"] = requestParameters["fsbUuid"];
        }

        if (requestParameters["invalidResponseAction"] != null) {
            queryParameters["invalid_response_action"] = requestParameters["invalidResponseAction"];
        }

        if (requestParameters["order"] != null) {
            queryParameters["order"] = requestParameters["order"];
        }

        if (requestParameters["ordering"] != null) {
            queryParameters["ordering"] = requestParameters["ordering"];
        }

        if (requestParameters["page"] != null) {
            queryParameters["page"] = requestParameters["page"];
        }

        if (requestParameters["pageSize"] != null) {
            queryParameters["page_size"] = requestParameters["pageSize"];
        }

        if (requestParameters["pbmUuid"] != null) {
            queryParameters["pbm_uuid"] = requestParameters["pbmUuid"];
        }

        if (requestParameters["policies"] != null) {
            queryParameters["policies"] = requestParameters["policies"];
        }

        if (requestParameters["policyEngineMode"] != null) {
            queryParameters["policy_engine_mode"] = requestParameters["policyEngineMode"];
        }

        if (requestParameters["reEvaluatePolicies"] != null) {
            queryParameters["re_evaluate_policies"] = requestParameters["reEvaluatePolicies"];
        }

        if (requestParameters["search"] != null) {
            queryParameters["search"] = requestParameters["search"];
        }

        if (requestParameters["stage"] != null) {
            queryParameters["stage"] = requestParameters["stage"];
        }

        if (requestParameters["target"] != null) {
            queryParameters["target"] = requestParameters["target"];
        }

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("authentik", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/flows/bindings/`;

        return {
            path: urlPath,
            method: "GET",
            headers: headerParameters,
            query: queryParameters,
        };
    }

    /**
     * FlowStageBinding Viewset
     */
    async flowsBindingsListRaw(
        requestParameters: FlowsBindingsListRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<PaginatedFlowStageBindingList>> {
        const requestOptions = await this.flowsBindingsListRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) =>
            PaginatedFlowStageBindingListFromJSON(jsonValue),
        );
    }

    /**
     * FlowStageBinding Viewset
     */
    async flowsBindingsList(
        requestParameters: FlowsBindingsListRequest = {},
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<PaginatedFlowStageBindingList> {
        const response = await this.flowsBindingsListRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Creates request options for flowsBindingsPartialUpdate without sending the request
     */
    async flowsBindingsPartialUpdateRequestOpts(
        requestParameters: FlowsBindingsPartialUpdateRequest,
    ): Promise<runtime.RequestOpts> {
        if (requestParameters["fsbUuid"] == null) {
            throw new runtime.RequiredError(
                "fsbUuid",
                'Required parameter "fsbUuid" was null or undefined when calling flowsBindingsPartialUpdate().',
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        headerParameters["Content-Type"] = "application/json";

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("authentik", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/flows/bindings/{fsb_uuid}/`;
        urlPath = urlPath.replace(
            `{${"fsb_uuid"}}`,
            encodeURIComponent(String(requestParameters["fsbUuid"])),
        );

        return {
            path: urlPath,
            method: "PATCH",
            headers: headerParameters,
            query: queryParameters,
            body: PatchedFlowStageBindingRequestToJSON(
                requestParameters["patchedFlowStageBindingRequest"],
            ),
        };
    }

    /**
     * FlowStageBinding Viewset
     */
    async flowsBindingsPartialUpdateRaw(
        requestParameters: FlowsBindingsPartialUpdateRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<FlowStageBinding>> {
        const requestOptions = await this.flowsBindingsPartialUpdateRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) =>
            FlowStageBindingFromJSON(jsonValue),
        );
    }

    /**
     * FlowStageBinding Viewset
     */
    async flowsBindingsPartialUpdate(
        requestParameters: FlowsBindingsPartialUpdateRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<FlowStageBinding> {
        const response = await this.flowsBindingsPartialUpdateRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Creates request options for flowsBindingsRetrieve without sending the request
     */
    async flowsBindingsRetrieveRequestOpts(
        requestParameters: FlowsBindingsRetrieveRequest,
    ): Promise<runtime.RequestOpts> {
        if (requestParameters["fsbUuid"] == null) {
            throw new runtime.RequiredError(
                "fsbUuid",
                'Required parameter "fsbUuid" was null or undefined when calling flowsBindingsRetrieve().',
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("authentik", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/flows/bindings/{fsb_uuid}/`;
        urlPath = urlPath.replace(
            `{${"fsb_uuid"}}`,
            encodeURIComponent(String(requestParameters["fsbUuid"])),
        );

        return {
            path: urlPath,
            method: "GET",
            headers: headerParameters,
            query: queryParameters,
        };
    }

    /**
     * FlowStageBinding Viewset
     */
    async flowsBindingsRetrieveRaw(
        requestParameters: FlowsBindingsRetrieveRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<FlowStageBinding>> {
        const requestOptions = await this.flowsBindingsRetrieveRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) =>
            FlowStageBindingFromJSON(jsonValue),
        );
    }

    /**
     * FlowStageBinding Viewset
     */
    async flowsBindingsRetrieve(
        requestParameters: FlowsBindingsRetrieveRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<FlowStageBinding> {
        const response = await this.flowsBindingsRetrieveRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Creates request options for flowsBindingsUpdate without sending the request
     */
    async flowsBindingsUpdateRequestOpts(
        requestParameters: FlowsBindingsUpdateRequest,
    ): Promise<runtime.RequestOpts> {
        if (requestParameters["fsbUuid"] == null) {
            throw new runtime.RequiredError(
                "fsbUuid",
                'Required parameter "fsbUuid" was null or undefined when calling flowsBindingsUpdate().',
            );
        }

        if (requestParameters["flowStageBindingRequest"] == null) {
            throw new runtime.RequiredError(
                "flowStageBindingRequest",
                'Required parameter "flowStageBindingRequest" was null or undefined when calling flowsBindingsUpdate().',
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        headerParameters["Content-Type"] = "application/json";

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("authentik", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/flows/bindings/{fsb_uuid}/`;
        urlPath = urlPath.replace(
            `{${"fsb_uuid"}}`,
            encodeURIComponent(String(requestParameters["fsbUuid"])),
        );

        return {
            path: urlPath,
            method: "PUT",
            headers: headerParameters,
            query: queryParameters,
            body: FlowStageBindingRequestToJSON(requestParameters["flowStageBindingRequest"]),
        };
    }

    /**
     * FlowStageBinding Viewset
     */
    async flowsBindingsUpdateRaw(
        requestParameters: FlowsBindingsUpdateRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<FlowStageBinding>> {
        const requestOptions = await this.flowsBindingsUpdateRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) =>
            FlowStageBindingFromJSON(jsonValue),
        );
    }

    /**
     * FlowStageBinding Viewset
     */
    async flowsBindingsUpdate(
        requestParameters: FlowsBindingsUpdateRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<FlowStageBinding> {
        const response = await this.flowsBindingsUpdateRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Creates request options for flowsBindingsUsedByList without sending the request
     */
    async flowsBindingsUsedByListRequestOpts(
        requestParameters: FlowsBindingsUsedByListRequest,
    ): Promise<runtime.RequestOpts> {
        if (requestParameters["fsbUuid"] == null) {
            throw new runtime.RequiredError(
                "fsbUuid",
                'Required parameter "fsbUuid" was null or undefined when calling flowsBindingsUsedByList().',
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("authentik", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/flows/bindings/{fsb_uuid}/used_by/`;
        urlPath = urlPath.replace(
            `{${"fsb_uuid"}}`,
            encodeURIComponent(String(requestParameters["fsbUuid"])),
        );

        return {
            path: urlPath,
            method: "GET",
            headers: headerParameters,
            query: queryParameters,
        };
    }

    /**
     * Get a list of all objects that use this object
     */
    async flowsBindingsUsedByListRaw(
        requestParameters: FlowsBindingsUsedByListRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<Array<UsedBy>>> {
        const requestOptions = await this.flowsBindingsUsedByListRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(UsedByFromJSON));
    }

    /**
     * Get a list of all objects that use this object
     */
    async flowsBindingsUsedByList(
        requestParameters: FlowsBindingsUsedByListRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<Array<UsedBy>> {
        const response = await this.flowsBindingsUsedByListRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Creates request options for flowsExecutorGet without sending the request
     */
    async flowsExecutorGetRequestOpts(
        requestParameters: FlowsExecutorGetRequest,
    ): Promise<runtime.RequestOpts> {
        if (requestParameters["flowSlug"] == null) {
            throw new runtime.RequiredError(
                "flowSlug",
                'Required parameter "flowSlug" was null or undefined when calling flowsExecutorGet().',
            );
        }

        if (requestParameters["query"] == null) {
            throw new runtime.RequiredError(
                "query",
                'Required parameter "query" was null or undefined when calling flowsExecutorGet().',
            );
        }

        const queryParameters: any = {};

        if (requestParameters["query"] != null) {
            queryParameters["query"] = requestParameters["query"];
        }

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("authentik", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/flows/executor/{flow_slug}/`;
        urlPath = urlPath.replace(
            `{${"flow_slug"}}`,
            encodeURIComponent(String(requestParameters["flowSlug"])),
        );

        return {
            path: urlPath,
            method: "GET",
            headers: headerParameters,
            query: queryParameters,
        };
    }

    /**
     * Get the next pending challenge from the currently active flow.
     */
    async flowsExecutorGetRaw(
        requestParameters: FlowsExecutorGetRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<ChallengeTypes>> {
        const requestOptions = await this.flowsExecutorGetRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) =>
            ChallengeTypesFromJSON(jsonValue),
        );
    }

    /**
     * Get the next pending challenge from the currently active flow.
     */
    async flowsExecutorGet(
        requestParameters: FlowsExecutorGetRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<ChallengeTypes> {
        const response = await this.flowsExecutorGetRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Creates request options for flowsExecutorSolve without sending the request
     */
    async flowsExecutorSolveRequestOpts(
        requestParameters: FlowsExecutorSolveRequest,
    ): Promise<runtime.RequestOpts> {
        if (requestParameters["flowSlug"] == null) {
            throw new runtime.RequiredError(
                "flowSlug",
                'Required parameter "flowSlug" was null or undefined when calling flowsExecutorSolve().',
            );
        }

        if (requestParameters["query"] == null) {
            throw new runtime.RequiredError(
                "query",
                'Required parameter "query" was null or undefined when calling flowsExecutorSolve().',
            );
        }

        const queryParameters: any = {};

        if (requestParameters["query"] != null) {
            queryParameters["query"] = requestParameters["query"];
        }

        const headerParameters: runtime.HTTPHeaders = {};

        headerParameters["Content-Type"] = "application/json";

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("authentik", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/flows/executor/{flow_slug}/`;
        urlPath = urlPath.replace(
            `{${"flow_slug"}}`,
            encodeURIComponent(String(requestParameters["flowSlug"])),
        );

        return {
            path: urlPath,
            method: "POST",
            headers: headerParameters,
            query: queryParameters,
            body: FlowChallengeResponseRequestToJSON(
                requestParameters["flowChallengeResponseRequest"],
            ),
        };
    }

    /**
     * Solve the previously retrieved challenge and advanced to the next stage.
     */
    async flowsExecutorSolveRaw(
        requestParameters: FlowsExecutorSolveRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<ChallengeTypes>> {
        const requestOptions = await this.flowsExecutorSolveRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) =>
            ChallengeTypesFromJSON(jsonValue),
        );
    }

    /**
     * Solve the previously retrieved challenge and advanced to the next stage.
     */
    async flowsExecutorSolve(
        requestParameters: FlowsExecutorSolveRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<ChallengeTypes> {
        const response = await this.flowsExecutorSolveRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Creates request options for flowsInspectorGet without sending the request
     */
    async flowsInspectorGetRequestOpts(
        requestParameters: FlowsInspectorGetRequest,
    ): Promise<runtime.RequestOpts> {
        if (requestParameters["flowSlug"] == null) {
            throw new runtime.RequiredError(
                "flowSlug",
                'Required parameter "flowSlug" was null or undefined when calling flowsInspectorGet().',
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("authentik", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/flows/inspector/{flow_slug}/`;
        urlPath = urlPath.replace(
            `{${"flow_slug"}}`,
            encodeURIComponent(String(requestParameters["flowSlug"])),
        );

        return {
            path: urlPath,
            method: "GET",
            headers: headerParameters,
            query: queryParameters,
        };
    }

    /**
     * Get current flow state and record it
     */
    async flowsInspectorGetRaw(
        requestParameters: FlowsInspectorGetRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<FlowInspection>> {
        const requestOptions = await this.flowsInspectorGetRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) =>
            FlowInspectionFromJSON(jsonValue),
        );
    }

    /**
     * Get current flow state and record it
     */
    async flowsInspectorGet(
        requestParameters: FlowsInspectorGetRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<FlowInspection> {
        const response = await this.flowsInspectorGetRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Creates request options for flowsInstancesCacheClearCreate without sending the request
     */
    async flowsInstancesCacheClearCreateRequestOpts(): Promise<runtime.RequestOpts> {
        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("authentik", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/flows/instances/cache_clear/`;

        return {
            path: urlPath,
            method: "POST",
            headers: headerParameters,
            query: queryParameters,
        };
    }

    /**
     * Clear flow cache
     */
    async flowsInstancesCacheClearCreateRaw(
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<void>> {
        const requestOptions = await this.flowsInstancesCacheClearCreateRequestOpts();
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Clear flow cache
     */
    async flowsInstancesCacheClearCreate(
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<void> {
        await this.flowsInstancesCacheClearCreateRaw(initOverrides);
    }

    /**
     * Creates request options for flowsInstancesCacheInfoRetrieve without sending the request
     */
    async flowsInstancesCacheInfoRetrieveRequestOpts(): Promise<runtime.RequestOpts> {
        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("authentik", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/flows/instances/cache_info/`;

        return {
            path: urlPath,
            method: "GET",
            headers: headerParameters,
            query: queryParameters,
        };
    }

    /**
     * Info about cached flows
     */
    async flowsInstancesCacheInfoRetrieveRaw(
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<Cache>> {
        const requestOptions = await this.flowsInstancesCacheInfoRetrieveRequestOpts();
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) => CacheFromJSON(jsonValue));
    }

    /**
     * Info about cached flows
     */
    async flowsInstancesCacheInfoRetrieve(
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<Cache> {
        const response = await this.flowsInstancesCacheInfoRetrieveRaw(initOverrides);
        return await response.value();
    }

    /**
     * Creates request options for flowsInstancesCreate without sending the request
     */
    async flowsInstancesCreateRequestOpts(
        requestParameters: FlowsInstancesCreateRequest,
    ): Promise<runtime.RequestOpts> {
        if (requestParameters["flowRequest"] == null) {
            throw new runtime.RequiredError(
                "flowRequest",
                'Required parameter "flowRequest" was null or undefined when calling flowsInstancesCreate().',
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        headerParameters["Content-Type"] = "application/json";

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("authentik", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/flows/instances/`;

        return {
            path: urlPath,
            method: "POST",
            headers: headerParameters,
            query: queryParameters,
            body: FlowRequestToJSON(requestParameters["flowRequest"]),
        };
    }

    /**
     * Flow Viewset
     */
    async flowsInstancesCreateRaw(
        requestParameters: FlowsInstancesCreateRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<Flow>> {
        const requestOptions = await this.flowsInstancesCreateRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) => FlowFromJSON(jsonValue));
    }

    /**
     * Flow Viewset
     */
    async flowsInstancesCreate(
        requestParameters: FlowsInstancesCreateRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<Flow> {
        const response = await this.flowsInstancesCreateRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Creates request options for flowsInstancesDestroy without sending the request
     */
    async flowsInstancesDestroyRequestOpts(
        requestParameters: FlowsInstancesDestroyRequest,
    ): Promise<runtime.RequestOpts> {
        if (requestParameters["slug"] == null) {
            throw new runtime.RequiredError(
                "slug",
                'Required parameter "slug" was null or undefined when calling flowsInstancesDestroy().',
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("authentik", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/flows/instances/{slug}/`;
        urlPath = urlPath.replace(
            `{${"slug"}}`,
            encodeURIComponent(String(requestParameters["slug"])),
        );

        return {
            path: urlPath,
            method: "DELETE",
            headers: headerParameters,
            query: queryParameters,
        };
    }

    /**
     * Flow Viewset
     */
    async flowsInstancesDestroyRaw(
        requestParameters: FlowsInstancesDestroyRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<void>> {
        const requestOptions = await this.flowsInstancesDestroyRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Flow Viewset
     */
    async flowsInstancesDestroy(
        requestParameters: FlowsInstancesDestroyRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<void> {
        await this.flowsInstancesDestroyRaw(requestParameters, initOverrides);
    }

    /**
     * Creates request options for flowsInstancesDiagramRetrieve without sending the request
     */
    async flowsInstancesDiagramRetrieveRequestOpts(
        requestParameters: FlowsInstancesDiagramRetrieveRequest,
    ): Promise<runtime.RequestOpts> {
        if (requestParameters["slug"] == null) {
            throw new runtime.RequiredError(
                "slug",
                'Required parameter "slug" was null or undefined when calling flowsInstancesDiagramRetrieve().',
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("authentik", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/flows/instances/{slug}/diagram/`;
        urlPath = urlPath.replace(
            `{${"slug"}}`,
            encodeURIComponent(String(requestParameters["slug"])),
        );

        return {
            path: urlPath,
            method: "GET",
            headers: headerParameters,
            query: queryParameters,
        };
    }

    /**
     * Return diagram for flow with slug `slug`, in the format used by flowchart.js
     */
    async flowsInstancesDiagramRetrieveRaw(
        requestParameters: FlowsInstancesDiagramRetrieveRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<FlowDiagram>> {
        const requestOptions =
            await this.flowsInstancesDiagramRetrieveRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) => FlowDiagramFromJSON(jsonValue));
    }

    /**
     * Return diagram for flow with slug `slug`, in the format used by flowchart.js
     */
    async flowsInstancesDiagramRetrieve(
        requestParameters: FlowsInstancesDiagramRetrieveRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<FlowDiagram> {
        const response = await this.flowsInstancesDiagramRetrieveRaw(
            requestParameters,
            initOverrides,
        );
        return await response.value();
    }

    /**
     * Creates request options for flowsInstancesExecuteRetrieve without sending the request
     */
    async flowsInstancesExecuteRetrieveRequestOpts(
        requestParameters: FlowsInstancesExecuteRetrieveRequest,
    ): Promise<runtime.RequestOpts> {
        if (requestParameters["slug"] == null) {
            throw new runtime.RequiredError(
                "slug",
                'Required parameter "slug" was null or undefined when calling flowsInstancesExecuteRetrieve().',
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("authentik", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/flows/instances/{slug}/execute/`;
        urlPath = urlPath.replace(
            `{${"slug"}}`,
            encodeURIComponent(String(requestParameters["slug"])),
        );

        return {
            path: urlPath,
            method: "GET",
            headers: headerParameters,
            query: queryParameters,
        };
    }

    /**
     * Execute flow for current user
     */
    async flowsInstancesExecuteRetrieveRaw(
        requestParameters: FlowsInstancesExecuteRetrieveRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<Link>> {
        const requestOptions =
            await this.flowsInstancesExecuteRetrieveRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) => LinkFromJSON(jsonValue));
    }

    /**
     * Execute flow for current user
     */
    async flowsInstancesExecuteRetrieve(
        requestParameters: FlowsInstancesExecuteRetrieveRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<Link> {
        const response = await this.flowsInstancesExecuteRetrieveRaw(
            requestParameters,
            initOverrides,
        );
        return await response.value();
    }

    /**
     * Creates request options for flowsInstancesExportRetrieve without sending the request
     */
    async flowsInstancesExportRetrieveRequestOpts(
        requestParameters: FlowsInstancesExportRetrieveRequest,
    ): Promise<runtime.RequestOpts> {
        if (requestParameters["slug"] == null) {
            throw new runtime.RequiredError(
                "slug",
                'Required parameter "slug" was null or undefined when calling flowsInstancesExportRetrieve().',
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("authentik", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/flows/instances/{slug}/export/`;
        urlPath = urlPath.replace(
            `{${"slug"}}`,
            encodeURIComponent(String(requestParameters["slug"])),
        );

        return {
            path: urlPath,
            method: "GET",
            headers: headerParameters,
            query: queryParameters,
        };
    }

    /**
     * Export flow to .yaml file
     */
    async flowsInstancesExportRetrieveRaw(
        requestParameters: FlowsInstancesExportRetrieveRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<Blob>> {
        const requestOptions =
            await this.flowsInstancesExportRetrieveRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.BlobApiResponse(response);
    }

    /**
     * Export flow to .yaml file
     */
    async flowsInstancesExportRetrieve(
        requestParameters: FlowsInstancesExportRetrieveRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<Blob> {
        const response = await this.flowsInstancesExportRetrieveRaw(
            requestParameters,
            initOverrides,
        );
        return await response.value();
    }

    /**
     * Creates request options for flowsInstancesList without sending the request
     */
    async flowsInstancesListRequestOpts(
        requestParameters: FlowsInstancesListRequest,
    ): Promise<runtime.RequestOpts> {
        const queryParameters: any = {};

        if (requestParameters["deniedAction"] != null) {
            queryParameters["denied_action"] = requestParameters["deniedAction"];
        }

        if (requestParameters["designation"] != null) {
            queryParameters["designation"] = requestParameters["designation"];
        }

        if (requestParameters["flowUuid"] != null) {
            queryParameters["flow_uuid"] = requestParameters["flowUuid"];
        }

        if (requestParameters["name"] != null) {
            queryParameters["name"] = requestParameters["name"];
        }

        if (requestParameters["ordering"] != null) {
            queryParameters["ordering"] = requestParameters["ordering"];
        }

        if (requestParameters["page"] != null) {
            queryParameters["page"] = requestParameters["page"];
        }

        if (requestParameters["pageSize"] != null) {
            queryParameters["page_size"] = requestParameters["pageSize"];
        }

        if (requestParameters["search"] != null) {
            queryParameters["search"] = requestParameters["search"];
        }

        if (requestParameters["slug"] != null) {
            queryParameters["slug"] = requestParameters["slug"];
        }

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("authentik", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/flows/instances/`;

        return {
            path: urlPath,
            method: "GET",
            headers: headerParameters,
            query: queryParameters,
        };
    }

    /**
     * Flow Viewset
     */
    async flowsInstancesListRaw(
        requestParameters: FlowsInstancesListRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<PaginatedFlowList>> {
        const requestOptions = await this.flowsInstancesListRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) =>
            PaginatedFlowListFromJSON(jsonValue),
        );
    }

    /**
     * Flow Viewset
     */
    async flowsInstancesList(
        requestParameters: FlowsInstancesListRequest = {},
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<PaginatedFlowList> {
        const response = await this.flowsInstancesListRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Creates request options for flowsInstancesPartialUpdate without sending the request
     */
    async flowsInstancesPartialUpdateRequestOpts(
        requestParameters: FlowsInstancesPartialUpdateRequest,
    ): Promise<runtime.RequestOpts> {
        if (requestParameters["slug"] == null) {
            throw new runtime.RequiredError(
                "slug",
                'Required parameter "slug" was null or undefined when calling flowsInstancesPartialUpdate().',
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        headerParameters["Content-Type"] = "application/json";

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("authentik", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/flows/instances/{slug}/`;
        urlPath = urlPath.replace(
            `{${"slug"}}`,
            encodeURIComponent(String(requestParameters["slug"])),
        );

        return {
            path: urlPath,
            method: "PATCH",
            headers: headerParameters,
            query: queryParameters,
            body: PatchedFlowRequestToJSON(requestParameters["patchedFlowRequest"]),
        };
    }

    /**
     * Flow Viewset
     */
    async flowsInstancesPartialUpdateRaw(
        requestParameters: FlowsInstancesPartialUpdateRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<Flow>> {
        const requestOptions = await this.flowsInstancesPartialUpdateRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) => FlowFromJSON(jsonValue));
    }

    /**
     * Flow Viewset
     */
    async flowsInstancesPartialUpdate(
        requestParameters: FlowsInstancesPartialUpdateRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<Flow> {
        const response = await this.flowsInstancesPartialUpdateRaw(
            requestParameters,
            initOverrides,
        );
        return await response.value();
    }

    /**
     * Creates request options for flowsInstancesRetrieve without sending the request
     */
    async flowsInstancesRetrieveRequestOpts(
        requestParameters: FlowsInstancesRetrieveRequest,
    ): Promise<runtime.RequestOpts> {
        if (requestParameters["slug"] == null) {
            throw new runtime.RequiredError(
                "slug",
                'Required parameter "slug" was null or undefined when calling flowsInstancesRetrieve().',
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("authentik", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/flows/instances/{slug}/`;
        urlPath = urlPath.replace(
            `{${"slug"}}`,
            encodeURIComponent(String(requestParameters["slug"])),
        );

        return {
            path: urlPath,
            method: "GET",
            headers: headerParameters,
            query: queryParameters,
        };
    }

    /**
     * Flow Viewset
     */
    async flowsInstancesRetrieveRaw(
        requestParameters: FlowsInstancesRetrieveRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<Flow>> {
        const requestOptions = await this.flowsInstancesRetrieveRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) => FlowFromJSON(jsonValue));
    }

    /**
     * Flow Viewset
     */
    async flowsInstancesRetrieve(
        requestParameters: FlowsInstancesRetrieveRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<Flow> {
        const response = await this.flowsInstancesRetrieveRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Creates request options for flowsInstancesUpdate without sending the request
     */
    async flowsInstancesUpdateRequestOpts(
        requestParameters: FlowsInstancesUpdateRequest,
    ): Promise<runtime.RequestOpts> {
        if (requestParameters["slug"] == null) {
            throw new runtime.RequiredError(
                "slug",
                'Required parameter "slug" was null or undefined when calling flowsInstancesUpdate().',
            );
        }

        if (requestParameters["flowRequest"] == null) {
            throw new runtime.RequiredError(
                "flowRequest",
                'Required parameter "flowRequest" was null or undefined when calling flowsInstancesUpdate().',
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        headerParameters["Content-Type"] = "application/json";

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("authentik", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/flows/instances/{slug}/`;
        urlPath = urlPath.replace(
            `{${"slug"}}`,
            encodeURIComponent(String(requestParameters["slug"])),
        );

        return {
            path: urlPath,
            method: "PUT",
            headers: headerParameters,
            query: queryParameters,
            body: FlowRequestToJSON(requestParameters["flowRequest"]),
        };
    }

    /**
     * Flow Viewset
     */
    async flowsInstancesUpdateRaw(
        requestParameters: FlowsInstancesUpdateRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<Flow>> {
        const requestOptions = await this.flowsInstancesUpdateRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) => FlowFromJSON(jsonValue));
    }

    /**
     * Flow Viewset
     */
    async flowsInstancesUpdate(
        requestParameters: FlowsInstancesUpdateRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<Flow> {
        const response = await this.flowsInstancesUpdateRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Creates request options for flowsInstancesUsedByList without sending the request
     */
    async flowsInstancesUsedByListRequestOpts(
        requestParameters: FlowsInstancesUsedByListRequest,
    ): Promise<runtime.RequestOpts> {
        if (requestParameters["slug"] == null) {
            throw new runtime.RequiredError(
                "slug",
                'Required parameter "slug" was null or undefined when calling flowsInstancesUsedByList().',
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("authentik", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/flows/instances/{slug}/used_by/`;
        urlPath = urlPath.replace(
            `{${"slug"}}`,
            encodeURIComponent(String(requestParameters["slug"])),
        );

        return {
            path: urlPath,
            method: "GET",
            headers: headerParameters,
            query: queryParameters,
        };
    }

    /**
     * Get a list of all objects that use this object
     */
    async flowsInstancesUsedByListRaw(
        requestParameters: FlowsInstancesUsedByListRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<Array<UsedBy>>> {
        const requestOptions = await this.flowsInstancesUsedByListRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(UsedByFromJSON));
    }

    /**
     * Get a list of all objects that use this object
     */
    async flowsInstancesUsedByList(
        requestParameters: FlowsInstancesUsedByListRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<Array<UsedBy>> {
        const response = await this.flowsInstancesUsedByListRaw(requestParameters, initOverrides);
        return await response.value();
    }
}
