-
Notifications
You must be signed in to change notification settings - Fork 150
/
Copy pathfirestore_admin_client.ts
1955 lines (1901 loc) · 72.9 KB
/
firestore_admin_client.ts
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright 2021 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
//
// https://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.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **
/* global window */
import * as gax from 'google-gax';
import {
Callback,
CallOptions,
Descriptors,
ClientOptions,
LROperation,
PaginationCallback,
GaxCall,
} from 'google-gax';
import * as path from 'path';
import {Transform} from 'stream';
import {RequestType} from 'google-gax/build/src/apitypes';
import * as protos from '../../protos/firestore_admin_v1_proto_api';
/**
* Client JSON configuration object, loaded from
* `src/v1/firestore_admin_client_config.json`.
* This file defines retry strategy and timeouts for all API methods in this library.
*/
import * as gapicConfig from './firestore_admin_client_config.json';
import {operationsProtos} from 'google-gax';
const version = require('../../../package.json').version;
/**
* Operations are created by service `FirestoreAdmin`, but are accessed via
* service `google.longrunning.Operations`.
* @class
* @memberof v1
*/
export class FirestoreAdminClient {
private _terminated = false;
private _opts: ClientOptions;
private _gaxModule: typeof gax | typeof gax.fallback;
private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient;
private _protos: {};
private _defaults: {[method: string]: gax.CallSettings};
auth: gax.GoogleAuth;
descriptors: Descriptors = {
page: {},
stream: {},
longrunning: {},
batching: {},
};
innerApiCalls: {[name: string]: Function};
pathTemplates: {[name: string]: gax.PathTemplate};
operationsClient: gax.OperationsClient;
firestoreAdminStub?: Promise<{[name: string]: Function}>;
/**
* Construct an instance of FirestoreAdminClient.
*
* @param {object} [options] - The configuration object.
* The options accepted by the constructor are described in detail
* in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance).
* The common options are:
* @param {object} [options.credentials] - Credentials object.
* @param {string} [options.credentials.client_email]
* @param {string} [options.credentials.private_key]
* @param {string} [options.email] - Account email address. Required when
* using a .pem or .p12 keyFilename.
* @param {string} [options.keyFilename] - Full path to the a .json, .pem, or
* .p12 key downloaded from the Google Developers Console. If you provide
* a path to a JSON file, the projectId option below is not necessary.
* NOTE: .pem and .p12 require you to specify options.email as well.
* @param {number} [options.port] - The port on which to connect to
* the remote host.
* @param {string} [options.projectId] - The project ID from the Google
* Developer's Console, e.g. 'grape-spaceship-123'. We will also check
* the environment variable GCLOUD_PROJECT for your project ID. If your
* app is running in an environment which supports
* {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials},
* your project ID will be detected automatically.
* @param {string} [options.apiEndpoint] - The domain name of the
* API remote host.
* @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
* Follows the structure of {@link gapicConfig}.
* @param {boolean} [options.fallback] - Use HTTP fallback mode.
* In fallback mode, a special browser-compatible transport implementation is used
* instead of gRPC transport. In browser context (if the `window` object is defined)
* the fallback mode is enabled automatically; set `options.fallback` to `false`
* if you need to override this behavior.
*/
constructor(opts?: ClientOptions) {
// Ensure that options include all the required fields.
const staticMembers = this.constructor as typeof FirestoreAdminClient;
const servicePath =
opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath;
const port = opts?.port || staticMembers.port;
const clientConfig = opts?.clientConfig ?? {};
const fallback =
opts?.fallback ??
(typeof window !== 'undefined' && typeof window?.fetch === 'function');
opts = Object.assign({servicePath, port, clientConfig, fallback}, opts);
// If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case.
if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) {
opts['scopes'] = staticMembers.scopes;
}
// Choose either gRPC or proto-over-HTTP implementation of google-gax.
this._gaxModule = opts.fallback ? gax.fallback : gax;
// Create a `gaxGrpc` object, with any grpc-specific options sent to the client.
this._gaxGrpc = new this._gaxModule.GrpcClient(opts);
// Save options to use in initialize() method.
this._opts = opts;
// Save the auth object to the client, for use by other methods.
this.auth = this._gaxGrpc.auth as gax.GoogleAuth;
// Set the default scopes in auth client if needed.
if (servicePath === staticMembers.servicePath) {
this.auth.defaultScopes = staticMembers.scopes;
}
// Determine the client header string.
const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`];
if (typeof process !== 'undefined' && 'versions' in process) {
clientHeader.push(`gl-node/${process.versions.node}`);
} else {
clientHeader.push(`gl-web/${this._gaxModule.version}`);
}
if (!opts.fallback) {
clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`);
}
if (opts.libName && opts.libVersion) {
clientHeader.push(`${opts.libName}/${opts.libVersion}`);
}
// Load the applicable protos.
// For Node.js, pass the path to JSON proto file.
// For browsers, pass the JSON content.
const nodejsProtoPath = path.join(
__dirname,
'..',
'..',
'protos',
'protos.json'
);
this._protos = this._gaxGrpc.loadProto(
opts.fallback
? // eslint-disable-next-line @typescript-eslint/no-var-requires
require('../../protos/protos.json')
: nodejsProtoPath
);
// This API contains "path templates"; forward-slash-separated
// identifiers to uniquely identify resources within the API.
// Create useful helper objects for these.
this.pathTemplates = {
collectionGroupPathTemplate: new this._gaxModule.PathTemplate(
'projects/{project}/databases/{database}/collectionGroups/{collection}'
),
databasePathTemplate: new this._gaxModule.PathTemplate(
'projects/{project}/databases/{database}'
),
fieldPathTemplate: new this._gaxModule.PathTemplate(
'projects/{project}/databases/{database}/collectionGroups/{collection}/fields/{field}'
),
indexPathTemplate: new this._gaxModule.PathTemplate(
'projects/{project}/databases/{database}/collectionGroups/{collection}/indexes/{index}'
),
};
// Some of the methods on this service return "paged" results,
// (e.g. 50 results at a time, with tokens to get subsequent
// pages). Denote the keys used for pagination and results.
this.descriptors.page = {
listIndexes: new this._gaxModule.PageDescriptor(
'pageToken',
'nextPageToken',
'indexes'
),
listFields: new this._gaxModule.PageDescriptor(
'pageToken',
'nextPageToken',
'fields'
),
};
// This API contains "long-running operations", which return a
// an Operation object that allows for tracking of the operation,
// rather than holding a request open.
const protoFilesRoot = opts.fallback
? this._gaxModule.protobuf.Root.fromJSON(
// eslint-disable-next-line @typescript-eslint/no-var-requires
require('../../protos/protos.json')
)
: this._gaxModule.protobuf.loadSync(nodejsProtoPath);
this.operationsClient = this._gaxModule
.lro({
auth: this.auth,
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
})
.operationsClient(opts);
const createIndexResponse = protoFilesRoot.lookup(
'.google.firestore.admin.v1.Index'
) as gax.protobuf.Type;
const createIndexMetadata = protoFilesRoot.lookup(
'.google.firestore.admin.v1.IndexOperationMetadata'
) as gax.protobuf.Type;
const updateFieldResponse = protoFilesRoot.lookup(
'.google.firestore.admin.v1.Field'
) as gax.protobuf.Type;
const updateFieldMetadata = protoFilesRoot.lookup(
'.google.firestore.admin.v1.FieldOperationMetadata'
) as gax.protobuf.Type;
const exportDocumentsResponse = protoFilesRoot.lookup(
'.google.firestore.admin.v1.ExportDocumentsResponse'
) as gax.protobuf.Type;
const exportDocumentsMetadata = protoFilesRoot.lookup(
'.google.firestore.admin.v1.ExportDocumentsMetadata'
) as gax.protobuf.Type;
const importDocumentsResponse = protoFilesRoot.lookup(
'.google.protobuf.Empty'
) as gax.protobuf.Type;
const importDocumentsMetadata = protoFilesRoot.lookup(
'.google.firestore.admin.v1.ImportDocumentsMetadata'
) as gax.protobuf.Type;
this.descriptors.longrunning = {
createIndex: new this._gaxModule.LongrunningDescriptor(
this.operationsClient,
createIndexResponse.decode.bind(createIndexResponse),
createIndexMetadata.decode.bind(createIndexMetadata)
),
updateField: new this._gaxModule.LongrunningDescriptor(
this.operationsClient,
updateFieldResponse.decode.bind(updateFieldResponse),
updateFieldMetadata.decode.bind(updateFieldMetadata)
),
exportDocuments: new this._gaxModule.LongrunningDescriptor(
this.operationsClient,
exportDocumentsResponse.decode.bind(exportDocumentsResponse),
exportDocumentsMetadata.decode.bind(exportDocumentsMetadata)
),
importDocuments: new this._gaxModule.LongrunningDescriptor(
this.operationsClient,
importDocumentsResponse.decode.bind(importDocumentsResponse),
importDocumentsMetadata.decode.bind(importDocumentsMetadata)
),
};
// Put together the default options sent with requests.
this._defaults = this._gaxGrpc.constructSettings(
'google.firestore.admin.v1.FirestoreAdmin',
gapicConfig as gax.ClientConfig,
opts.clientConfig || {},
{'x-goog-api-client': clientHeader.join(' ')}
);
// Set up a dictionary of "inner API calls"; the core implementation
// of calling the API is handled in `google-gax`, with this code
// merely providing the destination and request information.
this.innerApiCalls = {};
}
/**
* Initialize the client.
* Performs asynchronous operations (such as authentication) and prepares the client.
* This function will be called automatically when any class method is called for the
* first time, but if you need to initialize it before calling an actual method,
* feel free to call initialize() directly.
*
* You can await on this method if you want to make sure the client is initialized.
*
* @returns {Promise} A promise that resolves to an authenticated service stub.
*/
initialize() {
// If the client stub promise is already initialized, return immediately.
if (this.firestoreAdminStub) {
return this.firestoreAdminStub;
}
// Put together the "service stub" for
// google.firestore.admin.v1.FirestoreAdmin.
this.firestoreAdminStub = this._gaxGrpc.createStub(
this._opts.fallback
? (this._protos as protobuf.Root).lookupService(
'google.firestore.admin.v1.FirestoreAdmin'
)
: // eslint-disable-next-line @typescript-eslint/no-explicit-any
(this._protos as any).google.firestore.admin.v1.FirestoreAdmin,
this._opts
) as Promise<{[method: string]: Function}>;
// Iterate over each of the methods that the service provides
// and create an API call method for each.
const firestoreAdminStubMethods = [
'createIndex',
'listIndexes',
'getIndex',
'deleteIndex',
'getField',
'updateField',
'listFields',
'exportDocuments',
'importDocuments',
];
for (const methodName of firestoreAdminStubMethods) {
const callPromise = this.firestoreAdminStub.then(
stub => (...args: Array<{}>) => {
if (this._terminated) {
return Promise.reject('The client has already been closed.');
}
const func = stub[methodName];
return func.apply(stub, args);
},
(err: Error | null | undefined) => () => {
throw err;
}
);
const descriptor =
this.descriptors.page[methodName] ||
this.descriptors.longrunning[methodName] ||
undefined;
const apiCall = this._gaxModule.createApiCall(
callPromise,
this._defaults[methodName],
descriptor
);
this.innerApiCalls[methodName] = apiCall;
}
return this.firestoreAdminStub;
}
/**
* The DNS address for this API service.
* @returns {string} The DNS address for this service.
*/
static get servicePath() {
return 'firestore.googleapis.com';
}
/**
* The DNS address for this API service - same as servicePath(),
* exists for compatibility reasons.
* @returns {string} The DNS address for this service.
*/
static get apiEndpoint() {
return 'firestore.googleapis.com';
}
/**
* The port for this API service.
* @returns {number} The default port for this service.
*/
static get port() {
return 443;
}
/**
* The scopes needed to make gRPC calls for every method defined
* in this service.
* @returns {string[]} List of default scopes.
*/
static get scopes() {
return [
'https://www.googleapis.com/auth/cloud-platform',
'https://www.googleapis.com/auth/datastore',
];
}
getProjectId(): Promise<string>;
getProjectId(callback: Callback<string, undefined, undefined>): void;
/**
* Return the project ID used by this class.
* @returns {Promise} A promise that resolves to string containing the project ID.
*/
getProjectId(
callback?: Callback<string, undefined, undefined>
): Promise<string> | void {
if (callback) {
this.auth.getProjectId(callback);
return;
}
return this.auth.getProjectId();
}
// -------------------
// -- Service calls --
// -------------------
getIndex(
request: protos.google.firestore.admin.v1.IGetIndexRequest,
options?: CallOptions
): Promise<
[
protos.google.firestore.admin.v1.IIndex,
protos.google.firestore.admin.v1.IGetIndexRequest | undefined,
{} | undefined
]
>;
getIndex(
request: protos.google.firestore.admin.v1.IGetIndexRequest,
options: CallOptions,
callback: Callback<
protos.google.firestore.admin.v1.IIndex,
protos.google.firestore.admin.v1.IGetIndexRequest | null | undefined,
{} | null | undefined
>
): void;
getIndex(
request: protos.google.firestore.admin.v1.IGetIndexRequest,
callback: Callback<
protos.google.firestore.admin.v1.IIndex,
protos.google.firestore.admin.v1.IGetIndexRequest | null | undefined,
{} | null | undefined
>
): void;
/**
* Gets a composite index.
*
* @param {Object} request
* The request object that will be sent.
* @param {string} request.name
* Required. A name of the form
* `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}`
* @param {object} [options]
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
* @returns {Promise} - The promise which resolves to an array.
* The first element of the array is an object representing [Index]{@link google.firestore.admin.v1.Index}.
* Please see the
* [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods)
* for more details and examples.
* @example
* const [response] = await client.getIndex(request);
*/
getIndex(
request: protos.google.firestore.admin.v1.IGetIndexRequest,
optionsOrCallback?:
| CallOptions
| Callback<
protos.google.firestore.admin.v1.IIndex,
protos.google.firestore.admin.v1.IGetIndexRequest | null | undefined,
{} | null | undefined
>,
callback?: Callback<
protos.google.firestore.admin.v1.IIndex,
protos.google.firestore.admin.v1.IGetIndexRequest | null | undefined,
{} | null | undefined
>
): Promise<
[
protos.google.firestore.admin.v1.IIndex,
protos.google.firestore.admin.v1.IGetIndexRequest | undefined,
{} | undefined
]
> | void {
request = request || {};
let options: CallOptions;
if (typeof optionsOrCallback === 'function' && callback === undefined) {
callback = optionsOrCallback;
options = {};
} else {
options = optionsOrCallback as CallOptions;
}
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers[
'x-goog-request-params'
] = gax.routingHeader.fromParams({
name: request.name || '',
});
this.initialize();
return this.innerApiCalls.getIndex(request, options, callback);
}
deleteIndex(
request: protos.google.firestore.admin.v1.IDeleteIndexRequest,
options?: CallOptions
): Promise<
[
protos.google.protobuf.IEmpty,
protos.google.firestore.admin.v1.IDeleteIndexRequest | undefined,
{} | undefined
]
>;
deleteIndex(
request: protos.google.firestore.admin.v1.IDeleteIndexRequest,
options: CallOptions,
callback: Callback<
protos.google.protobuf.IEmpty,
protos.google.firestore.admin.v1.IDeleteIndexRequest | null | undefined,
{} | null | undefined
>
): void;
deleteIndex(
request: protos.google.firestore.admin.v1.IDeleteIndexRequest,
callback: Callback<
protos.google.protobuf.IEmpty,
protos.google.firestore.admin.v1.IDeleteIndexRequest | null | undefined,
{} | null | undefined
>
): void;
/**
* Deletes a composite index.
*
* @param {Object} request
* The request object that will be sent.
* @param {string} request.name
* Required. A name of the form
* `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}`
* @param {object} [options]
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
* @returns {Promise} - The promise which resolves to an array.
* The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}.
* Please see the
* [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods)
* for more details and examples.
* @example
* const [response] = await client.deleteIndex(request);
*/
deleteIndex(
request: protos.google.firestore.admin.v1.IDeleteIndexRequest,
optionsOrCallback?:
| CallOptions
| Callback<
protos.google.protobuf.IEmpty,
| protos.google.firestore.admin.v1.IDeleteIndexRequest
| null
| undefined,
{} | null | undefined
>,
callback?: Callback<
protos.google.protobuf.IEmpty,
protos.google.firestore.admin.v1.IDeleteIndexRequest | null | undefined,
{} | null | undefined
>
): Promise<
[
protos.google.protobuf.IEmpty,
protos.google.firestore.admin.v1.IDeleteIndexRequest | undefined,
{} | undefined
]
> | void {
request = request || {};
let options: CallOptions;
if (typeof optionsOrCallback === 'function' && callback === undefined) {
callback = optionsOrCallback;
options = {};
} else {
options = optionsOrCallback as CallOptions;
}
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers[
'x-goog-request-params'
] = gax.routingHeader.fromParams({
name: request.name || '',
});
this.initialize();
return this.innerApiCalls.deleteIndex(request, options, callback);
}
getField(
request: protos.google.firestore.admin.v1.IGetFieldRequest,
options?: CallOptions
): Promise<
[
protos.google.firestore.admin.v1.IField,
protos.google.firestore.admin.v1.IGetFieldRequest | undefined,
{} | undefined
]
>;
getField(
request: protos.google.firestore.admin.v1.IGetFieldRequest,
options: CallOptions,
callback: Callback<
protos.google.firestore.admin.v1.IField,
protos.google.firestore.admin.v1.IGetFieldRequest | null | undefined,
{} | null | undefined
>
): void;
getField(
request: protos.google.firestore.admin.v1.IGetFieldRequest,
callback: Callback<
protos.google.firestore.admin.v1.IField,
protos.google.firestore.admin.v1.IGetFieldRequest | null | undefined,
{} | null | undefined
>
): void;
/**
* Gets the metadata and configuration for a Field.
*
* @param {Object} request
* The request object that will be sent.
* @param {string} request.name
* Required. A name of the form
* `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_id}`
* @param {object} [options]
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
* @returns {Promise} - The promise which resolves to an array.
* The first element of the array is an object representing [Field]{@link google.firestore.admin.v1.Field}.
* Please see the
* [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods)
* for more details and examples.
* @example
* const [response] = await client.getField(request);
*/
getField(
request: protos.google.firestore.admin.v1.IGetFieldRequest,
optionsOrCallback?:
| CallOptions
| Callback<
protos.google.firestore.admin.v1.IField,
protos.google.firestore.admin.v1.IGetFieldRequest | null | undefined,
{} | null | undefined
>,
callback?: Callback<
protos.google.firestore.admin.v1.IField,
protos.google.firestore.admin.v1.IGetFieldRequest | null | undefined,
{} | null | undefined
>
): Promise<
[
protos.google.firestore.admin.v1.IField,
protos.google.firestore.admin.v1.IGetFieldRequest | undefined,
{} | undefined
]
> | void {
request = request || {};
let options: CallOptions;
if (typeof optionsOrCallback === 'function' && callback === undefined) {
callback = optionsOrCallback;
options = {};
} else {
options = optionsOrCallback as CallOptions;
}
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers[
'x-goog-request-params'
] = gax.routingHeader.fromParams({
name: request.name || '',
});
this.initialize();
return this.innerApiCalls.getField(request, options, callback);
}
createIndex(
request: protos.google.firestore.admin.v1.ICreateIndexRequest,
options?: CallOptions
): Promise<
[
LROperation<
protos.google.firestore.admin.v1.IIndex,
protos.google.firestore.admin.v1.IIndexOperationMetadata
>,
protos.google.longrunning.IOperation | undefined,
{} | undefined
]
>;
createIndex(
request: protos.google.firestore.admin.v1.ICreateIndexRequest,
options: CallOptions,
callback: Callback<
LROperation<
protos.google.firestore.admin.v1.IIndex,
protos.google.firestore.admin.v1.IIndexOperationMetadata
>,
protos.google.longrunning.IOperation | null | undefined,
{} | null | undefined
>
): void;
createIndex(
request: protos.google.firestore.admin.v1.ICreateIndexRequest,
callback: Callback<
LROperation<
protos.google.firestore.admin.v1.IIndex,
protos.google.firestore.admin.v1.IIndexOperationMetadata
>,
protos.google.longrunning.IOperation | null | undefined,
{} | null | undefined
>
): void;
/**
* Creates a composite index. This returns a {@link google.longrunning.Operation|google.longrunning.Operation}
* which may be used to track the status of the creation. The metadata for
* the operation will be the type {@link google.firestore.admin.v1.IndexOperationMetadata|IndexOperationMetadata}.
*
* @param {Object} request
* The request object that will be sent.
* @param {string} request.parent
* Required. A parent name of the form
* `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}`
* @param {google.firestore.admin.v1.Index} request.index
* Required. The composite index to create.
* @param {object} [options]
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
* @returns {Promise} - The promise which resolves to an array.
* The first element of the array is an object representing
* a long running operation. Its `promise()` method returns a promise
* you can `await` for.
* Please see the
* [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations)
* for more details and examples.
* @example
* const [operation] = await client.createIndex(request);
* const [response] = await operation.promise();
*/
createIndex(
request: protos.google.firestore.admin.v1.ICreateIndexRequest,
optionsOrCallback?:
| CallOptions
| Callback<
LROperation<
protos.google.firestore.admin.v1.IIndex,
protos.google.firestore.admin.v1.IIndexOperationMetadata
>,
protos.google.longrunning.IOperation | null | undefined,
{} | null | undefined
>,
callback?: Callback<
LROperation<
protos.google.firestore.admin.v1.IIndex,
protos.google.firestore.admin.v1.IIndexOperationMetadata
>,
protos.google.longrunning.IOperation | null | undefined,
{} | null | undefined
>
): Promise<
[
LROperation<
protos.google.firestore.admin.v1.IIndex,
protos.google.firestore.admin.v1.IIndexOperationMetadata
>,
protos.google.longrunning.IOperation | undefined,
{} | undefined
]
> | void {
request = request || {};
let options: CallOptions;
if (typeof optionsOrCallback === 'function' && callback === undefined) {
callback = optionsOrCallback;
options = {};
} else {
options = optionsOrCallback as CallOptions;
}
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers[
'x-goog-request-params'
] = gax.routingHeader.fromParams({
parent: request.parent || '',
});
this.initialize();
return this.innerApiCalls.createIndex(request, options, callback);
}
/**
* Check the status of the long running operation returned by `createIndex()`.
* @param {String} name
* The operation name that will be passed.
* @returns {Promise} - The promise which resolves to an object.
* The decoded operation object has result and metadata field to get information from.
* Please see the
* [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations)
* for more details and examples.
* @example
* const decodedOperation = await checkCreateIndexProgress(name);
* console.log(decodedOperation.result);
* console.log(decodedOperation.done);
* console.log(decodedOperation.metadata);
*/
async checkCreateIndexProgress(
name: string
): Promise<
LROperation<
protos.google.firestore.admin.v1.Index,
protos.google.firestore.admin.v1.IndexOperationMetadata
>
> {
const request = new operationsProtos.google.longrunning.GetOperationRequest(
{name}
);
const [operation] = await this.operationsClient.getOperation(request);
const decodeOperation = new gax.Operation(
operation,
this.descriptors.longrunning.createIndex,
gax.createDefaultBackoffSettings()
);
return decodeOperation as LROperation<
protos.google.firestore.admin.v1.Index,
protos.google.firestore.admin.v1.IndexOperationMetadata
>;
}
updateField(
request: protos.google.firestore.admin.v1.IUpdateFieldRequest,
options?: CallOptions
): Promise<
[
LROperation<
protos.google.firestore.admin.v1.IField,
protos.google.firestore.admin.v1.IFieldOperationMetadata
>,
protos.google.longrunning.IOperation | undefined,
{} | undefined
]
>;
updateField(
request: protos.google.firestore.admin.v1.IUpdateFieldRequest,
options: CallOptions,
callback: Callback<
LROperation<
protos.google.firestore.admin.v1.IField,
protos.google.firestore.admin.v1.IFieldOperationMetadata
>,
protos.google.longrunning.IOperation | null | undefined,
{} | null | undefined
>
): void;
updateField(
request: protos.google.firestore.admin.v1.IUpdateFieldRequest,
callback: Callback<
LROperation<
protos.google.firestore.admin.v1.IField,
protos.google.firestore.admin.v1.IFieldOperationMetadata
>,
protos.google.longrunning.IOperation | null | undefined,
{} | null | undefined
>
): void;
/**
* Updates a field configuration. Currently, field updates apply only to
* single field index configuration. However, calls to
* {@link google.firestore.admin.v1.FirestoreAdmin.UpdateField|FirestoreAdmin.UpdateField} should provide a field mask to avoid
* changing any configuration that the caller isn't aware of. The field mask
* should be specified as: `{ paths: "index_config" }`.
*
* This call returns a {@link google.longrunning.Operation|google.longrunning.Operation} which may be used to
* track the status of the field update. The metadata for
* the operation will be the type {@link google.firestore.admin.v1.FieldOperationMetadata|FieldOperationMetadata}.
*
* To configure the default field settings for the database, use
* the special `Field` with resource name:
* `projects/{project_id}/databases/{database_id}/collectionGroups/__default__/fields/*`.
*
* @param {Object} request
* The request object that will be sent.
* @param {google.firestore.admin.v1.Field} request.field
* Required. The field to be updated.
* @param {google.protobuf.FieldMask} request.updateMask
* A mask, relative to the field. If specified, only configuration specified
* by this field_mask will be updated in the field.
* @param {object} [options]
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
* @returns {Promise} - The promise which resolves to an array.
* The first element of the array is an object representing
* a long running operation. Its `promise()` method returns a promise
* you can `await` for.
* Please see the
* [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations)
* for more details and examples.
* @example
* const [operation] = await client.updateField(request);
* const [response] = await operation.promise();
*/
updateField(
request: protos.google.firestore.admin.v1.IUpdateFieldRequest,
optionsOrCallback?:
| CallOptions
| Callback<
LROperation<
protos.google.firestore.admin.v1.IField,
protos.google.firestore.admin.v1.IFieldOperationMetadata
>,
protos.google.longrunning.IOperation | null | undefined,
{} | null | undefined
>,
callback?: Callback<
LROperation<
protos.google.firestore.admin.v1.IField,
protos.google.firestore.admin.v1.IFieldOperationMetadata
>,
protos.google.longrunning.IOperation | null | undefined,
{} | null | undefined
>
): Promise<
[
LROperation<
protos.google.firestore.admin.v1.IField,
protos.google.firestore.admin.v1.IFieldOperationMetadata
>,
protos.google.longrunning.IOperation | undefined,
{} | undefined
]
> | void {
request = request || {};
let options: CallOptions;
if (typeof optionsOrCallback === 'function' && callback === undefined) {
callback = optionsOrCallback;
options = {};
} else {
options = optionsOrCallback as CallOptions;
}
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers[
'x-goog-request-params'
] = gax.routingHeader.fromParams({
'field.name': request.field!.name || '',
});
this.initialize();
return this.innerApiCalls.updateField(request, options, callback);
}
/**
* Check the status of the long running operation returned by `updateField()`.
* @param {String} name
* The operation name that will be passed.
* @returns {Promise} - The promise which resolves to an object.
* The decoded operation object has result and metadata field to get information from.
* Please see the
* [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations)
* for more details and examples.
* @example
* const decodedOperation = await checkUpdateFieldProgress(name);
* console.log(decodedOperation.result);
* console.log(decodedOperation.done);
* console.log(decodedOperation.metadata);
*/
async checkUpdateFieldProgress(
name: string
): Promise<
LROperation<
protos.google.firestore.admin.v1.Field,
protos.google.firestore.admin.v1.FieldOperationMetadata
>
> {
const request = new operationsProtos.google.longrunning.GetOperationRequest(
{name}
);
const [operation] = await this.operationsClient.getOperation(request);
const decodeOperation = new gax.Operation(
operation,
this.descriptors.longrunning.updateField,
gax.createDefaultBackoffSettings()
);
return decodeOperation as LROperation<
protos.google.firestore.admin.v1.Field,
protos.google.firestore.admin.v1.FieldOperationMetadata
>;
}
exportDocuments(
request: protos.google.firestore.admin.v1.IExportDocumentsRequest,
options?: CallOptions
): Promise<
[
LROperation<
protos.google.firestore.admin.v1.IExportDocumentsResponse,
protos.google.firestore.admin.v1.IExportDocumentsMetadata
>,
protos.google.longrunning.IOperation | undefined,
{} | undefined
]
>;
exportDocuments(
request: protos.google.firestore.admin.v1.IExportDocumentsRequest,
options: CallOptions,
callback: Callback<
LROperation<
protos.google.firestore.admin.v1.IExportDocumentsResponse,
protos.google.firestore.admin.v1.IExportDocumentsMetadata
>,
protos.google.longrunning.IOperation | null | undefined,
{} | null | undefined
>
): void;
exportDocuments(
request: protos.google.firestore.admin.v1.IExportDocumentsRequest,
callback: Callback<
LROperation<
protos.google.firestore.admin.v1.IExportDocumentsResponse,
protos.google.firestore.admin.v1.IExportDocumentsMetadata