From a7f3211c22be47b055d6c30039d2d37f104ac79b Mon Sep 17 00:00:00 2001 From: Twilio Date: Thu, 3 Oct 2024 15:38:23 +0000 Subject: [PATCH] [Librarian] Regenerated @ 021bab52f93b55d7a5786bd27716bf3a0be2d7b9 aa81ca7c51512c448626fafb32aeb46838510334 --- CHANGES.md | 13 + src/rest/PreviewBase.ts | 7 - src/rest/iam/V1.ts | 14 +- src/rest/iam/v1/{newApiKey.ts => key.ts} | 44 +- src/rest/numbers/v1/portingPortability.ts | 4 + src/rest/preview/DeployedDevices.ts | 37 - src/rest/preview/deployed_devices/fleet.ts | 738 ----------------- .../deployed_devices/fleet/certificate.ts | 724 ----------------- .../deployed_devices/fleet/deployment.ts | 712 ---------------- .../preview/deployed_devices/fleet/device.ts | 763 ------------------ .../preview/deployed_devices/fleet/key.ts | 717 ---------------- src/rest/taskrouter/v1/workspace/task.ts | 4 +- src/rest/verify/v2/service/verification.ts | 6 + .../verify/v2/service/verificationCheck.ts | 4 + 14 files changed, 58 insertions(+), 3729 deletions(-) rename src/rest/iam/v1/{newApiKey.ts => key.ts} (82%) delete mode 100644 src/rest/preview/DeployedDevices.ts delete mode 100644 src/rest/preview/deployed_devices/fleet.ts delete mode 100644 src/rest/preview/deployed_devices/fleet/certificate.ts delete mode 100644 src/rest/preview/deployed_devices/fleet/deployment.ts delete mode 100644 src/rest/preview/deployed_devices/fleet/device.ts delete mode 100644 src/rest/preview/deployed_devices/fleet/key.ts diff --git a/CHANGES.md b/CHANGES.md index 73869f63e8..c09b78e10d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,19 @@ twilio-node changelog ===================== +[2024-10-03] Version 5.3.3 +-------------------------- +**Messaging** +- Add A2P external campaign CnpMigration flag + +**Numbers** +- Add address sid to portability API + +**Verify** +- Add `SnaClientToken` optional parameter on Verification check. +- Add `EnableSnaClientToken` optional parameter for Verification creation. + + [2024-09-25] Version 5.3.2 -------------------------- **Library - Chore** diff --git a/src/rest/PreviewBase.ts b/src/rest/PreviewBase.ts index 2aeead219c..059903ee1b 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; @@ -32,11 +30,6 @@ class PreviewBase extends Domain { 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/iam/V1.ts b/src/rest/iam/V1.ts index 30b75755cb..28484249f7 100644 --- a/src/rest/iam/V1.ts +++ b/src/rest/iam/V1.ts @@ -16,7 +16,7 @@ import IamBase from "../IamBase"; import Version from "../../base/Version"; import { ApiKeyListInstance } from "./v1/apiKey"; import { GetApiKeysListInstance } from "./v1/getApiKeys"; -import { NewApiKeyListInstance } from "./v1/newApiKey"; +import { KeyListInstance } from "./v1/key"; export default class V1 extends Version { /** @@ -32,8 +32,8 @@ export default class V1 extends Version { protected _apiKey?: ApiKeyListInstance; /** getApiKeys - { Twilio.Iam.V1.GetApiKeysListInstance } resource */ protected _getApiKeys?: GetApiKeysListInstance; - /** newApiKey - { Twilio.Iam.V1.NewApiKeyListInstance } resource */ - protected _newApiKey?: NewApiKeyListInstance; + /** keys - { Twilio.Iam.V1.KeyListInstance } resource */ + protected _keys?: KeyListInstance; /** Getter for apiKey resource */ get apiKey(): ApiKeyListInstance { @@ -47,9 +47,9 @@ export default class V1 extends Version { return this._getApiKeys; } - /** Getter for newApiKey resource */ - get newApiKey(): NewApiKeyListInstance { - this._newApiKey = this._newApiKey || NewApiKeyListInstance(this); - return this._newApiKey; + /** Getter for keys resource */ + get keys(): KeyListInstance { + this._keys = this._keys || KeyListInstance(this); + return this._keys; } } diff --git a/src/rest/iam/v1/newApiKey.ts b/src/rest/iam/v1/key.ts similarity index 82% rename from src/rest/iam/v1/newApiKey.ts rename to src/rest/iam/v1/key.ts index 2fcfb48404..6dbbd39cc3 100644 --- a/src/rest/iam/v1/newApiKey.ts +++ b/src/rest/iam/v1/key.ts @@ -18,41 +18,41 @@ const deserialize = require("../../../base/deserialize"); const serialize = require("../../../base/serialize"); import { isValidPathParam } from "../../../base/utility"; -export type NewApiKeyKeytype = "restricted"; +export type KeyKeytype = "restricted"; /** - * Options to pass to create a NewApiKeyInstance + * Options to pass to create a KeyInstance */ -export interface NewApiKeyListInstanceCreateOptions { +export interface KeyListInstanceCreateOptions { /** The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Payments resource. */ accountSid: string; /** A descriptive string that you create to describe the resource. It can be up to 64 characters long. */ friendlyName?: string; /** */ - keyType?: NewApiKeyKeytype; + keyType?: KeyKeytype; /** The \\\\`Policy\\\\` object is a collection that specifies the allowed Twilio permissions for the restricted key. For more information on the permissions available with restricted API keys, refer to the [Twilio documentation](https://www.twilio.com/docs/iam/api-keys/restricted-api-keys#permissions-available-with-restricted-api-keys). */ policy?: any; } -export interface NewApiKeySolution {} +export interface KeySolution {} -export interface NewApiKeyListInstance { +export interface KeyListInstance { _version: V1; - _solution: NewApiKeySolution; + _solution: KeySolution; _uri: string; /** - * Create a NewApiKeyInstance + * Create a KeyInstance * * @param params - Parameter for request * @param callback - Callback to handle processed record * - * @returns Resolves to processed NewApiKeyInstance + * @returns Resolves to processed KeyInstance */ create( - params: NewApiKeyListInstanceCreateOptions, - callback?: (error: Error | null, item?: NewApiKeyInstance) => any - ): Promise; + params: KeyListInstanceCreateOptions, + callback?: (error: Error | null, item?: KeyInstance) => any + ): Promise; /** * Provide a user-friendly representation @@ -61,17 +61,17 @@ export interface NewApiKeyListInstance { [inspect.custom](_depth: any, options: InspectOptions): any; } -export function NewApiKeyListInstance(version: V1): NewApiKeyListInstance { - const instance = {} as NewApiKeyListInstance; +export function KeyListInstance(version: V1): KeyListInstance { + const instance = {} as KeyListInstance; instance._version = version; instance._solution = {}; instance._uri = `/Keys`; instance.create = function create( - params: NewApiKeyListInstanceCreateOptions, - callback?: (error: Error | null, items: NewApiKeyInstance) => any - ): Promise { + params: KeyListInstanceCreateOptions, + callback?: (error: Error | null, items: KeyInstance) => any + ): Promise { if (params === null || params === undefined) { throw new Error('Required parameter "params" missing.'); } @@ -101,7 +101,7 @@ export function NewApiKeyListInstance(version: V1): NewApiKeyListInstance { }); operationPromise = operationPromise.then( - (payload) => new NewApiKeyInstance(operationVersion, payload) + (payload) => new KeyInstance(operationVersion, payload) ); operationPromise = instance._version.setPromiseCallback( @@ -125,9 +125,9 @@ export function NewApiKeyListInstance(version: V1): NewApiKeyListInstance { return instance; } -interface NewApiKeyPayload extends NewApiKeyResource {} +interface KeyPayload extends KeyResource {} -interface NewApiKeyResource { +interface KeyResource { sid: string; friendly_name: string; date_created: Date; @@ -136,8 +136,8 @@ interface NewApiKeyResource { policy: any; } -export class NewApiKeyInstance { - constructor(protected _version: V1, payload: NewApiKeyResource) { +export class KeyInstance { + constructor(protected _version: V1, payload: KeyResource) { this.sid = payload.sid; this.friendlyName = payload.friendly_name; this.dateCreated = deserialize.rfc2822DateTime(payload.date_created); diff --git a/src/rest/numbers/v1/portingPortability.ts b/src/rest/numbers/v1/portingPortability.ts index 8bc592156c..9359872440 100644 --- a/src/rest/numbers/v1/portingPortability.ts +++ b/src/rest/numbers/v1/portingPortability.ts @@ -30,6 +30,8 @@ export type PortingPortabilityNumberType = export interface PortingPortabilityContextFetchOptions { /** Account Sid to which the number will be ported. This can be used to determine if a sub account already has the number in its inventory or a different sub account. If this is not provided, the authenticated account will be assumed to be the target account. */ targetAccountSid?: string; + /** Address Sid of customer to which the number will be ported. */ + addressSid?: string; } export interface PortingPortabilityContext { @@ -99,6 +101,8 @@ export class PortingPortabilityContextImpl if (params["targetAccountSid"] !== undefined) data["TargetAccountSid"] = params["targetAccountSid"]; + if (params["addressSid"] !== undefined) + data["AddressSid"] = params["addressSid"]; const headers: any = {}; 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); - } -} diff --git a/src/rest/taskrouter/v1/workspace/task.ts b/src/rest/taskrouter/v1/workspace/task.ts index 50542db8dd..3ac8827d8d 100644 --- a/src/rest/taskrouter/v1/workspace/task.ts +++ b/src/rest/taskrouter/v1/workspace/task.ts @@ -53,7 +53,7 @@ export interface TaskContextUpdateOptions { priority?: number; /** When MultiTasking is enabled, specify the TaskChannel with the task to update. Can be the TaskChannel\\\'s SID or its `unique_name`, such as `voice`, `sms`, or `default`. */ taskChannel?: string; - /** The task\\\'s new virtual start time value. When supplied, the Task takes on the specified virtual start time. Value can\\\'t be in the future. */ + /** The task\\\'s new virtual start time value. When supplied, the Task takes on the specified virtual start time. Value can\\\'t be in the future or before the year of 1900. */ virtualStartTime?: Date; } @@ -71,7 +71,7 @@ export interface TaskListInstanceCreateOptions { workflowSid?: string; /** A URL-encoded JSON string with the attributes of the new task. This value is passed to the Workflow\\\'s `assignment_callback_url` when the Task is assigned to a Worker. For example: `{ \\\"task_type\\\": \\\"call\\\", \\\"twilio_call_sid\\\": \\\"CAxxx\\\", \\\"customer_ticket_number\\\": \\\"12345\\\" }`. */ attributes?: string; - /** The virtual start time to assign the new task and override the default. When supplied, the new task will have this virtual start time. When not supplied, the new task will have the virtual start time equal to `date_created`. Value can\\\'t be in the future. */ + /** The virtual start time to assign the new task and override the default. When supplied, the new task will have this virtual start time. When not supplied, the new task will have the virtual start time equal to `date_created`. Value can\\\'t be in the future or before the year of 1900. */ virtualStartTime?: Date; /** A SID of a Worker, Queue, or Workflow to route a Task to */ routingTarget?: string; diff --git a/src/rest/verify/v2/service/verification.ts b/src/rest/verify/v2/service/verification.ts index f58804f8c8..ab42617358 100644 --- a/src/rest/verify/v2/service/verification.ts +++ b/src/rest/verify/v2/service/verification.ts @@ -66,6 +66,8 @@ export interface VerificationListInstanceCreateOptions { templateCustomSubstitutions?: string; /** Strongly encouraged if using the auto channel. The IP address of the client\\\'s device. If provided, it has to be a valid IPv4 or IPv6 address. */ deviceIp?: string; + /** An optional Boolean value to indicate the requirement of sna client token in the SNA URL invocation response for added security. This token must match in the Verification Check request to confirm phone number verification. */ + enableSnaClientToken?: boolean; /** */ riskCheck?: VerificationRiskCheck; /** A string containing a JSON map of key value pairs of tags to be recorded as metadata for the message. The object may contain up to 10 tags. Keys and values can each be up to 128 characters in length. */ @@ -488,6 +490,10 @@ export function VerificationListInstance( data["TemplateCustomSubstitutions"] = params["templateCustomSubstitutions"]; if (params["deviceIp"] !== undefined) data["DeviceIp"] = params["deviceIp"]; + if (params["enableSnaClientToken"] !== undefined) + data["EnableSnaClientToken"] = serialize.bool( + params["enableSnaClientToken"] + ); if (params["riskCheck"] !== undefined) data["RiskCheck"] = params["riskCheck"]; if (params["tags"] !== undefined) data["Tags"] = params["tags"]; diff --git a/src/rest/verify/v2/service/verificationCheck.ts b/src/rest/verify/v2/service/verificationCheck.ts index 4d642bb8db..a1074ebd48 100644 --- a/src/rest/verify/v2/service/verificationCheck.ts +++ b/src/rest/verify/v2/service/verificationCheck.ts @@ -39,6 +39,8 @@ export interface VerificationCheckListInstanceCreateOptions { amount?: string; /** The payee of the associated PSD2 compliant transaction. Requires the PSD2 Service flag enabled. */ payee?: string; + /** A sna client token received in sna url invocation response needs to be passed in Verification Check request and should match to get successful response. */ + snaClientToken?: string; } export interface VerificationCheckSolution { @@ -115,6 +117,8 @@ export function VerificationCheckListInstance( data["VerificationSid"] = params["verificationSid"]; if (params["amount"] !== undefined) data["Amount"] = params["amount"]; if (params["payee"] !== undefined) data["Payee"] = params["payee"]; + if (params["snaClientToken"] !== undefined) + data["SnaClientToken"] = params["snaClientToken"]; const headers: any = {}; headers["Content-Type"] = "application/x-www-form-urlencoded";