// File generated from our OpenAPI spec by Stainless.

import * as Core from "../../core";
import { APIResource } from "../../resource";
import * as ScheduleAPI from "./schedule";
import * as SpeedAPI from "./speed";
import * as TestsAPI from "./tests";

export class Schedule extends APIResource {
  /**
   * Creates a scheduled test for a page.
   */
  create(
    url: string,
    params: ScheduleCreateParams,
    options?: Core.RequestOptions,
  ): Core.APIPromise<ScheduleCreateResponse> {
    const { zone_id, region } = params;
    return (
      this._client.post(`/zones/${zone_id}/speed_api/schedule/${url}`, {
        query: { region },
        ...options,
      }) as Core.APIPromise<{ result: ScheduleCreateResponse }>
    )._thenUnwrap((obj) => obj.result);
  }
}

export interface ScheduleCreateResponse {
  /**
   * The test schedule.
   */
  schedule?: SpeedAPI.ObservatorySchedule;

  test?: TestsAPI.ObservatoryPageTest;
}

export interface ScheduleCreateParams {
  /**
   * Path param: Identifier
   */
  zone_id: string;

  /**
   * Query param: A test region.
   */
  region?:
    | 'asia-east1'
    | 'asia-northeast1'
    | 'asia-northeast2'
    | 'asia-south1'
    | 'asia-southeast1'
    | 'australia-southeast1'
    | 'europe-north1'
    | 'europe-southwest1'
    | 'europe-west1'
    | 'europe-west2'
    | 'europe-west3'
    | 'europe-west4'
    | 'europe-west8'
    | 'europe-west9'
    | 'me-west1'
    | 'southamerica-east1'
    | 'us-central1'
    | 'us-east1'
    | 'us-east4'
    | 'us-south1'
    | 'us-west1';
}

export namespace Schedule {
  export import ScheduleCreateResponse = ScheduleAPI.ScheduleCreateResponse;
  export import ScheduleCreateParams = ScheduleAPI.ScheduleCreateParams;
}
