UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

128 lines 6.16 kB
"use strict"; // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.VideosSinglePage = exports.Stream = void 0; const resource_1 = require("cloudflare/resource"); const AudioTracksAPI = __importStar(require("cloudflare/resources/stream/audio-tracks")); const ClipAPI = __importStar(require("cloudflare/resources/stream/clip")); const CopyAPI = __importStar(require("cloudflare/resources/stream/copy")); const DirectUploadAPI = __importStar(require("cloudflare/resources/stream/direct-upload")); const DownloadsAPI = __importStar(require("cloudflare/resources/stream/downloads")); const EmbedAPI = __importStar(require("cloudflare/resources/stream/embed")); const KeysAPI = __importStar(require("cloudflare/resources/stream/keys")); const TokenAPI = __importStar(require("cloudflare/resources/stream/token")); const VideosAPI = __importStar(require("cloudflare/resources/stream/videos")); const WatermarksAPI = __importStar(require("cloudflare/resources/stream/watermarks")); const WebhooksAPI = __importStar(require("cloudflare/resources/stream/webhooks")); const CaptionsAPI = __importStar(require("cloudflare/resources/stream/captions/captions")); const LiveInputsAPI = __importStar(require("cloudflare/resources/stream/live-inputs/live-inputs")); const pagination_1 = require("cloudflare/pagination"); class Stream extends resource_1.APIResource { constructor() { super(...arguments); this.audioTracks = new AudioTracksAPI.AudioTracks(this._client); this.videos = new VideosAPI.Videos(this._client); this.clip = new ClipAPI.ClipResource(this._client); this.copy = new CopyAPI.Copy(this._client); this.directUpload = new DirectUploadAPI.DirectUpload(this._client); this.keys = new KeysAPI.Keys(this._client); this.liveInputs = new LiveInputsAPI.LiveInputs(this._client); this.watermarks = new WatermarksAPI.Watermarks(this._client); this.webhooks = new WebhooksAPI.Webhooks(this._client); this.captions = new CaptionsAPI.Captions(this._client); this.downloads = new DownloadsAPI.Downloads(this._client); this.embed = new EmbedAPI.Embed(this._client); this.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, options) { const { account_id, body, 'Tus-Resumable': tusResumable, 'Upload-Length': uploadLength, 'Upload-Creator': uploadCreator, 'Upload-Metadata': uploadMetadata, } = params; return this._client.post(`/accounts/${account_id}/stream`, { body: body, ...options, headers: { Accept: '*/*', 'Tus-Resumable': tusResumable.toString(), 'Upload-Length': uploadLength.toString(), 'Upload-Creator': uploadCreator || '', 'Upload-Metadata': uploadMetadata || '', ...options?.headers, }, }); } /** * Lists up to 1000 videos from a single request. For a specific range, refer to * the optional parameters. */ list(params, options) { 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, params, options) { const { account_id, body } = params; return this._client.delete(`/accounts/${account_id}/stream/${identifier}`, { body: body, ...options, headers: { Accept: '*/*', ...options?.headers }, }); } /** * Fetches details for a single video. */ get(identifier, params, options) { const { account_id } = params; return this._client.get(`/accounts/${account_id}/stream/${identifier}`, options)._thenUnwrap((obj) => obj.result); } } exports.Stream = Stream; class VideosSinglePage extends pagination_1.SinglePage { } exports.VideosSinglePage = VideosSinglePage; (function (Stream) { Stream.AudioTracks = AudioTracksAPI.AudioTracks; Stream.Videos = VideosAPI.Videos; Stream.ClipResource = ClipAPI.ClipResource; Stream.Copy = CopyAPI.Copy; Stream.DirectUpload = DirectUploadAPI.DirectUpload; Stream.Keys = KeysAPI.Keys; Stream.LiveInputs = LiveInputsAPI.LiveInputs; Stream.Watermarks = WatermarksAPI.Watermarks; Stream.WatermarksSinglePage = WatermarksAPI.WatermarksSinglePage; Stream.Webhooks = WebhooksAPI.Webhooks; Stream.Captions = CaptionsAPI.Captions; Stream.Downloads = DownloadsAPI.Downloads; Stream.Embed = EmbedAPI.Embed; Stream.Token = TokenAPI.Token; })(Stream = exports.Stream || (exports.Stream = {})); //# sourceMappingURL=stream.js.map