/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import * as Swagger from 'swagger-schema-official' import { Agent } from 'http' export = openwhisk; declare function openwhisk(options?: openwhisk.Options): openwhisk.Client; declare namespace openwhisk { interface Options { api?: string; api_key?: string; apihost?: string; namespace?: string; ignore_certs?: boolean; apigw_token?: string; apigw_space_guid?: string; proxy?: string; agent?: Agent; apiversion?: string; noUserAgent?: boolean; cert?: string; key?: string; auth_handler?: { getAuthHeader: () => Promise } } // Client interface Client { actions: Actions; activations: Activations; namespaces: Namespaces; packages: Packages; rules: Rules; triggers: Triggers; feeds: Feeds; routes: Routes; } // Resources interface Actions { list(options?: { namespace?: string; skip?: number; limit?: number; count?: boolean; }): Promise; get(options: string): Promise get(options: { name: string; namespace?: string }): Promise; get(options: (string | { name: string; namespace?: string })[]): Promise; invoke(options: string): Promise<{ activationId: string }> invoke(options: { name: string; namespace?: string; blocking: boolean; params?: Dict; result: boolean; }): Promise; invoke(options: { name: string; namespace?: string; blocking: boolean; params?: Dict; result?: boolean; }): Promise>; invoke(options: { name: string; namespace?: string; blocking?: boolean; params?: Dict; result?: boolean; }): Promise<{ activationId: string }>; invoke(options: (string | { name: string; namespace?: string; blocking?: boolean; params?: Dict; result?: boolean; })[]): Promise<{ activationId: string }[]>; invoke(options: { name: string; namespace?: string; blocking: boolean; params?: In; result: boolean; }): Promise; invoke(options: { name: string; namespace?: string; blocking: boolean; params?: In; result?: boolean; }): Promise>; invoke(options: { name: string; namespace?: string; blocking?: boolean; params?: In; result?: boolean; }): Promise<{ activationId: string }>; create(options: { name: string; namespace?: string; action: (string | Buffer | Action); kind?: Kind; overwrite?: boolean; params?: Dict; annotations?: Dict; limits?: Limits; version?: string; }): Promise; //create(options: { name: string; namespace?: string; action: (string | Buffer | Action); kind?: Kind; overwrite?: boolean; params?: Dict; version?: string; }[]): Promise; update(options: { name: string; namespace?: string; action?: (string | Buffer | Action); kind?: Kind; params?: Dict; annotations?: Dict; limits?: Limits; version?: string; }): Promise; //update(options: ({ name: string; namespace?: string; action: (string | Buffer | Action); kind?: Kind; params?: Dict; version?: string; })[]): Promise; delete(options: string): Promise; delete(options: { name: string; namespace?: string; }): Promise; delete(options: (string | { name: string; namespace?: string; })[]): Promise; } interface Activations { list(options?: { namespace?: string; name?: string; skip?: number; limit?: number; upto?: number; docs?: boolean; since?: number; count?: boolean; }): Promise; get(options: string): Promise>; get(options: { name: string; namespace?: string }): Promise>; get(options: string): Promise>; get(options: { name: string; namespace?: string }): Promise>; //get(options: (string | { name: string; namespace?: string })[]): Promise[]>; logs(options: { name: string; namespace?: string }): Promise<{ logs: String[] }>; result(options: { name: string; namespace?: string }): Promise>; result(options: { name: string; namespace?: string }): Promise>; } interface Namespaces { list(): Promise; get(options: string): Promise get(options: { namespace: string }): Promise //get(options: (string | { namespace: string })[]): Promise } interface Packages { list(options?: { namespace?: string; skip?: number; limit?: number; public?: boolean; count?: boolean; }): Promise; get(options: string): Promise get(options: { name: string; namespace?: string }): Promise; get(options: (string | { name: string; namespace?: string })[]): Promise; create(options: { name: string; namespace?: string; package?: Package; overwrite?: boolean }): Promise; update(options: { name: string; namespace?: string; package?: Package }): Promise; delete(options: string): Promise delete(options: { name: string; namespace?: string; }): Promise; delete(options: (string | { name: string; namespace?: string; })[]): Promise; } interface Rules { list(options?: { namespace?: string; skip?: number; limit?: number; count?: boolean; }): Promise; get(options: string): Promise; get(options: { name: string; namespace?: string; }): Promise; get(options: (string | { name: string; namespace?: string; })[]): Promise; create(options: { name: string; namespace?: string; action: string; trigger: string; status?: Status; overwrite?: boolean }): Promise; update(options: { name: string; namespace?: string; action: string; trigger: string; status?: Status }): Promise; delete(options: string): Promise delete(options: { name: string; namespace?: string; }): Promise; delete(options: (string | { name: string; namespace?: string; })[]): Promise; enable(options: { name: string; namespace?: string; }): Promise; disable(options: { name: string; namespace?: string; }): Promise; } interface Triggers { list(options?: { namespace?: string; skip?: number; limit?: number; count?: boolean; }): Promise; get(options: string): Promise get(options: { name: string; namespace?: string; }): Promise; get(options: (string | { name: string; namespace?: string; })[]): Promise; invoke(options: string): Promise<{ activationId: string }> invoke(options: { name: string; namespace?: string; params?: Dict }): Promise<{ activationId: string }> invoke(options: (string | { name: string; namespace?: string; params?: Dict })[]): Promise<{ activationId: string }[]> invoke(options: { name: string; namespace?: string; params?: T }): Promise<{ activationId: string }> create(options: { name: string; namespace?: string; trigger?: Trigger; overwrite?: boolean; }): Promise; update(options: { name: string; namespace?: string; trigger?: Trigger }): Promise; delete(options: string): Promise delete(options: { name: string; namespace?: string; }): Promise; delete(options: (string | { name: string; namespace?: string; })[]): Promise; } interface Feeds { create(options: { name: string; trigger: string; namespace?: string; params?: Dict }): Promise>; delete(options: { name: string; trigger: string; namespace?: string; }): Promise>; feed(event: Event, options: { name: string; trigger: string; namespace?: string; }): Promise>; } interface Routes { list(options?: { relpath?: string, basepath?: string, operation?: string, limit?: number, skip?: number }): Promise<{ apis: Route[] }>; delete(options: { basepath: string; relpath?: string, operation?: Operation }): Promise<{}>; create(options: { basepath?: string; relpath: string, operation: Operation, action: string }): Promise; } // Descriptions interface ShortDesc { name?: string; annotations?: KeyVal[]; version?: string; } interface Desc extends ShortDesc { publish?: boolean; namespace?: string; } type ActionDesc = Desc interface ActivationDesc extends Desc { activationId: string; } interface PackageDesc extends Desc { binding?: boolean; } type RuleDesc = Desc type TriggerDesc = Desc interface FeedActionDesc { lifecycleEvent: Event; authKey: string; triggerName: string; } // Entities interface Action extends ActionDesc { parameters?: KeyVal[]; limits?: Limits; exec: Exec | Sequence; } interface Activation extends ActivationDesc { subject: string; start: number; end: number; duration: number; response?: Response; logs: string[]; } interface Namespace { actions?: ActionDesc[]; packages?: PackageDesc[]; rules?: RuleDesc[]; triggers?: TriggerDesc[]; } interface Package extends Desc { actions?: ShortDesc[]; feeds?: ShortDesc[]; parameters?: KeyVal[]; binding?: {} | Package; } interface Rule extends RuleDesc { trigger: PathName; status: Status; action: PathName; } interface Trigger extends TriggerDesc { parameters?: KeyVal[]; limits?: any; rules?: { [key: string]: { action: PathName; status: Status; } } } interface Route { id: string; key: string; value: Api; } // Other interface Dict { [key: string]: any } interface Exec { kind: Kind; code: string; binary?: boolean; main?: string; image?: string; } interface Sequence { kind: "sequence"; components: string[]; } type Kind = string; interface Limits { timeout?: number; memory?: number; logs?: number; concurrency?: number; } interface Response { status: "success" | "failure"; statusCode?: number; success: boolean; result: T } interface KeyVal { key: string; value: any; } interface PathName { path: string; name: string; } type Status = "" | "active" | "inactive" | "activating" | "deactivating"; type Event = "" | "CREATE" | "DELETE" | "PAUSE" | "UNPAUSE" type Operation = "" | "GET" | "POST" | "PUT" | "PATCH" | "DELETE" interface Api { namespace: string; gwApiActivated: boolean; tenantId: boolean; gwApiUrl: string; apidoc: Swagger.Spec; } }