/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 * @generated-id: 882f1243b4bb
 */

import { workflowsRunsGetRun } from "../funcs/workflowsRunsGetRun.js";
import { workflowsRunsGetRunHistory } from "../funcs/workflowsRunsGetRunHistory.js";
import { workflowsRunsListRuns } from "../funcs/workflowsRunsListRuns.js";
import { ClientSDK, RequestOptions } from "../lib/sdks.js";
import * as components from "../models/components/index.js";
import * as operations from "../models/operations/index.js";
import { unwrapAsync } from "../types/fp.js";
import { PageIterator, unwrapResultIterator } from "../types/operations.js";

export class Runs extends ClientSDK {
  /**
   * List Runs
   */
  async listRuns(
    request?: operations.ListRunsV1WorkflowsRunsGetRequest | undefined,
    options?: RequestOptions,
  ): Promise<
    PageIterator<
      operations.ListRunsV1WorkflowsRunsGetResponse,
      { cursor: string }
    >
  > {
    return unwrapResultIterator(workflowsRunsListRuns(
      this,
      request,
      options,
    ));
  }

  /**
   * Get Run
   */
  async getRun(
    request: operations.GetRunV1WorkflowsRunsRunIdGetRequest,
    options?: RequestOptions,
  ): Promise<components.WorkflowExecutionResponse> {
    return unwrapAsync(workflowsRunsGetRun(
      this,
      request,
      options,
    ));
  }

  /**
   * Get Run History
   */
  async getRunHistory(
    request: operations.GetRunHistoryV1WorkflowsRunsRunIdHistoryGetRequest,
    options?: RequestOptions,
  ): Promise<any> {
    return unwrapAsync(workflowsRunsGetRunHistory(
      this,
      request,
      options,
    ));
  }
}
