// File generated from our OpenAPI spec by Stainless.

import * as Core from 'cloudflare/core';
import { APIResource } from 'cloudflare/resource';
import * as ClipsAPI from 'cloudflare/resources/stream/clips';

export class Clips extends APIResource {
  /**
   * Clips a video based on the specified start and end times provided in seconds.
   */
  streamVideoClippingClipVideosGivenAStartAndEndTime(
    accountId: string,
    body: ClipStreamVideoClippingClipVideosGivenAStartAndEndTimeParams,
    options?: Core.RequestOptions,
  ): Core.APIPromise<ClipStreamVideoClippingClipVideosGivenAStartAndEndTimeResponse> {
    return (
      this._client.post(`/accounts/${accountId}/stream/clip`, { body, ...options }) as Core.APIPromise<{
        result: ClipStreamVideoClippingClipVideosGivenAStartAndEndTimeResponse;
      }>
    )._thenUnwrap((obj) => obj.result);
  }
}

export interface ClipStreamVideoClippingClipVideosGivenAStartAndEndTimeResponse {
  /**
   * Lists the origins allowed to display the video. Enter allowed origin domains in
   * an array and use `*` for wildcard subdomains. Empty arrays allow the video to be
   * viewed on any origin.
   */
  allowedOrigins?: Array<string>;

  /**
   * The unique video identifier (UID).
   */
  clippedFromVideoUID?: string;

  /**
   * The date and time the clip was created.
   */
  created?: string;

  /**
   * A user-defined identifier for the media creator.
   */
  creator?: string;

  /**
   * Specifies the end time for the video clip in seconds.
   */
  endTimeSeconds?: number;

  /**
   * The maximum duration in seconds for a video upload. Can be set for a video that
   * is not yet uploaded to limit its duration. Uploads that exceed the specified
   * duration will fail during processing. A value of `-1` means the value is
   * unknown.
   */
  maxDurationSeconds?: number;

  /**
   * A user modifiable key-value store used to reference other systems of record for
   * managing videos.
   */
  meta?: unknown;

  /**
   * The date and time the live input was last modified.
   */
  modified?: string;

  playback?: ClipStreamVideoClippingClipVideosGivenAStartAndEndTimeResponse.Playback;

  /**
   * The video's preview page URI. This field is omitted until encoding is complete.
   */
  preview?: string;

  /**
   * Indicates whether the video can be a accessed using the UID. When set to `true`,
   * a signed token must be generated with a signing key to view the video.
   */
  requireSignedURLs?: boolean;

  /**
   * Specifies the start time for the video clip in seconds.
   */
  startTimeSeconds?: number;

  /**
   * Specifies the processing status for all quality levels for a video.
   */
  status?: 'pendingupload' | 'downloading' | 'queued' | 'inprogress' | 'ready' | 'error';

  /**
   * The timestamp for a thumbnail image calculated as a percentage value of the
   * video's duration. To convert from a second-wise timestamp to a percentage,
   * divide the desired timestamp by the total duration of the video. If this value
   * is not set, the default thumbnail image is taken from 0s of the video.
   */
  thumbnailTimestampPct?: number;

  watermark?: ClipStreamVideoClippingClipVideosGivenAStartAndEndTimeResponse.Watermark;
}

export namespace ClipStreamVideoClippingClipVideosGivenAStartAndEndTimeResponse {
  export interface Playback {
    /**
     * DASH Media Presentation Description for the video.
     */
    dash?: string;

    /**
     * The HLS manifest for the video.
     */
    hls?: string;
  }

  export interface Watermark {
    /**
     * The unique identifier for the watermark profile.
     */
    uid?: string;
  }
}

export interface ClipStreamVideoClippingClipVideosGivenAStartAndEndTimeParams {
  /**
   * The unique video identifier (UID).
   */
  clippedFromVideoUID: string;

  /**
   * Specifies the end time for the video clip in seconds.
   */
  endTimeSeconds: number;

  /**
   * Specifies the start time for the video clip in seconds.
   */
  startTimeSeconds: number;

  /**
   * Lists the origins allowed to display the video. Enter allowed origin domains in
   * an array and use `*` for wildcard subdomains. Empty arrays allow the video to be
   * viewed on any origin.
   */
  allowedOrigins?: Array<string>;

  /**
   * A user-defined identifier for the media creator.
   */
  creator?: string;

  /**
   * The maximum duration in seconds for a video upload. Can be set for a video that
   * is not yet uploaded to limit its duration. Uploads that exceed the specified
   * duration will fail during processing. A value of `-1` means the value is
   * unknown.
   */
  maxDurationSeconds?: number;

  /**
   * Indicates whether the video can be a accessed using the UID. When set to `true`,
   * a signed token must be generated with a signing key to view the video.
   */
  requireSignedURLs?: boolean;

  /**
   * The timestamp for a thumbnail image calculated as a percentage value of the
   * video's duration. To convert from a second-wise timestamp to a percentage,
   * divide the desired timestamp by the total duration of the video. If this value
   * is not set, the default thumbnail image is taken from 0s of the video.
   */
  thumbnailTimestampPct?: number;

  watermark?: ClipStreamVideoClippingClipVideosGivenAStartAndEndTimeParams.Watermark;
}

export namespace ClipStreamVideoClippingClipVideosGivenAStartAndEndTimeParams {
  export interface Watermark {
    /**
     * The unique identifier for the watermark profile.
     */
    uid?: string;
  }
}

export namespace Clips {
  export import ClipStreamVideoClippingClipVideosGivenAStartAndEndTimeResponse = ClipsAPI.ClipStreamVideoClippingClipVideosGivenAStartAndEndTimeResponse;
  export import ClipStreamVideoClippingClipVideosGivenAStartAndEndTimeParams = ClipsAPI.ClipStreamVideoClippingClipVideosGivenAStartAndEndTimeParams;
}
