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

import { workflowsSchedulesGetSchedule } from "../funcs/workflowsSchedulesGetSchedule.js";
import { workflowsSchedulesGetSchedules } from "../funcs/workflowsSchedulesGetSchedules.js";
import { workflowsSchedulesPauseSchedule } from "../funcs/workflowsSchedulesPauseSchedule.js";
import { workflowsSchedulesResumeSchedule } from "../funcs/workflowsSchedulesResumeSchedule.js";
import { workflowsSchedulesScheduleWorkflow } from "../funcs/workflowsSchedulesScheduleWorkflow.js";
import { workflowsSchedulesTriggerSchedule } from "../funcs/workflowsSchedulesTriggerSchedule.js";
import { workflowsSchedulesUnscheduleWorkflow } from "../funcs/workflowsSchedulesUnscheduleWorkflow.js";
import { workflowsSchedulesUpdateSchedule } from "../funcs/workflowsSchedulesUpdateSchedule.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 Schedules extends ClientSDK {
  /**
   * Get Schedules
   */
  async getSchedules(
    request?: operations.GetSchedulesV1WorkflowsSchedulesGetRequest | undefined,
    options?: RequestOptions,
  ): Promise<
    PageIterator<
      operations.GetSchedulesV1WorkflowsSchedulesGetResponse,
      { cursor: string }
    >
  > {
    return unwrapResultIterator(workflowsSchedulesGetSchedules(
      this,
      request,
      options,
    ));
  }

  /**
   * Schedule Workflow
   */
  async scheduleWorkflow(
    request: components.WorkflowScheduleRequest,
    options?: RequestOptions,
  ): Promise<components.WorkflowScheduleResponse> {
    return unwrapAsync(workflowsSchedulesScheduleWorkflow(
      this,
      request,
      options,
    ));
  }

  /**
   * Get Schedule
   */
  async getSchedule(
    request: operations.GetScheduleV1WorkflowsSchedulesScheduleIdGetRequest,
    options?: RequestOptions,
  ): Promise<components.ScheduleDefinitionOutput> {
    return unwrapAsync(workflowsSchedulesGetSchedule(
      this,
      request,
      options,
    ));
  }

  /**
   * Unschedule Workflow
   */
  async unscheduleWorkflow(
    request:
      operations.UnscheduleWorkflowV1WorkflowsSchedulesScheduleIdDeleteRequest,
    options?: RequestOptions,
  ): Promise<void> {
    return unwrapAsync(workflowsSchedulesUnscheduleWorkflow(
      this,
      request,
      options,
    ));
  }

  /**
   * Update Schedule
   */
  async updateSchedule(
    request:
      operations.UpdateScheduleV1WorkflowsSchedulesScheduleIdPatchRequest,
    options?: RequestOptions,
  ): Promise<components.WorkflowScheduleResponse> {
    return unwrapAsync(workflowsSchedulesUpdateSchedule(
      this,
      request,
      options,
    ));
  }

  /**
   * Pause Schedule
   */
  async pauseSchedule(
    request:
      operations.PauseScheduleV1WorkflowsSchedulesScheduleIdPausePostRequest,
    options?: RequestOptions,
  ): Promise<void> {
    return unwrapAsync(workflowsSchedulesPauseSchedule(
      this,
      request,
      options,
    ));
  }

  /**
   * Resume Schedule
   */
  async resumeSchedule(
    request:
      operations.ResumeScheduleV1WorkflowsSchedulesScheduleIdResumePostRequest,
    options?: RequestOptions,
  ): Promise<void> {
    return unwrapAsync(workflowsSchedulesResumeSchedule(
      this,
      request,
      options,
    ));
  }

  /**
   * Trigger Schedule
   */
  async triggerSchedule(
    request:
      operations.TriggerScheduleV1WorkflowsSchedulesScheduleIdTriggerPostRequest,
    options?: RequestOptions,
  ): Promise<void> {
    return unwrapAsync(workflowsSchedulesTriggerSchedule(
      this,
      request,
      options,
    ));
  }
}
