/** @module @twilio-labs/serverless-api */ /// import events from 'events'; import { HTTPAlias, OptionsOfJSONResponseBody, OptionsOfTextResponseBody, Response } from 'got/dist/source'; import { LogsStream } from './streams/logs'; import { ActivateConfig, ActivateResult, ClientConfig, DeployLocalProjectConfig, DeployProjectConfig, DeployResult, GotClient, ListConfig, ListResult, LogApiResource, LogsConfig } from './types'; import { GetEnvironmentVariablesConfig, GetEnvironmentVariablesResult, RemoveEnvironmentVariablesConfig, RemoveEnvironmentVariablesResult, SetEnvironmentVariablesConfig, SetEnvironmentVariablesResult } from './types/env'; export declare function createGotClient(config: ClientConfig): GotClient; export declare class TwilioServerlessApiClient extends events.EventEmitter { /** * Contains the client config used to do API requests * * @private * @type {ClientConfig} * @memberof TwilioServerlessApiClient */ private config; /** * The `got` client that is used to make all the API requests * * @private * @type {GotClient} * @memberof TwilioServerlessApiClient */ private client; /** * * @private * @type {Limit} * @memberof TwilioServerlessApiClient */ private limit; constructor(config: ClientConfig); /** * Returns the internally used GotClient instance used to make API requests * @returns {GotClient} A client instance with set-up credentials */ getClient(): GotClient; /** * Sets a set of environment variables for a given Twilio Serverless environment * If append is false it will remove all existing environment variables. * * @param {SetEnvironmentVariablesConfig} config * @returns {Promise} * @memberof TwilioServerlessApiClient */ setEnvironmentVariables(config: SetEnvironmentVariablesConfig): Promise; /** * Retrieves a list of environment variables for a given Twilio Serverless environment. * If config.getValues is false (default) the values will be all set to undefined. * * @param {GetEnvironmentVariablesConfig} config * @returns {Promise} * @memberof TwilioServerlessApiClient */ getEnvironmentVariables(config: GetEnvironmentVariablesConfig): Promise; /** * Deletes a list of environment variables (by key) for a given Twilio Serverless environment. * * @param {RemoveEnvironmentVariablesConfig} config * @returns {Promise} * @memberof TwilioServerlessApiClient */ removeEnvironmentVariables(config: RemoveEnvironmentVariablesConfig): Promise; /** * Returns an object containing lists of services, environments, variables * functions or assets, depending on which have beeen requested in `listConfig` * @param {ListConfig} listConfig Specifies info around which things should be listed * @returns Promise Object containing the different lists. */ list(listConfig: ListConfig): Promise; getLogsStream(logsConfig: LogsConfig): Promise; getLogs(logsConfig: LogsConfig): Promise; /** * "Activates" a build by taking a specified build SID or a "source environment" * and activating the same build in the specified `environment`. * * Can optionally create the new environment when called with `activateConfig.createEnvironment` * @param {ActivateConfig} activateConfig Config to specify which build to activate in which environment * @returns Promise Object containing meta information around deployment */ activateBuild(activateConfig: ActivateConfig): Promise; /** * Deploys a set of functions, assets, variables and dependencies specified * in `deployConfig`. Functions & assets can either be paths to the local * filesystem or `Buffer` instances allowing you to dynamically upload * even without a file system. * * Unless a `deployConfig. serviceSid` is specified, it will try to create one. If a service * with the name `deployConfig.serviceName` already exists, it will throw * an error. You can make it use the existing service by setting `overrideExistingService` to * true. * * Updates to the deployment will be emitted as events to `status-update`. Example: * * ```js * client.on('status-update', ({ status, message }) => { * console.log('[%s]: %s', status, message); * }) * ``` * @param {DeployProjectConfig} deployConfig Config containing all details for deployment * @returns Promise Object containing meta information around deployment */ deployProject(deployConfig: DeployProjectConfig): Promise; /** * Deploys a local project by reading existing functions and assets * from `deployConfig.cwd` and calling `this.deployProject` with it. * * Functions have to be placed in a `functions` or `src` directory to be found. * Assets have to be placed into an `assets` or `static` directory. * * Nested folder structures will result in nested routes. * @param {DeployLocalProjectConfig} deployConfig * @returns Promise Object containing meta information around deployment */ deployLocalProject(deployConfig: DeployLocalProjectConfig): Promise; request(method: HTTPAlias, path: string): Promise>; request(method: HTTPAlias, path: string, options: OptionsOfJSONResponseBody): Promise>; request(method: HTTPAlias, path: string, options: OptionsOfTextResponseBody): Promise>; } export default TwilioServerlessApiClient;