Built motion from commit 6a09e18b.|2.6.11
[motion2.git] / legacy-libs / google-gax / build / src / grpc.d.ts
1 /// <reference types="node" />
2 import * as grpcProtoLoaderTypes from '@grpc/proto-loader';
3 import { GoogleAuth, GoogleAuthOptions } from 'google-auth-library';
4 import * as grpcTypes from 'grpc';
5 import { OutgoingHttpHeaders } from 'http';
6 import * as protobuf from 'protobufjs';
7 import * as gax from './gax';
8 export { GrpcObject } from 'grpc';
9 export interface GrpcClientOptions extends GoogleAuthOptions {
10     auth?: GoogleAuth;
11     promise?: PromiseConstructor;
12     grpc?: GrpcModule;
13 }
14 export interface MetadataValue {
15     equals: Function;
16 }
17 export interface Metadata {
18     new (): Metadata;
19     set: (key: {}, value?: {} | null) => void;
20     clone: () => Metadata;
21     value: MetadataValue;
22     get: (key: {}) => {};
23 }
24 export declare type GrpcModule = typeof grpcTypes & {
25     status: {
26         [index: string]: number;
27     };
28     isLegacy: boolean;
29 };
30 export interface ClientStubOptions {
31     servicePath: string;
32     port: number;
33     sslCreds?: grpcTypes.ChannelCredentials;
34 }
35 export declare class ClientStub extends grpcTypes.Client {
36     [name: string]: Function;
37 }
38 export declare class GrpcClient {
39     auth: GoogleAuth;
40     promise: PromiseConstructor;
41     grpc: GrpcModule;
42     grpcVersion: string;
43     grpcProtoLoader: typeof grpcProtoLoaderTypes;
44     /**
45      * A class which keeps the context of gRPC and auth for the gRPC.
46      *
47      * @param {Object=} options - The optional parameters. It will be directly
48      *   passed to google-auth-library library, so parameters like keyFile or
49      *   credentials will be valid.
50      * @param {Object=} options.auth - An instance of google-auth-library.
51      *   When specified, this auth instance will be used instead of creating
52      *   a new one.
53      * @param {Object=} options.grpc - When specified, this will be used
54      *   for the 'grpc' module in this context. By default, it will load the grpc
55      *   module in the standard way.
56      * @param {Function=} options.promise - A constructor for a promise that
57      * implements the ES6 specification of promise. If not provided, native
58      * promises will be used.
59      * @constructor
60      */
61     constructor(options?: GrpcClientOptions);
62     /**
63      * Creates a gRPC credentials. It asks the auth data if necessary.
64      * @private
65      * @param {Object} opts - options values for configuring credentials.
66      * @param {Object=} opts.sslCreds - when specified, this is used instead
67      *   of default channel credentials.
68      * @return {Promise} The promise which will be resolved to the gRPC credential.
69      */
70     _getCredentials(opts: ClientStubOptions): Promise<grpcTypes.ChannelCredentials>;
71     /**
72      * Loads the gRPC service from the proto file at the given path and with the
73      * given options.
74      * @param filename The path to the proto file.
75      * @param options Options for loading the proto file.
76      */
77     loadFromProto(filename: string, options: grpcProtoLoaderTypes.Options): grpcTypes.GrpcObject;
78     /**
79      * Load grpc proto service from a filename hooking in googleapis common protos
80      * when necessary. Uses legacy grpc.loadObject.
81      * @param {String} protoPath - The directory to search for the protofile.
82      * @param {String} filename - The filename of the proto to be loaded.
83      * @return {Object<string, *>} The gRPC loaded result (the toplevel namespace
84      *   object).
85      */
86     protected loadProtoLegacy(protoPath: string, filename: string): grpcTypes.GrpcObject;
87     /**
88      * Load grpc proto service from a filename hooking in googleapis common protos
89      * when necessary. Uses the new shiny @grpc/proto-loader.
90      * @param {String} protoPath - The directory to search for the protofile.
91      * @param {String} filename - The filename of the proto to be loaded.
92      * @return {Object<string, *>} The gRPC loaded result (the toplevel namespace
93      *   object).
94      */
95     protected loadProtoGrpcJs(protoPath: string, filename: string): grpcTypes.GrpcObject;
96     /**
97      * Load grpc proto service from a filename hooking in googleapis common protos
98      * when necessary. Can use either legacy grpc.loadProto, or new
99      * @grpc/proto-loader, depending on which gRPC backend is used.
100      * @param {String} protoPath - The directory to search for the protofile.
101      * @param {String} filename - The filename of the proto to be loaded.
102      * @return {Object<string, *>} The gRPC loaded result (the toplevel namespace
103      *   object).
104      */
105     loadProto(protoPath: string, filename: string): grpcTypes.GrpcObject;
106     static _resolveFile(protoPath: string, filename: string): string;
107     metadataBuilder(headers: OutgoingHttpHeaders): (abTests?: {} | undefined, moreHeaders?: OutgoingHttpHeaders | undefined) => grpcTypes.Metadata;
108     /**
109      * A wrapper of {@link constructSettings} function under the gRPC context.
110      *
111      * Most of parameters are common among constructSettings, please take a look.
112      * @param {string} serviceName - The fullly-qualified name of the service.
113      * @param {Object} clientConfig - A dictionary of the client config.
114      * @param {Object} configOverrides - A dictionary of overriding configs.
115      * @param {Object} headers - A dictionary of additional HTTP header name to
116      *   its value.
117      * @return {Object} A mapping of method names to CallSettings.
118      */
119     constructSettings(serviceName: string, clientConfig: gax.ClientConfig, configOverrides: gax.ClientConfig, headers: OutgoingHttpHeaders): any;
120     /**
121      * Creates a gRPC stub with current gRPC and auth.
122      * @param {function} CreateStub - The constructor function of the stub.
123      * @param {Object} options - The optional arguments to customize
124      *   gRPC connection. This options will be passed to the constructor of
125      *   gRPC client too.
126      * @param {string} options.servicePath - The name of the server of the service.
127      * @param {number} options.port - The port of the service.
128      * @param {grpcTypes.ClientCredentials=} options.sslCreds - The credentials to be used
129      *   to set up gRPC connection.
130      * @return {Promise} A promse which resolves to a gRPC stub instance.
131      */
132     createStub(CreateStub: typeof ClientStub, options: ClientStubOptions): Promise<ClientStub>;
133     /**
134      * Creates a 'bytelength' function for a given proto message class.
135      *
136      * See {@link BundleDescriptor} about the meaning of the return value.
137      *
138      * @param {function} message - a constructor function that is generated by
139      *   protobuf.js. Assumes 'encoder' field in the message.
140      * @return {function(Object):number} - a function to compute the byte length
141      *   for an object.
142      */
143     static createByteLengthFunction(message: {
144         encode: (obj: {}) => {
145             finish: () => Array<{}>;
146         };
147     }): (obj: {}) => number;
148 }
149 export declare class GoogleProtoFilesRoot extends protobuf.Root {
150     constructor(...args: Array<{}>);
151     resolvePath(originPath: string, includePath: string): string;
152     static _findIncludePath(originPath: string, includePath: string): string;
153 }