/* tslint:disable */
/* eslint-disable */
/**
 * Fabro Run API
 * HTTP API for managing Fabro workflow run executions.
 *
 * The version of the OpenAPI document: 0.2.0
 *
 *
 * 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 { Configuration } from '../configuration';
import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios';
import globalAxios from 'axios';
// Some imports not used depending on template conditions
// @ts-ignore
import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction, replaceWithSerializableTypeIfNeeded } from '../common';
// @ts-ignore
import { BASE_PATH, COLLECTION_FORMATS, type RequestArgs, BaseAPI, RequiredError, operationServerMap } from '../base';
// @ts-ignore
import type { CreateRunSessionRequest } from '../models';
// @ts-ignore
import type { ErrorResponse } from '../models';
// @ts-ignore
import type { EventEnvelope } from '../models';
// @ts-ignore
import type { PaginatedEventList } from '../models';
// @ts-ignore
import type { PaginatedSessionList } from '../models';
// @ts-ignore
import type { SessionDetail } from '../models';
// @ts-ignore
import type { SessionRecord } from '../models';
// @ts-ignore
import type { SubmitTurnRequest } from '../models';
/**
 * SessionsApi - axios parameter creator
 */
export const SessionsApiAxiosParamCreator = function (configuration?: Configuration) {
    return {
        /**
         * Replays and streams this session\'s durable `run.session.*` events from the owning run event log. The stream remains open until the client disconnects or the server shuts down.
         * @summary Attach to session events
         * @param {string} id
         * @param {number} [sinceSeq]
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        attachSessionEvents: async (id: string, sinceSeq?: number, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'id' is not null or undefined
            assertParamExists('attachSessionEvents', 'id', id)
            const localVarPath = `/api/v1/sessions/{id}/attach`
                .replace(`{${"id"}}`, encodeURIComponent(String(id)));
            // use dummy base URL string because the URL constructor only accepts absolute URLs.
            const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
            let baseOptions;
            if (configuration) {
                baseOptions = configuration.baseOptions;
            }

            const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
            const localVarHeaderParameter = {} as any;
            const localVarQueryParameter = {} as any;

            // authentication SessionCookie required

            // authentication BearerAuth required
            // http bearer authentication required
            await setBearerAuthToObject(localVarHeaderParameter, configuration)

            if (sinceSeq !== undefined) {
                localVarQueryParameter['since_seq'] = sinceSeq;
            }

            localVarHeaderParameter['Accept'] = 'text/event-stream,application/json';

            setSearchParams(localVarUrlObj, localVarQueryParameter);
            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * Creates a read-only Ask Fabro session bound to the run.
         * @summary Create run session
         * @param {string} id Unique run identifier (ULID).
         * @param {CreateRunSessionRequest} createRunSessionRequest
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        createRunSession: async (id: string, createRunSessionRequest: CreateRunSessionRequest, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'id' is not null or undefined
            assertParamExists('createRunSession', 'id', id)
            // verify required parameter 'createRunSessionRequest' is not null or undefined
            assertParamExists('createRunSession', 'createRunSessionRequest', createRunSessionRequest)
            const localVarPath = `/api/v1/runs/{id}/sessions`
                .replace(`{${"id"}}`, encodeURIComponent(String(id)));
            // use dummy base URL string because the URL constructor only accepts absolute URLs.
            const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
            let baseOptions;
            if (configuration) {
                baseOptions = configuration.baseOptions;
            }

            const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options};
            const localVarHeaderParameter = {} as any;
            const localVarQueryParameter = {} as any;

            // authentication SessionCookie required

            // authentication BearerAuth required
            // http bearer authentication required
            await setBearerAuthToObject(localVarHeaderParameter, configuration)

            localVarHeaderParameter['Content-Type'] = 'application/json';
            localVarHeaderParameter['Accept'] = 'application/json';

            setSearchParams(localVarUrlObj, localVarQueryParameter);
            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
            localVarRequestOptions.data = serializeDataIfNeeded(createRunSessionRequest, localVarRequestOptions, configuration)

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         *
         * @summary Get session
         * @param {string} id
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        getSession: async (id: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'id' is not null or undefined
            assertParamExists('getSession', 'id', id)
            const localVarPath = `/api/v1/sessions/{id}`
                .replace(`{${"id"}}`, encodeURIComponent(String(id)));
            // use dummy base URL string because the URL constructor only accepts absolute URLs.
            const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
            let baseOptions;
            if (configuration) {
                baseOptions = configuration.baseOptions;
            }

            const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
            const localVarHeaderParameter = {} as any;
            const localVarQueryParameter = {} as any;

            // authentication SessionCookie required

            // authentication BearerAuth required
            // http bearer authentication required
            await setBearerAuthToObject(localVarHeaderParameter, configuration)

            localVarHeaderParameter['Accept'] = 'application/json';

            setSearchParams(localVarUrlObj, localVarQueryParameter);
            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         *
         * @summary Interrupt a session turn
         * @param {string} id
         * @param {string} turnId
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        interruptSessionTurn: async (id: string, turnId: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'id' is not null or undefined
            assertParamExists('interruptSessionTurn', 'id', id)
            // verify required parameter 'turnId' is not null or undefined
            assertParamExists('interruptSessionTurn', 'turnId', turnId)
            const localVarPath = `/api/v1/sessions/{id}/turns/{turnId}/interrupt`
                .replace(`{${"id"}}`, encodeURIComponent(String(id)))
                .replace(`{${"turnId"}}`, encodeURIComponent(String(turnId)));
            // use dummy base URL string because the URL constructor only accepts absolute URLs.
            const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
            let baseOptions;
            if (configuration) {
                baseOptions = configuration.baseOptions;
            }

            const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options};
            const localVarHeaderParameter = {} as any;
            const localVarQueryParameter = {} as any;

            // authentication SessionCookie required

            // authentication BearerAuth required
            // http bearer authentication required
            await setBearerAuthToObject(localVarHeaderParameter, configuration)

            localVarHeaderParameter['Accept'] = 'application/json';

            setSearchParams(localVarUrlObj, localVarQueryParameter);
            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         *
         * @summary List run sessions
         * @param {string} id Unique run identifier (ULID).
         * @param {number} [pageLimit]
         * @param {number} [pageOffset]
         * @param {ListRunSessionsOrderEnum} [order]
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listRunSessions: async (id: string, pageLimit?: number, pageOffset?: number, order?: ListRunSessionsOrderEnum, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'id' is not null or undefined
            assertParamExists('listRunSessions', 'id', id)
            const localVarPath = `/api/v1/runs/{id}/sessions`
                .replace(`{${"id"}}`, encodeURIComponent(String(id)));
            // use dummy base URL string because the URL constructor only accepts absolute URLs.
            const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
            let baseOptions;
            if (configuration) {
                baseOptions = configuration.baseOptions;
            }

            const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
            const localVarHeaderParameter = {} as any;
            const localVarQueryParameter = {} as any;

            // authentication SessionCookie required

            // authentication BearerAuth required
            // http bearer authentication required
            await setBearerAuthToObject(localVarHeaderParameter, configuration)

            if (pageLimit !== undefined) {
                localVarQueryParameter['page[limit]'] = pageLimit;
            }

            if (pageOffset !== undefined) {
                localVarQueryParameter['page[offset]'] = pageOffset;
            }

            if (order !== undefined) {
                localVarQueryParameter['order'] = order;
            }

            localVarHeaderParameter['Accept'] = 'application/json';

            setSearchParams(localVarUrlObj, localVarQueryParameter);
            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * Returns run event envelopes filtered to this session\'s durable `run.session.*` events. `since_seq` uses the owning run event sequence.
         * @summary List session events
         * @param {string} id
         * @param {number} [sinceSeq]
         * @param {number} [limit]
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listSessionEvents: async (id: string, sinceSeq?: number, limit?: number, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'id' is not null or undefined
            assertParamExists('listSessionEvents', 'id', id)
            const localVarPath = `/api/v1/sessions/{id}/events`
                .replace(`{${"id"}}`, encodeURIComponent(String(id)));
            // use dummy base URL string because the URL constructor only accepts absolute URLs.
            const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
            let baseOptions;
            if (configuration) {
                baseOptions = configuration.baseOptions;
            }

            const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
            const localVarHeaderParameter = {} as any;
            const localVarQueryParameter = {} as any;

            // authentication SessionCookie required

            // authentication BearerAuth required
            // http bearer authentication required
            await setBearerAuthToObject(localVarHeaderParameter, configuration)

            if (sinceSeq !== undefined) {
                localVarQueryParameter['since_seq'] = sinceSeq;
            }

            if (limit !== undefined) {
                localVarQueryParameter['limit'] = limit;
            }

            localVarHeaderParameter['Accept'] = 'application/json';

            setSearchParams(localVarUrlObj, localVarQueryParameter);
            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * Starts a streamed turn immediately. Background turns are not supported in this API version.
         * @summary Submit a session turn
         * @param {string} id
         * @param {SubmitTurnRequest} submitTurnRequest
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        submitSessionTurn: async (id: string, submitTurnRequest: SubmitTurnRequest, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'id' is not null or undefined
            assertParamExists('submitSessionTurn', 'id', id)
            // verify required parameter 'submitTurnRequest' is not null or undefined
            assertParamExists('submitSessionTurn', 'submitTurnRequest', submitTurnRequest)
            const localVarPath = `/api/v1/sessions/{id}/turns`
                .replace(`{${"id"}}`, encodeURIComponent(String(id)));
            // use dummy base URL string because the URL constructor only accepts absolute URLs.
            const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
            let baseOptions;
            if (configuration) {
                baseOptions = configuration.baseOptions;
            }

            const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options};
            const localVarHeaderParameter = {} as any;
            const localVarQueryParameter = {} as any;

            // authentication SessionCookie required

            // authentication BearerAuth required
            // http bearer authentication required
            await setBearerAuthToObject(localVarHeaderParameter, configuration)

            localVarHeaderParameter['Content-Type'] = 'application/json';
            localVarHeaderParameter['Accept'] = 'text/event-stream,application/json';

            setSearchParams(localVarUrlObj, localVarQueryParameter);
            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
            localVarRequestOptions.data = serializeDataIfNeeded(submitTurnRequest, localVarRequestOptions, configuration)

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
    }
};

/**
 * SessionsApi - functional programming interface
 */
export const SessionsApiFp = function(configuration?: Configuration) {
    const localVarAxiosParamCreator = SessionsApiAxiosParamCreator(configuration)
    return {
        /**
         * Replays and streams this session\'s durable `run.session.*` events from the owning run event log. The stream remains open until the client disconnects or the server shuts down.
         * @summary Attach to session events
         * @param {string} id
         * @param {number} [sinceSeq]
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async attachSessionEvents(id: string, sinceSeq?: number, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<string>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.attachSessionEvents(id, sinceSeq, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['SessionsApi.attachSessionEvents']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * Creates a read-only Ask Fabro session bound to the run.
         * @summary Create run session
         * @param {string} id Unique run identifier (ULID).
         * @param {CreateRunSessionRequest} createRunSessionRequest
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async createRunSession(id: string, createRunSessionRequest: CreateRunSessionRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<SessionRecord>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.createRunSession(id, createRunSessionRequest, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['SessionsApi.createRunSession']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         *
         * @summary Get session
         * @param {string} id
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async getSession(id: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<SessionDetail>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.getSession(id, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['SessionsApi.getSession']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         *
         * @summary Interrupt a session turn
         * @param {string} id
         * @param {string} turnId
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async interruptSessionTurn(id: string, turnId: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<EventEnvelope>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.interruptSessionTurn(id, turnId, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['SessionsApi.interruptSessionTurn']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         *
         * @summary List run sessions
         * @param {string} id Unique run identifier (ULID).
         * @param {number} [pageLimit]
         * @param {number} [pageOffset]
         * @param {ListRunSessionsOrderEnum} [order]
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async listRunSessions(id: string, pageLimit?: number, pageOffset?: number, order?: ListRunSessionsOrderEnum, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<PaginatedSessionList>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.listRunSessions(id, pageLimit, pageOffset, order, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['SessionsApi.listRunSessions']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * Returns run event envelopes filtered to this session\'s durable `run.session.*` events. `since_seq` uses the owning run event sequence.
         * @summary List session events
         * @param {string} id
         * @param {number} [sinceSeq]
         * @param {number} [limit]
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async listSessionEvents(id: string, sinceSeq?: number, limit?: number, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<PaginatedEventList>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.listSessionEvents(id, sinceSeq, limit, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['SessionsApi.listSessionEvents']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * Starts a streamed turn immediately. Background turns are not supported in this API version.
         * @summary Submit a session turn
         * @param {string} id
         * @param {SubmitTurnRequest} submitTurnRequest
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async submitSessionTurn(id: string, submitTurnRequest: SubmitTurnRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<string>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.submitSessionTurn(id, submitTurnRequest, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['SessionsApi.submitSessionTurn']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
    }
};

/**
 * SessionsApi - factory interface
 */
export const SessionsApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
    const localVarFp = SessionsApiFp(configuration)
    return {
        /**
         * Replays and streams this session\'s durable `run.session.*` events from the owning run event log. The stream remains open until the client disconnects or the server shuts down.
         * @summary Attach to session events
         * @param {string} id
         * @param {number} [sinceSeq]
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        attachSessionEvents(id: string, sinceSeq?: number, options?: RawAxiosRequestConfig): AxiosPromise<string> {
            return localVarFp.attachSessionEvents(id, sinceSeq, options).then((request) => request(axios, basePath));
        },
        /**
         * Creates a read-only Ask Fabro session bound to the run.
         * @summary Create run session
         * @param {string} id Unique run identifier (ULID).
         * @param {CreateRunSessionRequest} createRunSessionRequest
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        createRunSession(id: string, createRunSessionRequest: CreateRunSessionRequest, options?: RawAxiosRequestConfig): AxiosPromise<SessionRecord> {
            return localVarFp.createRunSession(id, createRunSessionRequest, options).then((request) => request(axios, basePath));
        },
        /**
         *
         * @summary Get session
         * @param {string} id
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        getSession(id: string, options?: RawAxiosRequestConfig): AxiosPromise<SessionDetail> {
            return localVarFp.getSession(id, options).then((request) => request(axios, basePath));
        },
        /**
         *
         * @summary Interrupt a session turn
         * @param {string} id
         * @param {string} turnId
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        interruptSessionTurn(id: string, turnId: string, options?: RawAxiosRequestConfig): AxiosPromise<EventEnvelope> {
            return localVarFp.interruptSessionTurn(id, turnId, options).then((request) => request(axios, basePath));
        },
        /**
         *
         * @summary List run sessions
         * @param {string} id Unique run identifier (ULID).
         * @param {number} [pageLimit]
         * @param {number} [pageOffset]
         * @param {ListRunSessionsOrderEnum} [order]
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listRunSessions(id: string, pageLimit?: number, pageOffset?: number, order?: ListRunSessionsOrderEnum, options?: RawAxiosRequestConfig): AxiosPromise<PaginatedSessionList> {
            return localVarFp.listRunSessions(id, pageLimit, pageOffset, order, options).then((request) => request(axios, basePath));
        },
        /**
         * Returns run event envelopes filtered to this session\'s durable `run.session.*` events. `since_seq` uses the owning run event sequence.
         * @summary List session events
         * @param {string} id
         * @param {number} [sinceSeq]
         * @param {number} [limit]
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listSessionEvents(id: string, sinceSeq?: number, limit?: number, options?: RawAxiosRequestConfig): AxiosPromise<PaginatedEventList> {
            return localVarFp.listSessionEvents(id, sinceSeq, limit, options).then((request) => request(axios, basePath));
        },
        /**
         * Starts a streamed turn immediately. Background turns are not supported in this API version.
         * @summary Submit a session turn
         * @param {string} id
         * @param {SubmitTurnRequest} submitTurnRequest
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        submitSessionTurn(id: string, submitTurnRequest: SubmitTurnRequest, options?: RawAxiosRequestConfig): AxiosPromise<string> {
            return localVarFp.submitSessionTurn(id, submitTurnRequest, options).then((request) => request(axios, basePath));
        },
    };
};

/**
 * SessionsApi - object-oriented interface
 */
export class SessionsApi extends BaseAPI {
    /**
     * Replays and streams this session\'s durable `run.session.*` events from the owning run event log. The stream remains open until the client disconnects or the server shuts down.
     * @summary Attach to session events
     * @param {string} id
     * @param {number} [sinceSeq]
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public attachSessionEvents(id: string, sinceSeq?: number, options?: RawAxiosRequestConfig) {
        return SessionsApiFp(this.configuration).attachSessionEvents(id, sinceSeq, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Creates a read-only Ask Fabro session bound to the run.
     * @summary Create run session
     * @param {string} id Unique run identifier (ULID).
     * @param {CreateRunSessionRequest} createRunSessionRequest
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public createRunSession(id: string, createRunSessionRequest: CreateRunSessionRequest, options?: RawAxiosRequestConfig) {
        return SessionsApiFp(this.configuration).createRunSession(id, createRunSessionRequest, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     *
     * @summary Get session
     * @param {string} id
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public getSession(id: string, options?: RawAxiosRequestConfig) {
        return SessionsApiFp(this.configuration).getSession(id, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     *
     * @summary Interrupt a session turn
     * @param {string} id
     * @param {string} turnId
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public interruptSessionTurn(id: string, turnId: string, options?: RawAxiosRequestConfig) {
        return SessionsApiFp(this.configuration).interruptSessionTurn(id, turnId, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     *
     * @summary List run sessions
     * @param {string} id Unique run identifier (ULID).
     * @param {number} [pageLimit]
     * @param {number} [pageOffset]
     * @param {ListRunSessionsOrderEnum} [order]
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public listRunSessions(id: string, pageLimit?: number, pageOffset?: number, order?: ListRunSessionsOrderEnum, options?: RawAxiosRequestConfig) {
        return SessionsApiFp(this.configuration).listRunSessions(id, pageLimit, pageOffset, order, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Returns run event envelopes filtered to this session\'s durable `run.session.*` events. `since_seq` uses the owning run event sequence.
     * @summary List session events
     * @param {string} id
     * @param {number} [sinceSeq]
     * @param {number} [limit]
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public listSessionEvents(id: string, sinceSeq?: number, limit?: number, options?: RawAxiosRequestConfig) {
        return SessionsApiFp(this.configuration).listSessionEvents(id, sinceSeq, limit, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Starts a streamed turn immediately. Background turns are not supported in this API version.
     * @summary Submit a session turn
     * @param {string} id
     * @param {SubmitTurnRequest} submitTurnRequest
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public submitSessionTurn(id: string, submitTurnRequest: SubmitTurnRequest, options?: RawAxiosRequestConfig) {
        return SessionsApiFp(this.configuration).submitSessionTurn(id, submitTurnRequest, options).then((request) => request(this.axios, this.basePath));
    }
}

export const ListRunSessionsOrderEnum = {
    UPDATED_DESC: 'updated_desc',
    CREATED_DESC: 'created_desc'
} as const;
export type ListRunSessionsOrderEnum = typeof ListRunSessionsOrderEnum[keyof typeof ListRunSessionsOrderEnum];
