// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../../core/resource'; import { APIPromise } from '../../../core/api-promise'; import { PagePromise, SinglePage } from '../../../core/pagination'; import { buildHeaders } from '../../../internal/headers'; import { RequestOptions } from '../../../internal/request-options'; import { path } from '../../../internal/utils/path'; export class BaseOutputs extends APIResource { static override readonly _key: readonly ['stream', 'liveInputs', 'outputs'] = Object.freeze([ 'stream', 'liveInputs', 'outputs', ] as const); /** * Creates a new output that can be used to simulcast or restream live video to * other RTMP or SRT destinations. Outputs are always linked to a specific live * input — one live input can have many outputs. * * @example * ```ts * const output = * await client.stream.liveInputs.outputs.create( * '66be4bf738797e01e1fca35a7bdecdcd', * { * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * streamKey: 'uzya-f19y-g2g9-a2ee-51j2', * url: 'rtmp://a.rtmp.youtube.com/live2', * }, * ); * ``` */ create( liveInputIdentifier: string, params: OutputCreateParams, options?: RequestOptions, ): APIPromise { const { account_id, ...body } = params; return ( this._client.post(path`/accounts/${account_id}/stream/live_inputs/${liveInputIdentifier}/outputs`, { body, ...options, }) as APIPromise<{ result: Output }> )._thenUnwrap((obj) => obj.result); } /** * Updates the state of an output. * * @example * ```ts * const output = * await client.stream.liveInputs.outputs.update( * 'baea4d9c515887b80289d5c33cf01145', * { * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * live_input_identifier: * '66be4bf738797e01e1fca35a7bdecdcd', * enabled: true, * }, * ); * ``` */ update(outputIdentifier: string, params: OutputUpdateParams, options?: RequestOptions): APIPromise { const { account_id, live_input_identifier, ...body } = params; return ( this._client.put( path`/accounts/${account_id}/stream/live_inputs/${live_input_identifier}/outputs/${outputIdentifier}`, { body, ...options }, ) as APIPromise<{ result: Output }> )._thenUnwrap((obj) => obj.result); } /** * Retrieves all outputs associated with a specified live input. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const output of client.stream.liveInputs.outputs.list( * '66be4bf738797e01e1fca35a7bdecdcd', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * )) { * // ... * } * ``` */ list( liveInputIdentifier: string, params: OutputListParams, options?: RequestOptions, ): PagePromise { const { account_id } = params; return this._client.getAPIList( path`/accounts/${account_id}/stream/live_inputs/${liveInputIdentifier}/outputs`, SinglePage, options, ); } /** * Deletes an output and removes it from the associated live input. * * @example * ```ts * await client.stream.liveInputs.outputs.delete( * 'baea4d9c515887b80289d5c33cf01145', * { * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * live_input_identifier: * '66be4bf738797e01e1fca35a7bdecdcd', * }, * ); * ``` */ delete(outputIdentifier: string, params: OutputDeleteParams, options?: RequestOptions): APIPromise { const { account_id, live_input_identifier } = params; return this._client.delete( path`/accounts/${account_id}/stream/live_inputs/${live_input_identifier}/outputs/${outputIdentifier}`, { ...options, headers: buildHeaders([{ Accept: '*/*' }, options?.headers]) }, ); } } export class Outputs extends BaseOutputs {} export type OutputsSinglePage = SinglePage; export interface Output { /** * When enabled, live video streamed to the associated live input will be sent to * the output URL. When disabled, live video will not be sent to the output URL, * even when streaming to the associated live input. Use this to control precisely * when you start and stop simulcasting to specific destinations like YouTube and * Twitch. */ enabled?: boolean; /** * The streamKey used to authenticate against an output's target. */ streamKey?: string; /** * A unique identifier for the output. */ uid?: string; /** * The URL an output uses to restream. */ url?: string; } export interface OutputCreateParams { /** * Path param: Identifier. */ account_id: string; /** * Body param: The streamKey used to authenticate against an output's target. */ streamKey: string; /** * Body param: The URL an output uses to restream. */ url: string; /** * Body param: When enabled, live video streamed to the associated live input will * be sent to the output URL. When disabled, live video will not be sent to the * output URL, even when streaming to the associated live input. Use this to * control precisely when you start and stop simulcasting to specific destinations * like YouTube and Twitch. */ enabled?: boolean; } export interface OutputUpdateParams { /** * Path param: Identifier. */ account_id: string; /** * Path param: A unique identifier for a live input. */ live_input_identifier: string; /** * Body param: When enabled, live video streamed to the associated live input will * be sent to the output URL. When disabled, live video will not be sent to the * output URL, even when streaming to the associated live input. Use this to * control precisely when you start and stop simulcasting to specific destinations * like YouTube and Twitch. */ enabled: boolean; } export interface OutputListParams { /** * Identifier. */ account_id: string; } export interface OutputDeleteParams { /** * Identifier. */ account_id: string; /** * A unique identifier for a live input. */ live_input_identifier: string; } export declare namespace Outputs { export { type Output as Output, type OutputsSinglePage as OutputsSinglePage, type OutputCreateParams as OutputCreateParams, type OutputUpdateParams as OutputUpdateParams, type OutputListParams as OutputListParams, type OutputDeleteParams as OutputDeleteParams, }; }