UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

96 lines • 3.79 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../../../core/resource.mjs"; import * as VttAPI from "./vtt.mjs"; import { BaseVtt, Vtt } from "./vtt.mjs"; import { multipartFormRequestOptions } from "../../../../internal/uploads.mjs"; import { path } from "../../../../internal/utils/path.mjs"; export var BaseLanguage = /* @__PURE__ */ (() => { class BaseLanguage extends APIResource { /** * Generate captions or subtitles for provided language via AI. * * @example * ```ts * const caption = * await client.stream.captions.language.create('tr', { * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * identifier: 'ea95132c15732412d22c1476fa83f27a', * }); * ``` */ create(language, params, options) { const { account_id, identifier } = params; return this._client.post(path `/accounts/${account_id}/stream/${identifier}/captions/${language}/generate`, options)._thenUnwrap((obj) => obj.result); } /** * Uploads the caption or subtitle file to the endpoint for a specific BCP47 * language. One caption or subtitle file per language is allowed. * * @example * ```ts * const caption = * await client.stream.captions.language.update('tr', { * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * identifier: 'ea95132c15732412d22c1476fa83f27a', * file: '@/Users/kyle/Desktop/tr.vtt', * }); * ``` */ update(language, params, options) { const { account_id, identifier, ...body } = params; return this._client.put(path `/accounts/${account_id}/stream/${identifier}/captions/${language}`, multipartFormRequestOptions({ body, ...options }, this._client))._thenUnwrap((obj) => obj.result); } /** * Removes the captions or subtitles from a video. * * @example * ```ts * const language = * await client.stream.captions.language.delete('tr', { * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * identifier: 'ea95132c15732412d22c1476fa83f27a', * }); * ``` */ delete(language, params, options) { const { account_id, identifier } = params; return this._client.delete(path `/accounts/${account_id}/stream/${identifier}/captions/${language}`, options)._thenUnwrap((obj) => obj.result); } /** * Lists the captions or subtitles for provided language. * * @example * ```ts * const caption = await client.stream.captions.language.get( * 'tr', * { * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * identifier: 'ea95132c15732412d22c1476fa83f27a', * }, * ); * ``` */ get(language, params, options) { const { account_id, identifier } = params; return this._client.get(path `/accounts/${account_id}/stream/${identifier}/captions/${language}`, options)._thenUnwrap((obj) => obj.result); } } BaseLanguage._key = Object.freeze([ 'stream', 'captions', 'language', ]); return BaseLanguage; })(); export var Language = /* @__PURE__ */ (() => { class Language extends BaseLanguage { constructor() { super(...arguments); this.vtt = new VttAPI.Vtt(this._client); } } Language.Vtt = Vtt; Language.BaseVtt = BaseVtt; return Language; })(); //# sourceMappingURL=language.mjs.map