fallback.d.ts
6.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/**
* Copyright 2020 Google LLC
*
* Licensed 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.
*/
/// <reference types="node" />
import * as protobuf from 'protobufjs';
import * as gax from './gax';
import * as routingHeader from './routingHeader';
import { OutgoingHttpHeaders } from 'http';
import { GoogleAuth, OAuth2Client, Compute, JWT, UserRefreshClient, BaseExternalAccountClient } from 'google-auth-library';
import { OperationsClientBuilder } from './operationsClient';
import { GrpcClientOptions, ClientStubOptions } from './grpc';
import { GaxCall, GRPCCall } from './apitypes';
import { Descriptor } from './descriptor';
import { FallbackServiceError } from './fallbackError';
export { FallbackServiceError };
export { PathTemplate } from './pathTemplate';
export { routingHeader };
export { CallSettings, constructSettings, RetryOptions } from './gax';
export declare const version: string;
export { BundleDescriptor, LongrunningDescriptor, PageDescriptor, StreamDescriptor, } from './descriptor';
export { StreamType } from './streamingCalls/streaming';
interface FallbackServiceStub {
[method: string]: Function;
}
export declare class GrpcClient {
auth?: OAuth2Client | GoogleAuth;
authClient?: OAuth2Client | Compute | JWT | UserRefreshClient | BaseExternalAccountClient;
fallback: boolean | 'rest' | 'proto';
grpcVersion: string;
private static protoCache;
/**
* In rare cases users might need to deallocate all memory consumed by loaded protos.
* This method will delete the proto cache content.
*/
static clearProtoCache(): void;
/**
* gRPC-fallback version of GrpcClient
* Implements GrpcClient API for a browser using grpc-fallback protocol (sends serialized protobuf to HTTP/1 $rpc endpoint).
*
* @param {Object=} options.auth - An instance of OAuth2Client to use in browser, or an instance of GoogleAuth from google-auth-library
* to use in Node.js. Required for browser, optional for Node.js.
* @constructor
*/
constructor(options?: (GrpcClientOptions | {
auth: OAuth2Client;
}) & {
fallback?: boolean | 'rest' | 'proto';
});
/**
* gRPC-fallback version of loadProto
* Loads the protobuf root object from a JSON object created from a proto file
* @param {Object} jsonObject - A JSON version of a protofile created usin protobuf.js
* @returns {Object} Root namespace of proto JSON
*/
loadProto(jsonObject: {}): protobuf.Root;
loadProtoJSON(json: protobuf.INamespace, ignoreCache?: boolean): protobuf.Root;
private getServiceMethods;
/**
* gRPC-fallback version of constructSettings
* A wrapper of {@link constructSettings} function under the gRPC context.
*
* Most of parameters are common among constructSettings, please take a look.
* @param {string} serviceName - The fullly-qualified name of the service.
* @param {Object} clientConfig - A dictionary of the client config.
* @param {Object} configOverrides - A dictionary of overriding configs.
* @param {Object} headers - A dictionary of additional HTTP header name to
* its value.
* @return {Object} A mapping of method names to CallSettings.
*/
constructSettings(serviceName: string, clientConfig: gax.ClientConfig, configOverrides: gax.ClientConfig, headers: OutgoingHttpHeaders): any;
/**
* gRPC-fallback version of createStub
* Creates a gRPC-fallback stub with authentication headers built from supplied OAuth2Client instance
*
* @param {function} CreateStub - The constructor function of the stub.
* @param {Object} service - A protobufjs Service object (as returned by lookupService)
* @param {Object} opts - Connection options, as described below.
* @param {string} opts.servicePath - The hostname of the API endpoint service.
* @param {number} opts.port - The port of the service.
* @return {Promise} A promise which resolves to a gRPC-fallback service stub, which is a protobuf.js service stub instance modified to match the gRPC stub API
*/
createStub(service: protobuf.Service, opts: ClientStubOptions): Promise<FallbackServiceStub>;
}
/**
* gRPC-fallback version of lro
*
* @param {Object=} options.auth - An instance of google-auth-library.
* @return {Object} A OperationsClientBuilder that will return a OperationsClient
*/
export declare function lro(options: GrpcClientOptions): OperationsClientBuilder;
/**
* gRPC-fallback version of createApiCall
*
* Converts an rpc call into an API call governed by the settings.
*
* In typical usage, `func` will be a promise to a callable used to make an rpc
* request. This will mostly likely be a bound method from a request stub used
* to make an rpc call. It is not a direct function but a Promise instance,
* because of its asynchronism (typically, obtaining the auth information).
*
* The result is a function which manages the API call with the given settings
* and the options on the invocation.
*
* Throws exception on unsupported streaming calls
*
* @param {Promise<GRPCCall>|GRPCCall} func - is either a promise to be used to make
* a bare RPC call, or just a bare RPC call.
* @param {CallSettings} settings - provides the settings for this call
* @param {Descriptor} descriptor - optionally specify the descriptor for
* the method call.
* @return {GaxCall} func - a bound method on a request stub used
* to make an rpc call.
*/
export declare function createApiCall(func: Promise<GRPCCall> | GRPCCall, settings: gax.CallSettings, descriptor?: Descriptor): GaxCall;
export { protobuf };
export * as protobufMinimal from 'protobufjs/minimal';
declare const fallback: any;
export { fallback };