@google-cloud/spanner 7.18.0 → 7.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/README.md +1 -0
- package/build/protos/google/spanner/admin/database/v1/backup.proto +773 -0
- package/build/protos/google/spanner/admin/database/v1/backup_schedule.proto +230 -0
- package/build/protos/google/spanner/admin/database/v1/common.proto +132 -0
- package/build/protos/google/spanner/admin/database/v1/spanner_database_admin.proto +1279 -0
- package/build/protos/google/spanner/admin/instance/v1/common.proto +64 -0
- package/build/protos/google/spanner/admin/instance/v1/spanner_instance_admin.proto +2110 -0
- package/build/protos/google/spanner/executor/v1/cloud_executor.proto +1520 -0
- package/build/protos/google/spanner/v1/commit_response.proto +59 -0
- package/build/protos/google/spanner/v1/keys.proto +163 -0
- package/build/protos/google/spanner/v1/mutation.proto +107 -0
- package/build/protos/google/spanner/v1/query_plan.proto +128 -0
- package/build/protos/google/spanner/v1/result_set.proto +237 -0
- package/build/protos/google/spanner/v1/spanner.proto +1389 -0
- package/build/protos/google/spanner/v1/transaction.proto +622 -0
- package/build/protos/google/spanner/v1/type.proto +214 -0
- package/build/protos/protos.d.ts +39869 -0
- package/build/protos/protos.js +101659 -0
- package/build/protos/protos.json +10391 -0
- package/build/src/backup.d.ts +349 -0
- package/build/src/backup.js +246 -0
- package/build/src/batch-transaction.d.ts +247 -0
- package/build/src/batch-transaction.js +384 -0
- package/build/src/codec.d.ts +362 -0
- package/build/src/codec.js +791 -0
- package/build/src/common-grpc/service-object.d.ts +80 -0
- package/build/src/common-grpc/service-object.js +101 -0
- package/build/src/common-grpc/service.d.ts +445 -0
- package/build/src/common-grpc/service.js +826 -0
- package/build/src/common.d.ts +66 -0
- package/build/src/common.js +54 -0
- package/build/src/database.d.ts +2103 -0
- package/build/src/database.js +1660 -0
- package/build/src/extra_proto_list.json +1 -0
- package/build/src/helper.d.ts +45 -0
- package/build/src/helper.js +71 -0
- package/build/src/index.d.ts +1195 -0
- package/build/src/index.js +1059 -0
- package/build/src/instance-config.d.ts +294 -0
- package/build/src/instance-config.js +216 -0
- package/build/src/instance.d.ts +832 -0
- package/build/src/instance.js +781 -0
- package/build/src/instrument.d.ts +85 -0
- package/build/src/instrument.js +215 -0
- package/build/src/multiplexed-session.d.ts +135 -0
- package/build/src/multiplexed-session.js +194 -0
- package/build/src/partial-result-stream.d.ts +253 -0
- package/build/src/partial-result-stream.js +400 -0
- package/build/src/request_id_header.d.ts +41 -0
- package/build/src/request_id_header.js +138 -0
- package/build/src/session-factory.d.ts +115 -0
- package/build/src/session-factory.js +106 -0
- package/build/src/session-pool.d.ts +471 -0
- package/build/src/session-pool.js +765 -0
- package/build/src/session.d.ts +258 -0
- package/build/src/session.js +348 -0
- package/build/src/spanner_grpc_config.json +92 -0
- package/build/src/table.d.ts +831 -0
- package/build/src/table.js +277 -0
- package/build/src/transaction-runner.d.ts +185 -0
- package/build/src/transaction-runner.js +282 -0
- package/build/src/transaction.d.ts +1691 -0
- package/build/src/transaction.js +2003 -0
- package/build/src/v1/database_admin_client.d.ts +2332 -0
- package/build/src/v1/database_admin_client.js +2364 -0
- package/build/src/v1/database_admin_client_config.json +165 -0
- package/build/src/v1/database_admin_proto_list.json +6 -0
- package/build/src/v1/gapic_metadata.json +27 -0
- package/build/src/v1/index.d.ts +4 -0
- package/build/src/v1/index.js +29 -0
- package/build/src/v1/instance_admin_client.d.ts +1985 -0
- package/build/src/v1/instance_admin_client.js +1768 -0
- package/build/src/v1/instance_admin_client_config.json +129 -0
- package/build/src/v1/instance_admin_proto_list.json +4 -0
- package/build/src/v1/spanner_client.d.ts +1250 -0
- package/build/src/v1/spanner_client.js +1086 -0
- package/build/src/v1/spanner_client_config.json +119 -0
- package/build/src/v1/spanner_executor_proxy_client.d.ts +418 -0
- package/build/src/v1/spanner_executor_proxy_client.js +706 -0
- package/build/src/v1/spanner_executor_proxy_client_config.json +30 -0
- package/build/src/v1/spanner_executor_proxy_proto_list.json +14 -0
- package/build/src/v1/spanner_proto_list.json +10 -0
- package/package.json +1 -1
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright 2019 Google LLC
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/*!
|
|
17
|
+
* @module commonGrpc/serviceObject
|
|
18
|
+
*/
|
|
19
|
+
import { Metadata, MetadataCallback, ResponseCallback, ServiceObject, ServiceObjectConfig, SetMetadataResponse } from '@google-cloud/common';
|
|
20
|
+
import { RequestCallback, Response } from 'teeny-request';
|
|
21
|
+
export declare class GrpcServiceObject extends ServiceObject {
|
|
22
|
+
parent: GrpcServiceObject;
|
|
23
|
+
/**
|
|
24
|
+
* GrpcServiceObject is a base class, meant to be inherited from by a service
|
|
25
|
+
* object that uses the gRPC protobuf API.
|
|
26
|
+
*
|
|
27
|
+
* @constructor
|
|
28
|
+
* @alias module:common/grpc-service-object
|
|
29
|
+
*
|
|
30
|
+
* @private
|
|
31
|
+
*
|
|
32
|
+
* @param {object} config - Configuration object.
|
|
33
|
+
*/
|
|
34
|
+
constructor(config: ServiceObjectConfig);
|
|
35
|
+
/**
|
|
36
|
+
* Delete the object.
|
|
37
|
+
*
|
|
38
|
+
* @param {function=} callback - The callback function.
|
|
39
|
+
* @param {?error} callback.err - An error returned while making this request.
|
|
40
|
+
*/
|
|
41
|
+
delete(): Promise<[Response]>;
|
|
42
|
+
delete(callback: RequestCallback): void;
|
|
43
|
+
/**
|
|
44
|
+
* Get the metadata of this object.
|
|
45
|
+
*
|
|
46
|
+
* @param {function} callback - The callback function.
|
|
47
|
+
* @param {?error} callback.err - An error returned while making this request.
|
|
48
|
+
* @param {object} callback.metadata - The metadata for this object.
|
|
49
|
+
*/
|
|
50
|
+
getMetadata(): Promise<Metadata>;
|
|
51
|
+
getMetadata(callback: MetadataCallback): void;
|
|
52
|
+
/**
|
|
53
|
+
* Set the metadata for this object.
|
|
54
|
+
*
|
|
55
|
+
* @param {object} metadata - The metadata to set on this object.
|
|
56
|
+
* @param {function=} callback - The callback function.
|
|
57
|
+
* @param {?error} callback.err - An error returned while making this request.
|
|
58
|
+
*/
|
|
59
|
+
setMetadata(metadata: Metadata): Promise<SetMetadataResponse>;
|
|
60
|
+
setMetadata(metadata: Metadata, callback: ResponseCallback): void;
|
|
61
|
+
/**
|
|
62
|
+
* Patch a request to the GrpcService object.
|
|
63
|
+
*
|
|
64
|
+
* @private
|
|
65
|
+
*/
|
|
66
|
+
request(...args: Array<{}>): any;
|
|
67
|
+
/**
|
|
68
|
+
* Patch a streaming request to the GrpcService object.
|
|
69
|
+
*
|
|
70
|
+
* @private
|
|
71
|
+
*/
|
|
72
|
+
requestStream(...args: Array<{}>): any;
|
|
73
|
+
/**
|
|
74
|
+
* Patch a writable streaming request to the GrpcService object.
|
|
75
|
+
*
|
|
76
|
+
* @private
|
|
77
|
+
*/
|
|
78
|
+
requestWritableStream(...args: Array<{}>): any;
|
|
79
|
+
private getOpts;
|
|
80
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright 2019 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.GrpcServiceObject = void 0;
|
|
19
|
+
/*!
|
|
20
|
+
* @module commonGrpc/serviceObject
|
|
21
|
+
*/
|
|
22
|
+
const common_1 = require("@google-cloud/common");
|
|
23
|
+
const promisify_1 = require("@google-cloud/promisify");
|
|
24
|
+
const extend = require("extend");
|
|
25
|
+
class GrpcServiceObject extends common_1.ServiceObject {
|
|
26
|
+
/**
|
|
27
|
+
* GrpcServiceObject is a base class, meant to be inherited from by a service
|
|
28
|
+
* object that uses the gRPC protobuf API.
|
|
29
|
+
*
|
|
30
|
+
* @constructor
|
|
31
|
+
* @alias module:common/grpc-service-object
|
|
32
|
+
*
|
|
33
|
+
* @private
|
|
34
|
+
*
|
|
35
|
+
* @param {object} config - Configuration object.
|
|
36
|
+
*/
|
|
37
|
+
constructor(config) {
|
|
38
|
+
super(config);
|
|
39
|
+
}
|
|
40
|
+
delete(callback) {
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
42
|
+
const protoOpts = this.methods.delete.protoOpts;
|
|
43
|
+
const reqOpts = this.getOpts(this.methods.delete);
|
|
44
|
+
this.request(protoOpts, reqOpts, callback || common_1.util.noop);
|
|
45
|
+
}
|
|
46
|
+
getMetadata(callback) {
|
|
47
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
48
|
+
const protoOpts = this.methods.getMetadata.protoOpts;
|
|
49
|
+
const reqOpts = this.getOpts(this.methods.getMetadata);
|
|
50
|
+
this.request(protoOpts, reqOpts, (err, resp) => {
|
|
51
|
+
if (err) {
|
|
52
|
+
callback(err, null, resp);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
this.metadata = resp;
|
|
56
|
+
callback(null, this.metadata, resp);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
setMetadata(metadata, callback) {
|
|
60
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
61
|
+
const protoOpts = this.methods.setMetadata.protoOpts;
|
|
62
|
+
const reqOpts = extend(true, {}, this.getOpts(this.methods.setMetadata), metadata);
|
|
63
|
+
this.request(protoOpts, reqOpts, callback || common_1.util.noop);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Patch a request to the GrpcService object.
|
|
67
|
+
*
|
|
68
|
+
* @private
|
|
69
|
+
*/
|
|
70
|
+
request(...args) {
|
|
71
|
+
return this.parent.request(...args);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Patch a streaming request to the GrpcService object.
|
|
75
|
+
*
|
|
76
|
+
* @private
|
|
77
|
+
*/
|
|
78
|
+
requestStream(...args) {
|
|
79
|
+
return this.parent.requestStream(...args);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Patch a writable streaming request to the GrpcService object.
|
|
83
|
+
*
|
|
84
|
+
* @private
|
|
85
|
+
*/
|
|
86
|
+
requestWritableStream(...args) {
|
|
87
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
88
|
+
return this.parent.requestWritableStream.apply(this.parent, args);
|
|
89
|
+
}
|
|
90
|
+
getOpts(metadata) {
|
|
91
|
+
return typeof metadata === 'boolean' ? {} : metadata.reqOpts || {};
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
exports.GrpcServiceObject = GrpcServiceObject;
|
|
95
|
+
/*! Developer Documentation
|
|
96
|
+
*
|
|
97
|
+
* All async methods (except for streams) will return a Promise in the event
|
|
98
|
+
* that a callback is omitted.
|
|
99
|
+
*/
|
|
100
|
+
(0, promisify_1.promisifyAll)(GrpcServiceObject);
|
|
101
|
+
//# sourceMappingURL=service-object.js.map
|
|
@@ -0,0 +1,445 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright 2019 Google LLC
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { Abortable, BodyResponseCallback, DecorateRequestOptions, Service, ServiceConfig } from '@google-cloud/common';
|
|
17
|
+
import { grpc } from 'google-gax';
|
|
18
|
+
import { Request, Response } from 'teeny-request';
|
|
19
|
+
import { Duplex } from 'stream';
|
|
20
|
+
export interface ServiceRequestCallback {
|
|
21
|
+
(err: Error | null, apiResponse?: Response): void;
|
|
22
|
+
}
|
|
23
|
+
interface RetryOptions {
|
|
24
|
+
objectMode?: boolean;
|
|
25
|
+
request?: any;
|
|
26
|
+
retries?: number;
|
|
27
|
+
noResponseRetries?: number;
|
|
28
|
+
currentRetryAttempt?: number;
|
|
29
|
+
shouldRetryFn?: (response: Response) => boolean;
|
|
30
|
+
}
|
|
31
|
+
export interface ProtoOpts {
|
|
32
|
+
service: string;
|
|
33
|
+
method: string;
|
|
34
|
+
timeout?: number;
|
|
35
|
+
retryOpts?: RetryOptions;
|
|
36
|
+
stream?: Duplex;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Configuration object for GrpcService.
|
|
40
|
+
*/
|
|
41
|
+
export interface GrpcServiceConfig extends ServiceConfig {
|
|
42
|
+
/** gRPC implementation to use. By default, uses `@grpc/grpc-js`. */
|
|
43
|
+
grpc?: typeof grpc;
|
|
44
|
+
/** gRPC version, to send in headers */
|
|
45
|
+
grpcVersion?: string;
|
|
46
|
+
/** Metadata to send with every request. */
|
|
47
|
+
grpcMetadata: grpc.Metadata;
|
|
48
|
+
/** The root directory where proto files live. */
|
|
49
|
+
protosDir: string;
|
|
50
|
+
/**
|
|
51
|
+
* Directly provide the required proto files. This is useful when a single
|
|
52
|
+
* class requires multiple services.
|
|
53
|
+
*/
|
|
54
|
+
protoServices: {
|
|
55
|
+
[serviceName: string]: {
|
|
56
|
+
path: string;
|
|
57
|
+
service: string;
|
|
58
|
+
baseUrl: string;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
customEndpoint: boolean;
|
|
62
|
+
}
|
|
63
|
+
export interface ObjectToStructConverterConfig {
|
|
64
|
+
removeCircular?: boolean;
|
|
65
|
+
stringify?: boolean;
|
|
66
|
+
}
|
|
67
|
+
export declare class ObjectToStructConverter {
|
|
68
|
+
seenObjects: Set<{}>;
|
|
69
|
+
removeCircular: boolean;
|
|
70
|
+
stringify?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* A class that can be used to convert an object to a struct. Optionally this
|
|
73
|
+
* class can be used to erase/throw on circular references during conversion.
|
|
74
|
+
*
|
|
75
|
+
* @private
|
|
76
|
+
*
|
|
77
|
+
* @param {object=} options - Configuration object.
|
|
78
|
+
* @param {boolean} options.removeCircular - Remove circular references in the
|
|
79
|
+
* object with a placeholder string. (Default: `false`)
|
|
80
|
+
* @param {boolean} options.stringify - Stringify un-recognized types. (Default:
|
|
81
|
+
* `false`)
|
|
82
|
+
*/
|
|
83
|
+
constructor(options?: ObjectToStructConverterConfig);
|
|
84
|
+
/**
|
|
85
|
+
* Begin the conversion process from a JS object to an encoded gRPC Value
|
|
86
|
+
* message.
|
|
87
|
+
*
|
|
88
|
+
* @param {*} value - The input value.
|
|
89
|
+
* @return {object} - The encoded value.
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ObjectToStructConverter.convert({
|
|
93
|
+
* aString: 'Hi'
|
|
94
|
+
* });
|
|
95
|
+
* // {
|
|
96
|
+
* // fields: {
|
|
97
|
+
* // aString: {
|
|
98
|
+
* // stringValue: 'Hello!'
|
|
99
|
+
* // }
|
|
100
|
+
* // }
|
|
101
|
+
* // }
|
|
102
|
+
*/
|
|
103
|
+
convert(obj: {}): {
|
|
104
|
+
fields: {};
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Convert a raw value to a type-denoted protobuf message-friendly object.
|
|
108
|
+
*
|
|
109
|
+
* @private
|
|
110
|
+
*
|
|
111
|
+
* @param {*} value - The input value.
|
|
112
|
+
* @return {*} - The encoded value.
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ObjectToStructConverter.encodeValue('Hi');
|
|
116
|
+
* // {
|
|
117
|
+
* // stringValue: 'Hello!'
|
|
118
|
+
* // }
|
|
119
|
+
*/
|
|
120
|
+
encodeValue_(value: {}): any;
|
|
121
|
+
}
|
|
122
|
+
export declare class GrpcService extends Service {
|
|
123
|
+
grpc?: typeof grpc;
|
|
124
|
+
grpcVersion?: string;
|
|
125
|
+
grpcCredentials?: {};
|
|
126
|
+
grpcMetadata?: {
|
|
127
|
+
add: Function;
|
|
128
|
+
};
|
|
129
|
+
maxRetries?: number;
|
|
130
|
+
userAgent?: string;
|
|
131
|
+
activeServiceMap_: Map<any, any>;
|
|
132
|
+
protos: {};
|
|
133
|
+
/** A cache for proto objects. */
|
|
134
|
+
private static protoObjectCache;
|
|
135
|
+
static readonly GRPC_SERVICE_OPTIONS: {
|
|
136
|
+
'grpc.max_send_message_length': number;
|
|
137
|
+
'grpc.max_receive_message_length': number;
|
|
138
|
+
'grpc.initial_reconnect_backoff_ms': number;
|
|
139
|
+
};
|
|
140
|
+
static readonly GRPC_ERROR_CODE_TO_HTTP: {
|
|
141
|
+
0: {
|
|
142
|
+
code: number;
|
|
143
|
+
message: string;
|
|
144
|
+
};
|
|
145
|
+
1: {
|
|
146
|
+
code: number;
|
|
147
|
+
message: string;
|
|
148
|
+
};
|
|
149
|
+
2: {
|
|
150
|
+
code: number;
|
|
151
|
+
message: string;
|
|
152
|
+
};
|
|
153
|
+
3: {
|
|
154
|
+
code: number;
|
|
155
|
+
message: string;
|
|
156
|
+
};
|
|
157
|
+
4: {
|
|
158
|
+
code: number;
|
|
159
|
+
message: string;
|
|
160
|
+
};
|
|
161
|
+
5: {
|
|
162
|
+
code: number;
|
|
163
|
+
message: string;
|
|
164
|
+
};
|
|
165
|
+
6: {
|
|
166
|
+
code: number;
|
|
167
|
+
message: string;
|
|
168
|
+
};
|
|
169
|
+
7: {
|
|
170
|
+
code: number;
|
|
171
|
+
message: string;
|
|
172
|
+
};
|
|
173
|
+
8: {
|
|
174
|
+
code: number;
|
|
175
|
+
message: string;
|
|
176
|
+
};
|
|
177
|
+
9: {
|
|
178
|
+
code: number;
|
|
179
|
+
message: string;
|
|
180
|
+
};
|
|
181
|
+
10: {
|
|
182
|
+
code: number;
|
|
183
|
+
message: string;
|
|
184
|
+
};
|
|
185
|
+
11: {
|
|
186
|
+
code: number;
|
|
187
|
+
message: string;
|
|
188
|
+
};
|
|
189
|
+
12: {
|
|
190
|
+
code: number;
|
|
191
|
+
message: string;
|
|
192
|
+
};
|
|
193
|
+
13: {
|
|
194
|
+
code: number;
|
|
195
|
+
message: string;
|
|
196
|
+
};
|
|
197
|
+
14: {
|
|
198
|
+
code: number;
|
|
199
|
+
message: string;
|
|
200
|
+
};
|
|
201
|
+
15: {
|
|
202
|
+
code: number;
|
|
203
|
+
message: string;
|
|
204
|
+
};
|
|
205
|
+
16: {
|
|
206
|
+
code: number;
|
|
207
|
+
message: string;
|
|
208
|
+
};
|
|
209
|
+
};
|
|
210
|
+
static readonly ObjectToStructConverter: typeof ObjectToStructConverter;
|
|
211
|
+
/**
|
|
212
|
+
* Service is a base class, meant to be inherited from by a "service," like
|
|
213
|
+
* BigQuery or Storage.
|
|
214
|
+
*
|
|
215
|
+
* This handles making authenticated requests by exposing a `makeReq_`
|
|
216
|
+
* function.
|
|
217
|
+
*
|
|
218
|
+
* @constructor
|
|
219
|
+
* @alias module:common/grpc-service
|
|
220
|
+
*
|
|
221
|
+
* @param config - Configuration object.
|
|
222
|
+
* @param {object} options - [Configuration object](#/docs/?method=gcloud).
|
|
223
|
+
*/
|
|
224
|
+
constructor(config: GrpcServiceConfig, options: any);
|
|
225
|
+
/**
|
|
226
|
+
* Make an authenticated request with gRPC.
|
|
227
|
+
*
|
|
228
|
+
* @param {object} protoOpts - The proto options.
|
|
229
|
+
* @param {string} protoOpts.service - The service name.
|
|
230
|
+
* @param {string} protoOpts.method - The method name.
|
|
231
|
+
* @param {number=} protoOpts.timeout - After how many milliseconds should the
|
|
232
|
+
* request cancel.
|
|
233
|
+
* @param {object} reqOpts - The request options.
|
|
234
|
+
* @param {function=} callback - The callback function.
|
|
235
|
+
*/
|
|
236
|
+
request(reqOpts: DecorateRequestOptions): Promise<Response>;
|
|
237
|
+
request(reqOpts: DecorateRequestOptions, callback: BodyResponseCallback): void;
|
|
238
|
+
request(reqOpts: DecorateRequestOptions, callback?: BodyResponseCallback): void | Promise<Response>;
|
|
239
|
+
request(protoOpts: ProtoOpts, reqOpts: DecorateRequestOptions, callback: ServiceRequestCallback): Abortable | void;
|
|
240
|
+
/**
|
|
241
|
+
* Make an authenticated streaming request with gRPC.
|
|
242
|
+
*
|
|
243
|
+
* @param {object} protoOpts - The proto options.
|
|
244
|
+
* @param {string} protoOpts.service - The service.
|
|
245
|
+
* @param {string} protoOpts.method - The method name.
|
|
246
|
+
* @param {number=} protoOpts.timeout - After how many milliseconds should the
|
|
247
|
+
* request cancel.
|
|
248
|
+
* @param {object} reqOpts - The request options.
|
|
249
|
+
*/
|
|
250
|
+
requestStream(reqOpts: DecorateRequestOptions): Request;
|
|
251
|
+
requestStream(protoOpts: ProtoOpts, reqOpts: DecorateRequestOptions): Duplex;
|
|
252
|
+
/**
|
|
253
|
+
* Make an authenticated writable streaming request with gRPC.
|
|
254
|
+
*
|
|
255
|
+
* @param {object} protoOpts - The proto options.
|
|
256
|
+
* @param {string} protoOpts.service - The service.
|
|
257
|
+
* @param {string} protoOpts.method - The method name.
|
|
258
|
+
* @param {number=} protoOpts.timeout - After how many milliseconds should the
|
|
259
|
+
* request cancel.
|
|
260
|
+
* @param {object} reqOpts - The request options.
|
|
261
|
+
*/
|
|
262
|
+
requestWritableStream(protoOpts: any, reqOpts: any): any;
|
|
263
|
+
/**
|
|
264
|
+
* Decode a protobuf Struct's value.
|
|
265
|
+
*
|
|
266
|
+
* @param {object} value - A Struct's Field message.
|
|
267
|
+
* @return {*} - The decoded value.
|
|
268
|
+
*/
|
|
269
|
+
static decodeValue_(value: any): any;
|
|
270
|
+
/**
|
|
271
|
+
* Convert a raw value to a type-denoted protobuf message-friendly object.
|
|
272
|
+
*
|
|
273
|
+
*
|
|
274
|
+
* @param {*} value - The input value.
|
|
275
|
+
* @return {*} - The encoded value.
|
|
276
|
+
*
|
|
277
|
+
* @example
|
|
278
|
+
* ObjectToStructConverter.encodeValue('Hi');
|
|
279
|
+
* // {
|
|
280
|
+
* // stringValue: 'Hello!'
|
|
281
|
+
* // }
|
|
282
|
+
*/
|
|
283
|
+
static encodeValue_(value: any): any;
|
|
284
|
+
/**
|
|
285
|
+
* Creates a deadline.
|
|
286
|
+
*
|
|
287
|
+
* @private
|
|
288
|
+
*
|
|
289
|
+
* @param {number} timeout - Timeout in miliseconds.
|
|
290
|
+
* @return {date} deadline - The deadline in Date object form.
|
|
291
|
+
*/
|
|
292
|
+
private static createDeadline_;
|
|
293
|
+
/**
|
|
294
|
+
* Checks for a grpc status code and extends the error object with additional
|
|
295
|
+
* information.
|
|
296
|
+
*
|
|
297
|
+
* @private
|
|
298
|
+
*
|
|
299
|
+
* @param {error|object} err - The grpc error.
|
|
300
|
+
* @return {error|null}
|
|
301
|
+
*/
|
|
302
|
+
static decorateError_(err: Error): Error | null;
|
|
303
|
+
/**
|
|
304
|
+
* Checks for a grpc status code and extends the supplied object with
|
|
305
|
+
* additional information.
|
|
306
|
+
*
|
|
307
|
+
* @private
|
|
308
|
+
*
|
|
309
|
+
* @param {object} obj - The object to be extended.
|
|
310
|
+
* @param {object} response - The grpc response.
|
|
311
|
+
* @return {object|null}
|
|
312
|
+
*/
|
|
313
|
+
private static decorateGrpcResponse_;
|
|
314
|
+
/**
|
|
315
|
+
* Checks for grpc status code and extends the status object with additional
|
|
316
|
+
* information
|
|
317
|
+
*
|
|
318
|
+
* @private
|
|
319
|
+
* @param {object} status - The grpc status.
|
|
320
|
+
* @return {object|null}
|
|
321
|
+
*/
|
|
322
|
+
private static decorateStatus_;
|
|
323
|
+
/**
|
|
324
|
+
* Function to decide whether or not a request retry could occur.
|
|
325
|
+
*
|
|
326
|
+
* @private
|
|
327
|
+
*
|
|
328
|
+
* @param {object} response - The request response.
|
|
329
|
+
* @return {boolean} shouldRetry
|
|
330
|
+
*/
|
|
331
|
+
private static shouldRetryRequest_;
|
|
332
|
+
/**
|
|
333
|
+
* Convert an object to a struct.
|
|
334
|
+
*
|
|
335
|
+
* @private
|
|
336
|
+
*
|
|
337
|
+
* @param {object} obj - An object to convert.
|
|
338
|
+
* @param {object=} options - Configuration object.
|
|
339
|
+
* @param {boolean} options.removeCircular - Remove circular references in the
|
|
340
|
+
* object with a placeholder string.
|
|
341
|
+
* @param {boolean} options.stringify - Stringify un-recognized types.
|
|
342
|
+
* @return {array} - The converted object.
|
|
343
|
+
*
|
|
344
|
+
* @example
|
|
345
|
+
* GrpcService.objToStruct_({
|
|
346
|
+
* greeting: 'Hello!',
|
|
347
|
+
* favNumber: 7,
|
|
348
|
+
* friendIds: [
|
|
349
|
+
* 1004,
|
|
350
|
+
* 1006
|
|
351
|
+
* ],
|
|
352
|
+
* userDetails: {
|
|
353
|
+
* termsSigned: true
|
|
354
|
+
* }
|
|
355
|
+
* });
|
|
356
|
+
* // {
|
|
357
|
+
* // fields: {
|
|
358
|
+
* // greeting: {
|
|
359
|
+
* // stringValue: 'Hello!'
|
|
360
|
+
* // },
|
|
361
|
+
* // favNumber: {
|
|
362
|
+
* // numberValue: 7
|
|
363
|
+
* // },
|
|
364
|
+
* // friendIds: {
|
|
365
|
+
* // listValue: [
|
|
366
|
+
* // {
|
|
367
|
+
* // numberValue: 1004
|
|
368
|
+
* // },
|
|
369
|
+
* // {
|
|
370
|
+
* // numberValue: 1006
|
|
371
|
+
* // }
|
|
372
|
+
* // ]
|
|
373
|
+
* // },
|
|
374
|
+
* // userDetails: {
|
|
375
|
+
* // fields: {
|
|
376
|
+
* // termsSigned: {
|
|
377
|
+
* // booleanValue: true
|
|
378
|
+
* // }
|
|
379
|
+
* // }
|
|
380
|
+
* // }
|
|
381
|
+
* // }
|
|
382
|
+
* // }
|
|
383
|
+
*/
|
|
384
|
+
private static objToStruct_;
|
|
385
|
+
/**
|
|
386
|
+
* Condense a protobuf Struct into an object of only its values.
|
|
387
|
+
*
|
|
388
|
+
* @private
|
|
389
|
+
*
|
|
390
|
+
* @param {object} struct - A protobuf Struct message.
|
|
391
|
+
* @return {object} - The simplified object.
|
|
392
|
+
*
|
|
393
|
+
* @example
|
|
394
|
+
* GrpcService.structToObj_({
|
|
395
|
+
* fields: {
|
|
396
|
+
* name: {
|
|
397
|
+
* kind: 'stringValue',
|
|
398
|
+
* stringValue: 'Stephen'
|
|
399
|
+
* }
|
|
400
|
+
* }
|
|
401
|
+
* });
|
|
402
|
+
* // {
|
|
403
|
+
* // name: 'Stephen'
|
|
404
|
+
* // }
|
|
405
|
+
*/
|
|
406
|
+
private static structToObj_;
|
|
407
|
+
/**
|
|
408
|
+
* Assign a projectId if one is specified to all request options.
|
|
409
|
+
*
|
|
410
|
+
* @param {object} reqOpts - The request options.
|
|
411
|
+
* @return {object} - The decorated request object.
|
|
412
|
+
*/
|
|
413
|
+
decorateRequest_(reqOpts: any): any;
|
|
414
|
+
/**
|
|
415
|
+
* To authorize requests through gRPC, we must get the raw google-auth-library
|
|
416
|
+
* auth client object.
|
|
417
|
+
*
|
|
418
|
+
* @private
|
|
419
|
+
*
|
|
420
|
+
* @param {function} callback - The callback function.
|
|
421
|
+
* @param {?error} callback.err - An error getting an auth client.
|
|
422
|
+
*/
|
|
423
|
+
private getGrpcCredentials_;
|
|
424
|
+
/**
|
|
425
|
+
* Loads a proto file, useful when handling multiple proto files/services
|
|
426
|
+
* within a single instance of GrpcService.
|
|
427
|
+
*
|
|
428
|
+
* @private
|
|
429
|
+
*
|
|
430
|
+
* @param protoConfig - The proto specific configs for this file.
|
|
431
|
+
* @param config - The base config for the GrpcService.
|
|
432
|
+
* @return protoObject - The loaded proto object.
|
|
433
|
+
*/
|
|
434
|
+
private loadProtoFile;
|
|
435
|
+
/**
|
|
436
|
+
* Retrieves the service object used to make the grpc requests.
|
|
437
|
+
*
|
|
438
|
+
* @private
|
|
439
|
+
*
|
|
440
|
+
* @param {object} protoOpts - The proto options.
|
|
441
|
+
* @return {object} service - The proto service.
|
|
442
|
+
*/
|
|
443
|
+
private getService_;
|
|
444
|
+
}
|
|
445
|
+
export {};
|