diff --git a/src/rest/Media.ts b/src/rest/Media.ts deleted file mode 100644 index 8eb1ca3e49..0000000000 --- a/src/rest/Media.ts +++ /dev/null @@ -1,5 +0,0 @@ -import MediaBase from "./MediaBase"; - -class Media extends MediaBase {} - -export = Media; diff --git a/src/rest/MediaBase.ts b/src/rest/MediaBase.ts deleted file mode 100644 index e67bfb10ba..0000000000 --- a/src/rest/MediaBase.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * NOTE: This class is auto generated by OpenAPI Generator. - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import Domain from "../base/Domain"; -import V1 from "./media/V1"; - -class MediaBase extends Domain { - _v1?: V1; - - /** - * Initialize media domain - * - * @param twilio - The twilio client - */ - constructor(twilio: any) { - super(twilio, "https://media.twilio.com"); - } - - get v1(): V1 { - this._v1 = this._v1 || new V1(this); - return this._v1; - } -} - -export = MediaBase; diff --git a/src/rest/Twilio.ts b/src/rest/Twilio.ts index c7fba2893e..6dd19fddbb 100644 --- a/src/rest/Twilio.ts +++ b/src/rest/Twilio.ts @@ -23,7 +23,6 @@ import Insights from "./Insights"; import Intelligence from "./Intelligence"; import IpMessaging from "./IpMessaging"; import Lookups from "./Lookups"; -import Media from "./Media"; import PreviewMessaging from "./PreviewMessaging"; import Messaging from "./Messaging"; import Microvisor from "./Microvisor"; @@ -104,8 +103,6 @@ class Twilio extends Client { _ipMessaging?: IpMessaging; /** (Twilio.Lookups) - lookups domain */ _lookups?: Lookups; - /** (Twilio.Media) - media domain */ - _media?: Media; /** (Twilio.PreviewMessaging) - previewMessaging domain */ _previewMessaging?: PreviewMessaging; /** (Twilio.Messaging) - messaging domain */ @@ -181,7 +178,6 @@ class Twilio extends Client { this.intelligence; this.ipMessaging; this.lookups; - this.media; this.previewMessaging; this.messaging; this.microvisor; @@ -279,10 +275,6 @@ class Twilio extends Client { get lookups(): Lookups { return this._lookups ?? (this._lookups = new (require("./Lookups"))(this)); } - /** Getter for (Twilio.Media) domain */ - get media(): Media { - return this._media ?? (this._media = new (require("./Media"))(this)); - } /** Getter for (Twilio.PreviewMessaging) domain */ get previewMessaging(): PreviewMessaging { return ( diff --git a/src/rest/media/V1.ts b/src/rest/media/V1.ts deleted file mode 100644 index 9042fec7d8..0000000000 --- a/src/rest/media/V1.ts +++ /dev/null @@ -1,58 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Twilio - Media - * This is the public Twilio REST API. - * - * NOTE: This class is auto generated by OpenAPI Generator. - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import MediaBase from "../MediaBase"; -import Version from "../../base/Version"; -import { MediaProcessorListInstance } from "./v1/mediaProcessor"; -import { MediaRecordingListInstance } from "./v1/mediaRecording"; -import { PlayerStreamerListInstance } from "./v1/playerStreamer"; - -export default class V1 extends Version { - /** - * Initialize the V1 version of Media - * - * @param domain - The Twilio (Twilio.Media) domain - */ - constructor(domain: MediaBase) { - super(domain, "v1"); - } - - /** mediaProcessor - { Twilio.Media.V1.MediaProcessorListInstance } resource */ - protected _mediaProcessor?: MediaProcessorListInstance; - /** mediaRecording - { Twilio.Media.V1.MediaRecordingListInstance } resource */ - protected _mediaRecording?: MediaRecordingListInstance; - /** playerStreamer - { Twilio.Media.V1.PlayerStreamerListInstance } resource */ - protected _playerStreamer?: PlayerStreamerListInstance; - - /** Getter for mediaProcessor resource */ - get mediaProcessor(): MediaProcessorListInstance { - this._mediaProcessor = - this._mediaProcessor || MediaProcessorListInstance(this); - return this._mediaProcessor; - } - - /** Getter for mediaRecording resource */ - get mediaRecording(): MediaRecordingListInstance { - this._mediaRecording = - this._mediaRecording || MediaRecordingListInstance(this); - return this._mediaRecording; - } - - /** Getter for playerStreamer resource */ - get playerStreamer(): PlayerStreamerListInstance { - this._playerStreamer = - this._playerStreamer || PlayerStreamerListInstance(this); - return this._playerStreamer; - } -} diff --git a/src/rest/media/v1/mediaProcessor.ts b/src/rest/media/v1/mediaProcessor.ts deleted file mode 100644 index ab4351d4e6..0000000000 --- a/src/rest/media/v1/mediaProcessor.ts +++ /dev/null @@ -1,682 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Twilio - Media - * This is the public Twilio REST API. - * - * NOTE: This class is auto generated by OpenAPI Generator. - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { inspect, InspectOptions } from "util"; -import Page, { TwilioResponsePayload } from "../../../base/Page"; -import Response from "../../../http/response"; -import V1 from "../V1"; -const deserialize = require("../../../base/deserialize"); -const serialize = require("../../../base/serialize"); -import { isValidPathParam } from "../../../base/utility"; - -export type MediaProcessorOrder = "asc" | "desc"; - -export type MediaProcessorStatus = "failed" | "started" | "ended"; - -export type MediaProcessorUpdateStatus = "ended"; - -/** - * Options to pass to update a MediaProcessorInstance - */ -export interface MediaProcessorContextUpdateOptions { - /** */ - status: MediaProcessorUpdateStatus; -} - -/** - * Options to pass to create a MediaProcessorInstance - */ -export interface MediaProcessorListInstanceCreateOptions { - /** The [Media Extension](/docs/live/media-extensions-overview) name or URL. Ex: `video-composer-v2` */ - extension: string; - /** The context of the Media Extension, represented as a JSON dictionary. See the documentation for the specific [Media Extension](/docs/live/media-extensions-overview) you are using for more information about the context to send. */ - extensionContext: string; - /** User-defined environment variables for the Media Extension, represented as a JSON dictionary of key/value strings. See the documentation for the specific [Media Extension](/docs/live/media-extensions-overview) you are using for more information about whether you need to provide this. */ - extensionEnvironment?: any; - /** The URL to which Twilio will send asynchronous webhook requests for every MediaProcessor event. See [Status Callbacks](/docs/live/api/status-callbacks) for details. */ - statusCallback?: string; - /** The HTTP method Twilio should use to call the `status_callback` URL. Can be `POST` or `GET` and the default is `POST`. */ - statusCallbackMethod?: string; - /** The maximum time, in seconds, that the MediaProcessor can run before automatically ends. The default value is 300 seconds, and the maximum value is 90000 seconds. Once this maximum duration is reached, Twilio will end the MediaProcessor, regardless of whether media is still streaming. */ - maxDuration?: number; -} -/** - * Options to pass to each - */ -export interface MediaProcessorListInstanceEachOptions { - /** The sort order of the list by `date_created`. Can be: `asc` (ascending) or `desc` (descending) with `desc` as the default. */ - order?: MediaProcessorOrder; - /** Status to filter by, with possible values `started`, `ended` or `failed`. */ - status?: MediaProcessorStatus; - /** How many resources to return in each list page. The default is 50, and the maximum is 1000. */ - pageSize?: number; - /** Function to process each record. If this and a positional callback are passed, this one will be used */ - callback?: ( - item: MediaProcessorInstance, - done: (err?: Error) => void - ) => void; - /** Function to be called upon completion of streaming */ - done?: Function; - /** Upper limit for the number of records to return. each() guarantees never to return more than limit. Default is no limit */ - limit?: number; -} - -/** - * Options to pass to list - */ -export interface MediaProcessorListInstanceOptions { - /** The sort order of the list by `date_created`. Can be: `asc` (ascending) or `desc` (descending) with `desc` as the default. */ - order?: MediaProcessorOrder; - /** Status to filter by, with possible values `started`, `ended` or `failed`. */ - status?: MediaProcessorStatus; - /** How many resources to return in each list page. The default is 50, and the maximum is 1000. */ - pageSize?: number; - /** Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit */ - limit?: number; -} - -/** - * Options to pass to page - */ -export interface MediaProcessorListInstancePageOptions { - /** The sort order of the list by `date_created`. Can be: `asc` (ascending) or `desc` (descending) with `desc` as the default. */ - order?: MediaProcessorOrder; - /** Status to filter by, with possible values `started`, `ended` or `failed`. */ - status?: MediaProcessorStatus; - /** How many resources to return in each list page. The default is 50, and the maximum is 1000. */ - pageSize?: number; - /** Page Number, this value is simply for client state */ - pageNumber?: number; - /** PageToken provided by the API */ - pageToken?: string; -} - -export interface MediaProcessorContext { - /** - * Fetch a MediaProcessorInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed MediaProcessorInstance - */ - fetch( - callback?: (error: Error | null, item?: MediaProcessorInstance) => any - ): Promise; - - /** - * Update a MediaProcessorInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed MediaProcessorInstance - */ - update( - params: MediaProcessorContextUpdateOptions, - callback?: (error: Error | null, item?: MediaProcessorInstance) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export interface MediaProcessorContextSolution { - sid: string; -} - -export class MediaProcessorContextImpl implements MediaProcessorContext { - protected _solution: MediaProcessorContextSolution; - protected _uri: string; - - constructor(protected _version: V1, sid: string) { - if (!isValidPathParam(sid)) { - throw new Error("Parameter 'sid' is not valid."); - } - - this._solution = { sid }; - this._uri = `/MediaProcessors/${sid}`; - } - - fetch( - callback?: (error: Error | null, item?: MediaProcessorInstance) => any - ): Promise { - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.fetch({ - uri: instance._uri, - method: "get", - }); - - operationPromise = operationPromise.then( - (payload) => - new MediaProcessorInstance( - operationVersion, - payload, - instance._solution.sid - ) - ); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback - ); - return operationPromise; - } - - update( - params: MediaProcessorContextUpdateOptions, - callback?: (error: Error | null, item?: MediaProcessorInstance) => any - ): Promise { - if (params === null || params === undefined) { - throw new Error('Required parameter "params" missing.'); - } - - if (params["status"] === null || params["status"] === undefined) { - throw new Error("Required parameter \"params['status']\" missing."); - } - - let data: any = {}; - - data["Status"] = params["status"]; - - const headers: any = {}; - headers["Content-Type"] = "application/x-www-form-urlencoded"; - - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.update({ - uri: instance._uri, - method: "post", - data, - headers, - }); - - operationPromise = operationPromise.then( - (payload) => - new MediaProcessorInstance( - operationVersion, - payload, - instance._solution.sid - ) - ); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback - ); - return operationPromise; - } - - /** - * Provide a user-friendly representation - * - * @returns Object - */ - toJSON() { - return this._solution; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -interface MediaProcessorPayload extends TwilioResponsePayload { - media_processors: MediaProcessorResource[]; -} - -interface MediaProcessorResource { - account_sid: string; - sid: string; - date_created: Date; - date_updated: Date; - extension: string; - extension_context: string; - status: MediaProcessorStatus; - url: string; - ended_reason: string; - status_callback: string; - status_callback_method: string; - max_duration: number; -} - -export class MediaProcessorInstance { - protected _solution: MediaProcessorContextSolution; - protected _context?: MediaProcessorContext; - - constructor( - protected _version: V1, - payload: MediaProcessorResource, - sid?: string - ) { - this.accountSid = payload.account_sid; - this.sid = payload.sid; - this.dateCreated = deserialize.iso8601DateTime(payload.date_created); - this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated); - this.extension = payload.extension; - this.extensionContext = payload.extension_context; - this.status = payload.status; - this.url = payload.url; - this.endedReason = payload.ended_reason; - this.statusCallback = payload.status_callback; - this.statusCallbackMethod = payload.status_callback_method; - this.maxDuration = deserialize.integer(payload.max_duration); - - this._solution = { sid: sid || this.sid }; - } - - /** - * The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the MediaProcessor resource. - */ - accountSid: string; - /** - * The unique string generated to identify the MediaProcessor resource. - */ - sid: string; - /** - * The date and time in GMT when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. - */ - dateCreated: Date; - /** - * The date and time in GMT when the resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. - */ - dateUpdated: Date; - /** - * The [Media Extension](/docs/live/media-extensions-overview) name or URL. Ex: `video-composer-v2` - */ - extension: string; - /** - * The context of the Media Extension, represented as a JSON dictionary. See the documentation for the specific [Media Extension](/docs/live/media-extensions-overview) you are using for more information about the context to send. - */ - extensionContext: string; - status: MediaProcessorStatus; - /** - * The absolute URL of the resource. - */ - url: string; - /** - * The reason why a MediaProcessor ended. When a MediaProcessor is in progress, will be `null`. When a MediaProcessor is completed, can be `ended-via-api`, `max-duration-exceeded`, `error-loading-extension`, `error-streaming-media` or `internal-service-error`. See [ended reasons](/docs/live/api/mediaprocessors#mediaprocessor-ended-reason-values) for more details. - */ - endedReason: string; - /** - * The URL to which Twilio will send asynchronous webhook requests for every MediaProcessor event. See [Status Callbacks](/docs/live/api/status-callbacks) for details. - */ - statusCallback: string; - /** - * The HTTP method Twilio should use to call the `status_callback` URL. Can be `POST` or `GET` and the default is `POST`. - */ - statusCallbackMethod: string; - /** - * The maximum time, in seconds, that the MediaProcessor can run before automatically ends. The default value is 300 seconds, and the maximum value is 90000 seconds. Once this maximum duration is reached, Twilio will end the MediaProcessor, regardless of whether media is still streaming. - */ - maxDuration: number; - - private get _proxy(): MediaProcessorContext { - this._context = - this._context || - new MediaProcessorContextImpl(this._version, this._solution.sid); - return this._context; - } - - /** - * Fetch a MediaProcessorInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed MediaProcessorInstance - */ - fetch( - callback?: (error: Error | null, item?: MediaProcessorInstance) => any - ): Promise { - return this._proxy.fetch(callback); - } - - /** - * Update a MediaProcessorInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed MediaProcessorInstance - */ - update( - params: MediaProcessorContextUpdateOptions, - callback?: (error: Error | null, item?: MediaProcessorInstance) => any - ): Promise; - - update( - params?: any, - callback?: (error: Error | null, item?: MediaProcessorInstance) => any - ): Promise { - return this._proxy.update(params, callback); - } - - /** - * Provide a user-friendly representation - * - * @returns Object - */ - toJSON() { - return { - accountSid: this.accountSid, - sid: this.sid, - dateCreated: this.dateCreated, - dateUpdated: this.dateUpdated, - extension: this.extension, - extensionContext: this.extensionContext, - status: this.status, - url: this.url, - endedReason: this.endedReason, - statusCallback: this.statusCallback, - statusCallbackMethod: this.statusCallbackMethod, - maxDuration: this.maxDuration, - }; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -export interface MediaProcessorSolution {} - -export interface MediaProcessorListInstance { - _version: V1; - _solution: MediaProcessorSolution; - _uri: string; - - (sid: string): MediaProcessorContext; - get(sid: string): MediaProcessorContext; - - /** - * Create a MediaProcessorInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed MediaProcessorInstance - */ - create( - params: MediaProcessorListInstanceCreateOptions, - callback?: (error: Error | null, item?: MediaProcessorInstance) => any - ): Promise; - - /** - * Streams MediaProcessorInstance records from the API. - * - * This operation lazily loads records as efficiently as possible until the limit - * is reached. - * - * The results are passed into the callback function, so this operation is memory - * efficient. - * - * If a function is passed as the first argument, it will be used as the callback - * function. - * - * @param { MediaProcessorListInstanceEachOptions } [params] - Options for request - * @param { function } [callback] - Function to process each record - */ - each( - callback?: ( - item: MediaProcessorInstance, - done: (err?: Error) => void - ) => void - ): void; - each( - params: MediaProcessorListInstanceEachOptions, - callback?: ( - item: MediaProcessorInstance, - done: (err?: Error) => void - ) => void - ): void; - /** - * Retrieve a single target page of MediaProcessorInstance records from the API. - * - * The request is executed immediately. - * - * @param { string } [targetUrl] - API-generated URL for the requested results page - * @param { function } [callback] - Callback to handle list of records - */ - getPage( - targetUrl: string, - callback?: (error: Error | null, items: MediaProcessorPage) => any - ): Promise; - /** - * Lists MediaProcessorInstance records from the API as a list. - * - * If a function is passed as the first argument, it will be used as the callback - * function. - * - * @param { MediaProcessorListInstanceOptions } [params] - Options for request - * @param { function } [callback] - Callback to handle list of records - */ - list( - callback?: (error: Error | null, items: MediaProcessorInstance[]) => any - ): Promise; - list( - params: MediaProcessorListInstanceOptions, - callback?: (error: Error | null, items: MediaProcessorInstance[]) => any - ): Promise; - /** - * Retrieve a single page of MediaProcessorInstance records from the API. - * - * The request is executed immediately. - * - * If a function is passed as the first argument, it will be used as the callback - * function. - * - * @param { MediaProcessorListInstancePageOptions } [params] - Options for request - * @param { function } [callback] - Callback to handle list of records - */ - page( - callback?: (error: Error | null, items: MediaProcessorPage) => any - ): Promise; - page( - params: MediaProcessorListInstancePageOptions, - callback?: (error: Error | null, items: MediaProcessorPage) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export function MediaProcessorListInstance( - version: V1 -): MediaProcessorListInstance { - const instance = ((sid) => instance.get(sid)) as MediaProcessorListInstance; - - instance.get = function get(sid): MediaProcessorContext { - return new MediaProcessorContextImpl(version, sid); - }; - - instance._version = version; - instance._solution = {}; - instance._uri = `/MediaProcessors`; - - instance.create = function create( - params: MediaProcessorListInstanceCreateOptions, - callback?: (error: Error | null, items: MediaProcessorInstance) => any - ): Promise { - if (params === null || params === undefined) { - throw new Error('Required parameter "params" missing.'); - } - - if (params["extension"] === null || params["extension"] === undefined) { - throw new Error("Required parameter \"params['extension']\" missing."); - } - - if ( - params["extensionContext"] === null || - params["extensionContext"] === undefined - ) { - throw new Error( - "Required parameter \"params['extensionContext']\" missing." - ); - } - - let data: any = {}; - - data["Extension"] = params["extension"]; - - data["ExtensionContext"] = params["extensionContext"]; - if (params["extensionEnvironment"] !== undefined) - data["ExtensionEnvironment"] = serialize.object( - params["extensionEnvironment"] - ); - if (params["statusCallback"] !== undefined) - data["StatusCallback"] = params["statusCallback"]; - if (params["statusCallbackMethod"] !== undefined) - data["StatusCallbackMethod"] = params["statusCallbackMethod"]; - if (params["maxDuration"] !== undefined) - data["MaxDuration"] = params["maxDuration"]; - - const headers: any = {}; - headers["Content-Type"] = "application/x-www-form-urlencoded"; - - let operationVersion = version, - operationPromise = operationVersion.create({ - uri: instance._uri, - method: "post", - data, - headers, - }); - - operationPromise = operationPromise.then( - (payload) => new MediaProcessorInstance(operationVersion, payload) - ); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback - ); - return operationPromise; - }; - - instance.page = function page( - params?: - | MediaProcessorListInstancePageOptions - | ((error: Error | null, items: MediaProcessorPage) => any), - callback?: (error: Error | null, items: MediaProcessorPage) => any - ): Promise { - if (params instanceof Function) { - callback = params; - params = {}; - } else { - params = params || {}; - } - - let data: any = {}; - - if (params["order"] !== undefined) data["Order"] = params["order"]; - if (params["status"] !== undefined) data["Status"] = params["status"]; - if (params["pageSize"] !== undefined) data["PageSize"] = params["pageSize"]; - - if (params.pageNumber !== undefined) data["Page"] = params.pageNumber; - if (params.pageToken !== undefined) data["PageToken"] = params.pageToken; - - const headers: any = {}; - - let operationVersion = version, - operationPromise = operationVersion.page({ - uri: instance._uri, - method: "get", - params: data, - headers, - }); - - operationPromise = operationPromise.then( - (payload) => - new MediaProcessorPage(operationVersion, payload, instance._solution) - ); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback - ); - return operationPromise; - }; - instance.each = instance._version.each; - instance.list = instance._version.list; - - instance.getPage = function getPage( - targetUrl: string, - callback?: (error: Error | null, items: MediaProcessorPage) => any - ): Promise { - const operationPromise = instance._version._domain.twilio.request({ - method: "get", - uri: targetUrl, - }); - - let pagePromise = operationPromise.then( - (payload) => - new MediaProcessorPage(instance._version, payload, instance._solution) - ); - pagePromise = instance._version.setPromiseCallback(pagePromise, callback); - return pagePromise; - }; - - instance.toJSON = function toJSON() { - return instance._solution; - }; - - instance[inspect.custom] = function inspectImpl( - _depth: any, - options: InspectOptions - ) { - return inspect(instance.toJSON(), options); - }; - - return instance; -} - -export class MediaProcessorPage extends Page< - V1, - MediaProcessorPayload, - MediaProcessorResource, - MediaProcessorInstance -> { - /** - * Initialize the MediaProcessorPage - * - * @param version - Version of the resource - * @param response - Response from the API - * @param solution - Path solution - */ - constructor( - version: V1, - response: Response, - solution: MediaProcessorSolution - ) { - super(version, response, solution); - } - - /** - * Build an instance of MediaProcessorInstance - * - * @param payload - Payload response from the API - */ - getInstance(payload: MediaProcessorResource): MediaProcessorInstance { - return new MediaProcessorInstance(this._version, payload); - } - - [inspect.custom](depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} diff --git a/src/rest/media/v1/mediaRecording.ts b/src/rest/media/v1/mediaRecording.ts deleted file mode 100644 index b316f2da4c..0000000000 --- a/src/rest/media/v1/mediaRecording.ts +++ /dev/null @@ -1,587 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Twilio - Media - * This is the public Twilio REST API. - * - * NOTE: This class is auto generated by OpenAPI Generator. - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { inspect, InspectOptions } from "util"; -import Page, { TwilioResponsePayload } from "../../../base/Page"; -import Response from "../../../http/response"; -import V1 from "../V1"; -const deserialize = require("../../../base/deserialize"); -const serialize = require("../../../base/serialize"); -import { isValidPathParam } from "../../../base/utility"; - -export type MediaRecordingFormat = "mp4" | "webm"; - -export type MediaRecordingOrder = "asc" | "desc"; - -export type MediaRecordingStatus = - | "processing" - | "completed" - | "deleted" - | "failed"; - -/** - * Options to pass to each - */ -export interface MediaRecordingListInstanceEachOptions { - /** The sort order of the list by `date_created`. Can be: `asc` (ascending) or `desc` (descending) with `desc` as the default. */ - order?: MediaRecordingOrder; - /** Status to filter by, with possible values `processing`, `completed`, `deleted`, or `failed`. */ - status?: MediaRecordingStatus; - /** SID of a MediaProcessor to filter by. */ - processorSid?: string; - /** SID of a MediaRecording source to filter by. */ - sourceSid?: string; - /** How many resources to return in each list page. The default is 50, and the maximum is 1000. */ - pageSize?: number; - /** Function to process each record. If this and a positional callback are passed, this one will be used */ - callback?: ( - item: MediaRecordingInstance, - done: (err?: Error) => void - ) => void; - /** Function to be called upon completion of streaming */ - done?: Function; - /** Upper limit for the number of records to return. each() guarantees never to return more than limit. Default is no limit */ - limit?: number; -} - -/** - * Options to pass to list - */ -export interface MediaRecordingListInstanceOptions { - /** The sort order of the list by `date_created`. Can be: `asc` (ascending) or `desc` (descending) with `desc` as the default. */ - order?: MediaRecordingOrder; - /** Status to filter by, with possible values `processing`, `completed`, `deleted`, or `failed`. */ - status?: MediaRecordingStatus; - /** SID of a MediaProcessor to filter by. */ - processorSid?: string; - /** SID of a MediaRecording source to filter by. */ - sourceSid?: string; - /** How many resources to return in each list page. The default is 50, and the maximum is 1000. */ - pageSize?: number; - /** Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit */ - limit?: number; -} - -/** - * Options to pass to page - */ -export interface MediaRecordingListInstancePageOptions { - /** The sort order of the list by `date_created`. Can be: `asc` (ascending) or `desc` (descending) with `desc` as the default. */ - order?: MediaRecordingOrder; - /** Status to filter by, with possible values `processing`, `completed`, `deleted`, or `failed`. */ - status?: MediaRecordingStatus; - /** SID of a MediaProcessor to filter by. */ - processorSid?: string; - /** SID of a MediaRecording source to filter by. */ - sourceSid?: string; - /** How many resources to return in each list page. The default is 50, and the maximum is 1000. */ - pageSize?: number; - /** Page Number, this value is simply for client state */ - pageNumber?: number; - /** PageToken provided by the API */ - pageToken?: string; -} - -export interface MediaRecordingContext { - /** - * Remove a MediaRecordingInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed boolean - */ - remove( - callback?: (error: Error | null, item?: boolean) => any - ): Promise; - - /** - * Fetch a MediaRecordingInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed MediaRecordingInstance - */ - fetch( - callback?: (error: Error | null, item?: MediaRecordingInstance) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export interface MediaRecordingContextSolution { - sid: string; -} - -export class MediaRecordingContextImpl implements MediaRecordingContext { - protected _solution: MediaRecordingContextSolution; - protected _uri: string; - - constructor(protected _version: V1, sid: string) { - if (!isValidPathParam(sid)) { - throw new Error("Parameter 'sid' is not valid."); - } - - this._solution = { sid }; - this._uri = `/MediaRecordings/${sid}`; - } - - remove( - callback?: (error: Error | null, item?: boolean) => any - ): Promise { - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.remove({ - uri: instance._uri, - method: "delete", - }); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback - ); - return operationPromise; - } - - fetch( - callback?: (error: Error | null, item?: MediaRecordingInstance) => any - ): Promise { - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.fetch({ - uri: instance._uri, - method: "get", - }); - - operationPromise = operationPromise.then( - (payload) => - new MediaRecordingInstance( - operationVersion, - payload, - instance._solution.sid - ) - ); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback - ); - return operationPromise; - } - - /** - * Provide a user-friendly representation - * - * @returns Object - */ - toJSON() { - return this._solution; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -interface MediaRecordingPayload extends TwilioResponsePayload { - media_recordings: MediaRecordingResource[]; -} - -interface MediaRecordingResource { - account_sid: string; - date_created: Date; - date_updated: Date; - duration: number; - format: MediaRecordingFormat; - links: Record; - processor_sid: string; - resolution: string; - source_sid: string; - sid: string; - media_size: number; - status: MediaRecordingStatus; - status_callback: string; - status_callback_method: string; - url: string; -} - -export class MediaRecordingInstance { - protected _solution: MediaRecordingContextSolution; - protected _context?: MediaRecordingContext; - - constructor( - protected _version: V1, - payload: MediaRecordingResource, - sid?: string - ) { - this.accountSid = payload.account_sid; - this.dateCreated = deserialize.iso8601DateTime(payload.date_created); - this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated); - this.duration = deserialize.integer(payload.duration); - this.format = payload.format; - this.links = payload.links; - this.processorSid = payload.processor_sid; - this.resolution = payload.resolution; - this.sourceSid = payload.source_sid; - this.sid = payload.sid; - this.mediaSize = payload.media_size; - this.status = payload.status; - this.statusCallback = payload.status_callback; - this.statusCallbackMethod = payload.status_callback_method; - this.url = payload.url; - - this._solution = { sid: sid || this.sid }; - } - - /** - * The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the MediaRecording resource. - */ - accountSid: string; - /** - * The date and time in GMT when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. - */ - dateCreated: Date; - /** - * The date and time in GMT when the resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. - */ - dateUpdated: Date; - /** - * The duration of the MediaRecording in seconds. - */ - duration: number; - format: MediaRecordingFormat; - /** - * The URLs of related resources. - */ - links: Record; - /** - * The SID of the MediaProcessor resource which produced the MediaRecording. - */ - processorSid: string; - /** - * The dimensions of the video image in pixels expressed as columns (width) and rows (height). - */ - resolution: string; - /** - * The SID of the resource that generated the original media track(s) of the MediaRecording. - */ - sourceSid: string; - /** - * The unique string generated to identify the MediaRecording resource. - */ - sid: string; - /** - * The size of the recording media in bytes. - */ - mediaSize: number; - status: MediaRecordingStatus; - /** - * The URL to which Twilio will send asynchronous webhook requests for every MediaRecording event. See [Status Callbacks](/docs/live/api/status-callbacks) for more details. - */ - statusCallback: string; - /** - * The HTTP method Twilio should use to call the `status_callback` URL. Can be `POST` or `GET` and the default is `POST`. - */ - statusCallbackMethod: string; - /** - * The absolute URL of the resource. - */ - url: string; - - private get _proxy(): MediaRecordingContext { - this._context = - this._context || - new MediaRecordingContextImpl(this._version, this._solution.sid); - return this._context; - } - - /** - * Remove a MediaRecordingInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed boolean - */ - remove( - callback?: (error: Error | null, item?: boolean) => any - ): Promise { - return this._proxy.remove(callback); - } - - /** - * Fetch a MediaRecordingInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed MediaRecordingInstance - */ - fetch( - callback?: (error: Error | null, item?: MediaRecordingInstance) => any - ): Promise { - return this._proxy.fetch(callback); - } - - /** - * Provide a user-friendly representation - * - * @returns Object - */ - toJSON() { - return { - accountSid: this.accountSid, - dateCreated: this.dateCreated, - dateUpdated: this.dateUpdated, - duration: this.duration, - format: this.format, - links: this.links, - processorSid: this.processorSid, - resolution: this.resolution, - sourceSid: this.sourceSid, - sid: this.sid, - mediaSize: this.mediaSize, - status: this.status, - statusCallback: this.statusCallback, - statusCallbackMethod: this.statusCallbackMethod, - url: this.url, - }; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -export interface MediaRecordingSolution {} - -export interface MediaRecordingListInstance { - _version: V1; - _solution: MediaRecordingSolution; - _uri: string; - - (sid: string): MediaRecordingContext; - get(sid: string): MediaRecordingContext; - - /** - * Streams MediaRecordingInstance records from the API. - * - * This operation lazily loads records as efficiently as possible until the limit - * is reached. - * - * The results are passed into the callback function, so this operation is memory - * efficient. - * - * If a function is passed as the first argument, it will be used as the callback - * function. - * - * @param { MediaRecordingListInstanceEachOptions } [params] - Options for request - * @param { function } [callback] - Function to process each record - */ - each( - callback?: ( - item: MediaRecordingInstance, - done: (err?: Error) => void - ) => void - ): void; - each( - params: MediaRecordingListInstanceEachOptions, - callback?: ( - item: MediaRecordingInstance, - done: (err?: Error) => void - ) => void - ): void; - /** - * Retrieve a single target page of MediaRecordingInstance records from the API. - * - * The request is executed immediately. - * - * @param { string } [targetUrl] - API-generated URL for the requested results page - * @param { function } [callback] - Callback to handle list of records - */ - getPage( - targetUrl: string, - callback?: (error: Error | null, items: MediaRecordingPage) => any - ): Promise; - /** - * Lists MediaRecordingInstance records from the API as a list. - * - * If a function is passed as the first argument, it will be used as the callback - * function. - * - * @param { MediaRecordingListInstanceOptions } [params] - Options for request - * @param { function } [callback] - Callback to handle list of records - */ - list( - callback?: (error: Error | null, items: MediaRecordingInstance[]) => any - ): Promise; - list( - params: MediaRecordingListInstanceOptions, - callback?: (error: Error | null, items: MediaRecordingInstance[]) => any - ): Promise; - /** - * Retrieve a single page of MediaRecordingInstance records from the API. - * - * The request is executed immediately. - * - * If a function is passed as the first argument, it will be used as the callback - * function. - * - * @param { MediaRecordingListInstancePageOptions } [params] - Options for request - * @param { function } [callback] - Callback to handle list of records - */ - page( - callback?: (error: Error | null, items: MediaRecordingPage) => any - ): Promise; - page( - params: MediaRecordingListInstancePageOptions, - callback?: (error: Error | null, items: MediaRecordingPage) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export function MediaRecordingListInstance( - version: V1 -): MediaRecordingListInstance { - const instance = ((sid) => instance.get(sid)) as MediaRecordingListInstance; - - instance.get = function get(sid): MediaRecordingContext { - return new MediaRecordingContextImpl(version, sid); - }; - - instance._version = version; - instance._solution = {}; - instance._uri = `/MediaRecordings`; - - instance.page = function page( - params?: - | MediaRecordingListInstancePageOptions - | ((error: Error | null, items: MediaRecordingPage) => any), - callback?: (error: Error | null, items: MediaRecordingPage) => any - ): Promise { - if (params instanceof Function) { - callback = params; - params = {}; - } else { - params = params || {}; - } - - let data: any = {}; - - if (params["order"] !== undefined) data["Order"] = params["order"]; - if (params["status"] !== undefined) data["Status"] = params["status"]; - if (params["processorSid"] !== undefined) - data["ProcessorSid"] = params["processorSid"]; - if (params["sourceSid"] !== undefined) - data["SourceSid"] = params["sourceSid"]; - if (params["pageSize"] !== undefined) data["PageSize"] = params["pageSize"]; - - if (params.pageNumber !== undefined) data["Page"] = params.pageNumber; - if (params.pageToken !== undefined) data["PageToken"] = params.pageToken; - - const headers: any = {}; - - let operationVersion = version, - operationPromise = operationVersion.page({ - uri: instance._uri, - method: "get", - params: data, - headers, - }); - - operationPromise = operationPromise.then( - (payload) => - new MediaRecordingPage(operationVersion, payload, instance._solution) - ); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback - ); - return operationPromise; - }; - instance.each = instance._version.each; - instance.list = instance._version.list; - - instance.getPage = function getPage( - targetUrl: string, - callback?: (error: Error | null, items: MediaRecordingPage) => any - ): Promise { - const operationPromise = instance._version._domain.twilio.request({ - method: "get", - uri: targetUrl, - }); - - let pagePromise = operationPromise.then( - (payload) => - new MediaRecordingPage(instance._version, payload, instance._solution) - ); - pagePromise = instance._version.setPromiseCallback(pagePromise, callback); - return pagePromise; - }; - - instance.toJSON = function toJSON() { - return instance._solution; - }; - - instance[inspect.custom] = function inspectImpl( - _depth: any, - options: InspectOptions - ) { - return inspect(instance.toJSON(), options); - }; - - return instance; -} - -export class MediaRecordingPage extends Page< - V1, - MediaRecordingPayload, - MediaRecordingResource, - MediaRecordingInstance -> { - /** - * Initialize the MediaRecordingPage - * - * @param version - Version of the resource - * @param response - Response from the API - * @param solution - Path solution - */ - constructor( - version: V1, - response: Response, - solution: MediaRecordingSolution - ) { - super(version, response, solution); - } - - /** - * Build an instance of MediaRecordingInstance - * - * @param payload - Payload response from the API - */ - getInstance(payload: MediaRecordingResource): MediaRecordingInstance { - return new MediaRecordingInstance(this._version, payload); - } - - [inspect.custom](depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} diff --git a/src/rest/media/v1/playerStreamer.ts b/src/rest/media/v1/playerStreamer.ts deleted file mode 100644 index c55acb044e..0000000000 --- a/src/rest/media/v1/playerStreamer.ts +++ /dev/null @@ -1,697 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Twilio - Media - * This is the public Twilio REST API. - * - * NOTE: This class is auto generated by OpenAPI Generator. - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { inspect, InspectOptions } from "util"; -import Page, { TwilioResponsePayload } from "../../../base/Page"; -import Response from "../../../http/response"; -import V1 from "../V1"; -const deserialize = require("../../../base/deserialize"); -const serialize = require("../../../base/serialize"); -import { isValidPathParam } from "../../../base/utility"; -import { PlaybackGrantListInstance } from "./playerStreamer/playbackGrant"; - -export type PlayerStreamerEndedReason = - | "ended-via-api" - | "max-duration-exceeded" - | "stream-disconnected-by-source" - | "unexpected-failure"; - -export type PlayerStreamerOrder = "asc" | "desc"; - -export type PlayerStreamerStatus = "created" | "started" | "ended" | "failed"; - -export type PlayerStreamerUpdateStatus = "ended"; - -/** - * Options to pass to update a PlayerStreamerInstance - */ -export interface PlayerStreamerContextUpdateOptions { - /** */ - status: PlayerStreamerUpdateStatus; -} - -/** - * Options to pass to create a PlayerStreamerInstance - */ -export interface PlayerStreamerListInstanceCreateOptions { - /** Specifies whether the PlayerStreamer is configured to stream video. Defaults to `true`. */ - video?: boolean; - /** The URL to which Twilio will send asynchronous webhook requests for every PlayerStreamer event. See [Status Callbacks](/docs/live/api/status-callbacks) for more details. */ - statusCallback?: string; - /** The HTTP method Twilio should use to call the `status_callback` URL. Can be `POST` or `GET` and the default is `POST`. */ - statusCallbackMethod?: string; - /** The maximum time, in seconds, that the PlayerStreamer is active (`created` or `started`) before automatically ends. The default value is 300 seconds, and the maximum value is 90000 seconds. Once this maximum duration is reached, Twilio will end the PlayerStreamer, regardless of whether media is still streaming. */ - maxDuration?: number; -} -/** - * Options to pass to each - */ -export interface PlayerStreamerListInstanceEachOptions { - /** The sort order of the list by `date_created`. Can be: `asc` (ascending) or `desc` (descending) with `desc` as the default. */ - order?: PlayerStreamerOrder; - /** Status to filter by, with possible values `created`, `started`, `ended`, or `failed`. */ - status?: PlayerStreamerStatus; - /** How many resources to return in each list page. The default is 50, and the maximum is 1000. */ - pageSize?: number; - /** Function to process each record. If this and a positional callback are passed, this one will be used */ - callback?: ( - item: PlayerStreamerInstance, - done: (err?: Error) => void - ) => void; - /** Function to be called upon completion of streaming */ - done?: Function; - /** Upper limit for the number of records to return. each() guarantees never to return more than limit. Default is no limit */ - limit?: number; -} - -/** - * Options to pass to list - */ -export interface PlayerStreamerListInstanceOptions { - /** The sort order of the list by `date_created`. Can be: `asc` (ascending) or `desc` (descending) with `desc` as the default. */ - order?: PlayerStreamerOrder; - /** Status to filter by, with possible values `created`, `started`, `ended`, or `failed`. */ - status?: PlayerStreamerStatus; - /** How many resources to return in each list page. The default is 50, and the maximum is 1000. */ - pageSize?: number; - /** Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit */ - limit?: number; -} - -/** - * Options to pass to page - */ -export interface PlayerStreamerListInstancePageOptions { - /** The sort order of the list by `date_created`. Can be: `asc` (ascending) or `desc` (descending) with `desc` as the default. */ - order?: PlayerStreamerOrder; - /** Status to filter by, with possible values `created`, `started`, `ended`, or `failed`. */ - status?: PlayerStreamerStatus; - /** How many resources to return in each list page. The default is 50, and the maximum is 1000. */ - pageSize?: number; - /** Page Number, this value is simply for client state */ - pageNumber?: number; - /** PageToken provided by the API */ - pageToken?: string; -} - -export interface PlayerStreamerContext { - playbackGrant: PlaybackGrantListInstance; - - /** - * Fetch a PlayerStreamerInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed PlayerStreamerInstance - */ - fetch( - callback?: (error: Error | null, item?: PlayerStreamerInstance) => any - ): Promise; - - /** - * Update a PlayerStreamerInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed PlayerStreamerInstance - */ - update( - params: PlayerStreamerContextUpdateOptions, - callback?: (error: Error | null, item?: PlayerStreamerInstance) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export interface PlayerStreamerContextSolution { - sid: string; -} - -export class PlayerStreamerContextImpl implements PlayerStreamerContext { - protected _solution: PlayerStreamerContextSolution; - protected _uri: string; - - protected _playbackGrant?: PlaybackGrantListInstance; - - constructor(protected _version: V1, sid: string) { - if (!isValidPathParam(sid)) { - throw new Error("Parameter 'sid' is not valid."); - } - - this._solution = { sid }; - this._uri = `/PlayerStreamers/${sid}`; - } - - get playbackGrant(): PlaybackGrantListInstance { - this._playbackGrant = - this._playbackGrant || - PlaybackGrantListInstance(this._version, this._solution.sid); - return this._playbackGrant; - } - - fetch( - callback?: (error: Error | null, item?: PlayerStreamerInstance) => any - ): Promise { - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.fetch({ - uri: instance._uri, - method: "get", - }); - - operationPromise = operationPromise.then( - (payload) => - new PlayerStreamerInstance( - operationVersion, - payload, - instance._solution.sid - ) - ); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback - ); - return operationPromise; - } - - update( - params: PlayerStreamerContextUpdateOptions, - callback?: (error: Error | null, item?: PlayerStreamerInstance) => any - ): Promise { - if (params === null || params === undefined) { - throw new Error('Required parameter "params" missing.'); - } - - if (params["status"] === null || params["status"] === undefined) { - throw new Error("Required parameter \"params['status']\" missing."); - } - - let data: any = {}; - - data["Status"] = params["status"]; - - const headers: any = {}; - headers["Content-Type"] = "application/x-www-form-urlencoded"; - - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.update({ - uri: instance._uri, - method: "post", - data, - headers, - }); - - operationPromise = operationPromise.then( - (payload) => - new PlayerStreamerInstance( - operationVersion, - payload, - instance._solution.sid - ) - ); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback - ); - return operationPromise; - } - - /** - * Provide a user-friendly representation - * - * @returns Object - */ - toJSON() { - return this._solution; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -interface PlayerStreamerPayload extends TwilioResponsePayload { - player_streamers: PlayerStreamerResource[]; -} - -interface PlayerStreamerResource { - account_sid: string; - date_created: Date; - date_updated: Date; - video: boolean; - links: Record; - sid: string; - status: PlayerStreamerStatus; - url: string; - status_callback: string; - status_callback_method: string; - ended_reason: PlayerStreamerEndedReason; - max_duration: number; -} - -export class PlayerStreamerInstance { - protected _solution: PlayerStreamerContextSolution; - protected _context?: PlayerStreamerContext; - - constructor( - protected _version: V1, - payload: PlayerStreamerResource, - sid?: string - ) { - this.accountSid = payload.account_sid; - this.dateCreated = deserialize.iso8601DateTime(payload.date_created); - this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated); - this.video = payload.video; - this.links = payload.links; - this.sid = payload.sid; - this.status = payload.status; - this.url = payload.url; - this.statusCallback = payload.status_callback; - this.statusCallbackMethod = payload.status_callback_method; - this.endedReason = payload.ended_reason; - this.maxDuration = deserialize.integer(payload.max_duration); - - this._solution = { sid: sid || this.sid }; - } - - /** - * The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the PlayerStreamer resource. - */ - accountSid: string; - /** - * The date and time in GMT when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. - */ - dateCreated: Date; - /** - * The date and time in GMT when the resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. - */ - dateUpdated: Date; - /** - * Specifies whether the PlayerStreamer is configured to stream video. Defaults to `true`. - */ - video: boolean; - /** - * The URLs of related resources. - */ - links: Record; - /** - * The unique string generated to identify the PlayerStreamer resource. - */ - sid: string; - status: PlayerStreamerStatus; - /** - * The absolute URL of the resource. - */ - url: string; - /** - * The URL to which Twilio will send asynchronous webhook requests for every PlayerStreamer event. See [Status Callbacks](/docs/live/api/status-callbacks) for more details. - */ - statusCallback: string; - /** - * The HTTP method Twilio should use to call the `status_callback` URL. Can be `POST` or `GET` and the default is `POST`. - */ - statusCallbackMethod: string; - endedReason: PlayerStreamerEndedReason; - /** - * The maximum time, in seconds, that the PlayerStreamer is active (`created` or `started`) before automatically ends. The default value is 300 seconds, and the maximum value is 90000 seconds. Once this maximum duration is reached, Twilio will end the PlayerStreamer, regardless of whether media is still streaming. - */ - maxDuration: number; - - private get _proxy(): PlayerStreamerContext { - this._context = - this._context || - new PlayerStreamerContextImpl(this._version, this._solution.sid); - return this._context; - } - - /** - * Fetch a PlayerStreamerInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed PlayerStreamerInstance - */ - fetch( - callback?: (error: Error | null, item?: PlayerStreamerInstance) => any - ): Promise { - return this._proxy.fetch(callback); - } - - /** - * Update a PlayerStreamerInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed PlayerStreamerInstance - */ - update( - params: PlayerStreamerContextUpdateOptions, - callback?: (error: Error | null, item?: PlayerStreamerInstance) => any - ): Promise; - - update( - params?: any, - callback?: (error: Error | null, item?: PlayerStreamerInstance) => any - ): Promise { - return this._proxy.update(params, callback); - } - - /** - * Access the playbackGrant. - */ - playbackGrant(): PlaybackGrantListInstance { - return this._proxy.playbackGrant; - } - - /** - * Provide a user-friendly representation - * - * @returns Object - */ - toJSON() { - return { - accountSid: this.accountSid, - dateCreated: this.dateCreated, - dateUpdated: this.dateUpdated, - video: this.video, - links: this.links, - sid: this.sid, - status: this.status, - url: this.url, - statusCallback: this.statusCallback, - statusCallbackMethod: this.statusCallbackMethod, - endedReason: this.endedReason, - maxDuration: this.maxDuration, - }; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -export interface PlayerStreamerSolution {} - -export interface PlayerStreamerListInstance { - _version: V1; - _solution: PlayerStreamerSolution; - _uri: string; - - (sid: string): PlayerStreamerContext; - get(sid: string): PlayerStreamerContext; - - /** - * Create a PlayerStreamerInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed PlayerStreamerInstance - */ - create( - callback?: (error: Error | null, item?: PlayerStreamerInstance) => any - ): Promise; - /** - * Create a PlayerStreamerInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed PlayerStreamerInstance - */ - create( - params: PlayerStreamerListInstanceCreateOptions, - callback?: (error: Error | null, item?: PlayerStreamerInstance) => any - ): Promise; - - /** - * Streams PlayerStreamerInstance records from the API. - * - * This operation lazily loads records as efficiently as possible until the limit - * is reached. - * - * The results are passed into the callback function, so this operation is memory - * efficient. - * - * If a function is passed as the first argument, it will be used as the callback - * function. - * - * @param { PlayerStreamerListInstanceEachOptions } [params] - Options for request - * @param { function } [callback] - Function to process each record - */ - each( - callback?: ( - item: PlayerStreamerInstance, - done: (err?: Error) => void - ) => void - ): void; - each( - params: PlayerStreamerListInstanceEachOptions, - callback?: ( - item: PlayerStreamerInstance, - done: (err?: Error) => void - ) => void - ): void; - /** - * Retrieve a single target page of PlayerStreamerInstance records from the API. - * - * The request is executed immediately. - * - * @param { string } [targetUrl] - API-generated URL for the requested results page - * @param { function } [callback] - Callback to handle list of records - */ - getPage( - targetUrl: string, - callback?: (error: Error | null, items: PlayerStreamerPage) => any - ): Promise; - /** - * Lists PlayerStreamerInstance records from the API as a list. - * - * If a function is passed as the first argument, it will be used as the callback - * function. - * - * @param { PlayerStreamerListInstanceOptions } [params] - Options for request - * @param { function } [callback] - Callback to handle list of records - */ - list( - callback?: (error: Error | null, items: PlayerStreamerInstance[]) => any - ): Promise; - list( - params: PlayerStreamerListInstanceOptions, - callback?: (error: Error | null, items: PlayerStreamerInstance[]) => any - ): Promise; - /** - * Retrieve a single page of PlayerStreamerInstance records from the API. - * - * The request is executed immediately. - * - * If a function is passed as the first argument, it will be used as the callback - * function. - * - * @param { PlayerStreamerListInstancePageOptions } [params] - Options for request - * @param { function } [callback] - Callback to handle list of records - */ - page( - callback?: (error: Error | null, items: PlayerStreamerPage) => any - ): Promise; - page( - params: PlayerStreamerListInstancePageOptions, - callback?: (error: Error | null, items: PlayerStreamerPage) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export function PlayerStreamerListInstance( - version: V1 -): PlayerStreamerListInstance { - const instance = ((sid) => instance.get(sid)) as PlayerStreamerListInstance; - - instance.get = function get(sid): PlayerStreamerContext { - return new PlayerStreamerContextImpl(version, sid); - }; - - instance._version = version; - instance._solution = {}; - instance._uri = `/PlayerStreamers`; - - instance.create = function create( - params?: - | PlayerStreamerListInstanceCreateOptions - | ((error: Error | null, items: PlayerStreamerInstance) => any), - callback?: (error: Error | null, items: PlayerStreamerInstance) => any - ): Promise { - if (params instanceof Function) { - callback = params; - params = {}; - } else { - params = params || {}; - } - - let data: any = {}; - - if (params["video"] !== undefined) - data["Video"] = serialize.bool(params["video"]); - if (params["statusCallback"] !== undefined) - data["StatusCallback"] = params["statusCallback"]; - if (params["statusCallbackMethod"] !== undefined) - data["StatusCallbackMethod"] = params["statusCallbackMethod"]; - if (params["maxDuration"] !== undefined) - data["MaxDuration"] = params["maxDuration"]; - - const headers: any = {}; - headers["Content-Type"] = "application/x-www-form-urlencoded"; - - let operationVersion = version, - operationPromise = operationVersion.create({ - uri: instance._uri, - method: "post", - data, - headers, - }); - - operationPromise = operationPromise.then( - (payload) => new PlayerStreamerInstance(operationVersion, payload) - ); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback - ); - return operationPromise; - }; - - instance.page = function page( - params?: - | PlayerStreamerListInstancePageOptions - | ((error: Error | null, items: PlayerStreamerPage) => any), - callback?: (error: Error | null, items: PlayerStreamerPage) => any - ): Promise { - if (params instanceof Function) { - callback = params; - params = {}; - } else { - params = params || {}; - } - - let data: any = {}; - - if (params["order"] !== undefined) data["Order"] = params["order"]; - if (params["status"] !== undefined) data["Status"] = params["status"]; - if (params["pageSize"] !== undefined) data["PageSize"] = params["pageSize"]; - - if (params.pageNumber !== undefined) data["Page"] = params.pageNumber; - if (params.pageToken !== undefined) data["PageToken"] = params.pageToken; - - const headers: any = {}; - - let operationVersion = version, - operationPromise = operationVersion.page({ - uri: instance._uri, - method: "get", - params: data, - headers, - }); - - operationPromise = operationPromise.then( - (payload) => - new PlayerStreamerPage(operationVersion, payload, instance._solution) - ); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback - ); - return operationPromise; - }; - instance.each = instance._version.each; - instance.list = instance._version.list; - - instance.getPage = function getPage( - targetUrl: string, - callback?: (error: Error | null, items: PlayerStreamerPage) => any - ): Promise { - const operationPromise = instance._version._domain.twilio.request({ - method: "get", - uri: targetUrl, - }); - - let pagePromise = operationPromise.then( - (payload) => - new PlayerStreamerPage(instance._version, payload, instance._solution) - ); - pagePromise = instance._version.setPromiseCallback(pagePromise, callback); - return pagePromise; - }; - - instance.toJSON = function toJSON() { - return instance._solution; - }; - - instance[inspect.custom] = function inspectImpl( - _depth: any, - options: InspectOptions - ) { - return inspect(instance.toJSON(), options); - }; - - return instance; -} - -export class PlayerStreamerPage extends Page< - V1, - PlayerStreamerPayload, - PlayerStreamerResource, - PlayerStreamerInstance -> { - /** - * Initialize the PlayerStreamerPage - * - * @param version - Version of the resource - * @param response - Response from the API - * @param solution - Path solution - */ - constructor( - version: V1, - response: Response, - solution: PlayerStreamerSolution - ) { - super(version, response, solution); - } - - /** - * Build an instance of PlayerStreamerInstance - * - * @param payload - Payload response from the API - */ - getInstance(payload: PlayerStreamerResource): PlayerStreamerInstance { - return new PlayerStreamerInstance(this._version, payload); - } - - [inspect.custom](depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} diff --git a/src/rest/media/v1/playerStreamer/playbackGrant.ts b/src/rest/media/v1/playerStreamer/playbackGrant.ts deleted file mode 100644 index f9f8fd3ad1..0000000000 --- a/src/rest/media/v1/playerStreamer/playbackGrant.ts +++ /dev/null @@ -1,345 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Twilio - Media - * This is the public Twilio REST API. - * - * NOTE: This class is auto generated by OpenAPI Generator. - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { inspect, InspectOptions } from "util"; -import V1 from "../../V1"; -const deserialize = require("../../../../base/deserialize"); -const serialize = require("../../../../base/serialize"); -import { isValidPathParam } from "../../../../base/utility"; - -/** - * Options to pass to create a PlaybackGrantInstance - */ -export interface PlaybackGrantContextCreateOptions { - /** The time to live of the PlaybackGrant. Default value is 15 seconds. Maximum value is 60 seconds. */ - ttl?: number; - /** The full origin URL where the livestream can be streamed. If this is not provided, it can be streamed from any domain. */ - accessControlAllowOrigin?: string; -} - -export interface PlaybackGrantContext { - /** - * Create a PlaybackGrantInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed PlaybackGrantInstance - */ - create( - callback?: (error: Error | null, item?: PlaybackGrantInstance) => any - ): Promise; - /** - * Create a PlaybackGrantInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed PlaybackGrantInstance - */ - create( - params: PlaybackGrantContextCreateOptions, - callback?: (error: Error | null, item?: PlaybackGrantInstance) => any - ): Promise; - - /** - * Fetch a PlaybackGrantInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed PlaybackGrantInstance - */ - fetch( - callback?: (error: Error | null, item?: PlaybackGrantInstance) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export interface PlaybackGrantContextSolution { - sid: string; -} - -export class PlaybackGrantContextImpl implements PlaybackGrantContext { - protected _solution: PlaybackGrantContextSolution; - protected _uri: string; - - constructor(protected _version: V1, sid: string) { - if (!isValidPathParam(sid)) { - throw new Error("Parameter 'sid' is not valid."); - } - - this._solution = { sid }; - this._uri = `/PlayerStreamers/${sid}/PlaybackGrant`; - } - - create( - params?: - | PlaybackGrantContextCreateOptions - | ((error: Error | null, item?: PlaybackGrantInstance) => any), - callback?: (error: Error | null, item?: PlaybackGrantInstance) => any - ): Promise { - if (params instanceof Function) { - callback = params; - params = {}; - } else { - params = params || {}; - } - - let data: any = {}; - - if (params["ttl"] !== undefined) data["Ttl"] = params["ttl"]; - if (params["accessControlAllowOrigin"] !== undefined) - data["AccessControlAllowOrigin"] = params["accessControlAllowOrigin"]; - - const headers: any = {}; - headers["Content-Type"] = "application/x-www-form-urlencoded"; - - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.create({ - uri: instance._uri, - method: "post", - data, - headers, - }); - - operationPromise = operationPromise.then( - (payload) => - new PlaybackGrantInstance( - operationVersion, - payload, - instance._solution.sid - ) - ); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback - ); - return operationPromise; - } - - fetch( - callback?: (error: Error | null, item?: PlaybackGrantInstance) => any - ): Promise { - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.fetch({ - uri: instance._uri, - method: "get", - }); - - operationPromise = operationPromise.then( - (payload) => - new PlaybackGrantInstance( - operationVersion, - payload, - instance._solution.sid - ) - ); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback - ); - return operationPromise; - } - - /** - * Provide a user-friendly representation - * - * @returns Object - */ - toJSON() { - return this._solution; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -interface PlaybackGrantPayload extends PlaybackGrantResource {} - -interface PlaybackGrantResource { - sid: string; - url: string; - account_sid: string; - date_created: Date; - grant: any; -} - -export class PlaybackGrantInstance { - protected _solution: PlaybackGrantContextSolution; - protected _context?: PlaybackGrantContext; - - constructor( - protected _version: V1, - payload: PlaybackGrantResource, - sid: string - ) { - this.sid = payload.sid; - this.url = payload.url; - this.accountSid = payload.account_sid; - this.dateCreated = deserialize.iso8601DateTime(payload.date_created); - this.grant = payload.grant; - - this._solution = { sid }; - } - - /** - * The unique string generated to identify the PlayerStreamer resource that this PlaybackGrant authorizes views for. - */ - sid: string; - /** - * The absolute URL of the resource. - */ - url: string; - /** - * The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created this resource. - */ - accountSid: string; - /** - * The date and time in GMT when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. - */ - dateCreated: Date; - /** - * The grant that authorizes the player sdk to connect to the livestream - */ - grant: any; - - private get _proxy(): PlaybackGrantContext { - this._context = - this._context || - new PlaybackGrantContextImpl(this._version, this._solution.sid); - return this._context; - } - - /** - * Create a PlaybackGrantInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed PlaybackGrantInstance - */ - create( - callback?: (error: Error | null, item?: PlaybackGrantInstance) => any - ): Promise; - /** - * Create a PlaybackGrantInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed PlaybackGrantInstance - */ - create( - params: PlaybackGrantContextCreateOptions, - callback?: (error: Error | null, item?: PlaybackGrantInstance) => any - ): Promise; - - create( - params?: any, - callback?: (error: Error | null, item?: PlaybackGrantInstance) => any - ): Promise { - return this._proxy.create(params, callback); - } - - /** - * Fetch a PlaybackGrantInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed PlaybackGrantInstance - */ - fetch( - callback?: (error: Error | null, item?: PlaybackGrantInstance) => any - ): Promise { - return this._proxy.fetch(callback); - } - - /** - * Provide a user-friendly representation - * - * @returns Object - */ - toJSON() { - return { - sid: this.sid, - url: this.url, - accountSid: this.accountSid, - dateCreated: this.dateCreated, - grant: this.grant, - }; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -export interface PlaybackGrantSolution { - sid: string; -} - -export interface PlaybackGrantListInstance { - _version: V1; - _solution: PlaybackGrantSolution; - _uri: string; - - (): PlaybackGrantContext; - get(): PlaybackGrantContext; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export function PlaybackGrantListInstance( - version: V1, - sid: string -): PlaybackGrantListInstance { - if (!isValidPathParam(sid)) { - throw new Error("Parameter 'sid' is not valid."); - } - - const instance = (() => instance.get()) as PlaybackGrantListInstance; - - instance.get = function get(): PlaybackGrantContext { - return new PlaybackGrantContextImpl(version, sid); - }; - - instance._version = version; - instance._solution = { sid }; - instance._uri = ``; - - instance.toJSON = function toJSON() { - return instance._solution; - }; - - instance[inspect.custom] = function inspectImpl( - _depth: any, - options: InspectOptions - ) { - return inspect(instance.toJSON(), options); - }; - - return instance; -}