diff --git a/src/rest/Preview.ts b/src/rest/Preview.ts index 02f87e9fc4..aacf2e6e37 100644 --- a/src/rest/Preview.ts +++ b/src/rest/Preview.ts @@ -1,4 +1,3 @@ -import { FleetListInstance } from "./preview/deployed_devices/fleet"; import { AuthorizationDocumentListInstance } from "./preview/hosted_numbers/authorizationDocument"; import { HostedNumberOrderListInstance } from "./preview/hosted_numbers/hostedNumberOrder"; import { AvailableAddOnListInstance } from "./preview/marketplace/availableAddOn"; @@ -10,14 +9,6 @@ import { SimListInstance } from "./preview/wireless/sim"; import PreviewBase from "./PreviewBase"; class Preview extends PreviewBase { - /** - * @deprecated - Use deployed_devices.fleets instead - */ - get fleets(): FleetListInstance { - console.warn("fleets is deprecated. Use deployed_devices.fleets instead."); - return this.deployed_devices.fleets; - } - /** * @deprecated - Use hosted_numbers.authorizationDocuments instead */ diff --git a/src/rest/PreviewBase.ts b/src/rest/PreviewBase.ts index 2aeead219c..80c7d7eb00 100644 --- a/src/rest/PreviewBase.ts +++ b/src/rest/PreviewBase.ts @@ -10,14 +10,12 @@ */ import Domain from "../base/Domain"; -import DeployedDevices from "./preview/DeployedDevices"; import HostedNumbers from "./preview/HostedNumbers"; import Sync from "./preview/Sync"; import Marketplace from "./preview/Marketplace"; import Wireless from "./preview/Wireless"; class PreviewBase extends Domain { - _deployed_devices?: DeployedDevices; _hosted_numbers?: HostedNumbers; _sync?: Sync; _marketplace?: Marketplace; @@ -31,12 +29,6 @@ class PreviewBase extends Domain { constructor(twilio: any) { super(twilio, "https://preview.twilio.com"); } - - get deployed_devices(): DeployedDevices { - this._deployed_devices = - this._deployed_devices || new DeployedDevices(this); - return this._deployed_devices; - } get hosted_numbers(): HostedNumbers { this._hosted_numbers = this._hosted_numbers || new HostedNumbers(this); return this._hosted_numbers; diff --git a/src/rest/preview/DeployedDevices.ts b/src/rest/preview/DeployedDevices.ts deleted file mode 100644 index e400afccbf..0000000000 --- a/src/rest/preview/DeployedDevices.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Twilio - Preview - * 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 PreviewBase from "../PreviewBase"; -import Version from "../../base/Version"; -import { FleetListInstance } from "./deployed_devices/fleet"; - -export default class DeployedDevices extends Version { - /** - * Initialize the DeployedDevices version of Preview - * - * @param domain - The Twilio (Twilio.Preview) domain - */ - constructor(domain: PreviewBase) { - super(domain, "DeployedDevices"); - } - - /** fleets - { Twilio.Preview.DeployedDevices.FleetListInstance } resource */ - protected _fleets?: FleetListInstance; - - /** Getter for fleets resource */ - get fleets(): FleetListInstance { - this._fleets = this._fleets || FleetListInstance(this); - return this._fleets; - } -} diff --git a/src/rest/preview/deployed_devices/fleet.ts b/src/rest/preview/deployed_devices/fleet.ts deleted file mode 100644 index 1a63121ae7..0000000000 --- a/src/rest/preview/deployed_devices/fleet.ts +++ /dev/null @@ -1,738 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Twilio - Preview - * 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 DeployedDevices from "../DeployedDevices"; -const deserialize = require("../../../base/deserialize"); -const serialize = require("../../../base/serialize"); -import { isValidPathParam } from "../../../base/utility"; -import { CertificateListInstance } from "./fleet/certificate"; -import { DeploymentListInstance } from "./fleet/deployment"; -import { DeviceListInstance } from "./fleet/device"; -import { KeyListInstance } from "./fleet/key"; - -/** - * Options to pass to update a FleetInstance - */ -export interface FleetContextUpdateOptions { - /** Provides a human readable descriptive text for this Fleet, up to 256 characters long. */ - friendlyName?: string; - /** Provides a string identifier of a Deployment that is going to be used as a default one for this Fleet. */ - defaultDeploymentSid?: string; -} - -/** - * Options to pass to create a FleetInstance - */ -export interface FleetListInstanceCreateOptions { - /** Provides a human readable descriptive text for this Fleet, up to 256 characters long. */ - friendlyName?: string; -} -/** - * Options to pass to each - */ -export interface FleetListInstanceEachOptions { - /** 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: FleetInstance, 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 FleetListInstanceOptions { - /** 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 FleetListInstancePageOptions { - /** 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 FleetContext { - certificates: CertificateListInstance; - deployments: DeploymentListInstance; - devices: DeviceListInstance; - keys: KeyListInstance; - - /** - * Remove a FleetInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed boolean - */ - remove( - callback?: (error: Error | null, item?: boolean) => any - ): Promise; - - /** - * Fetch a FleetInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed FleetInstance - */ - fetch( - callback?: (error: Error | null, item?: FleetInstance) => any - ): Promise; - - /** - * Update a FleetInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed FleetInstance - */ - update( - callback?: (error: Error | null, item?: FleetInstance) => any - ): Promise; - /** - * Update a FleetInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed FleetInstance - */ - update( - params: FleetContextUpdateOptions, - callback?: (error: Error | null, item?: FleetInstance) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export interface FleetContextSolution { - sid: string; -} - -export class FleetContextImpl implements FleetContext { - protected _solution: FleetContextSolution; - protected _uri: string; - - protected _certificates?: CertificateListInstance; - protected _deployments?: DeploymentListInstance; - protected _devices?: DeviceListInstance; - protected _keys?: KeyListInstance; - - constructor(protected _version: DeployedDevices, sid: string) { - if (!isValidPathParam(sid)) { - throw new Error("Parameter 'sid' is not valid."); - } - - this._solution = { sid }; - this._uri = `/Fleets/${sid}`; - } - - get certificates(): CertificateListInstance { - this._certificates = - this._certificates || - CertificateListInstance(this._version, this._solution.sid); - return this._certificates; - } - - get deployments(): DeploymentListInstance { - this._deployments = - this._deployments || - DeploymentListInstance(this._version, this._solution.sid); - return this._deployments; - } - - get devices(): DeviceListInstance { - this._devices = - this._devices || DeviceListInstance(this._version, this._solution.sid); - return this._devices; - } - - get keys(): KeyListInstance { - this._keys = - this._keys || KeyListInstance(this._version, this._solution.sid); - return this._keys; - } - - 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?: FleetInstance) => any - ): Promise { - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.fetch({ - uri: instance._uri, - method: "get", - }); - - operationPromise = operationPromise.then( - (payload) => - new FleetInstance(operationVersion, payload, instance._solution.sid) - ); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback - ); - return operationPromise; - } - - update( - params?: - | FleetContextUpdateOptions - | ((error: Error | null, item?: FleetInstance) => any), - callback?: (error: Error | null, item?: FleetInstance) => any - ): Promise { - if (params instanceof Function) { - callback = params; - params = {}; - } else { - params = params || {}; - } - - let data: any = {}; - - if (params["friendlyName"] !== undefined) - data["FriendlyName"] = params["friendlyName"]; - if (params["defaultDeploymentSid"] !== undefined) - data["DefaultDeploymentSid"] = params["defaultDeploymentSid"]; - - 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 FleetInstance(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 FleetPayload extends TwilioResponsePayload { - fleets: FleetResource[]; -} - -interface FleetResource { - sid: string; - url: string; - unique_name: string; - friendly_name: string; - account_sid: string; - default_deployment_sid: string; - date_created: Date; - date_updated: Date; - links: Record; -} - -export class FleetInstance { - protected _solution: FleetContextSolution; - protected _context?: FleetContext; - - constructor( - protected _version: DeployedDevices, - payload: FleetResource, - sid?: string - ) { - this.sid = payload.sid; - this.url = payload.url; - this.uniqueName = payload.unique_name; - this.friendlyName = payload.friendly_name; - this.accountSid = payload.account_sid; - this.defaultDeploymentSid = payload.default_deployment_sid; - this.dateCreated = deserialize.iso8601DateTime(payload.date_created); - this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated); - this.links = payload.links; - - this._solution = { sid: sid || this.sid }; - } - - /** - * Contains a 34 character string that uniquely identifies this Fleet resource. - */ - sid: string; - /** - * Contains an absolute URL for this Fleet resource. - */ - url: string; - /** - * Contains a unique and addressable name of this Fleet, e.g. \'default\', up to 128 characters long. - */ - uniqueName: string; - /** - * Contains a human readable descriptive text for this Fleet, up to 256 characters long. - */ - friendlyName: string; - /** - * Speicifies the unique string identifier of the Account responsible for this Fleet. - */ - accountSid: string; - /** - * Contains the string identifier of the automatically provisioned default Deployment of this Fleet. - */ - defaultDeploymentSid: string; - /** - * Specifies the date this Fleet was created, given in UTC ISO 8601 format. - */ - dateCreated: Date; - /** - * Specifies the date this Fleet was last updated, given in UTC ISO 8601 format. - */ - dateUpdated: Date; - /** - * Contains a dictionary of URL links to nested resources of this Fleet. - */ - links: Record; - - private get _proxy(): FleetContext { - this._context = - this._context || new FleetContextImpl(this._version, this._solution.sid); - return this._context; - } - - /** - * Remove a FleetInstance - * - * @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 FleetInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed FleetInstance - */ - fetch( - callback?: (error: Error | null, item?: FleetInstance) => any - ): Promise { - return this._proxy.fetch(callback); - } - - /** - * Update a FleetInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed FleetInstance - */ - update( - callback?: (error: Error | null, item?: FleetInstance) => any - ): Promise; - /** - * Update a FleetInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed FleetInstance - */ - update( - params: FleetContextUpdateOptions, - callback?: (error: Error | null, item?: FleetInstance) => any - ): Promise; - - update( - params?: any, - callback?: (error: Error | null, item?: FleetInstance) => any - ): Promise { - return this._proxy.update(params, callback); - } - - /** - * Access the certificates. - */ - certificates(): CertificateListInstance { - return this._proxy.certificates; - } - - /** - * Access the deployments. - */ - deployments(): DeploymentListInstance { - return this._proxy.deployments; - } - - /** - * Access the devices. - */ - devices(): DeviceListInstance { - return this._proxy.devices; - } - - /** - * Access the keys. - */ - keys(): KeyListInstance { - return this._proxy.keys; - } - - /** - * Provide a user-friendly representation - * - * @returns Object - */ - toJSON() { - return { - sid: this.sid, - url: this.url, - uniqueName: this.uniqueName, - friendlyName: this.friendlyName, - accountSid: this.accountSid, - defaultDeploymentSid: this.defaultDeploymentSid, - dateCreated: this.dateCreated, - dateUpdated: this.dateUpdated, - links: this.links, - }; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -export interface FleetSolution {} - -export interface FleetListInstance { - _version: DeployedDevices; - _solution: FleetSolution; - _uri: string; - - (sid: string): FleetContext; - get(sid: string): FleetContext; - - /** - * Create a FleetInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed FleetInstance - */ - create( - callback?: (error: Error | null, item?: FleetInstance) => any - ): Promise; - /** - * Create a FleetInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed FleetInstance - */ - create( - params: FleetListInstanceCreateOptions, - callback?: (error: Error | null, item?: FleetInstance) => any - ): Promise; - - /** - * Streams FleetInstance 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 { FleetListInstanceEachOptions } [params] - Options for request - * @param { function } [callback] - Function to process each record - */ - each( - callback?: (item: FleetInstance, done: (err?: Error) => void) => void - ): void; - each( - params: FleetListInstanceEachOptions, - callback?: (item: FleetInstance, done: (err?: Error) => void) => void - ): void; - /** - * Retrieve a single target page of FleetInstance 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: FleetPage) => any - ): Promise; - /** - * Lists FleetInstance 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 { FleetListInstanceOptions } [params] - Options for request - * @param { function } [callback] - Callback to handle list of records - */ - list( - callback?: (error: Error | null, items: FleetInstance[]) => any - ): Promise; - list( - params: FleetListInstanceOptions, - callback?: (error: Error | null, items: FleetInstance[]) => any - ): Promise; - /** - * Retrieve a single page of FleetInstance 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 { FleetListInstancePageOptions } [params] - Options for request - * @param { function } [callback] - Callback to handle list of records - */ - page( - callback?: (error: Error | null, items: FleetPage) => any - ): Promise; - page( - params: FleetListInstancePageOptions, - callback?: (error: Error | null, items: FleetPage) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export function FleetListInstance(version: DeployedDevices): FleetListInstance { - const instance = ((sid) => instance.get(sid)) as FleetListInstance; - - instance.get = function get(sid): FleetContext { - return new FleetContextImpl(version, sid); - }; - - instance._version = version; - instance._solution = {}; - instance._uri = `/Fleets`; - - instance.create = function create( - params?: - | FleetListInstanceCreateOptions - | ((error: Error | null, items: FleetInstance) => any), - callback?: (error: Error | null, items: FleetInstance) => any - ): Promise { - if (params instanceof Function) { - callback = params; - params = {}; - } else { - params = params || {}; - } - - let data: any = {}; - - if (params["friendlyName"] !== undefined) - data["FriendlyName"] = params["friendlyName"]; - - 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 FleetInstance(operationVersion, payload) - ); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback - ); - return operationPromise; - }; - - instance.page = function page( - params?: - | FleetListInstancePageOptions - | ((error: Error | null, items: FleetPage) => any), - callback?: (error: Error | null, items: FleetPage) => any - ): Promise { - if (params instanceof Function) { - callback = params; - params = {}; - } else { - params = params || {}; - } - - let data: any = {}; - - 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 FleetPage(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: FleetPage) => any - ): Promise { - const operationPromise = instance._version._domain.twilio.request({ - method: "get", - uri: targetUrl, - }); - - let pagePromise = operationPromise.then( - (payload) => new FleetPage(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 FleetPage extends Page< - DeployedDevices, - FleetPayload, - FleetResource, - FleetInstance -> { - /** - * Initialize the FleetPage - * - * @param version - Version of the resource - * @param response - Response from the API - * @param solution - Path solution - */ - constructor( - version: DeployedDevices, - response: Response, - solution: FleetSolution - ) { - super(version, response, solution); - } - - /** - * Build an instance of FleetInstance - * - * @param payload - Payload response from the API - */ - getInstance(payload: FleetResource): FleetInstance { - return new FleetInstance(this._version, payload); - } - - [inspect.custom](depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} diff --git a/src/rest/preview/deployed_devices/fleet/certificate.ts b/src/rest/preview/deployed_devices/fleet/certificate.ts deleted file mode 100644 index 788abbc0a7..0000000000 --- a/src/rest/preview/deployed_devices/fleet/certificate.ts +++ /dev/null @@ -1,724 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Twilio - Preview - * 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 DeployedDevices from "../../DeployedDevices"; -const deserialize = require("../../../../base/deserialize"); -const serialize = require("../../../../base/serialize"); -import { isValidPathParam } from "../../../../base/utility"; - -/** - * Options to pass to update a CertificateInstance - */ -export interface CertificateContextUpdateOptions { - /** Provides a human readable descriptive text for this Certificate credential, up to 256 characters long. */ - friendlyName?: string; - /** Provides the unique string identifier of an existing Device to become authenticated with this Certificate credential. */ - deviceSid?: string; -} - -/** - * Options to pass to create a CertificateInstance - */ -export interface CertificateListInstanceCreateOptions { - /** Provides a URL encoded representation of the public certificate in PEM format. */ - certificateData: string; - /** Provides a human readable descriptive text for this Certificate credential, up to 256 characters long. */ - friendlyName?: string; - /** Provides the unique string identifier of an existing Device to become authenticated with this Certificate credential. */ - deviceSid?: string; -} -/** - * Options to pass to each - */ -export interface CertificateListInstanceEachOptions { - /** Filters the resulting list of Certificates by a unique string identifier of an authenticated Device. */ - deviceSid?: 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: CertificateInstance, 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 CertificateListInstanceOptions { - /** Filters the resulting list of Certificates by a unique string identifier of an authenticated Device. */ - deviceSid?: 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 CertificateListInstancePageOptions { - /** Filters the resulting list of Certificates by a unique string identifier of an authenticated Device. */ - deviceSid?: 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 CertificateContext { - /** - * Remove a CertificateInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed boolean - */ - remove( - callback?: (error: Error | null, item?: boolean) => any - ): Promise; - - /** - * Fetch a CertificateInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed CertificateInstance - */ - fetch( - callback?: (error: Error | null, item?: CertificateInstance) => any - ): Promise; - - /** - * Update a CertificateInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed CertificateInstance - */ - update( - callback?: (error: Error | null, item?: CertificateInstance) => any - ): Promise; - /** - * Update a CertificateInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed CertificateInstance - */ - update( - params: CertificateContextUpdateOptions, - callback?: (error: Error | null, item?: CertificateInstance) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export interface CertificateContextSolution { - fleetSid: string; - sid: string; -} - -export class CertificateContextImpl implements CertificateContext { - protected _solution: CertificateContextSolution; - protected _uri: string; - - constructor( - protected _version: DeployedDevices, - fleetSid: string, - sid: string - ) { - if (!isValidPathParam(fleetSid)) { - throw new Error("Parameter 'fleetSid' is not valid."); - } - - if (!isValidPathParam(sid)) { - throw new Error("Parameter 'sid' is not valid."); - } - - this._solution = { fleetSid, sid }; - this._uri = `/Fleets/${fleetSid}/Certificates/${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?: CertificateInstance) => any - ): Promise { - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.fetch({ - uri: instance._uri, - method: "get", - }); - - operationPromise = operationPromise.then( - (payload) => - new CertificateInstance( - operationVersion, - payload, - instance._solution.fleetSid, - instance._solution.sid - ) - ); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback - ); - return operationPromise; - } - - update( - params?: - | CertificateContextUpdateOptions - | ((error: Error | null, item?: CertificateInstance) => any), - callback?: (error: Error | null, item?: CertificateInstance) => any - ): Promise { - if (params instanceof Function) { - callback = params; - params = {}; - } else { - params = params || {}; - } - - let data: any = {}; - - if (params["friendlyName"] !== undefined) - data["FriendlyName"] = params["friendlyName"]; - if (params["deviceSid"] !== undefined) - data["DeviceSid"] = params["deviceSid"]; - - 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 CertificateInstance( - operationVersion, - payload, - instance._solution.fleetSid, - 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 CertificatePayload extends TwilioResponsePayload { - certificates: CertificateResource[]; -} - -interface CertificateResource { - sid: string; - url: string; - friendly_name: string; - fleet_sid: string; - account_sid: string; - device_sid: string; - thumbprint: string; - date_created: Date; - date_updated: Date; -} - -export class CertificateInstance { - protected _solution: CertificateContextSolution; - protected _context?: CertificateContext; - - constructor( - protected _version: DeployedDevices, - payload: CertificateResource, - fleetSid: string, - sid?: string - ) { - this.sid = payload.sid; - this.url = payload.url; - this.friendlyName = payload.friendly_name; - this.fleetSid = payload.fleet_sid; - this.accountSid = payload.account_sid; - this.deviceSid = payload.device_sid; - this.thumbprint = payload.thumbprint; - this.dateCreated = deserialize.iso8601DateTime(payload.date_created); - this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated); - - this._solution = { fleetSid, sid: sid || this.sid }; - } - - /** - * Contains a 34 character string that uniquely identifies this Certificate credential resource. - */ - sid: string; - /** - * Contains an absolute URL for this Certificate credential resource. - */ - url: string; - /** - * Contains a human readable descriptive text for this Certificate credential, up to 256 characters long. - */ - friendlyName: string; - /** - * Specifies the unique string identifier of the Fleet that the given Certificate credential belongs to. - */ - fleetSid: string; - /** - * Specifies the unique string identifier of the Account responsible for this Certificate credential. - */ - accountSid: string; - /** - * Specifies the unique string identifier of a Device authenticated with this Certificate credential. - */ - deviceSid: string; - /** - * Contains a unique hash of the payload of this Certificate credential, used to authenticate the Device. - */ - thumbprint: string; - /** - * Specifies the date this Certificate credential was created, given in UTC ISO 8601 format. - */ - dateCreated: Date; - /** - * Specifies the date this Certificate credential was last updated, given in UTC ISO 8601 format. - */ - dateUpdated: Date; - - private get _proxy(): CertificateContext { - this._context = - this._context || - new CertificateContextImpl( - this._version, - this._solution.fleetSid, - this._solution.sid - ); - return this._context; - } - - /** - * Remove a CertificateInstance - * - * @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 CertificateInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed CertificateInstance - */ - fetch( - callback?: (error: Error | null, item?: CertificateInstance) => any - ): Promise { - return this._proxy.fetch(callback); - } - - /** - * Update a CertificateInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed CertificateInstance - */ - update( - callback?: (error: Error | null, item?: CertificateInstance) => any - ): Promise; - /** - * Update a CertificateInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed CertificateInstance - */ - update( - params: CertificateContextUpdateOptions, - callback?: (error: Error | null, item?: CertificateInstance) => any - ): Promise; - - update( - params?: any, - callback?: (error: Error | null, item?: CertificateInstance) => any - ): Promise { - return this._proxy.update(params, callback); - } - - /** - * Provide a user-friendly representation - * - * @returns Object - */ - toJSON() { - return { - sid: this.sid, - url: this.url, - friendlyName: this.friendlyName, - fleetSid: this.fleetSid, - accountSid: this.accountSid, - deviceSid: this.deviceSid, - thumbprint: this.thumbprint, - dateCreated: this.dateCreated, - dateUpdated: this.dateUpdated, - }; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -export interface CertificateSolution { - fleetSid: string; -} - -export interface CertificateListInstance { - _version: DeployedDevices; - _solution: CertificateSolution; - _uri: string; - - (sid: string): CertificateContext; - get(sid: string): CertificateContext; - - /** - * Create a CertificateInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed CertificateInstance - */ - create( - params: CertificateListInstanceCreateOptions, - callback?: (error: Error | null, item?: CertificateInstance) => any - ): Promise; - - /** - * Streams CertificateInstance 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 { CertificateListInstanceEachOptions } [params] - Options for request - * @param { function } [callback] - Function to process each record - */ - each( - callback?: (item: CertificateInstance, done: (err?: Error) => void) => void - ): void; - each( - params: CertificateListInstanceEachOptions, - callback?: (item: CertificateInstance, done: (err?: Error) => void) => void - ): void; - /** - * Retrieve a single target page of CertificateInstance 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: CertificatePage) => any - ): Promise; - /** - * Lists CertificateInstance 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 { CertificateListInstanceOptions } [params] - Options for request - * @param { function } [callback] - Callback to handle list of records - */ - list( - callback?: (error: Error | null, items: CertificateInstance[]) => any - ): Promise; - list( - params: CertificateListInstanceOptions, - callback?: (error: Error | null, items: CertificateInstance[]) => any - ): Promise; - /** - * Retrieve a single page of CertificateInstance 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 { CertificateListInstancePageOptions } [params] - Options for request - * @param { function } [callback] - Callback to handle list of records - */ - page( - callback?: (error: Error | null, items: CertificatePage) => any - ): Promise; - page( - params: CertificateListInstancePageOptions, - callback?: (error: Error | null, items: CertificatePage) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export function CertificateListInstance( - version: DeployedDevices, - fleetSid: string -): CertificateListInstance { - if (!isValidPathParam(fleetSid)) { - throw new Error("Parameter 'fleetSid' is not valid."); - } - - const instance = ((sid) => instance.get(sid)) as CertificateListInstance; - - instance.get = function get(sid): CertificateContext { - return new CertificateContextImpl(version, fleetSid, sid); - }; - - instance._version = version; - instance._solution = { fleetSid }; - instance._uri = `/Fleets/${fleetSid}/Certificates`; - - instance.create = function create( - params: CertificateListInstanceCreateOptions, - callback?: (error: Error | null, items: CertificateInstance) => any - ): Promise { - if (params === null || params === undefined) { - throw new Error('Required parameter "params" missing.'); - } - - if ( - params["certificateData"] === null || - params["certificateData"] === undefined - ) { - throw new Error( - "Required parameter \"params['certificateData']\" missing." - ); - } - - let data: any = {}; - - data["CertificateData"] = params["certificateData"]; - if (params["friendlyName"] !== undefined) - data["FriendlyName"] = params["friendlyName"]; - if (params["deviceSid"] !== undefined) - data["DeviceSid"] = params["deviceSid"]; - - 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 CertificateInstance( - operationVersion, - payload, - instance._solution.fleetSid - ) - ); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback - ); - return operationPromise; - }; - - instance.page = function page( - params?: - | CertificateListInstancePageOptions - | ((error: Error | null, items: CertificatePage) => any), - callback?: (error: Error | null, items: CertificatePage) => any - ): Promise { - if (params instanceof Function) { - callback = params; - params = {}; - } else { - params = params || {}; - } - - let data: any = {}; - - if (params["deviceSid"] !== undefined) - data["DeviceSid"] = params["deviceSid"]; - 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 CertificatePage(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: CertificatePage) => any - ): Promise { - const operationPromise = instance._version._domain.twilio.request({ - method: "get", - uri: targetUrl, - }); - - let pagePromise = operationPromise.then( - (payload) => - new CertificatePage(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 CertificatePage extends Page< - DeployedDevices, - CertificatePayload, - CertificateResource, - CertificateInstance -> { - /** - * Initialize the CertificatePage - * - * @param version - Version of the resource - * @param response - Response from the API - * @param solution - Path solution - */ - constructor( - version: DeployedDevices, - response: Response, - solution: CertificateSolution - ) { - super(version, response, solution); - } - - /** - * Build an instance of CertificateInstance - * - * @param payload - Payload response from the API - */ - getInstance(payload: CertificateResource): CertificateInstance { - return new CertificateInstance( - this._version, - payload, - this._solution.fleetSid - ); - } - - [inspect.custom](depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} diff --git a/src/rest/preview/deployed_devices/fleet/deployment.ts b/src/rest/preview/deployed_devices/fleet/deployment.ts deleted file mode 100644 index 21c07750bc..0000000000 --- a/src/rest/preview/deployed_devices/fleet/deployment.ts +++ /dev/null @@ -1,712 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Twilio - Preview - * 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 DeployedDevices from "../../DeployedDevices"; -const deserialize = require("../../../../base/deserialize"); -const serialize = require("../../../../base/serialize"); -import { isValidPathParam } from "../../../../base/utility"; - -/** - * Options to pass to update a DeploymentInstance - */ -export interface DeploymentContextUpdateOptions { - /** Provides a human readable descriptive text for this Deployment, up to 64 characters long */ - friendlyName?: string; - /** Provides the unique string identifier of the Twilio Sync service instance that will be linked to and accessible by this Deployment. */ - syncServiceSid?: string; -} - -/** - * Options to pass to create a DeploymentInstance - */ -export interface DeploymentListInstanceCreateOptions { - /** Provides a human readable descriptive text for this Deployment, up to 256 characters long. */ - friendlyName?: string; - /** Provides the unique string identifier of the Twilio Sync service instance that will be linked to and accessible by this Deployment. */ - syncServiceSid?: string; -} -/** - * Options to pass to each - */ -export interface DeploymentListInstanceEachOptions { - /** 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: DeploymentInstance, 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 DeploymentListInstanceOptions { - /** 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 DeploymentListInstancePageOptions { - /** 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 DeploymentContext { - /** - * Remove a DeploymentInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed boolean - */ - remove( - callback?: (error: Error | null, item?: boolean) => any - ): Promise; - - /** - * Fetch a DeploymentInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed DeploymentInstance - */ - fetch( - callback?: (error: Error | null, item?: DeploymentInstance) => any - ): Promise; - - /** - * Update a DeploymentInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed DeploymentInstance - */ - update( - callback?: (error: Error | null, item?: DeploymentInstance) => any - ): Promise; - /** - * Update a DeploymentInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed DeploymentInstance - */ - update( - params: DeploymentContextUpdateOptions, - callback?: (error: Error | null, item?: DeploymentInstance) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export interface DeploymentContextSolution { - fleetSid: string; - sid: string; -} - -export class DeploymentContextImpl implements DeploymentContext { - protected _solution: DeploymentContextSolution; - protected _uri: string; - - constructor( - protected _version: DeployedDevices, - fleetSid: string, - sid: string - ) { - if (!isValidPathParam(fleetSid)) { - throw new Error("Parameter 'fleetSid' is not valid."); - } - - if (!isValidPathParam(sid)) { - throw new Error("Parameter 'sid' is not valid."); - } - - this._solution = { fleetSid, sid }; - this._uri = `/Fleets/${fleetSid}/Deployments/${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?: DeploymentInstance) => any - ): Promise { - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.fetch({ - uri: instance._uri, - method: "get", - }); - - operationPromise = operationPromise.then( - (payload) => - new DeploymentInstance( - operationVersion, - payload, - instance._solution.fleetSid, - instance._solution.sid - ) - ); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback - ); - return operationPromise; - } - - update( - params?: - | DeploymentContextUpdateOptions - | ((error: Error | null, item?: DeploymentInstance) => any), - callback?: (error: Error | null, item?: DeploymentInstance) => any - ): Promise { - if (params instanceof Function) { - callback = params; - params = {}; - } else { - params = params || {}; - } - - let data: any = {}; - - if (params["friendlyName"] !== undefined) - data["FriendlyName"] = params["friendlyName"]; - if (params["syncServiceSid"] !== undefined) - data["SyncServiceSid"] = params["syncServiceSid"]; - - 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 DeploymentInstance( - operationVersion, - payload, - instance._solution.fleetSid, - 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 DeploymentPayload extends TwilioResponsePayload { - deployments: DeploymentResource[]; -} - -interface DeploymentResource { - sid: string; - url: string; - friendly_name: string; - fleet_sid: string; - account_sid: string; - sync_service_sid: string; - date_created: Date; - date_updated: Date; -} - -export class DeploymentInstance { - protected _solution: DeploymentContextSolution; - protected _context?: DeploymentContext; - - constructor( - protected _version: DeployedDevices, - payload: DeploymentResource, - fleetSid: string, - sid?: string - ) { - this.sid = payload.sid; - this.url = payload.url; - this.friendlyName = payload.friendly_name; - this.fleetSid = payload.fleet_sid; - this.accountSid = payload.account_sid; - this.syncServiceSid = payload.sync_service_sid; - this.dateCreated = deserialize.iso8601DateTime(payload.date_created); - this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated); - - this._solution = { fleetSid, sid: sid || this.sid }; - } - - /** - * Contains a 34 character string that uniquely identifies this Deployment resource. - */ - sid: string; - /** - * Contains an absolute URL for this Deployment resource. - */ - url: string; - /** - * Contains a human readable descriptive text for this Deployment, up to 64 characters long - */ - friendlyName: string; - /** - * Specifies the unique string identifier of the Fleet that the given Deployment belongs to. - */ - fleetSid: string; - /** - * Specifies the unique string identifier of the Account responsible for this Deployment. - */ - accountSid: string; - /** - * Specifies the unique string identifier of the Twilio Sync service instance linked to and accessible by this Deployment. - */ - syncServiceSid: string; - /** - * Specifies the date this Deployment was created, given in UTC ISO 8601 format. - */ - dateCreated: Date; - /** - * Specifies the date this Deployment was last updated, given in UTC ISO 8601 format. - */ - dateUpdated: Date; - - private get _proxy(): DeploymentContext { - this._context = - this._context || - new DeploymentContextImpl( - this._version, - this._solution.fleetSid, - this._solution.sid - ); - return this._context; - } - - /** - * Remove a DeploymentInstance - * - * @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 DeploymentInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed DeploymentInstance - */ - fetch( - callback?: (error: Error | null, item?: DeploymentInstance) => any - ): Promise { - return this._proxy.fetch(callback); - } - - /** - * Update a DeploymentInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed DeploymentInstance - */ - update( - callback?: (error: Error | null, item?: DeploymentInstance) => any - ): Promise; - /** - * Update a DeploymentInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed DeploymentInstance - */ - update( - params: DeploymentContextUpdateOptions, - callback?: (error: Error | null, item?: DeploymentInstance) => any - ): Promise; - - update( - params?: any, - callback?: (error: Error | null, item?: DeploymentInstance) => any - ): Promise { - return this._proxy.update(params, callback); - } - - /** - * Provide a user-friendly representation - * - * @returns Object - */ - toJSON() { - return { - sid: this.sid, - url: this.url, - friendlyName: this.friendlyName, - fleetSid: this.fleetSid, - accountSid: this.accountSid, - syncServiceSid: this.syncServiceSid, - dateCreated: this.dateCreated, - dateUpdated: this.dateUpdated, - }; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -export interface DeploymentSolution { - fleetSid: string; -} - -export interface DeploymentListInstance { - _version: DeployedDevices; - _solution: DeploymentSolution; - _uri: string; - - (sid: string): DeploymentContext; - get(sid: string): DeploymentContext; - - /** - * Create a DeploymentInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed DeploymentInstance - */ - create( - callback?: (error: Error | null, item?: DeploymentInstance) => any - ): Promise; - /** - * Create a DeploymentInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed DeploymentInstance - */ - create( - params: DeploymentListInstanceCreateOptions, - callback?: (error: Error | null, item?: DeploymentInstance) => any - ): Promise; - - /** - * Streams DeploymentInstance 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 { DeploymentListInstanceEachOptions } [params] - Options for request - * @param { function } [callback] - Function to process each record - */ - each( - callback?: (item: DeploymentInstance, done: (err?: Error) => void) => void - ): void; - each( - params: DeploymentListInstanceEachOptions, - callback?: (item: DeploymentInstance, done: (err?: Error) => void) => void - ): void; - /** - * Retrieve a single target page of DeploymentInstance 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: DeploymentPage) => any - ): Promise; - /** - * Lists DeploymentInstance 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 { DeploymentListInstanceOptions } [params] - Options for request - * @param { function } [callback] - Callback to handle list of records - */ - list( - callback?: (error: Error | null, items: DeploymentInstance[]) => any - ): Promise; - list( - params: DeploymentListInstanceOptions, - callback?: (error: Error | null, items: DeploymentInstance[]) => any - ): Promise; - /** - * Retrieve a single page of DeploymentInstance 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 { DeploymentListInstancePageOptions } [params] - Options for request - * @param { function } [callback] - Callback to handle list of records - */ - page( - callback?: (error: Error | null, items: DeploymentPage) => any - ): Promise; - page( - params: DeploymentListInstancePageOptions, - callback?: (error: Error | null, items: DeploymentPage) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export function DeploymentListInstance( - version: DeployedDevices, - fleetSid: string -): DeploymentListInstance { - if (!isValidPathParam(fleetSid)) { - throw new Error("Parameter 'fleetSid' is not valid."); - } - - const instance = ((sid) => instance.get(sid)) as DeploymentListInstance; - - instance.get = function get(sid): DeploymentContext { - return new DeploymentContextImpl(version, fleetSid, sid); - }; - - instance._version = version; - instance._solution = { fleetSid }; - instance._uri = `/Fleets/${fleetSid}/Deployments`; - - instance.create = function create( - params?: - | DeploymentListInstanceCreateOptions - | ((error: Error | null, items: DeploymentInstance) => any), - callback?: (error: Error | null, items: DeploymentInstance) => any - ): Promise { - if (params instanceof Function) { - callback = params; - params = {}; - } else { - params = params || {}; - } - - let data: any = {}; - - if (params["friendlyName"] !== undefined) - data["FriendlyName"] = params["friendlyName"]; - if (params["syncServiceSid"] !== undefined) - data["SyncServiceSid"] = params["syncServiceSid"]; - - 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 DeploymentInstance( - operationVersion, - payload, - instance._solution.fleetSid - ) - ); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback - ); - return operationPromise; - }; - - instance.page = function page( - params?: - | DeploymentListInstancePageOptions - | ((error: Error | null, items: DeploymentPage) => any), - callback?: (error: Error | null, items: DeploymentPage) => any - ): Promise { - if (params instanceof Function) { - callback = params; - params = {}; - } else { - params = params || {}; - } - - let data: any = {}; - - 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 DeploymentPage(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: DeploymentPage) => any - ): Promise { - const operationPromise = instance._version._domain.twilio.request({ - method: "get", - uri: targetUrl, - }); - - let pagePromise = operationPromise.then( - (payload) => - new DeploymentPage(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 DeploymentPage extends Page< - DeployedDevices, - DeploymentPayload, - DeploymentResource, - DeploymentInstance -> { - /** - * Initialize the DeploymentPage - * - * @param version - Version of the resource - * @param response - Response from the API - * @param solution - Path solution - */ - constructor( - version: DeployedDevices, - response: Response, - solution: DeploymentSolution - ) { - super(version, response, solution); - } - - /** - * Build an instance of DeploymentInstance - * - * @param payload - Payload response from the API - */ - getInstance(payload: DeploymentResource): DeploymentInstance { - return new DeploymentInstance( - this._version, - payload, - this._solution.fleetSid - ); - } - - [inspect.custom](depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} diff --git a/src/rest/preview/deployed_devices/fleet/device.ts b/src/rest/preview/deployed_devices/fleet/device.ts deleted file mode 100644 index f6ad90ac4d..0000000000 --- a/src/rest/preview/deployed_devices/fleet/device.ts +++ /dev/null @@ -1,763 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Twilio - Preview - * 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 DeployedDevices from "../../DeployedDevices"; -const deserialize = require("../../../../base/deserialize"); -const serialize = require("../../../../base/serialize"); -import { isValidPathParam } from "../../../../base/utility"; - -/** - * Options to pass to update a DeviceInstance - */ -export interface DeviceContextUpdateOptions { - /** Provides a human readable descriptive text to be assigned to this Device, up to 256 characters long. */ - friendlyName?: string; - /** Provides an arbitrary string identifier representing a human user to be associated with this Device, up to 256 characters long. */ - identity?: string; - /** Specifies the unique string identifier of the Deployment group that this Device is going to be associated with. */ - deploymentSid?: string; - /** */ - enabled?: boolean; -} - -/** - * Options to pass to create a DeviceInstance - */ -export interface DeviceListInstanceCreateOptions { - /** Provides a unique and addressable name to be assigned to this Device, to be used in addition to SID, up to 128 characters long. */ - uniqueName?: string; - /** Provides a human readable descriptive text to be assigned to this Device, up to 256 characters long. */ - friendlyName?: string; - /** Provides an arbitrary string identifier representing a human user to be associated with this Device, up to 256 characters long. */ - identity?: string; - /** Specifies the unique string identifier of the Deployment group that this Device is going to be associated with. */ - deploymentSid?: string; - /** */ - enabled?: boolean; -} -/** - * Options to pass to each - */ -export interface DeviceListInstanceEachOptions { - /** Filters the resulting list of Devices by a unique string identifier of the Deployment they are associated with. */ - deploymentSid?: 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: DeviceInstance, 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 DeviceListInstanceOptions { - /** Filters the resulting list of Devices by a unique string identifier of the Deployment they are associated with. */ - deploymentSid?: 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 DeviceListInstancePageOptions { - /** Filters the resulting list of Devices by a unique string identifier of the Deployment they are associated with. */ - deploymentSid?: 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 DeviceContext { - /** - * Remove a DeviceInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed boolean - */ - remove( - callback?: (error: Error | null, item?: boolean) => any - ): Promise; - - /** - * Fetch a DeviceInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed DeviceInstance - */ - fetch( - callback?: (error: Error | null, item?: DeviceInstance) => any - ): Promise; - - /** - * Update a DeviceInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed DeviceInstance - */ - update( - callback?: (error: Error | null, item?: DeviceInstance) => any - ): Promise; - /** - * Update a DeviceInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed DeviceInstance - */ - update( - params: DeviceContextUpdateOptions, - callback?: (error: Error | null, item?: DeviceInstance) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export interface DeviceContextSolution { - fleetSid: string; - sid: string; -} - -export class DeviceContextImpl implements DeviceContext { - protected _solution: DeviceContextSolution; - protected _uri: string; - - constructor( - protected _version: DeployedDevices, - fleetSid: string, - sid: string - ) { - if (!isValidPathParam(fleetSid)) { - throw new Error("Parameter 'fleetSid' is not valid."); - } - - if (!isValidPathParam(sid)) { - throw new Error("Parameter 'sid' is not valid."); - } - - this._solution = { fleetSid, sid }; - this._uri = `/Fleets/${fleetSid}/Devices/${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?: DeviceInstance) => any - ): Promise { - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.fetch({ - uri: instance._uri, - method: "get", - }); - - operationPromise = operationPromise.then( - (payload) => - new DeviceInstance( - operationVersion, - payload, - instance._solution.fleetSid, - instance._solution.sid - ) - ); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback - ); - return operationPromise; - } - - update( - params?: - | DeviceContextUpdateOptions - | ((error: Error | null, item?: DeviceInstance) => any), - callback?: (error: Error | null, item?: DeviceInstance) => any - ): Promise { - if (params instanceof Function) { - callback = params; - params = {}; - } else { - params = params || {}; - } - - let data: any = {}; - - if (params["friendlyName"] !== undefined) - data["FriendlyName"] = params["friendlyName"]; - if (params["identity"] !== undefined) data["Identity"] = params["identity"]; - if (params["deploymentSid"] !== undefined) - data["DeploymentSid"] = params["deploymentSid"]; - if (params["enabled"] !== undefined) - data["Enabled"] = serialize.bool(params["enabled"]); - - 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 DeviceInstance( - operationVersion, - payload, - instance._solution.fleetSid, - 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 DevicePayload extends TwilioResponsePayload { - devices: DeviceResource[]; -} - -interface DeviceResource { - sid: string; - url: string; - unique_name: string; - friendly_name: string; - fleet_sid: string; - enabled: boolean; - account_sid: string; - identity: string; - deployment_sid: string; - date_created: Date; - date_updated: Date; - date_authenticated: Date; -} - -export class DeviceInstance { - protected _solution: DeviceContextSolution; - protected _context?: DeviceContext; - - constructor( - protected _version: DeployedDevices, - payload: DeviceResource, - fleetSid: string, - sid?: string - ) { - this.sid = payload.sid; - this.url = payload.url; - this.uniqueName = payload.unique_name; - this.friendlyName = payload.friendly_name; - this.fleetSid = payload.fleet_sid; - this.enabled = payload.enabled; - this.accountSid = payload.account_sid; - this.identity = payload.identity; - this.deploymentSid = payload.deployment_sid; - this.dateCreated = deserialize.iso8601DateTime(payload.date_created); - this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated); - this.dateAuthenticated = deserialize.iso8601DateTime( - payload.date_authenticated - ); - - this._solution = { fleetSid, sid: sid || this.sid }; - } - - /** - * Contains a 34 character string that uniquely identifies this Device resource. - */ - sid: string; - /** - * Contains an absolute URL for this Device resource. - */ - url: string; - /** - * Contains a unique and addressable name of this Device, assigned by the developer, up to 128 characters long. - */ - uniqueName: string; - /** - * Contains a human readable descriptive text for this Device, up to 256 characters long - */ - friendlyName: string; - /** - * Specifies the unique string identifier of the Fleet that the given Device belongs to. - */ - fleetSid: string; - /** - * Contains a boolean flag indicating whether the device is enabled or not, blocks device connectivity if set to false. - */ - enabled: boolean; - /** - * Specifies the unique string identifier of the Account responsible for this Device. - */ - accountSid: string; - /** - * Contains an arbitrary string identifier representing a human user associated with this Device, assigned by the developer, up to 256 characters long. - */ - identity: string; - /** - * Specifies the unique string identifier of the Deployment group that this Device is associated with. - */ - deploymentSid: string; - /** - * Specifies the date this Device was created, given in UTC ISO 8601 format. - */ - dateCreated: Date; - /** - * Specifies the date this Device was last updated, given in UTC ISO 8601 format. - */ - dateUpdated: Date; - /** - * Specifies the date this Device was last authenticated, given in UTC ISO 8601 format. - */ - dateAuthenticated: Date; - - private get _proxy(): DeviceContext { - this._context = - this._context || - new DeviceContextImpl( - this._version, - this._solution.fleetSid, - this._solution.sid - ); - return this._context; - } - - /** - * Remove a DeviceInstance - * - * @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 DeviceInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed DeviceInstance - */ - fetch( - callback?: (error: Error | null, item?: DeviceInstance) => any - ): Promise { - return this._proxy.fetch(callback); - } - - /** - * Update a DeviceInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed DeviceInstance - */ - update( - callback?: (error: Error | null, item?: DeviceInstance) => any - ): Promise; - /** - * Update a DeviceInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed DeviceInstance - */ - update( - params: DeviceContextUpdateOptions, - callback?: (error: Error | null, item?: DeviceInstance) => any - ): Promise; - - update( - params?: any, - callback?: (error: Error | null, item?: DeviceInstance) => any - ): Promise { - return this._proxy.update(params, callback); - } - - /** - * Provide a user-friendly representation - * - * @returns Object - */ - toJSON() { - return { - sid: this.sid, - url: this.url, - uniqueName: this.uniqueName, - friendlyName: this.friendlyName, - fleetSid: this.fleetSid, - enabled: this.enabled, - accountSid: this.accountSid, - identity: this.identity, - deploymentSid: this.deploymentSid, - dateCreated: this.dateCreated, - dateUpdated: this.dateUpdated, - dateAuthenticated: this.dateAuthenticated, - }; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -export interface DeviceSolution { - fleetSid: string; -} - -export interface DeviceListInstance { - _version: DeployedDevices; - _solution: DeviceSolution; - _uri: string; - - (sid: string): DeviceContext; - get(sid: string): DeviceContext; - - /** - * Create a DeviceInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed DeviceInstance - */ - create( - callback?: (error: Error | null, item?: DeviceInstance) => any - ): Promise; - /** - * Create a DeviceInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed DeviceInstance - */ - create( - params: DeviceListInstanceCreateOptions, - callback?: (error: Error | null, item?: DeviceInstance) => any - ): Promise; - - /** - * Streams DeviceInstance 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 { DeviceListInstanceEachOptions } [params] - Options for request - * @param { function } [callback] - Function to process each record - */ - each( - callback?: (item: DeviceInstance, done: (err?: Error) => void) => void - ): void; - each( - params: DeviceListInstanceEachOptions, - callback?: (item: DeviceInstance, done: (err?: Error) => void) => void - ): void; - /** - * Retrieve a single target page of DeviceInstance 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: DevicePage) => any - ): Promise; - /** - * Lists DeviceInstance 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 { DeviceListInstanceOptions } [params] - Options for request - * @param { function } [callback] - Callback to handle list of records - */ - list( - callback?: (error: Error | null, items: DeviceInstance[]) => any - ): Promise; - list( - params: DeviceListInstanceOptions, - callback?: (error: Error | null, items: DeviceInstance[]) => any - ): Promise; - /** - * Retrieve a single page of DeviceInstance 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 { DeviceListInstancePageOptions } [params] - Options for request - * @param { function } [callback] - Callback to handle list of records - */ - page( - callback?: (error: Error | null, items: DevicePage) => any - ): Promise; - page( - params: DeviceListInstancePageOptions, - callback?: (error: Error | null, items: DevicePage) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export function DeviceListInstance( - version: DeployedDevices, - fleetSid: string -): DeviceListInstance { - if (!isValidPathParam(fleetSid)) { - throw new Error("Parameter 'fleetSid' is not valid."); - } - - const instance = ((sid) => instance.get(sid)) as DeviceListInstance; - - instance.get = function get(sid): DeviceContext { - return new DeviceContextImpl(version, fleetSid, sid); - }; - - instance._version = version; - instance._solution = { fleetSid }; - instance._uri = `/Fleets/${fleetSid}/Devices`; - - instance.create = function create( - params?: - | DeviceListInstanceCreateOptions - | ((error: Error | null, items: DeviceInstance) => any), - callback?: (error: Error | null, items: DeviceInstance) => any - ): Promise { - if (params instanceof Function) { - callback = params; - params = {}; - } else { - params = params || {}; - } - - let data: any = {}; - - if (params["uniqueName"] !== undefined) - data["UniqueName"] = params["uniqueName"]; - if (params["friendlyName"] !== undefined) - data["FriendlyName"] = params["friendlyName"]; - if (params["identity"] !== undefined) data["Identity"] = params["identity"]; - if (params["deploymentSid"] !== undefined) - data["DeploymentSid"] = params["deploymentSid"]; - if (params["enabled"] !== undefined) - data["Enabled"] = serialize.bool(params["enabled"]); - - 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 DeviceInstance( - operationVersion, - payload, - instance._solution.fleetSid - ) - ); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback - ); - return operationPromise; - }; - - instance.page = function page( - params?: - | DeviceListInstancePageOptions - | ((error: Error | null, items: DevicePage) => any), - callback?: (error: Error | null, items: DevicePage) => any - ): Promise { - if (params instanceof Function) { - callback = params; - params = {}; - } else { - params = params || {}; - } - - let data: any = {}; - - if (params["deploymentSid"] !== undefined) - data["DeploymentSid"] = params["deploymentSid"]; - 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 DevicePage(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: DevicePage) => any - ): Promise { - const operationPromise = instance._version._domain.twilio.request({ - method: "get", - uri: targetUrl, - }); - - let pagePromise = operationPromise.then( - (payload) => - new DevicePage(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 DevicePage extends Page< - DeployedDevices, - DevicePayload, - DeviceResource, - DeviceInstance -> { - /** - * Initialize the DevicePage - * - * @param version - Version of the resource - * @param response - Response from the API - * @param solution - Path solution - */ - constructor( - version: DeployedDevices, - response: Response, - solution: DeviceSolution - ) { - super(version, response, solution); - } - - /** - * Build an instance of DeviceInstance - * - * @param payload - Payload response from the API - */ - getInstance(payload: DeviceResource): DeviceInstance { - return new DeviceInstance(this._version, payload, this._solution.fleetSid); - } - - [inspect.custom](depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} diff --git a/src/rest/preview/deployed_devices/fleet/key.ts b/src/rest/preview/deployed_devices/fleet/key.ts deleted file mode 100644 index 0d334f582b..0000000000 --- a/src/rest/preview/deployed_devices/fleet/key.ts +++ /dev/null @@ -1,717 +0,0 @@ -/* - * This code was generated by - * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - * - * Twilio - Preview - * 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 DeployedDevices from "../../DeployedDevices"; -const deserialize = require("../../../../base/deserialize"); -const serialize = require("../../../../base/serialize"); -import { isValidPathParam } from "../../../../base/utility"; - -/** - * Options to pass to update a KeyInstance - */ -export interface KeyContextUpdateOptions { - /** Provides a human readable descriptive text for this Key credential, up to 256 characters long. */ - friendlyName?: string; - /** Provides the unique string identifier of an existing Device to become authenticated with this Key credential. */ - deviceSid?: string; -} - -/** - * Options to pass to create a KeyInstance - */ -export interface KeyListInstanceCreateOptions { - /** Provides a human readable descriptive text for this Key credential, up to 256 characters long. */ - friendlyName?: string; - /** Provides the unique string identifier of an existing Device to become authenticated with this Key credential. */ - deviceSid?: string; -} -/** - * Options to pass to each - */ -export interface KeyListInstanceEachOptions { - /** Filters the resulting list of Keys by a unique string identifier of an authenticated Device. */ - deviceSid?: 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: KeyInstance, 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 KeyListInstanceOptions { - /** Filters the resulting list of Keys by a unique string identifier of an authenticated Device. */ - deviceSid?: 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 KeyListInstancePageOptions { - /** Filters the resulting list of Keys by a unique string identifier of an authenticated Device. */ - deviceSid?: 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 KeyContext { - /** - * Remove a KeyInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed boolean - */ - remove( - callback?: (error: Error | null, item?: boolean) => any - ): Promise; - - /** - * Fetch a KeyInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed KeyInstance - */ - fetch( - callback?: (error: Error | null, item?: KeyInstance) => any - ): Promise; - - /** - * Update a KeyInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed KeyInstance - */ - update( - callback?: (error: Error | null, item?: KeyInstance) => any - ): Promise; - /** - * Update a KeyInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed KeyInstance - */ - update( - params: KeyContextUpdateOptions, - callback?: (error: Error | null, item?: KeyInstance) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export interface KeyContextSolution { - fleetSid: string; - sid: string; -} - -export class KeyContextImpl implements KeyContext { - protected _solution: KeyContextSolution; - protected _uri: string; - - constructor( - protected _version: DeployedDevices, - fleetSid: string, - sid: string - ) { - if (!isValidPathParam(fleetSid)) { - throw new Error("Parameter 'fleetSid' is not valid."); - } - - if (!isValidPathParam(sid)) { - throw new Error("Parameter 'sid' is not valid."); - } - - this._solution = { fleetSid, sid }; - this._uri = `/Fleets/${fleetSid}/Keys/${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?: KeyInstance) => any - ): Promise { - const instance = this; - let operationVersion = instance._version, - operationPromise = operationVersion.fetch({ - uri: instance._uri, - method: "get", - }); - - operationPromise = operationPromise.then( - (payload) => - new KeyInstance( - operationVersion, - payload, - instance._solution.fleetSid, - instance._solution.sid - ) - ); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback - ); - return operationPromise; - } - - update( - params?: - | KeyContextUpdateOptions - | ((error: Error | null, item?: KeyInstance) => any), - callback?: (error: Error | null, item?: KeyInstance) => any - ): Promise { - if (params instanceof Function) { - callback = params; - params = {}; - } else { - params = params || {}; - } - - let data: any = {}; - - if (params["friendlyName"] !== undefined) - data["FriendlyName"] = params["friendlyName"]; - if (params["deviceSid"] !== undefined) - data["DeviceSid"] = params["deviceSid"]; - - 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 KeyInstance( - operationVersion, - payload, - instance._solution.fleetSid, - 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 KeyPayload extends TwilioResponsePayload { - keys: KeyResource[]; -} - -interface KeyResource { - sid: string; - url: string; - friendly_name: string; - fleet_sid: string; - account_sid: string; - device_sid: string; - secret: string; - date_created: Date; - date_updated: Date; -} - -export class KeyInstance { - protected _solution: KeyContextSolution; - protected _context?: KeyContext; - - constructor( - protected _version: DeployedDevices, - payload: KeyResource, - fleetSid: string, - sid?: string - ) { - this.sid = payload.sid; - this.url = payload.url; - this.friendlyName = payload.friendly_name; - this.fleetSid = payload.fleet_sid; - this.accountSid = payload.account_sid; - this.deviceSid = payload.device_sid; - this.secret = payload.secret; - this.dateCreated = deserialize.iso8601DateTime(payload.date_created); - this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated); - - this._solution = { fleetSid, sid: sid || this.sid }; - } - - /** - * Contains a 34 character string that uniquely identifies this Key credential resource. - */ - sid: string; - /** - * Contains an absolute URL for this Key credential resource. - */ - url: string; - /** - * Contains a human readable descriptive text for this Key credential, up to 256 characters long. - */ - friendlyName: string; - /** - * Specifies the unique string identifier of the Fleet that the given Key credential belongs to. - */ - fleetSid: string; - /** - * Specifies the unique string identifier of the Account responsible for this Key credential. - */ - accountSid: string; - /** - * Specifies the unique string identifier of a Device authenticated with this Key credential. - */ - deviceSid: string; - /** - * Contains the automatically generated secret belonging to this Key credential, used to authenticate the Device. - */ - secret: string; - /** - * Specifies the date this Key credential was created, given in UTC ISO 8601 format. - */ - dateCreated: Date; - /** - * Specifies the date this Key credential was last updated, given in UTC ISO 8601 format. - */ - dateUpdated: Date; - - private get _proxy(): KeyContext { - this._context = - this._context || - new KeyContextImpl( - this._version, - this._solution.fleetSid, - this._solution.sid - ); - return this._context; - } - - /** - * Remove a KeyInstance - * - * @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 KeyInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed KeyInstance - */ - fetch( - callback?: (error: Error | null, item?: KeyInstance) => any - ): Promise { - return this._proxy.fetch(callback); - } - - /** - * Update a KeyInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed KeyInstance - */ - update( - callback?: (error: Error | null, item?: KeyInstance) => any - ): Promise; - /** - * Update a KeyInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed KeyInstance - */ - update( - params: KeyContextUpdateOptions, - callback?: (error: Error | null, item?: KeyInstance) => any - ): Promise; - - update( - params?: any, - callback?: (error: Error | null, item?: KeyInstance) => any - ): Promise { - return this._proxy.update(params, callback); - } - - /** - * Provide a user-friendly representation - * - * @returns Object - */ - toJSON() { - return { - sid: this.sid, - url: this.url, - friendlyName: this.friendlyName, - fleetSid: this.fleetSid, - accountSid: this.accountSid, - deviceSid: this.deviceSid, - secret: this.secret, - dateCreated: this.dateCreated, - dateUpdated: this.dateUpdated, - }; - } - - [inspect.custom](_depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -} - -export interface KeySolution { - fleetSid: string; -} - -export interface KeyListInstance { - _version: DeployedDevices; - _solution: KeySolution; - _uri: string; - - (sid: string): KeyContext; - get(sid: string): KeyContext; - - /** - * Create a KeyInstance - * - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed KeyInstance - */ - create( - callback?: (error: Error | null, item?: KeyInstance) => any - ): Promise; - /** - * Create a KeyInstance - * - * @param params - Parameter for request - * @param callback - Callback to handle processed record - * - * @returns Resolves to processed KeyInstance - */ - create( - params: KeyListInstanceCreateOptions, - callback?: (error: Error | null, item?: KeyInstance) => any - ): Promise; - - /** - * Streams KeyInstance 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 { KeyListInstanceEachOptions } [params] - Options for request - * @param { function } [callback] - Function to process each record - */ - each( - callback?: (item: KeyInstance, done: (err?: Error) => void) => void - ): void; - each( - params: KeyListInstanceEachOptions, - callback?: (item: KeyInstance, done: (err?: Error) => void) => void - ): void; - /** - * Retrieve a single target page of KeyInstance 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: KeyPage) => any - ): Promise; - /** - * Lists KeyInstance 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 { KeyListInstanceOptions } [params] - Options for request - * @param { function } [callback] - Callback to handle list of records - */ - list( - callback?: (error: Error | null, items: KeyInstance[]) => any - ): Promise; - list( - params: KeyListInstanceOptions, - callback?: (error: Error | null, items: KeyInstance[]) => any - ): Promise; - /** - * Retrieve a single page of KeyInstance 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 { KeyListInstancePageOptions } [params] - Options for request - * @param { function } [callback] - Callback to handle list of records - */ - page( - callback?: (error: Error | null, items: KeyPage) => any - ): Promise; - page( - params: KeyListInstancePageOptions, - callback?: (error: Error | null, items: KeyPage) => any - ): Promise; - - /** - * Provide a user-friendly representation - */ - toJSON(): any; - [inspect.custom](_depth: any, options: InspectOptions): any; -} - -export function KeyListInstance( - version: DeployedDevices, - fleetSid: string -): KeyListInstance { - if (!isValidPathParam(fleetSid)) { - throw new Error("Parameter 'fleetSid' is not valid."); - } - - const instance = ((sid) => instance.get(sid)) as KeyListInstance; - - instance.get = function get(sid): KeyContext { - return new KeyContextImpl(version, fleetSid, sid); - }; - - instance._version = version; - instance._solution = { fleetSid }; - instance._uri = `/Fleets/${fleetSid}/Keys`; - - instance.create = function create( - params?: - | KeyListInstanceCreateOptions - | ((error: Error | null, items: KeyInstance) => any), - callback?: (error: Error | null, items: KeyInstance) => any - ): Promise { - if (params instanceof Function) { - callback = params; - params = {}; - } else { - params = params || {}; - } - - let data: any = {}; - - if (params["friendlyName"] !== undefined) - data["FriendlyName"] = params["friendlyName"]; - if (params["deviceSid"] !== undefined) - data["DeviceSid"] = params["deviceSid"]; - - 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 KeyInstance(operationVersion, payload, instance._solution.fleetSid) - ); - - operationPromise = instance._version.setPromiseCallback( - operationPromise, - callback - ); - return operationPromise; - }; - - instance.page = function page( - params?: - | KeyListInstancePageOptions - | ((error: Error | null, items: KeyPage) => any), - callback?: (error: Error | null, items: KeyPage) => any - ): Promise { - if (params instanceof Function) { - callback = params; - params = {}; - } else { - params = params || {}; - } - - let data: any = {}; - - if (params["deviceSid"] !== undefined) - data["DeviceSid"] = params["deviceSid"]; - 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 KeyPage(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: KeyPage) => any - ): Promise { - const operationPromise = instance._version._domain.twilio.request({ - method: "get", - uri: targetUrl, - }); - - let pagePromise = operationPromise.then( - (payload) => new KeyPage(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 KeyPage extends Page< - DeployedDevices, - KeyPayload, - KeyResource, - KeyInstance -> { - /** - * Initialize the KeyPage - * - * @param version - Version of the resource - * @param response - Response from the API - * @param solution - Path solution - */ - constructor( - version: DeployedDevices, - response: Response, - solution: KeySolution - ) { - super(version, response, solution); - } - - /** - * Build an instance of KeyInstance - * - * @param payload - Payload response from the API - */ - getInstance(payload: KeyResource): KeyInstance { - return new KeyInstance(this._version, payload, this._solution.fleetSid); - } - - [inspect.custom](depth: any, options: InspectOptions) { - return inspect(this.toJSON(), options); - } -}