adaptation_client.js
47.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
"use strict";
// 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. **
Object.defineProperty(exports, "__esModule", { value: true });
exports.AdaptationClient = void 0;
/* global window */
const gax = require("google-gax");
const jsonProtos = require("../../protos/protos.json");
/**
* Client JSON configuration object, loaded from
* `src/v1p1beta1/adaptation_client_config.json`.
* This file defines retry strategy and timeouts for all API methods in this library.
*/
const gapicConfig = require("./adaptation_client_config.json");
const version = require('../../../package.json').version;
/**
* Service that implements Google Cloud Speech Adaptation API.
* @class
* @memberof v1p1beta1
*/
class AdaptationClient {
/**
* Construct an instance of AdaptationClient.
*
* @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) {
var _a, _b;
this._terminated = false;
this.descriptors = {
page: {},
stream: {},
longrunning: {},
batching: {},
};
// Ensure that options include all the required fields.
const staticMembers = this.constructor;
const servicePath = (opts === null || opts === void 0 ? void 0 : opts.servicePath) || (opts === null || opts === void 0 ? void 0 : opts.apiEndpoint) || staticMembers.servicePath;
const port = (opts === null || opts === void 0 ? void 0 : opts.port) || staticMembers.port;
const clientConfig = (_a = opts === null || opts === void 0 ? void 0 : opts.clientConfig) !== null && _a !== void 0 ? _a : {};
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');
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;
// 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}`);
}
else if (opts.fallback === 'rest') {
clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`);
}
if (opts.libName && opts.libVersion) {
clientHeader.push(`${opts.libName}/${opts.libVersion}`);
}
// Load the applicable protos.
this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos);
// This API contains "path templates"; forward-slash-separated
// identifiers to uniquely identify resources within the API.
// Create useful helper objects for these.
this.pathTemplates = {
customClassPathTemplate: new this._gaxModule.PathTemplate('projects/{project}/locations/{location}/customClasses/{custom_class}'),
locationPathTemplate: new this._gaxModule.PathTemplate('projects/{project}/locations/{location}'),
phraseSetPathTemplate: new this._gaxModule.PathTemplate('projects/{project}/locations/{location}/phraseSets/{phrase_set}'),
projectPathTemplate: new this._gaxModule.PathTemplate('projects/{project}'),
};
// 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 = {
listPhraseSet: new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'phraseSets'),
listCustomClasses: new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'customClasses'),
};
// Put together the default options sent with requests.
this._defaults = this._gaxGrpc.constructSettings('google.cloud.speech.v1p1beta1.Adaptation', gapicConfig, 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.adaptationStub) {
return this.adaptationStub;
}
// Put together the "service stub" for
// google.cloud.speech.v1p1beta1.Adaptation.
this.adaptationStub = this._gaxGrpc.createStub(this._opts.fallback
? this._protos.lookupService('google.cloud.speech.v1p1beta1.Adaptation')
: // eslint-disable-next-line @typescript-eslint/no-explicit-any
this._protos.google.cloud.speech.v1p1beta1.Adaptation, this._opts);
// Iterate over each of the methods that the service provides
// and create an API call method for each.
const adaptationStubMethods = [
'createPhraseSet',
'getPhraseSet',
'listPhraseSet',
'updatePhraseSet',
'deletePhraseSet',
'createCustomClass',
'getCustomClass',
'listCustomClasses',
'updateCustomClass',
'deleteCustomClass',
];
for (const methodName of adaptationStubMethods) {
const callPromise = this.adaptationStub.then(stub => (...args) => {
if (this._terminated) {
return Promise.reject('The client has already been closed.');
}
const func = stub[methodName];
return func.apply(stub, args);
}, (err) => () => {
throw err;
});
const descriptor = this.descriptors.page[methodName] || undefined;
const apiCall = this._gaxModule.createApiCall(callPromise, this._defaults[methodName], descriptor);
this.innerApiCalls[methodName] = apiCall;
}
return this.adaptationStub;
}
/**
* The DNS address for this API service.
* @returns {string} The DNS address for this service.
*/
static get servicePath() {
return 'speech.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 'speech.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'];
}
/**
* Return the project ID used by this class.
* @returns {Promise} A promise that resolves to string containing the project ID.
*/
getProjectId(callback) {
if (callback) {
this.auth.getProjectId(callback);
return;
}
return this.auth.getProjectId();
}
/**
* Create a set of phrase hints. Each item in the set can be a single word or
* a multi-word phrase. The items in the PhraseSet are favored by the
* recognition model when you send a call that includes the PhraseSet.
*
* @param {Object} request
* The request object that will be sent.
* @param {string} request.parent
* Required. The parent resource where this phrase set will be created.
* Format:
* {api_version}/projects/{project}/locations/{location}/phraseSets
* @param {string} request.phraseSetId
* The ID to use for the phrase set, which will become the final
* component of the phrase set's resource name.
*
* This value should be 4-63 characters, and valid characters
* are /{@link 0-9|a-z}-/.
* @param {google.cloud.speech.v1p1beta1.PhraseSet} request.phraseSet
* Required. The phrase set 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 [PhraseSet]{@link google.cloud.speech.v1p1beta1.PhraseSet}.
* 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.createPhraseSet(request);
*/
createPhraseSet(request, optionsOrCallback, callback) {
request = request || {};
let options;
if (typeof optionsOrCallback === 'function' && callback === undefined) {
callback = optionsOrCallback;
options = {};
}
else {
options = optionsOrCallback;
}
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.createPhraseSet(request, options, callback);
}
/**
* Get a phrase set.
*
* @param {Object} request
* The request object that will be sent.
* @param {string} request.name
* Required. The name of the phrase set to retrieve.
* Format:
* {api_version}/projects/{project}/locations/{location}/phraseSets/{phrase_set}
* @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 [PhraseSet]{@link google.cloud.speech.v1p1beta1.PhraseSet}.
* 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.getPhraseSet(request);
*/
getPhraseSet(request, optionsOrCallback, callback) {
request = request || {};
let options;
if (typeof optionsOrCallback === 'function' && callback === undefined) {
callback = optionsOrCallback;
options = {};
}
else {
options = optionsOrCallback;
}
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.getPhraseSet(request, options, callback);
}
/**
* Update a phrase set.
*
* @param {Object} request
* The request object that will be sent.
* @param {google.cloud.speech.v1p1beta1.PhraseSet} request.phraseSet
* Required. The phrase set to update.
*
* The phrase set's `name` field is used to identify the set to be
* updated. Format:
* {api_version}/projects/{project}/locations/{location}/phraseSets/{phrase_set}
* @param {google.protobuf.FieldMask} request.updateMask
* The list of fields to be updated.
* @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 [PhraseSet]{@link google.cloud.speech.v1p1beta1.PhraseSet}.
* 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.updatePhraseSet(request);
*/
updatePhraseSet(request, optionsOrCallback, callback) {
request = request || {};
let options;
if (typeof optionsOrCallback === 'function' && callback === undefined) {
callback = optionsOrCallback;
options = {};
}
else {
options = optionsOrCallback;
}
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
'phrase_set.name': request.phraseSet.name || '',
});
this.initialize();
return this.innerApiCalls.updatePhraseSet(request, options, callback);
}
/**
* Delete a phrase set.
*
* @param {Object} request
* The request object that will be sent.
* @param {string} request.name
* Required. The name of the phrase set to delete.
* Format:
* {api_version}/projects/{project}/locations/{location}/phraseSets/{phrase_set}
* @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.deletePhraseSet(request);
*/
deletePhraseSet(request, optionsOrCallback, callback) {
request = request || {};
let options;
if (typeof optionsOrCallback === 'function' && callback === undefined) {
callback = optionsOrCallback;
options = {};
}
else {
options = optionsOrCallback;
}
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.deletePhraseSet(request, options, callback);
}
/**
* Create a custom class.
*
* @param {Object} request
* The request object that will be sent.
* @param {string} request.parent
* Required. The parent resource where this custom class will be created.
* Format:
* {api_version}/projects/{project}/locations/{location}/customClasses
* @param {string} request.customClassId
* The ID to use for the custom class, which will become the final
* component of the custom class' resource name.
*
* This value should be 4-63 characters, and valid characters
* are /{@link 0-9|a-z}-/.
* @param {google.cloud.speech.v1p1beta1.CustomClass} request.customClass
* Required. The custom class 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 [CustomClass]{@link google.cloud.speech.v1p1beta1.CustomClass}.
* 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.createCustomClass(request);
*/
createCustomClass(request, optionsOrCallback, callback) {
request = request || {};
let options;
if (typeof optionsOrCallback === 'function' && callback === undefined) {
callback = optionsOrCallback;
options = {};
}
else {
options = optionsOrCallback;
}
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.createCustomClass(request, options, callback);
}
/**
* Get a custom class.
*
* @param {Object} request
* The request object that will be sent.
* @param {string} request.name
* Required. The name of the custom class to retrieve.
* Format:
* {api_version}/projects/{project}/locations/{location}/customClasses/{custom_class}
* @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 [CustomClass]{@link google.cloud.speech.v1p1beta1.CustomClass}.
* 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.getCustomClass(request);
*/
getCustomClass(request, optionsOrCallback, callback) {
request = request || {};
let options;
if (typeof optionsOrCallback === 'function' && callback === undefined) {
callback = optionsOrCallback;
options = {};
}
else {
options = optionsOrCallback;
}
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.getCustomClass(request, options, callback);
}
/**
* Update a custom class.
*
* @param {Object} request
* The request object that will be sent.
* @param {google.cloud.speech.v1p1beta1.CustomClass} request.customClass
* Required. The custom class to update.
*
* The custom class's `name` field is used to identify the custom class to be
* updated. Format:
* {api_version}/projects/{project}/locations/{location}/customClasses/{custom_class}
* @param {google.protobuf.FieldMask} request.updateMask
* The list of fields to be updated.
* @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 [CustomClass]{@link google.cloud.speech.v1p1beta1.CustomClass}.
* 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.updateCustomClass(request);
*/
updateCustomClass(request, optionsOrCallback, callback) {
request = request || {};
let options;
if (typeof optionsOrCallback === 'function' && callback === undefined) {
callback = optionsOrCallback;
options = {};
}
else {
options = optionsOrCallback;
}
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
'custom_class.name': request.customClass.name || '',
});
this.initialize();
return this.innerApiCalls.updateCustomClass(request, options, callback);
}
/**
* Delete a custom class.
*
* @param {Object} request
* The request object that will be sent.
* @param {string} request.name
* Required. The name of the custom class to delete.
* Format:
* {api_version}/projects/{project}/locations/{location}/customClasses/{custom_class}
* @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.deleteCustomClass(request);
*/
deleteCustomClass(request, optionsOrCallback, callback) {
request = request || {};
let options;
if (typeof optionsOrCallback === 'function' && callback === undefined) {
callback = optionsOrCallback;
options = {};
}
else {
options = optionsOrCallback;
}
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.deleteCustomClass(request, options, callback);
}
/**
* List phrase sets.
*
* @param {Object} request
* The request object that will be sent.
* @param {string} request.parent
* Required. The parent, which owns this collection of phrase set.
* Format:
* projects/{project}/locations/{location}
* @param {number} request.pageSize
* The maximum number of phrase sets to return. The service may return
* fewer than this value. If unspecified, at most 50 phrase sets will be
* returned. The maximum value is 1000; values above 1000 will be coerced to
* 1000.
* @param {string} request.pageToken
* A page token, received from a previous `ListPhraseSet` call.
* Provide this to retrieve the subsequent page.
*
* When paginating, all other parameters provided to `ListPhraseSet` must
* match the call that provided the page token.
* @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 Array of [PhraseSet]{@link google.cloud.speech.v1p1beta1.PhraseSet}.
* The client library will perform auto-pagination by default: it will call the API as many
* times as needed and will merge results from all the pages into this array.
* Note that it can affect your quota.
* We recommend using `listPhraseSetAsync()`
* method described below for async iteration which you can stop as needed.
* Please see the
* [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination)
* for more details and examples.
*/
listPhraseSet(request, optionsOrCallback, callback) {
request = request || {};
let options;
if (typeof optionsOrCallback === 'function' && callback === undefined) {
callback = optionsOrCallback;
options = {};
}
else {
options = optionsOrCallback;
}
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.listPhraseSet(request, options, callback);
}
/**
* Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object.
* @param {Object} request
* The request object that will be sent.
* @param {string} request.parent
* Required. The parent, which owns this collection of phrase set.
* Format:
* projects/{project}/locations/{location}
* @param {number} request.pageSize
* The maximum number of phrase sets to return. The service may return
* fewer than this value. If unspecified, at most 50 phrase sets will be
* returned. The maximum value is 1000; values above 1000 will be coerced to
* 1000.
* @param {string} request.pageToken
* A page token, received from a previous `ListPhraseSet` call.
* Provide this to retrieve the subsequent page.
*
* When paginating, all other parameters provided to `ListPhraseSet` must
* match the call that provided the page token.
* @param {object} [options]
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
* @returns {Stream}
* An object stream which emits an object representing [PhraseSet]{@link google.cloud.speech.v1p1beta1.PhraseSet} on 'data' event.
* The client library will perform auto-pagination by default: it will call the API as many
* times as needed. Note that it can affect your quota.
* We recommend using `listPhraseSetAsync()`
* method described below for async iteration which you can stop as needed.
* Please see the
* [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination)
* for more details and examples.
*/
listPhraseSetStream(request, options) {
request = request || {};
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 || '',
});
const callSettings = new gax.CallSettings(options);
this.initialize();
return this.descriptors.page.listPhraseSet.createStream(this.innerApiCalls.listPhraseSet, request, callSettings);
}
/**
* Equivalent to `listPhraseSet`, but returns an iterable object.
*
* `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand.
* @param {Object} request
* The request object that will be sent.
* @param {string} request.parent
* Required. The parent, which owns this collection of phrase set.
* Format:
* projects/{project}/locations/{location}
* @param {number} request.pageSize
* The maximum number of phrase sets to return. The service may return
* fewer than this value. If unspecified, at most 50 phrase sets will be
* returned. The maximum value is 1000; values above 1000 will be coerced to
* 1000.
* @param {string} request.pageToken
* A page token, received from a previous `ListPhraseSet` call.
* Provide this to retrieve the subsequent page.
*
* When paginating, all other parameters provided to `ListPhraseSet` must
* match the call that provided the page token.
* @param {object} [options]
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
* @returns {Object}
* An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols).
* When you iterate the returned iterable, each element will be an object representing
* [PhraseSet]{@link google.cloud.speech.v1p1beta1.PhraseSet}. The API will be called under the hood as needed, once per the page,
* so you can stop the iteration when you don't need more results.
* Please see the
* [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination)
* for more details and examples.
* @example
* const iterable = client.listPhraseSetAsync(request);
* for await (const response of iterable) {
* // process response
* }
*/
listPhraseSetAsync(request, options) {
request = request || {};
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 || '',
});
options = options || {};
const callSettings = new gax.CallSettings(options);
this.initialize();
return this.descriptors.page.listPhraseSet.asyncIterate(this.innerApiCalls['listPhraseSet'], request, callSettings);
}
/**
* List custom classes.
*
* @param {Object} request
* The request object that will be sent.
* @param {string} request.parent
* Required. The parent, which owns this collection of custom classes.
* Format:
* {api_version}/projects/{project}/locations/{location}/customClasses
* @param {number} request.pageSize
* The maximum number of custom classes to return. The service may return
* fewer than this value. If unspecified, at most 50 custom classes will be
* returned. The maximum value is 1000; values above 1000 will be coerced to
* 1000.
* @param {string} request.pageToken
* A page token, received from a previous `ListCustomClass` call.
* Provide this to retrieve the subsequent page.
*
* When paginating, all other parameters provided to `ListCustomClass` must
* match the call that provided the page token.
* @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 Array of [CustomClass]{@link google.cloud.speech.v1p1beta1.CustomClass}.
* The client library will perform auto-pagination by default: it will call the API as many
* times as needed and will merge results from all the pages into this array.
* Note that it can affect your quota.
* We recommend using `listCustomClassesAsync()`
* method described below for async iteration which you can stop as needed.
* Please see the
* [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination)
* for more details and examples.
*/
listCustomClasses(request, optionsOrCallback, callback) {
request = request || {};
let options;
if (typeof optionsOrCallback === 'function' && callback === undefined) {
callback = optionsOrCallback;
options = {};
}
else {
options = optionsOrCallback;
}
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.listCustomClasses(request, options, callback);
}
/**
* Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object.
* @param {Object} request
* The request object that will be sent.
* @param {string} request.parent
* Required. The parent, which owns this collection of custom classes.
* Format:
* {api_version}/projects/{project}/locations/{location}/customClasses
* @param {number} request.pageSize
* The maximum number of custom classes to return. The service may return
* fewer than this value. If unspecified, at most 50 custom classes will be
* returned. The maximum value is 1000; values above 1000 will be coerced to
* 1000.
* @param {string} request.pageToken
* A page token, received from a previous `ListCustomClass` call.
* Provide this to retrieve the subsequent page.
*
* When paginating, all other parameters provided to `ListCustomClass` must
* match the call that provided the page token.
* @param {object} [options]
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
* @returns {Stream}
* An object stream which emits an object representing [CustomClass]{@link google.cloud.speech.v1p1beta1.CustomClass} on 'data' event.
* The client library will perform auto-pagination by default: it will call the API as many
* times as needed. Note that it can affect your quota.
* We recommend using `listCustomClassesAsync()`
* method described below for async iteration which you can stop as needed.
* Please see the
* [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination)
* for more details and examples.
*/
listCustomClassesStream(request, options) {
request = request || {};
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 || '',
});
const callSettings = new gax.CallSettings(options);
this.initialize();
return this.descriptors.page.listCustomClasses.createStream(this.innerApiCalls.listCustomClasses, request, callSettings);
}
/**
* Equivalent to `listCustomClasses`, but returns an iterable object.
*
* `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand.
* @param {Object} request
* The request object that will be sent.
* @param {string} request.parent
* Required. The parent, which owns this collection of custom classes.
* Format:
* {api_version}/projects/{project}/locations/{location}/customClasses
* @param {number} request.pageSize
* The maximum number of custom classes to return. The service may return
* fewer than this value. If unspecified, at most 50 custom classes will be
* returned. The maximum value is 1000; values above 1000 will be coerced to
* 1000.
* @param {string} request.pageToken
* A page token, received from a previous `ListCustomClass` call.
* Provide this to retrieve the subsequent page.
*
* When paginating, all other parameters provided to `ListCustomClass` must
* match the call that provided the page token.
* @param {object} [options]
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
* @returns {Object}
* An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols).
* When you iterate the returned iterable, each element will be an object representing
* [CustomClass]{@link google.cloud.speech.v1p1beta1.CustomClass}. The API will be called under the hood as needed, once per the page,
* so you can stop the iteration when you don't need more results.
* Please see the
* [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination)
* for more details and examples.
* @example
* const iterable = client.listCustomClassesAsync(request);
* for await (const response of iterable) {
* // process response
* }
*/
listCustomClassesAsync(request, options) {
request = request || {};
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 || '',
});
options = options || {};
const callSettings = new gax.CallSettings(options);
this.initialize();
return this.descriptors.page.listCustomClasses.asyncIterate(this.innerApiCalls['listCustomClasses'], request, callSettings);
}
// --------------------
// -- Path templates --
// --------------------
/**
* Return a fully-qualified customClass resource name string.
*
* @param {string} project
* @param {string} location
* @param {string} custom_class
* @returns {string} Resource name string.
*/
customClassPath(project, location, customClass) {
return this.pathTemplates.customClassPathTemplate.render({
project: project,
location: location,
custom_class: customClass,
});
}
/**
* Parse the project from CustomClass resource.
*
* @param {string} customClassName
* A fully-qualified path representing CustomClass resource.
* @returns {string} A string representing the project.
*/
matchProjectFromCustomClassName(customClassName) {
return this.pathTemplates.customClassPathTemplate.match(customClassName)
.project;
}
/**
* Parse the location from CustomClass resource.
*
* @param {string} customClassName
* A fully-qualified path representing CustomClass resource.
* @returns {string} A string representing the location.
*/
matchLocationFromCustomClassName(customClassName) {
return this.pathTemplates.customClassPathTemplate.match(customClassName)
.location;
}
/**
* Parse the custom_class from CustomClass resource.
*
* @param {string} customClassName
* A fully-qualified path representing CustomClass resource.
* @returns {string} A string representing the custom_class.
*/
matchCustomClassFromCustomClassName(customClassName) {
return this.pathTemplates.customClassPathTemplate.match(customClassName)
.custom_class;
}
/**
* Return a fully-qualified location resource name string.
*
* @param {string} project
* @param {string} location
* @returns {string} Resource name string.
*/
locationPath(project, location) {
return this.pathTemplates.locationPathTemplate.render({
project: project,
location: location,
});
}
/**
* Parse the project from Location resource.
*
* @param {string} locationName
* A fully-qualified path representing Location resource.
* @returns {string} A string representing the project.
*/
matchProjectFromLocationName(locationName) {
return this.pathTemplates.locationPathTemplate.match(locationName).project;
}
/**
* Parse the location from Location resource.
*
* @param {string} locationName
* A fully-qualified path representing Location resource.
* @returns {string} A string representing the location.
*/
matchLocationFromLocationName(locationName) {
return this.pathTemplates.locationPathTemplate.match(locationName).location;
}
/**
* Return a fully-qualified phraseSet resource name string.
*
* @param {string} project
* @param {string} location
* @param {string} phrase_set
* @returns {string} Resource name string.
*/
phraseSetPath(project, location, phraseSet) {
return this.pathTemplates.phraseSetPathTemplate.render({
project: project,
location: location,
phrase_set: phraseSet,
});
}
/**
* Parse the project from PhraseSet resource.
*
* @param {string} phraseSetName
* A fully-qualified path representing PhraseSet resource.
* @returns {string} A string representing the project.
*/
matchProjectFromPhraseSetName(phraseSetName) {
return this.pathTemplates.phraseSetPathTemplate.match(phraseSetName)
.project;
}
/**
* Parse the location from PhraseSet resource.
*
* @param {string} phraseSetName
* A fully-qualified path representing PhraseSet resource.
* @returns {string} A string representing the location.
*/
matchLocationFromPhraseSetName(phraseSetName) {
return this.pathTemplates.phraseSetPathTemplate.match(phraseSetName)
.location;
}
/**
* Parse the phrase_set from PhraseSet resource.
*
* @param {string} phraseSetName
* A fully-qualified path representing PhraseSet resource.
* @returns {string} A string representing the phrase_set.
*/
matchPhraseSetFromPhraseSetName(phraseSetName) {
return this.pathTemplates.phraseSetPathTemplate.match(phraseSetName)
.phrase_set;
}
/**
* Return a fully-qualified project resource name string.
*
* @param {string} project
* @returns {string} Resource name string.
*/
projectPath(project) {
return this.pathTemplates.projectPathTemplate.render({
project: project,
});
}
/**
* Parse the project from Project resource.
*
* @param {string} projectName
* A fully-qualified path representing Project resource.
* @returns {string} A string representing the project.
*/
matchProjectFromProjectName(projectName) {
return this.pathTemplates.projectPathTemplate.match(projectName).project;
}
/**
* Terminate the gRPC channel and close the client.
*
* The client will no longer be usable and all future behavior is undefined.
* @returns {Promise} A promise that resolves when the client is closed.
*/
close() {
this.initialize();
if (!this._terminated) {
return this.adaptationStub.then(stub => {
this._terminated = true;
stub.close();
});
}
return Promise.resolve();
}
}
exports.AdaptationClient = AdaptationClient;
//# sourceMappingURL=adaptation_client.js.map