googleapis-nodejs-functions
Version:
Google Cloud Functions Client Library for Node.js (unofficial)
157 lines (156 loc) • 4.66 kB
TypeScript
import { Service, GoogleAuthOptions } from '@google-cloud/common';
import * as request from 'request';
import { CloudFunction } from './cloudfunction';
export declare enum CloudFunctionStatus {
CLOUD_FUNCTION_STATUS_UNSPECIFIED = 0,
ACTIVE = 1,
OFFLINE = 2,
DEPLOY_IN_PROGRESS = 3,
DELETE_IN_PROGRESS = 4,
UNKNOWN = 5
}
export declare enum CloudFunctionRuntimes {
nodejs6 = 0,
nodejs8 = 1,
python3 = 2
}
export interface HttpsTrigger {
url: string;
}
export interface FailurePolicy {
retry: any;
}
export interface EventTrigger {
eventType: string;
resource: string;
service: string;
failurePolicy?: FailurePolicy;
}
export interface SourceRepository {
url: string;
deployedUrl?: string;
}
export interface CloudFunctionMetadata {
runtime: string;
description: string;
status: CloudFunctionStatus;
entryPoint: string;
timeout: string;
availableMemoryMb: number;
serviceAccountEmail: string;
updateTime: string;
versionId: string;
labels: any;
environmentVariables: any;
network: string;
maxInstances: number;
sourceArchiveUrl?: string;
sourceRepository?: SourceRepository;
sourceUploadUrl?: string;
httpsTrigger?: HttpsTrigger;
eventTrigger?: EventTrigger;
}
export interface CloudFunctionConfig {
location?: string;
runtime?: string;
description?: string;
entryPoint?: string;
timeout?: string;
availableMemoryMb?: number;
labels?: any;
sourceArchiveUrl?: string;
sourceRepository?: SourceRepository;
sourceUploadUrl?: string;
httpsTrigger?: HttpsTrigger;
eventTrigger?: EventTrigger;
}
export interface CloudFunctionQuery {
autoPaginate?: true;
maxApiCalls?: number;
maxResults?: number;
pageToken?: string;
userProject?: string;
location?: string;
}
export interface Status {
code: number;
message: string;
details?: any;
}
export interface Operation {
name: string;
metadata: any;
done: boolean;
error?: Status;
response?: any;
}
export interface ListOperationsResponse {
operations: Operation[];
nextPageToken: string;
}
export interface ApiResponse {
}
export interface Credentials {
client_email?: string;
private_key?: string;
}
export interface ConfigurationObject extends GoogleAuthOptions {
autoRetry?: boolean;
credentials?: Credentials;
email?: string;
keyFilename?: string;
maxRetries?: number;
projectId?: string;
promise?: typeof Promise;
}
export interface CloudFunctionCallback {
(err: Error | null, fn?: CloudFunction | null | undefined | Operation, apiResponse?: request.Response): void;
}
export interface CloudFunctionsCallback {
(err: Error | null, fns?: CloudFunction[] | null | undefined, nextQuery?: string | null | undefined, apiResponse?: request.Response): void;
}
/*!
* @param {ConfigurationObject} [options] Configuration options.
*/
declare class GCF extends Service {
/**
* {@link CloudFunction} class.
*
* @name GCF.CloudFunction
* @see CloudFunction
* @type {Constructor}
*/
static CloudFunction: typeof CloudFunction;
location: string;
constructor(options?: ConfigurationObject, location?: string);
/**
* Get a reference to a Cloud Functions function.
*
* @param {string} name Name of the function.
* @returns {CloudFunction}
*/
cloudFunction(name: string, metadata?: CloudFunctionMetadata): CloudFunction;
/**
* Create a function.
*
* @param {string} name Name of the function to create.
* @param {CloudFunctionConfig} [metadata] Metadata to set for the function.
* @param {CloudFunctionCallback} [callback]
* @returns {Promise<CloudFunction>}
* @throws {Error} If a name is not provided.
*
*/
createCloudFunction(name: string, callback: CloudFunctionCallback): void | Promise<[Operation, any]>;
createCloudFunction(name: string, metadata: CloudFunctionConfig, callback?: CloudFunctionCallback): void | Promise<[Operation, any]>;
private getLocations;
/**
* Get Function objects for all of the functions in your project.
*
* @param {CloudFunctionQuery} [query] Query object for listing function.
* @param {CloudFunctionCallback} [callback] Callback function.
* @returns {Promise<CloudFunction[]>}
*/
getCloudFunctions(query?: CloudFunctionQuery, callback?: CloudFunctionsCallback): void | Promise<[CloudFunction[], any]>;
operation(name: string, callback?: CloudFunctionCallback): void | Promise<[Operation, any]>;
}
export { GCF, CloudFunction };