@twilio-labs/serverless-api
Version:
API-wrapper for the Twilio Serverless API
52 lines (51 loc) • 2.58 kB
TypeScript
/** @module @twilio-labs/serverless-api/dist/api */
import { FunctionApiResource, FunctionResource, ServerlessResourceConfig, Sid, ClientConfig, FunctionContent, FunctionVersion } from '../types';
import { TwilioServerlessApiClient } from '../client';
/**
* Creates a new Function instance by calling the API
*
* @param {string} name the friendly name of the function to create
* @param {string} serviceSid the service the function should belong to
* @param {TwilioServerlessApiClient} client API client
* @returns {Promise<FunctionApiResource>}
*/
export declare function createFunctionResource(name: string, serviceSid: string, client: TwilioServerlessApiClient): Promise<FunctionApiResource>;
/**
* Lists all functions associated to a service
*
* @export
* @param {string} serviceSid the service to look up
* @param {TwilioServerlessApiClient} client API client
* @returns
*/
export declare function listFunctionResources(serviceSid: string, client: TwilioServerlessApiClient): Promise<FunctionApiResource[]>;
/**
* Given a list of functions it will create the ones that don't exist and retrieves the others
*
* @export
* @param {FileInfo[]} functions list of functions to get or create
* @param {string} serviceSid service the functions belong to
* @param {TwilioServerlessApiClient} client API client
* @returns {Promise<FunctionResource[]>}
*/
export declare function getOrCreateFunctionResources(functions: ServerlessResourceConfig[], serviceSid: string, client: TwilioServerlessApiClient): Promise<FunctionResource[]>;
/**
* Uploads a given function by creating a new version, reading the content if necessary and uploading the content
*
* @export
* @param {FunctionResource} fn function to be uploaded
* @param {string} serviceSid service that the function is connected to
* @param {TwilioServerlessApiClient} client API client
* @returns {Promise<Sid>}
*/
export declare function uploadFunction(fn: FunctionResource, serviceSid: string, client: TwilioServerlessApiClient, clientConfig: ClientConfig): Promise<Sid>;
/**
* Checks if a string is an function SID by checking its prefix and length
*
* @export
* @param {string} str the string to check
* @returns
*/
export declare function isFunctionSid(str: string): boolean;
export declare function listFunctionVersions(serviceSid: Sid, functionSid: Sid, client: TwilioServerlessApiClient): Promise<FunctionVersion[]>;
export declare function downloadFunctionVersion(serviceSid: Sid, functionSid: Sid, functionVersionSid: Sid, client: TwilioServerlessApiClient): Promise<FunctionContent>;