import { Got } from 'got'; import { LoginController } from '../controller/login.controller'; import { ILambda, IRuntime, ISchedule, IDomain } from '../types'; import { IScheduleConfig } from '../controller/create.controller'; import { CsdsClient } from './csds.service'; export declare type HttpMethods = 'POST' | 'GET' | 'DELETE' | 'PUT'; export interface IPayload { headers: string[]; payload: any; } export interface IInvokeResponse { result: any; logs: { level: string; message: any; extras: any[]; timestamp: number; }[]; } export interface IDeploymentResponse { /** * Deployment message from the LivePerson functions platform * @type {string} * @memberof IDeploymentResponse */ message: string; /** * UUID of the lambda that was deployed (optional) * @type {string} * @memberof IDeploymentResponse */ uuid?: string; } export interface IFaaSService { /** * Runs the initial setup for the faas service. * Checks if a valid temp file is available and will use this for authentication. * If not, the user will have to enter his accountId, username and password. * Have to be called before all other functions. * @returns {Promise} * @memberof IFaaSService */ setup(): Promise; /** * Undeploys a function on the LivePerson functions platform. Setup before is necessary. * The correct LivePerson url will be fetched by the accountId. * @param {string} uuid - lambda uuid * @returns {Promise} * @memberof IFaaSService */ undeploy(uuid: string): Promise; /** * Deploys a function on the LivePerson functions platform. Setup before is necessary. * The correct LivePerson url will be fetched by the accountId. * @param {string} uuid - lambda uuid * @returns {Promise} * @memberof IFaaSService */ deploy(uuid: string): Promise; /** * Gather all information from the LivePerson functions platform by lambda names. Setup before is necessary. * The correct LivePerson url will be fetched by the accountId. * @param {string[]} lambdaNames - lambda names which should be collected * @returns {Promise} * @memberof IFaaSService */ getLambdasByNames(lambdaNames: string[]): Promise<(ILambda | { name: string; })[]>; /** * Gather all information from the LivePerson functions platform. Setup before is necessary. * The correct LivePerson url will be fetched by the accountId. * @returns {Promise} * @memberof IFaaSService */ getAllLambdas(): Promise; /** * Gather the information from one lambda by uuid. Setup before is necessary. * The correct LivePerson url will be fetched by the accountId. * @param {string} uuid - lambda uuid * @returns {Promise} * @memberof IFaaSService */ getLambdaByUUID(uuid: string): Promise; /** * Push a local lambda to the LP-Functions platform. Either creates * a new lambda or overwrites an existing one. * @param {Object} input - Object containing all the other inputs * @param {HttpMethods} input.method - The HTTP Method that will be used for the push request. * @param {ILambda} input.body - The HTTP body that will be used for the push request. * @param {string} input.uuid - Uuid that identifies a lambda to overwrite on the LP-Functions platform. * Only needed if the function already exists. * @returns {Promise} * @memberof IFaaSService */ push(input: { method: HttpMethods; body: ILambda; uuid?: string; }): void; /** * Return the current runtime of the LivePerson functions platform * The correct LivePerson url will be fetched by the accountId. * @returns {Promise} * @memberof IFaaSService */ getRuntime(): Promise; /** * Invokes a function on the LivePerson functions platform with a provided payload * The correct LivePerson url will be fetched by the accountId. * @param {string} uuid * @param {IPayload} payload * @returns {Promise} * @memberof IFaaSService */ invoke(uuid: string, payload: IPayload): Promise; /** * Creates a schedule in an account based on a cron expression and the lambda uuid. Every function can only be scheduled once and must be deployed. * @param uuid uuid of lambda for which a schedule will be created * @param cronExpression string which is in the cron expression format */ createSchedule(schedule: { uuid: string; cronExpression: string; }): Promise; /** * Creates a schedule in an account based on a cron expression and the lambda uuid. Every function can only be scheduled once and must be deployed. * @param uuid uuid of lambda for which a schedule will be created * @param cronExpression string which is in the cron expression format */ addDomain(domain: string): Promise; /** * Get logs from the LivePerson functions platform by lambda names. Setup before is necessary. * The correct LivePerson url will be fetched by the accountId. * @param {string} uuid uuid of lambda for which logs should be fetched * @param {number} start start timestamp for logs * @param {number} end end timestamp for logs * @param {string[]} levels which is in the cron expression format * @returns {Promise} * @memberof IFaaSService */ getLogs(options: { uuid: string; start?: string; end?: string; levels?: string[]; removeHeader?: boolean; }): Promise; } interface IFaasServiceConfig { username?: string; loginController?: LoginController; csdsClient?: CsdsClient; gotDefault?: Got; } export declare class FaasService implements IFaaSService { username: string; accountId: string | undefined; userId: string | undefined; token: string | undefined; private readonly loginController; private readonly csdsClient; private readonly got; constructor({ username, loginController, csdsClient, gotDefault, }?: IFaasServiceConfig); undeploy(uuid: string): Promise; deploy(uuid: string): Promise; getLambdasByNames(lambdaNames: string[], collectNonExistingLambas?: boolean): Promise<(ILambda | { name: string; })[]>; getRuntime(): Promise; getAllLambdas(): Promise; createSchedule(schedule: IScheduleConfig): Promise; addDomain(domain: string): Promise; getLambdaInvocationMetrics({ uuid, startTimestamp, endTimestamp, bucketSize, }: { uuid: string; startTimestamp: number; endTimestamp: number; bucketSize: any; }): Promise; getAccountStatistic(): Promise; push({ method, body, uuid, }: { method: HttpMethods; body: ILambda; uuid?: string; }): Promise; getLambdaByUUID(uuid: string): Promise; invoke(uuid: string, payload: IPayload): Promise; getEvents(): Promise; getLogs({ uuid, start, end, levels, removeHeader, }: { uuid: string; start?: string; end?: string; levels?: string[]; removeHeader?: boolean; }): Promise; setup(): Promise; private getCsdsEntry; private getStream; private doFetch; } export {};