// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../resource'; import * as Core from '../../core'; import * as AudioTracksAPI from './audio-tracks'; import { Audio, AudioSinglePage, AudioTrackCopyParams, AudioTrackDeleteParams, AudioTrackDeleteResponse, AudioTrackEditParams, AudioTrackGetParams, AudioTracks, } from './audio-tracks'; import * as ClipAPI from './clip'; import { Clip, ClipCreateParams, ClipResource } from './clip'; import * as CopyAPI from './copy'; import { Copy, CopyCreateParams } from './copy'; import * as DirectUploadAPI from './direct-upload'; import { DirectUpload, DirectUploadCreateParams, DirectUploadCreateResponse } from './direct-upload'; import * as DownloadsAPI from './downloads'; import { DownloadCreateParams, DownloadCreateResponse, DownloadDeleteParams, DownloadDeleteResponse, DownloadGetParams, DownloadGetResponse, Downloads, } from './downloads'; import * as EmbedAPI from './embed'; import { Embed, EmbedGetParams, EmbedGetResponse } from './embed'; import * as KeysAPI from './keys'; import { KeyCreateParams, KeyDeleteParams, KeyDeleteResponse, KeyGetParams, KeyGetResponse, KeyGetResponsesSinglePage, Keys, } from './keys'; import * as TokenAPI from './token'; import { Token, TokenCreateParams, TokenCreateResponse } from './token'; import * as VideosAPI from './videos'; import { VideoStorageUsageParams, VideoStorageUsageResponse, Videos } from './videos'; import * as WatermarksAPI from './watermarks'; import { Watermark, WatermarkCreateParams, WatermarkDeleteParams, WatermarkDeleteResponse, WatermarkGetParams, WatermarkListParams, Watermarks, WatermarksSinglePage, } from './watermarks'; import * as WebhooksAPI from './webhooks'; import { WebhookDeleteParams, WebhookDeleteResponse, WebhookGetParams, WebhookGetResponse, WebhookUpdateParams, WebhookUpdateResponse, Webhooks, } from './webhooks'; import * as CaptionsAPI from './captions/captions'; import { Caption, CaptionGetParams, Captions, CaptionsSinglePage } from './captions/captions'; import * as LiveInputsAPI from './live-inputs/live-inputs'; import { LiveInput, LiveInputCreateParams, LiveInputDeleteParams, LiveInputGetParams, LiveInputListParams, LiveInputListResponse, LiveInputUpdateParams, LiveInputs, } from './live-inputs/live-inputs'; import { SinglePage } from '../../pagination'; export class Stream extends APIResource { audioTracks: AudioTracksAPI.AudioTracks = new AudioTracksAPI.AudioTracks(this._client); videos: VideosAPI.Videos = new VideosAPI.Videos(this._client); clip: ClipAPI.ClipResource = new ClipAPI.ClipResource(this._client); copy: CopyAPI.Copy = new CopyAPI.Copy(this._client); directUpload: DirectUploadAPI.DirectUpload = new DirectUploadAPI.DirectUpload(this._client); keys: KeysAPI.Keys = new KeysAPI.Keys(this._client); liveInputs: LiveInputsAPI.LiveInputs = new LiveInputsAPI.LiveInputs(this._client); watermarks: WatermarksAPI.Watermarks = new WatermarksAPI.Watermarks(this._client); webhooks: WebhooksAPI.Webhooks = new WebhooksAPI.Webhooks(this._client); captions: CaptionsAPI.Captions = new CaptionsAPI.Captions(this._client); downloads: DownloadsAPI.Downloads = new DownloadsAPI.Downloads(this._client); embed: EmbedAPI.Embed = new EmbedAPI.Embed(this._client); token: TokenAPI.Token = new TokenAPI.Token(this._client); /** * Initiates a video upload using the TUS protocol. On success, the server responds * with a status code 201 (created) and includes a `location` header to indicate * where the content should be uploaded. Refer to https://tus.io for protocol * details. */ create(params: StreamCreateParams, options?: Core.RequestOptions): Core.APIPromise { const { account_id, body, 'Tus-Resumable': tusResumable, 'Upload-Length': uploadLength, direct_user, 'Upload-Creator': uploadCreator, 'Upload-Metadata': uploadMetadata, } = params; return this._client.post(`/accounts/${account_id}/stream`, { query: { direct_user }, body: body, ...options, headers: { Accept: '*/*', 'Tus-Resumable': tusResumable.toString(), 'Upload-Length': uploadLength.toString(), ...(uploadCreator != null ? { 'Upload-Creator': uploadCreator } : undefined), ...(uploadMetadata != null ? { 'Upload-Metadata': uploadMetadata } : undefined), ...options?.headers, }, }); } /** * Lists up to 1000 videos from a single request. For a specific range, refer to * the optional parameters. */ list(params: StreamListParams, options?: Core.RequestOptions): Core.PagePromise { const { account_id, ...query } = params; return this._client.getAPIList(`/accounts/${account_id}/stream`, VideosSinglePage, { query, ...options }); } /** * Deletes a video and its copies from Cloudflare Stream. */ delete( identifier: string, params: StreamDeleteParams, options?: Core.RequestOptions, ): Core.APIPromise { const { account_id } = params; return this._client.delete(`/accounts/${account_id}/stream/${identifier}`, { ...options, headers: { Accept: '*/*', ...options?.headers }, }); } /** * Edit details for a single video. */ edit(identifier: string, params: StreamEditParams, options?: Core.RequestOptions): Core.APIPromise