/* tslint:disable */
/* eslint-disable */
/**
 * HumanLayer Daemon REST API
 * REST API for HumanLayer daemon operations, providing session management, approval workflows, and real-time event streaming capabilities.
 *
 * The version of the OpenAPI document: 1.0.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 * as runtime from '../runtime';
import type {
  EventType,
} from '../models/index';
import {
    EventTypeFromJSON,
    EventTypeToJSON,
} from '../models/index';

export interface StreamEventsRequest {
    eventTypes?: Array<EventType>;
    sessionId?: string;
    runId?: string;
}

/**
 * EventsApi - interface
 *
 * @export
 * @interface EventsApiInterface
 */
export interface EventsApiInterface {
    /**
     * Subscribe to real-time events using Server-Sent Events (SSE). This endpoint streams events as they occur in the system.  **Note**: This endpoint uses Server-Sent Events which is not natively supported by OpenAPI 3.1. Client code generation will not work for this endpoint. Manual SSE client implementation is required using: - JavaScript/TypeScript: Native EventSource API - Go: r3labs/sse or similar SSE client library - Other languages: Language-specific SSE client libraries
     * @summary Server-Sent Events stream
     * @param {Array<EventType>} [eventTypes] Filter by event types
     * @param {string} [sessionId] Filter events by session ID
     * @param {string} [runId] Filter events by run ID
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof EventsApiInterface
     */
    streamEventsRaw(requestParameters: StreamEventsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<string>>;

    /**
     * Subscribe to real-time events using Server-Sent Events (SSE). This endpoint streams events as they occur in the system.  **Note**: This endpoint uses Server-Sent Events which is not natively supported by OpenAPI 3.1. Client code generation will not work for this endpoint. Manual SSE client implementation is required using: - JavaScript/TypeScript: Native EventSource API - Go: r3labs/sse or similar SSE client library - Other languages: Language-specific SSE client libraries
     * Server-Sent Events stream
     */
    streamEvents(requestParameters: StreamEventsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<string>;

}

/**
 *
 */
export class EventsApi extends runtime.BaseAPI implements EventsApiInterface {

    /**
     * Subscribe to real-time events using Server-Sent Events (SSE). This endpoint streams events as they occur in the system.  **Note**: This endpoint uses Server-Sent Events which is not natively supported by OpenAPI 3.1. Client code generation will not work for this endpoint. Manual SSE client implementation is required using: - JavaScript/TypeScript: Native EventSource API - Go: r3labs/sse or similar SSE client library - Other languages: Language-specific SSE client libraries
     * Server-Sent Events stream
     */
    async streamEventsRaw(requestParameters: StreamEventsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<string>> {
        const queryParameters: any = {};

        if (requestParameters['eventTypes'] != null) {
            queryParameters['eventTypes'] = requestParameters['eventTypes'];
        }

        if (requestParameters['sessionId'] != null) {
            queryParameters['sessionId'] = requestParameters['sessionId'];
        }

        if (requestParameters['runId'] != null) {
            queryParameters['runId'] = requestParameters['runId'];
        }

        const headerParameters: runtime.HTTPHeaders = {};


        let urlPath = `/stream/events`;

        const response = await this.request({
            path: urlPath,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        if (this.isJsonMime(response.headers.get('content-type'))) {
            return new runtime.JSONApiResponse<string>(response);
        } else {
            return new runtime.TextApiResponse(response) as any;
        }
    }

    /**
     * Subscribe to real-time events using Server-Sent Events (SSE). This endpoint streams events as they occur in the system.  **Note**: This endpoint uses Server-Sent Events which is not natively supported by OpenAPI 3.1. Client code generation will not work for this endpoint. Manual SSE client implementation is required using: - JavaScript/TypeScript: Native EventSource API - Go: r3labs/sse or similar SSE client library - Other languages: Language-specific SSE client libraries
     * Server-Sent Events stream
     */
    async streamEvents(requestParameters: StreamEventsRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<string> {
        const response = await this.streamEventsRaw(requestParameters, initOverrides);
        return await response.value();
    }

}
