@google-cloud/discoveryengine 0.1.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.
Files changed (32) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/LICENSE +202 -0
  3. package/README.md +209 -0
  4. package/build/protos/google/cloud/discoveryengine/v1beta/common.proto +93 -0
  5. package/build/protos/google/cloud/discoveryengine/v1beta/document.proto +77 -0
  6. package/build/protos/google/cloud/discoveryengine/v1beta/document_service.proto +261 -0
  7. package/build/protos/google/cloud/discoveryengine/v1beta/import_config.proto +265 -0
  8. package/build/protos/google/cloud/discoveryengine/v1beta/recommendation_service.proto +182 -0
  9. package/build/protos/google/cloud/discoveryengine/v1beta/user_event.proto +453 -0
  10. package/build/protos/google/cloud/discoveryengine/v1beta/user_event_service.proto +122 -0
  11. package/build/protos/protos.d.ts +10120 -0
  12. package/build/protos/protos.js +26118 -0
  13. package/build/protos/protos.json +2682 -0
  14. package/build/src/index.d.ts +17 -0
  15. package/build/src/index.js +37 -0
  16. package/build/src/index.js.map +1 -0
  17. package/build/src/v1beta/document_service_client.d.ts +684 -0
  18. package/build/src/v1beta/document_service_client.js +830 -0
  19. package/build/src/v1beta/document_service_client.js.map +1 -0
  20. package/build/src/v1beta/document_service_client_config.json +77 -0
  21. package/build/src/v1beta/index.d.ts +3 -0
  22. package/build/src/v1beta/index.js +27 -0
  23. package/build/src/v1beta/index.js.map +1 -0
  24. package/build/src/v1beta/recommendation_service_client.d.ts +307 -0
  25. package/build/src/v1beta/recommendation_service_client.js +407 -0
  26. package/build/src/v1beta/recommendation_service_client.js.map +1 -0
  27. package/build/src/v1beta/recommendation_service_client_config.json +43 -0
  28. package/build/src/v1beta/user_event_service_client.d.ts +445 -0
  29. package/build/src/v1beta/user_event_service_client.js +628 -0
  30. package/build/src/v1beta/user_event_service_client.js.map +1 -0
  31. package/build/src/v1beta/user_event_service_client_config.json +62 -0
  32. package/package.json +66 -0
@@ -0,0 +1,830 @@
1
+ "use strict";
2
+ // Copyright 2022 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
+ // https://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
+ // ** This file is automatically generated by gapic-generator-typescript. **
17
+ // ** https://github.com/googleapis/gapic-generator-typescript **
18
+ // ** All changes to this file may be overwritten. **
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.DocumentServiceClient = void 0;
21
+ const jsonProtos = require("../../protos/protos.json");
22
+ /**
23
+ * Client JSON configuration object, loaded from
24
+ * `src/v1beta/document_service_client_config.json`.
25
+ * This file defines retry strategy and timeouts for all API methods in this library.
26
+ */
27
+ const gapicConfig = require("./document_service_client_config.json");
28
+ const version = require('../../../package.json').version;
29
+ /**
30
+ * Service for ingesting
31
+ * {@link google.cloud.discoveryengine.v1beta.Document|Document} information of the
32
+ * customer's website.
33
+ * @class
34
+ * @memberof v1beta
35
+ */
36
+ class DocumentServiceClient {
37
+ /**
38
+ * Construct an instance of DocumentServiceClient.
39
+ *
40
+ * @param {object} [options] - The configuration object.
41
+ * The options accepted by the constructor are described in detail
42
+ * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance).
43
+ * The common options are:
44
+ * @param {object} [options.credentials] - Credentials object.
45
+ * @param {string} [options.credentials.client_email]
46
+ * @param {string} [options.credentials.private_key]
47
+ * @param {string} [options.email] - Account email address. Required when
48
+ * using a .pem or .p12 keyFilename.
49
+ * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or
50
+ * .p12 key downloaded from the Google Developers Console. If you provide
51
+ * a path to a JSON file, the projectId option below is not necessary.
52
+ * NOTE: .pem and .p12 require you to specify options.email as well.
53
+ * @param {number} [options.port] - The port on which to connect to
54
+ * the remote host.
55
+ * @param {string} [options.projectId] - The project ID from the Google
56
+ * Developer's Console, e.g. 'grape-spaceship-123'. We will also check
57
+ * the environment variable GCLOUD_PROJECT for your project ID. If your
58
+ * app is running in an environment which supports
59
+ * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials},
60
+ * your project ID will be detected automatically.
61
+ * @param {string} [options.apiEndpoint] - The domain name of the
62
+ * API remote host.
63
+ * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
64
+ * Follows the structure of {@link gapicConfig}.
65
+ * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode.
66
+ * Pass "rest" to use HTTP/1.1 REST API instead of gRPC.
67
+ * For more information, please check the
68
+ * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
69
+ * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you
70
+ * need to avoid loading the default gRPC version and want to use the fallback
71
+ * HTTP implementation. Load only fallback version and pass it to the constructor:
72
+ * ```
73
+ * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC
74
+ * const client = new DocumentServiceClient({fallback: 'rest'}, gax);
75
+ * ```
76
+ */
77
+ constructor(opts, gaxInstance) {
78
+ var _a, _b;
79
+ this._terminated = false;
80
+ this.descriptors = {
81
+ page: {},
82
+ stream: {},
83
+ longrunning: {},
84
+ batching: {},
85
+ };
86
+ // Ensure that options include all the required fields.
87
+ const staticMembers = this.constructor;
88
+ const servicePath = (opts === null || opts === void 0 ? void 0 : opts.servicePath) || (opts === null || opts === void 0 ? void 0 : opts.apiEndpoint) || staticMembers.servicePath;
89
+ this._providedCustomServicePath = !!((opts === null || opts === void 0 ? void 0 : opts.servicePath) || (opts === null || opts === void 0 ? void 0 : opts.apiEndpoint));
90
+ const port = (opts === null || opts === void 0 ? void 0 : opts.port) || staticMembers.port;
91
+ const clientConfig = (_a = opts === null || opts === void 0 ? void 0 : opts.clientConfig) !== null && _a !== void 0 ? _a : {};
92
+ const fallback = (_b = opts === null || opts === void 0 ? void 0 : opts.fallback) !== null && _b !== void 0 ? _b : (typeof window !== 'undefined' && typeof (window === null || window === void 0 ? void 0 : window.fetch) === 'function');
93
+ opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts);
94
+ // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case.
95
+ if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) {
96
+ opts['scopes'] = staticMembers.scopes;
97
+ }
98
+ // Load google-gax module synchronously if needed
99
+ if (!gaxInstance) {
100
+ gaxInstance = require('google-gax');
101
+ }
102
+ // Choose either gRPC or proto-over-HTTP implementation of google-gax.
103
+ this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance;
104
+ // Create a `gaxGrpc` object, with any grpc-specific options sent to the client.
105
+ this._gaxGrpc = new this._gaxModule.GrpcClient(opts);
106
+ // Save options to use in initialize() method.
107
+ this._opts = opts;
108
+ // Save the auth object to the client, for use by other methods.
109
+ this.auth = this._gaxGrpc.auth;
110
+ // Set useJWTAccessWithScope on the auth object.
111
+ this.auth.useJWTAccessWithScope = true;
112
+ // Set defaultServicePath on the auth object.
113
+ this.auth.defaultServicePath = staticMembers.servicePath;
114
+ // Set the default scopes in auth client if needed.
115
+ if (servicePath === staticMembers.servicePath) {
116
+ this.auth.defaultScopes = staticMembers.scopes;
117
+ }
118
+ // Determine the client header string.
119
+ const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`];
120
+ if (typeof process !== 'undefined' && 'versions' in process) {
121
+ clientHeader.push(`gl-node/${process.versions.node}`);
122
+ }
123
+ else {
124
+ clientHeader.push(`gl-web/${this._gaxModule.version}`);
125
+ }
126
+ if (!opts.fallback) {
127
+ clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`);
128
+ }
129
+ else if (opts.fallback === 'rest') {
130
+ clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`);
131
+ }
132
+ if (opts.libName && opts.libVersion) {
133
+ clientHeader.push(`${opts.libName}/${opts.libVersion}`);
134
+ }
135
+ // Load the applicable protos.
136
+ this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos);
137
+ // This API contains "path templates"; forward-slash-separated
138
+ // identifiers to uniquely identify resources within the API.
139
+ // Create useful helper objects for these.
140
+ this.pathTemplates = {
141
+ branchPathTemplate: new this._gaxModule.PathTemplate('projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}'),
142
+ documentPathTemplate: new this._gaxModule.PathTemplate('projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document}'),
143
+ };
144
+ // Some of the methods on this service return "paged" results,
145
+ // (e.g. 50 results at a time, with tokens to get subsequent
146
+ // pages). Denote the keys used for pagination and results.
147
+ this.descriptors.page = {
148
+ listDocuments: new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'documents'),
149
+ };
150
+ const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
151
+ // This API contains "long-running operations", which return a
152
+ // an Operation object that allows for tracking of the operation,
153
+ // rather than holding a request open.
154
+ const lroOptions = {
155
+ auth: this.auth,
156
+ grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
157
+ };
158
+ if (opts.fallback === 'rest') {
159
+ lroOptions.protoJson = protoFilesRoot;
160
+ lroOptions.httpRules = [
161
+ {
162
+ selector: 'google.longrunning.Operations.GetOperation',
163
+ get: '/v1beta/{name=projects/*/locations/*/dataStores/*/branches/*/operations/*}',
164
+ additional_bindings: [
165
+ {
166
+ get: '/v1beta/{name=projects/*/locations/*/dataStores/*/operations/*}',
167
+ },
168
+ { get: '/v1beta/{name=projects/*/locations/*/operations/*}' },
169
+ { get: '/v1beta/{name=projects/*/operations/*}' },
170
+ ],
171
+ },
172
+ {
173
+ selector: 'google.longrunning.Operations.ListOperations',
174
+ get: '/v1beta/{name=projects/*/locations/*/dataStores/*}/operations',
175
+ additional_bindings: [
176
+ { get: '/v1beta/{name=projects/*/locations/*}/operations' },
177
+ { get: '/v1beta/{name=projects/*}/operations' },
178
+ ],
179
+ },
180
+ ];
181
+ }
182
+ this.operationsClient = this._gaxModule
183
+ .lro(lroOptions)
184
+ .operationsClient(opts);
185
+ const importDocumentsResponse = protoFilesRoot.lookup('.google.cloud.discoveryengine.v1beta.ImportDocumentsResponse');
186
+ const importDocumentsMetadata = protoFilesRoot.lookup('.google.cloud.discoveryengine.v1beta.ImportDocumentsMetadata');
187
+ this.descriptors.longrunning = {
188
+ importDocuments: new this._gaxModule.LongrunningDescriptor(this.operationsClient, importDocumentsResponse.decode.bind(importDocumentsResponse), importDocumentsMetadata.decode.bind(importDocumentsMetadata)),
189
+ };
190
+ // Put together the default options sent with requests.
191
+ this._defaults = this._gaxGrpc.constructSettings('google.cloud.discoveryengine.v1beta.DocumentService', gapicConfig, opts.clientConfig || {}, { 'x-goog-api-client': clientHeader.join(' ') });
192
+ // Set up a dictionary of "inner API calls"; the core implementation
193
+ // of calling the API is handled in `google-gax`, with this code
194
+ // merely providing the destination and request information.
195
+ this.innerApiCalls = {};
196
+ // Add a warn function to the client constructor so it can be easily tested.
197
+ this.warn = this._gaxModule.warn;
198
+ }
199
+ /**
200
+ * Initialize the client.
201
+ * Performs asynchronous operations (such as authentication) and prepares the client.
202
+ * This function will be called automatically when any class method is called for the
203
+ * first time, but if you need to initialize it before calling an actual method,
204
+ * feel free to call initialize() directly.
205
+ *
206
+ * You can await on this method if you want to make sure the client is initialized.
207
+ *
208
+ * @returns {Promise} A promise that resolves to an authenticated service stub.
209
+ */
210
+ initialize() {
211
+ // If the client stub promise is already initialized, return immediately.
212
+ if (this.documentServiceStub) {
213
+ return this.documentServiceStub;
214
+ }
215
+ // Put together the "service stub" for
216
+ // google.cloud.discoveryengine.v1beta.DocumentService.
217
+ this.documentServiceStub = this._gaxGrpc.createStub(this._opts.fallback
218
+ ? this._protos.lookupService('google.cloud.discoveryengine.v1beta.DocumentService')
219
+ : // eslint-disable-next-line @typescript-eslint/no-explicit-any
220
+ this._protos.google.cloud.discoveryengine.v1beta
221
+ .DocumentService, this._opts, this._providedCustomServicePath);
222
+ // Iterate over each of the methods that the service provides
223
+ // and create an API call method for each.
224
+ const documentServiceStubMethods = [
225
+ 'getDocument',
226
+ 'listDocuments',
227
+ 'createDocument',
228
+ 'updateDocument',
229
+ 'deleteDocument',
230
+ 'importDocuments',
231
+ ];
232
+ for (const methodName of documentServiceStubMethods) {
233
+ const callPromise = this.documentServiceStub.then(stub => (...args) => {
234
+ if (this._terminated) {
235
+ return Promise.reject('The client has already been closed.');
236
+ }
237
+ const func = stub[methodName];
238
+ return func.apply(stub, args);
239
+ }, (err) => () => {
240
+ throw err;
241
+ });
242
+ const descriptor = this.descriptors.page[methodName] ||
243
+ this.descriptors.longrunning[methodName] ||
244
+ undefined;
245
+ const apiCall = this._gaxModule.createApiCall(callPromise, this._defaults[methodName], descriptor, this._opts.fallback);
246
+ this.innerApiCalls[methodName] = apiCall;
247
+ }
248
+ return this.documentServiceStub;
249
+ }
250
+ /**
251
+ * The DNS address for this API service.
252
+ * @returns {string} The DNS address for this service.
253
+ */
254
+ static get servicePath() {
255
+ return 'discoveryengine.googleapis.com';
256
+ }
257
+ /**
258
+ * The DNS address for this API service - same as servicePath(),
259
+ * exists for compatibility reasons.
260
+ * @returns {string} The DNS address for this service.
261
+ */
262
+ static get apiEndpoint() {
263
+ return 'discoveryengine.googleapis.com';
264
+ }
265
+ /**
266
+ * The port for this API service.
267
+ * @returns {number} The default port for this service.
268
+ */
269
+ static get port() {
270
+ return 443;
271
+ }
272
+ /**
273
+ * The scopes needed to make gRPC calls for every method defined
274
+ * in this service.
275
+ * @returns {string[]} List of default scopes.
276
+ */
277
+ static get scopes() {
278
+ return ['https://www.googleapis.com/auth/cloud-platform'];
279
+ }
280
+ /**
281
+ * Return the project ID used by this class.
282
+ * @returns {Promise} A promise that resolves to string containing the project ID.
283
+ */
284
+ getProjectId(callback) {
285
+ if (callback) {
286
+ this.auth.getProjectId(callback);
287
+ return;
288
+ }
289
+ return this.auth.getProjectId();
290
+ }
291
+ getDocument(request, optionsOrCallback, callback) {
292
+ var _a;
293
+ request = request || {};
294
+ let options;
295
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
296
+ callback = optionsOrCallback;
297
+ options = {};
298
+ }
299
+ else {
300
+ options = optionsOrCallback;
301
+ }
302
+ options = options || {};
303
+ options.otherArgs = options.otherArgs || {};
304
+ options.otherArgs.headers = options.otherArgs.headers || {};
305
+ options.otherArgs.headers['x-goog-request-params'] =
306
+ this._gaxModule.routingHeader.fromParams({
307
+ name: (_a = request.name) !== null && _a !== void 0 ? _a : '',
308
+ });
309
+ this.initialize();
310
+ return this.innerApiCalls.getDocument(request, options, callback);
311
+ }
312
+ createDocument(request, optionsOrCallback, callback) {
313
+ var _a;
314
+ request = request || {};
315
+ let options;
316
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
317
+ callback = optionsOrCallback;
318
+ options = {};
319
+ }
320
+ else {
321
+ options = optionsOrCallback;
322
+ }
323
+ options = options || {};
324
+ options.otherArgs = options.otherArgs || {};
325
+ options.otherArgs.headers = options.otherArgs.headers || {};
326
+ options.otherArgs.headers['x-goog-request-params'] =
327
+ this._gaxModule.routingHeader.fromParams({
328
+ parent: (_a = request.parent) !== null && _a !== void 0 ? _a : '',
329
+ });
330
+ this.initialize();
331
+ return this.innerApiCalls.createDocument(request, options, callback);
332
+ }
333
+ updateDocument(request, optionsOrCallback, callback) {
334
+ var _a;
335
+ request = request || {};
336
+ let options;
337
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
338
+ callback = optionsOrCallback;
339
+ options = {};
340
+ }
341
+ else {
342
+ options = optionsOrCallback;
343
+ }
344
+ options = options || {};
345
+ options.otherArgs = options.otherArgs || {};
346
+ options.otherArgs.headers = options.otherArgs.headers || {};
347
+ options.otherArgs.headers['x-goog-request-params'] =
348
+ this._gaxModule.routingHeader.fromParams({
349
+ 'document.name': (_a = request.document.name) !== null && _a !== void 0 ? _a : '',
350
+ });
351
+ this.initialize();
352
+ return this.innerApiCalls.updateDocument(request, options, callback);
353
+ }
354
+ deleteDocument(request, optionsOrCallback, callback) {
355
+ var _a;
356
+ request = request || {};
357
+ let options;
358
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
359
+ callback = optionsOrCallback;
360
+ options = {};
361
+ }
362
+ else {
363
+ options = optionsOrCallback;
364
+ }
365
+ options = options || {};
366
+ options.otherArgs = options.otherArgs || {};
367
+ options.otherArgs.headers = options.otherArgs.headers || {};
368
+ options.otherArgs.headers['x-goog-request-params'] =
369
+ this._gaxModule.routingHeader.fromParams({
370
+ name: (_a = request.name) !== null && _a !== void 0 ? _a : '',
371
+ });
372
+ this.initialize();
373
+ return this.innerApiCalls.deleteDocument(request, options, callback);
374
+ }
375
+ importDocuments(request, optionsOrCallback, callback) {
376
+ var _a;
377
+ request = request || {};
378
+ let options;
379
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
380
+ callback = optionsOrCallback;
381
+ options = {};
382
+ }
383
+ else {
384
+ options = optionsOrCallback;
385
+ }
386
+ options = options || {};
387
+ options.otherArgs = options.otherArgs || {};
388
+ options.otherArgs.headers = options.otherArgs.headers || {};
389
+ options.otherArgs.headers['x-goog-request-params'] =
390
+ this._gaxModule.routingHeader.fromParams({
391
+ parent: (_a = request.parent) !== null && _a !== void 0 ? _a : '',
392
+ });
393
+ this.initialize();
394
+ return this.innerApiCalls.importDocuments(request, options, callback);
395
+ }
396
+ /**
397
+ * Check the status of the long running operation returned by `importDocuments()`.
398
+ * @param {String} name
399
+ * The operation name that will be passed.
400
+ * @returns {Promise} - The promise which resolves to an object.
401
+ * The decoded operation object has result and metadata field to get information from.
402
+ * Please see the
403
+ * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations)
404
+ * for more details and examples.
405
+ * @example <caption>include:samples/generated/v1beta/document_service.import_documents.js</caption>
406
+ * region_tag:discoveryengine_v1beta_generated_DocumentService_ImportDocuments_async
407
+ */
408
+ async checkImportDocumentsProgress(name) {
409
+ const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({ name });
410
+ const [operation] = await this.operationsClient.getOperation(request);
411
+ const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.importDocuments, this._gaxModule.createDefaultBackoffSettings());
412
+ return decodeOperation;
413
+ }
414
+ listDocuments(request, optionsOrCallback, callback) {
415
+ var _a;
416
+ request = request || {};
417
+ let options;
418
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
419
+ callback = optionsOrCallback;
420
+ options = {};
421
+ }
422
+ else {
423
+ options = optionsOrCallback;
424
+ }
425
+ options = options || {};
426
+ options.otherArgs = options.otherArgs || {};
427
+ options.otherArgs.headers = options.otherArgs.headers || {};
428
+ options.otherArgs.headers['x-goog-request-params'] =
429
+ this._gaxModule.routingHeader.fromParams({
430
+ parent: (_a = request.parent) !== null && _a !== void 0 ? _a : '',
431
+ });
432
+ this.initialize();
433
+ return this.innerApiCalls.listDocuments(request, options, callback);
434
+ }
435
+ /**
436
+ * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object.
437
+ * @param {Object} request
438
+ * The request object that will be sent.
439
+ * @param {string} request.parent
440
+ * Required. The parent branch resource name, such as
441
+ * `projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}`.
442
+ * Use `default_branch` as the branch ID, to list documents under the default
443
+ * branch.
444
+ *
445
+ * If the caller does not have permission to list {@link |Documents}s under this
446
+ * branch, regardless of whether or not this branch exists, a
447
+ * PERMISSION_DENIED error is returned.
448
+ * @param {number} request.pageSize
449
+ * Maximum number of {@link google.cloud.discoveryengine.v1beta.Document|Document}s
450
+ * to return. If unspecified, defaults to 100. The maximum allowed value is
451
+ * 1000. Values above 1000 will be coerced to 1000.
452
+ *
453
+ * If this field is negative, an INVALID_ARGUMENT error is returned.
454
+ * @param {string} request.pageToken
455
+ * A page token
456
+ * {@link google.cloud.discoveryengine.v1beta.ListDocumentsResponse.next_page_token|ListDocumentsResponse.next_page_token},
457
+ * received from a previous
458
+ * {@link google.cloud.discoveryengine.v1beta.DocumentService.ListDocuments|DocumentService.ListDocuments}
459
+ * call. Provide this to retrieve the subsequent page.
460
+ *
461
+ * When paginating, all other parameters provided to
462
+ * {@link google.cloud.discoveryengine.v1beta.DocumentService.ListDocuments|DocumentService.ListDocuments}
463
+ * must match the call that provided the page token. Otherwise, an
464
+ * INVALID_ARGUMENT error is returned.
465
+ * @param {object} [options]
466
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
467
+ * @returns {Stream}
468
+ * An object stream which emits an object representing [Document]{@link google.cloud.discoveryengine.v1beta.Document} on 'data' event.
469
+ * The client library will perform auto-pagination by default: it will call the API as many
470
+ * times as needed. Note that it can affect your quota.
471
+ * We recommend using `listDocumentsAsync()`
472
+ * method described below for async iteration which you can stop as needed.
473
+ * Please see the
474
+ * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination)
475
+ * for more details and examples.
476
+ */
477
+ listDocumentsStream(request, options) {
478
+ var _a;
479
+ request = request || {};
480
+ options = options || {};
481
+ options.otherArgs = options.otherArgs || {};
482
+ options.otherArgs.headers = options.otherArgs.headers || {};
483
+ options.otherArgs.headers['x-goog-request-params'] =
484
+ this._gaxModule.routingHeader.fromParams({
485
+ parent: (_a = request.parent) !== null && _a !== void 0 ? _a : '',
486
+ });
487
+ const defaultCallSettings = this._defaults['listDocuments'];
488
+ const callSettings = defaultCallSettings.merge(options);
489
+ this.initialize();
490
+ return this.descriptors.page.listDocuments.createStream(this.innerApiCalls.listDocuments, request, callSettings);
491
+ }
492
+ /**
493
+ * Equivalent to `listDocuments`, but returns an iterable object.
494
+ *
495
+ * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand.
496
+ * @param {Object} request
497
+ * The request object that will be sent.
498
+ * @param {string} request.parent
499
+ * Required. The parent branch resource name, such as
500
+ * `projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}`.
501
+ * Use `default_branch` as the branch ID, to list documents under the default
502
+ * branch.
503
+ *
504
+ * If the caller does not have permission to list {@link |Documents}s under this
505
+ * branch, regardless of whether or not this branch exists, a
506
+ * PERMISSION_DENIED error is returned.
507
+ * @param {number} request.pageSize
508
+ * Maximum number of {@link google.cloud.discoveryengine.v1beta.Document|Document}s
509
+ * to return. If unspecified, defaults to 100. The maximum allowed value is
510
+ * 1000. Values above 1000 will be coerced to 1000.
511
+ *
512
+ * If this field is negative, an INVALID_ARGUMENT error is returned.
513
+ * @param {string} request.pageToken
514
+ * A page token
515
+ * {@link google.cloud.discoveryengine.v1beta.ListDocumentsResponse.next_page_token|ListDocumentsResponse.next_page_token},
516
+ * received from a previous
517
+ * {@link google.cloud.discoveryengine.v1beta.DocumentService.ListDocuments|DocumentService.ListDocuments}
518
+ * call. Provide this to retrieve the subsequent page.
519
+ *
520
+ * When paginating, all other parameters provided to
521
+ * {@link google.cloud.discoveryengine.v1beta.DocumentService.ListDocuments|DocumentService.ListDocuments}
522
+ * must match the call that provided the page token. Otherwise, an
523
+ * INVALID_ARGUMENT error is returned.
524
+ * @param {object} [options]
525
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
526
+ * @returns {Object}
527
+ * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols).
528
+ * When you iterate the returned iterable, each element will be an object representing
529
+ * [Document]{@link google.cloud.discoveryengine.v1beta.Document}. The API will be called under the hood as needed, once per the page,
530
+ * so you can stop the iteration when you don't need more results.
531
+ * Please see the
532
+ * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination)
533
+ * for more details and examples.
534
+ * @example <caption>include:samples/generated/v1beta/document_service.list_documents.js</caption>
535
+ * region_tag:discoveryengine_v1beta_generated_DocumentService_ListDocuments_async
536
+ */
537
+ listDocumentsAsync(request, options) {
538
+ var _a;
539
+ request = request || {};
540
+ options = options || {};
541
+ options.otherArgs = options.otherArgs || {};
542
+ options.otherArgs.headers = options.otherArgs.headers || {};
543
+ options.otherArgs.headers['x-goog-request-params'] =
544
+ this._gaxModule.routingHeader.fromParams({
545
+ parent: (_a = request.parent) !== null && _a !== void 0 ? _a : '',
546
+ });
547
+ const defaultCallSettings = this._defaults['listDocuments'];
548
+ const callSettings = defaultCallSettings.merge(options);
549
+ this.initialize();
550
+ return this.descriptors.page.listDocuments.asyncIterate(this.innerApiCalls['listDocuments'], request, callSettings);
551
+ }
552
+ /**
553
+ * Gets the latest state of a long-running operation. Clients can use this
554
+ * method to poll the operation result at intervals as recommended by the API
555
+ * service.
556
+ *
557
+ * @param {Object} request - The request object that will be sent.
558
+ * @param {string} request.name - The name of the operation resource.
559
+ * @param {Object=} options
560
+ * Optional parameters. You can override the default settings for this call,
561
+ * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link
562
+ * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the
563
+ * details.
564
+ * @param {function(?Error, ?Object)=} callback
565
+ * The function which will be called with the result of the API call.
566
+ *
567
+ * The second parameter to the callback is an object representing
568
+ * [google.longrunning.Operation]{@link
569
+ * external:"google.longrunning.Operation"}.
570
+ * @return {Promise} - The promise which resolves to an array.
571
+ * The first element of the array is an object representing
572
+ * [google.longrunning.Operation]{@link
573
+ * external:"google.longrunning.Operation"}. The promise has a method named
574
+ * "cancel" which cancels the ongoing API call.
575
+ *
576
+ * @example
577
+ * ```
578
+ * const client = longrunning.operationsClient();
579
+ * const name = '';
580
+ * const [response] = await client.getOperation({name});
581
+ * // doThingsWith(response)
582
+ * ```
583
+ */
584
+ getOperation(request, options, callback) {
585
+ return this.operationsClient.getOperation(request, options, callback);
586
+ }
587
+ /**
588
+ * Lists operations that match the specified filter in the request. If the
589
+ * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object.
590
+ *
591
+ * For-await-of syntax is used with the iterable to recursively get response element on-demand.
592
+ *
593
+ * @param {Object} request - The request object that will be sent.
594
+ * @param {string} request.name - The name of the operation collection.
595
+ * @param {string} request.filter - The standard list filter.
596
+ * @param {number=} request.pageSize -
597
+ * The maximum number of resources contained in the underlying API
598
+ * response. If page streaming is performed per-resource, this
599
+ * parameter does not affect the return value. If page streaming is
600
+ * performed per-page, this determines the maximum number of
601
+ * resources in a page.
602
+ * @param {Object=} options
603
+ * Optional parameters. You can override the default settings for this call,
604
+ * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link
605
+ * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the
606
+ * details.
607
+ * @returns {Object}
608
+ * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols.
609
+ *
610
+ * @example
611
+ * ```
612
+ * const client = longrunning.operationsClient();
613
+ * for await (const response of client.listOperationsAsync(request));
614
+ * // doThingsWith(response)
615
+ * ```
616
+ */
617
+ listOperationsAsync(request, options) {
618
+ return this.operationsClient.listOperationsAsync(request, options);
619
+ }
620
+ /**
621
+ * Starts asynchronous cancellation on a long-running operation. The server
622
+ * makes a best effort to cancel the operation, but success is not
623
+ * guaranteed. If the server doesn't support this method, it returns
624
+ * `google.rpc.Code.UNIMPLEMENTED`. Clients can use
625
+ * {@link Operations.GetOperation} or
626
+ * other methods to check whether the cancellation succeeded or whether the
627
+ * operation completed despite cancellation. On successful cancellation,
628
+ * the operation is not deleted; instead, it becomes an operation with
629
+ * an {@link Operation.error} value with a {@link google.rpc.Status.code} of
630
+ * 1, corresponding to `Code.CANCELLED`.
631
+ *
632
+ * @param {Object} request - The request object that will be sent.
633
+ * @param {string} request.name - The name of the operation resource to be cancelled.
634
+ * @param {Object=} options
635
+ * Optional parameters. You can override the default settings for this call,
636
+ * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link
637
+ * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the
638
+ * details.
639
+ * @param {function(?Error)=} callback
640
+ * The function which will be called with the result of the API call.
641
+ * @return {Promise} - The promise which resolves when API call finishes.
642
+ * The promise has a method named "cancel" which cancels the ongoing API
643
+ * call.
644
+ *
645
+ * @example
646
+ * ```
647
+ * const client = longrunning.operationsClient();
648
+ * await client.cancelOperation({name: ''});
649
+ * ```
650
+ */
651
+ cancelOperation(request, options, callback) {
652
+ return this.operationsClient.cancelOperation(request, options, callback);
653
+ }
654
+ /**
655
+ * Deletes a long-running operation. This method indicates that the client is
656
+ * no longer interested in the operation result. It does not cancel the
657
+ * operation. If the server doesn't support this method, it returns
658
+ * `google.rpc.Code.UNIMPLEMENTED`.
659
+ *
660
+ * @param {Object} request - The request object that will be sent.
661
+ * @param {string} request.name - The name of the operation resource to be deleted.
662
+ * @param {Object=} options
663
+ * Optional parameters. You can override the default settings for this call,
664
+ * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link
665
+ * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the
666
+ * details.
667
+ * @param {function(?Error)=} callback
668
+ * The function which will be called with the result of the API call.
669
+ * @return {Promise} - The promise which resolves when API call finishes.
670
+ * The promise has a method named "cancel" which cancels the ongoing API
671
+ * call.
672
+ *
673
+ * @example
674
+ * ```
675
+ * const client = longrunning.operationsClient();
676
+ * await client.deleteOperation({name: ''});
677
+ * ```
678
+ */
679
+ deleteOperation(request, options, callback) {
680
+ return this.operationsClient.deleteOperation(request, options, callback);
681
+ }
682
+ // --------------------
683
+ // -- Path templates --
684
+ // --------------------
685
+ /**
686
+ * Return a fully-qualified branch resource name string.
687
+ *
688
+ * @param {string} project
689
+ * @param {string} location
690
+ * @param {string} data_store
691
+ * @param {string} branch
692
+ * @returns {string} Resource name string.
693
+ */
694
+ branchPath(project, location, dataStore, branch) {
695
+ return this.pathTemplates.branchPathTemplate.render({
696
+ project: project,
697
+ location: location,
698
+ data_store: dataStore,
699
+ branch: branch,
700
+ });
701
+ }
702
+ /**
703
+ * Parse the project from Branch resource.
704
+ *
705
+ * @param {string} branchName
706
+ * A fully-qualified path representing Branch resource.
707
+ * @returns {string} A string representing the project.
708
+ */
709
+ matchProjectFromBranchName(branchName) {
710
+ return this.pathTemplates.branchPathTemplate.match(branchName).project;
711
+ }
712
+ /**
713
+ * Parse the location from Branch resource.
714
+ *
715
+ * @param {string} branchName
716
+ * A fully-qualified path representing Branch resource.
717
+ * @returns {string} A string representing the location.
718
+ */
719
+ matchLocationFromBranchName(branchName) {
720
+ return this.pathTemplates.branchPathTemplate.match(branchName).location;
721
+ }
722
+ /**
723
+ * Parse the data_store from Branch resource.
724
+ *
725
+ * @param {string} branchName
726
+ * A fully-qualified path representing Branch resource.
727
+ * @returns {string} A string representing the data_store.
728
+ */
729
+ matchDataStoreFromBranchName(branchName) {
730
+ return this.pathTemplates.branchPathTemplate.match(branchName).data_store;
731
+ }
732
+ /**
733
+ * Parse the branch from Branch resource.
734
+ *
735
+ * @param {string} branchName
736
+ * A fully-qualified path representing Branch resource.
737
+ * @returns {string} A string representing the branch.
738
+ */
739
+ matchBranchFromBranchName(branchName) {
740
+ return this.pathTemplates.branchPathTemplate.match(branchName).branch;
741
+ }
742
+ /**
743
+ * Return a fully-qualified document resource name string.
744
+ *
745
+ * @param {string} project
746
+ * @param {string} location
747
+ * @param {string} data_store
748
+ * @param {string} branch
749
+ * @param {string} document
750
+ * @returns {string} Resource name string.
751
+ */
752
+ documentPath(project, location, dataStore, branch, document) {
753
+ return this.pathTemplates.documentPathTemplate.render({
754
+ project: project,
755
+ location: location,
756
+ data_store: dataStore,
757
+ branch: branch,
758
+ document: document,
759
+ });
760
+ }
761
+ /**
762
+ * Parse the project from Document resource.
763
+ *
764
+ * @param {string} documentName
765
+ * A fully-qualified path representing Document resource.
766
+ * @returns {string} A string representing the project.
767
+ */
768
+ matchProjectFromDocumentName(documentName) {
769
+ return this.pathTemplates.documentPathTemplate.match(documentName).project;
770
+ }
771
+ /**
772
+ * Parse the location from Document resource.
773
+ *
774
+ * @param {string} documentName
775
+ * A fully-qualified path representing Document resource.
776
+ * @returns {string} A string representing the location.
777
+ */
778
+ matchLocationFromDocumentName(documentName) {
779
+ return this.pathTemplates.documentPathTemplate.match(documentName).location;
780
+ }
781
+ /**
782
+ * Parse the data_store from Document resource.
783
+ *
784
+ * @param {string} documentName
785
+ * A fully-qualified path representing Document resource.
786
+ * @returns {string} A string representing the data_store.
787
+ */
788
+ matchDataStoreFromDocumentName(documentName) {
789
+ return this.pathTemplates.documentPathTemplate.match(documentName)
790
+ .data_store;
791
+ }
792
+ /**
793
+ * Parse the branch from Document resource.
794
+ *
795
+ * @param {string} documentName
796
+ * A fully-qualified path representing Document resource.
797
+ * @returns {string} A string representing the branch.
798
+ */
799
+ matchBranchFromDocumentName(documentName) {
800
+ return this.pathTemplates.documentPathTemplate.match(documentName).branch;
801
+ }
802
+ /**
803
+ * Parse the document from Document resource.
804
+ *
805
+ * @param {string} documentName
806
+ * A fully-qualified path representing Document resource.
807
+ * @returns {string} A string representing the document.
808
+ */
809
+ matchDocumentFromDocumentName(documentName) {
810
+ return this.pathTemplates.documentPathTemplate.match(documentName).document;
811
+ }
812
+ /**
813
+ * Terminate the gRPC channel and close the client.
814
+ *
815
+ * The client will no longer be usable and all future behavior is undefined.
816
+ * @returns {Promise} A promise that resolves when the client is closed.
817
+ */
818
+ close() {
819
+ if (this.documentServiceStub && !this._terminated) {
820
+ return this.documentServiceStub.then(stub => {
821
+ this._terminated = true;
822
+ stub.close();
823
+ this.operationsClient.close();
824
+ });
825
+ }
826
+ return Promise.resolve();
827
+ }
828
+ }
829
+ exports.DocumentServiceClient = DocumentServiceClient;
830
+ //# sourceMappingURL=document_service_client.js.map