1 | ;
|
2 | // Copyright 2021 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.AdaptationClient = void 0;
|
21 | /* global window */
|
22 | const gax = require("google-gax");
|
23 | const jsonProtos = require("../../protos/protos.json");
|
24 | /**
|
25 | * Client JSON configuration object, loaded from
|
26 | * `src/v1p1beta1/adaptation_client_config.json`.
|
27 | * This file defines retry strategy and timeouts for all API methods in this library.
|
28 | */
|
29 | const gapicConfig = require("./adaptation_client_config.json");
|
30 | const version = require('../../../package.json').version;
|
31 | /**
|
32 | * Service that implements Google Cloud Speech Adaptation API.
|
33 | * @class
|
34 | * @memberof v1p1beta1
|
35 | */
|
36 | class AdaptationClient {
|
37 | /**
|
38 | * Construct an instance of AdaptationClient.
|
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/master/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} [options.fallback] - Use HTTP fallback mode.
|
66 | * In fallback mode, a special browser-compatible transport implementation is used
|
67 | * instead of gRPC transport. In browser context (if the `window` object is defined)
|
68 | * the fallback mode is enabled automatically; set `options.fallback` to `false`
|
69 | * if you need to override this behavior.
|
70 | */
|
71 | constructor(opts) {
|
72 | var _a, _b;
|
73 | this._terminated = false;
|
74 | this.descriptors = {
|
75 | page: {},
|
76 | stream: {},
|
77 | longrunning: {},
|
78 | batching: {},
|
79 | };
|
80 | // Ensure that options include all the required fields.
|
81 | const staticMembers = this.constructor;
|
82 | const servicePath = (opts === null || opts === void 0 ? void 0 : opts.servicePath) || (opts === null || opts === void 0 ? void 0 : opts.apiEndpoint) || staticMembers.servicePath;
|
83 | this._providedCustomServicePath = !!((opts === null || opts === void 0 ? void 0 : opts.servicePath) || (opts === null || opts === void 0 ? void 0 : opts.apiEndpoint));
|
84 | const port = (opts === null || opts === void 0 ? void 0 : opts.port) || staticMembers.port;
|
85 | const clientConfig = (_a = opts === null || opts === void 0 ? void 0 : opts.clientConfig) !== null && _a !== void 0 ? _a : {};
|
86 | 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');
|
87 | opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts);
|
88 | // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case.
|
89 | if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) {
|
90 | opts['scopes'] = staticMembers.scopes;
|
91 | }
|
92 | // Choose either gRPC or proto-over-HTTP implementation of google-gax.
|
93 | this._gaxModule = opts.fallback ? gax.fallback : gax;
|
94 | // Create a `gaxGrpc` object, with any grpc-specific options sent to the client.
|
95 | this._gaxGrpc = new this._gaxModule.GrpcClient(opts);
|
96 | // Save options to use in initialize() method.
|
97 | this._opts = opts;
|
98 | // Save the auth object to the client, for use by other methods.
|
99 | this.auth = this._gaxGrpc.auth;
|
100 | // Set useJWTAccessWithScope on the auth object.
|
101 | this.auth.useJWTAccessWithScope = true;
|
102 | // Set defaultServicePath on the auth object.
|
103 | this.auth.defaultServicePath = staticMembers.servicePath;
|
104 | // Set the default scopes in auth client if needed.
|
105 | if (servicePath === staticMembers.servicePath) {
|
106 | this.auth.defaultScopes = staticMembers.scopes;
|
107 | }
|
108 | // Determine the client header string.
|
109 | const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`];
|
110 | if (typeof process !== 'undefined' && 'versions' in process) {
|
111 | clientHeader.push(`gl-node/${process.versions.node}`);
|
112 | }
|
113 | else {
|
114 | clientHeader.push(`gl-web/${this._gaxModule.version}`);
|
115 | }
|
116 | if (!opts.fallback) {
|
117 | clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`);
|
118 | }
|
119 | else if (opts.fallback === 'rest') {
|
120 | clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`);
|
121 | }
|
122 | if (opts.libName && opts.libVersion) {
|
123 | clientHeader.push(`${opts.libName}/${opts.libVersion}`);
|
124 | }
|
125 | // Load the applicable protos.
|
126 | this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos);
|
127 | // This API contains "path templates"; forward-slash-separated
|
128 | // identifiers to uniquely identify resources within the API.
|
129 | // Create useful helper objects for these.
|
130 | this.pathTemplates = {
|
131 | customClassPathTemplate: new this._gaxModule.PathTemplate('projects/{project}/locations/{location}/customClasses/{custom_class}'),
|
132 | locationPathTemplate: new this._gaxModule.PathTemplate('projects/{project}/locations/{location}'),
|
133 | phraseSetPathTemplate: new this._gaxModule.PathTemplate('projects/{project}/locations/{location}/phraseSets/{phrase_set}'),
|
134 | projectPathTemplate: new this._gaxModule.PathTemplate('projects/{project}'),
|
135 | };
|
136 | // Some of the methods on this service return "paged" results,
|
137 | // (e.g. 50 results at a time, with tokens to get subsequent
|
138 | // pages). Denote the keys used for pagination and results.
|
139 | this.descriptors.page = {
|
140 | listPhraseSet: new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'phraseSets'),
|
141 | listCustomClasses: new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'customClasses'),
|
142 | };
|
143 | // Put together the default options sent with requests.
|
144 | this._defaults = this._gaxGrpc.constructSettings('google.cloud.speech.v1p1beta1.Adaptation', gapicConfig, opts.clientConfig || {}, { 'x-goog-api-client': clientHeader.join(' ') });
|
145 | // Set up a dictionary of "inner API calls"; the core implementation
|
146 | // of calling the API is handled in `google-gax`, with this code
|
147 | // merely providing the destination and request information.
|
148 | this.innerApiCalls = {};
|
149 | // Add a warn function to the client constructor so it can be easily tested.
|
150 | this.warn = gax.warn;
|
151 | }
|
152 | /**
|
153 | * Initialize the client.
|
154 | * Performs asynchronous operations (such as authentication) and prepares the client.
|
155 | * This function will be called automatically when any class method is called for the
|
156 | * first time, but if you need to initialize it before calling an actual method,
|
157 | * feel free to call initialize() directly.
|
158 | *
|
159 | * You can await on this method if you want to make sure the client is initialized.
|
160 | *
|
161 | * @returns {Promise} A promise that resolves to an authenticated service stub.
|
162 | */
|
163 | initialize() {
|
164 | // If the client stub promise is already initialized, return immediately.
|
165 | if (this.adaptationStub) {
|
166 | return this.adaptationStub;
|
167 | }
|
168 | // Put together the "service stub" for
|
169 | // google.cloud.speech.v1p1beta1.Adaptation.
|
170 | this.adaptationStub = this._gaxGrpc.createStub(this._opts.fallback
|
171 | ? this._protos.lookupService('google.cloud.speech.v1p1beta1.Adaptation')
|
172 | : // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
173 | this._protos.google.cloud.speech.v1p1beta1.Adaptation, this._opts, this._providedCustomServicePath);
|
174 | // Iterate over each of the methods that the service provides
|
175 | // and create an API call method for each.
|
176 | const adaptationStubMethods = [
|
177 | 'createPhraseSet',
|
178 | 'getPhraseSet',
|
179 | 'listPhraseSet',
|
180 | 'updatePhraseSet',
|
181 | 'deletePhraseSet',
|
182 | 'createCustomClass',
|
183 | 'getCustomClass',
|
184 | 'listCustomClasses',
|
185 | 'updateCustomClass',
|
186 | 'deleteCustomClass',
|
187 | ];
|
188 | for (const methodName of adaptationStubMethods) {
|
189 | const callPromise = this.adaptationStub.then(stub => (...args) => {
|
190 | if (this._terminated) {
|
191 | return Promise.reject('The client has already been closed.');
|
192 | }
|
193 | const func = stub[methodName];
|
194 | return func.apply(stub, args);
|
195 | }, (err) => () => {
|
196 | throw err;
|
197 | });
|
198 | const descriptor = this.descriptors.page[methodName] || undefined;
|
199 | const apiCall = this._gaxModule.createApiCall(callPromise, this._defaults[methodName], descriptor);
|
200 | this.innerApiCalls[methodName] = apiCall;
|
201 | }
|
202 | return this.adaptationStub;
|
203 | }
|
204 | /**
|
205 | * The DNS address for this API service.
|
206 | * @returns {string} The DNS address for this service.
|
207 | */
|
208 | static get servicePath() {
|
209 | return 'speech.googleapis.com';
|
210 | }
|
211 | /**
|
212 | * The DNS address for this API service - same as servicePath(),
|
213 | * exists for compatibility reasons.
|
214 | * @returns {string} The DNS address for this service.
|
215 | */
|
216 | static get apiEndpoint() {
|
217 | return 'speech.googleapis.com';
|
218 | }
|
219 | /**
|
220 | * The port for this API service.
|
221 | * @returns {number} The default port for this service.
|
222 | */
|
223 | static get port() {
|
224 | return 443;
|
225 | }
|
226 | /**
|
227 | * The scopes needed to make gRPC calls for every method defined
|
228 | * in this service.
|
229 | * @returns {string[]} List of default scopes.
|
230 | */
|
231 | static get scopes() {
|
232 | return ['https://www.googleapis.com/auth/cloud-platform'];
|
233 | }
|
234 | /**
|
235 | * Return the project ID used by this class.
|
236 | * @returns {Promise} A promise that resolves to string containing the project ID.
|
237 | */
|
238 | getProjectId(callback) {
|
239 | if (callback) {
|
240 | this.auth.getProjectId(callback);
|
241 | return;
|
242 | }
|
243 | return this.auth.getProjectId();
|
244 | }
|
245 | createPhraseSet(request, optionsOrCallback, callback) {
|
246 | request = request || {};
|
247 | let options;
|
248 | if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
249 | callback = optionsOrCallback;
|
250 | options = {};
|
251 | }
|
252 | else {
|
253 | options = optionsOrCallback;
|
254 | }
|
255 | options = options || {};
|
256 | options.otherArgs = options.otherArgs || {};
|
257 | options.otherArgs.headers = options.otherArgs.headers || {};
|
258 | options.otherArgs.headers['x-goog-request-params'] =
|
259 | gax.routingHeader.fromParams({
|
260 | parent: request.parent || '',
|
261 | });
|
262 | this.initialize();
|
263 | return this.innerApiCalls.createPhraseSet(request, options, callback);
|
264 | }
|
265 | getPhraseSet(request, optionsOrCallback, callback) {
|
266 | request = request || {};
|
267 | let options;
|
268 | if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
269 | callback = optionsOrCallback;
|
270 | options = {};
|
271 | }
|
272 | else {
|
273 | options = optionsOrCallback;
|
274 | }
|
275 | options = options || {};
|
276 | options.otherArgs = options.otherArgs || {};
|
277 | options.otherArgs.headers = options.otherArgs.headers || {};
|
278 | options.otherArgs.headers['x-goog-request-params'] =
|
279 | gax.routingHeader.fromParams({
|
280 | name: request.name || '',
|
281 | });
|
282 | this.initialize();
|
283 | return this.innerApiCalls.getPhraseSet(request, options, callback);
|
284 | }
|
285 | updatePhraseSet(request, optionsOrCallback, callback) {
|
286 | request = request || {};
|
287 | let options;
|
288 | if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
289 | callback = optionsOrCallback;
|
290 | options = {};
|
291 | }
|
292 | else {
|
293 | options = optionsOrCallback;
|
294 | }
|
295 | options = options || {};
|
296 | options.otherArgs = options.otherArgs || {};
|
297 | options.otherArgs.headers = options.otherArgs.headers || {};
|
298 | options.otherArgs.headers['x-goog-request-params'] =
|
299 | gax.routingHeader.fromParams({
|
300 | 'phrase_set.name': request.phraseSet.name || '',
|
301 | });
|
302 | this.initialize();
|
303 | return this.innerApiCalls.updatePhraseSet(request, options, callback);
|
304 | }
|
305 | deletePhraseSet(request, optionsOrCallback, callback) {
|
306 | request = request || {};
|
307 | let options;
|
308 | if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
309 | callback = optionsOrCallback;
|
310 | options = {};
|
311 | }
|
312 | else {
|
313 | options = optionsOrCallback;
|
314 | }
|
315 | options = options || {};
|
316 | options.otherArgs = options.otherArgs || {};
|
317 | options.otherArgs.headers = options.otherArgs.headers || {};
|
318 | options.otherArgs.headers['x-goog-request-params'] =
|
319 | gax.routingHeader.fromParams({
|
320 | name: request.name || '',
|
321 | });
|
322 | this.initialize();
|
323 | return this.innerApiCalls.deletePhraseSet(request, options, callback);
|
324 | }
|
325 | createCustomClass(request, optionsOrCallback, callback) {
|
326 | request = request || {};
|
327 | let options;
|
328 | if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
329 | callback = optionsOrCallback;
|
330 | options = {};
|
331 | }
|
332 | else {
|
333 | options = optionsOrCallback;
|
334 | }
|
335 | options = options || {};
|
336 | options.otherArgs = options.otherArgs || {};
|
337 | options.otherArgs.headers = options.otherArgs.headers || {};
|
338 | options.otherArgs.headers['x-goog-request-params'] =
|
339 | gax.routingHeader.fromParams({
|
340 | parent: request.parent || '',
|
341 | });
|
342 | this.initialize();
|
343 | return this.innerApiCalls.createCustomClass(request, options, callback);
|
344 | }
|
345 | getCustomClass(request, optionsOrCallback, callback) {
|
346 | request = request || {};
|
347 | let options;
|
348 | if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
349 | callback = optionsOrCallback;
|
350 | options = {};
|
351 | }
|
352 | else {
|
353 | options = optionsOrCallback;
|
354 | }
|
355 | options = options || {};
|
356 | options.otherArgs = options.otherArgs || {};
|
357 | options.otherArgs.headers = options.otherArgs.headers || {};
|
358 | options.otherArgs.headers['x-goog-request-params'] =
|
359 | gax.routingHeader.fromParams({
|
360 | name: request.name || '',
|
361 | });
|
362 | this.initialize();
|
363 | return this.innerApiCalls.getCustomClass(request, options, callback);
|
364 | }
|
365 | updateCustomClass(request, optionsOrCallback, callback) {
|
366 | request = request || {};
|
367 | let options;
|
368 | if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
369 | callback = optionsOrCallback;
|
370 | options = {};
|
371 | }
|
372 | else {
|
373 | options = optionsOrCallback;
|
374 | }
|
375 | options = options || {};
|
376 | options.otherArgs = options.otherArgs || {};
|
377 | options.otherArgs.headers = options.otherArgs.headers || {};
|
378 | options.otherArgs.headers['x-goog-request-params'] =
|
379 | gax.routingHeader.fromParams({
|
380 | 'custom_class.name': request.customClass.name || '',
|
381 | });
|
382 | this.initialize();
|
383 | return this.innerApiCalls.updateCustomClass(request, options, callback);
|
384 | }
|
385 | deleteCustomClass(request, optionsOrCallback, callback) {
|
386 | request = request || {};
|
387 | let options;
|
388 | if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
389 | callback = optionsOrCallback;
|
390 | options = {};
|
391 | }
|
392 | else {
|
393 | options = optionsOrCallback;
|
394 | }
|
395 | options = options || {};
|
396 | options.otherArgs = options.otherArgs || {};
|
397 | options.otherArgs.headers = options.otherArgs.headers || {};
|
398 | options.otherArgs.headers['x-goog-request-params'] =
|
399 | gax.routingHeader.fromParams({
|
400 | name: request.name || '',
|
401 | });
|
402 | this.initialize();
|
403 | return this.innerApiCalls.deleteCustomClass(request, options, callback);
|
404 | }
|
405 | listPhraseSet(request, optionsOrCallback, callback) {
|
406 | request = request || {};
|
407 | let options;
|
408 | if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
409 | callback = optionsOrCallback;
|
410 | options = {};
|
411 | }
|
412 | else {
|
413 | options = optionsOrCallback;
|
414 | }
|
415 | options = options || {};
|
416 | options.otherArgs = options.otherArgs || {};
|
417 | options.otherArgs.headers = options.otherArgs.headers || {};
|
418 | options.otherArgs.headers['x-goog-request-params'] =
|
419 | gax.routingHeader.fromParams({
|
420 | parent: request.parent || '',
|
421 | });
|
422 | this.initialize();
|
423 | return this.innerApiCalls.listPhraseSet(request, options, callback);
|
424 | }
|
425 | /**
|
426 | * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object.
|
427 | * @param {Object} request
|
428 | * The request object that will be sent.
|
429 | * @param {string} request.parent
|
430 | * Required. The parent, which owns this collection of phrase set. Format:
|
431 | *
|
432 | * `projects/{project}/locations/{location}`
|
433 | *
|
434 | * Speech-to-Text supports three locations: `global`, `us` (US North America),
|
435 | * and `eu` (Europe). If you are calling the `speech.googleapis.com`
|
436 | * endpoint, use the `global` location. To specify a region, use a
|
437 | * [regional endpoint](/speech-to-text/docs/endpoints) with matching `us` or
|
438 | * `eu` location value.
|
439 | * @param {number} request.pageSize
|
440 | * The maximum number of phrase sets to return. The service may return
|
441 | * fewer than this value. If unspecified, at most 50 phrase sets will be
|
442 | * returned. The maximum value is 1000; values above 1000 will be coerced to
|
443 | * 1000.
|
444 | * @param {string} request.pageToken
|
445 | * A page token, received from a previous `ListPhraseSet` call.
|
446 | * Provide this to retrieve the subsequent page.
|
447 | *
|
448 | * When paginating, all other parameters provided to `ListPhraseSet` must
|
449 | * match the call that provided the page token.
|
450 | * @param {object} [options]
|
451 | * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
|
452 | * @returns {Stream}
|
453 | * An object stream which emits an object representing [PhraseSet]{@link google.cloud.speech.v1p1beta1.PhraseSet} on 'data' event.
|
454 | * The client library will perform auto-pagination by default: it will call the API as many
|
455 | * times as needed. Note that it can affect your quota.
|
456 | * We recommend using `listPhraseSetAsync()`
|
457 | * method described below for async iteration which you can stop as needed.
|
458 | * Please see the
|
459 | * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination)
|
460 | * for more details and examples.
|
461 | */
|
462 | listPhraseSetStream(request, options) {
|
463 | request = request || {};
|
464 | options = options || {};
|
465 | options.otherArgs = options.otherArgs || {};
|
466 | options.otherArgs.headers = options.otherArgs.headers || {};
|
467 | options.otherArgs.headers['x-goog-request-params'] =
|
468 | gax.routingHeader.fromParams({
|
469 | parent: request.parent || '',
|
470 | });
|
471 | const defaultCallSettings = this._defaults['listPhraseSet'];
|
472 | const callSettings = defaultCallSettings.merge(options);
|
473 | this.initialize();
|
474 | return this.descriptors.page.listPhraseSet.createStream(this.innerApiCalls.listPhraseSet, request, callSettings);
|
475 | }
|
476 | /**
|
477 | * Equivalent to `listPhraseSet`, but returns an iterable object.
|
478 | *
|
479 | * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand.
|
480 | * @param {Object} request
|
481 | * The request object that will be sent.
|
482 | * @param {string} request.parent
|
483 | * Required. The parent, which owns this collection of phrase set. Format:
|
484 | *
|
485 | * `projects/{project}/locations/{location}`
|
486 | *
|
487 | * Speech-to-Text supports three locations: `global`, `us` (US North America),
|
488 | * and `eu` (Europe). If you are calling the `speech.googleapis.com`
|
489 | * endpoint, use the `global` location. To specify a region, use a
|
490 | * [regional endpoint](/speech-to-text/docs/endpoints) with matching `us` or
|
491 | * `eu` location value.
|
492 | * @param {number} request.pageSize
|
493 | * The maximum number of phrase sets to return. The service may return
|
494 | * fewer than this value. If unspecified, at most 50 phrase sets will be
|
495 | * returned. The maximum value is 1000; values above 1000 will be coerced to
|
496 | * 1000.
|
497 | * @param {string} request.pageToken
|
498 | * A page token, received from a previous `ListPhraseSet` call.
|
499 | * Provide this to retrieve the subsequent page.
|
500 | *
|
501 | * When paginating, all other parameters provided to `ListPhraseSet` must
|
502 | * match the call that provided the page token.
|
503 | * @param {object} [options]
|
504 | * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
|
505 | * @returns {Object}
|
506 | * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols).
|
507 | * When you iterate the returned iterable, each element will be an object representing
|
508 | * [PhraseSet]{@link google.cloud.speech.v1p1beta1.PhraseSet}. The API will be called under the hood as needed, once per the page,
|
509 | * so you can stop the iteration when you don't need more results.
|
510 | * Please see the
|
511 | * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination)
|
512 | * for more details and examples.
|
513 | * @example <caption>include:samples/generated/v1p1beta1/adaptation.list_phrase_set.js</caption>
|
514 | * region_tag:speech_v1p1beta1_generated_Adaptation_ListPhraseSet_async
|
515 | */
|
516 | listPhraseSetAsync(request, options) {
|
517 | request = request || {};
|
518 | options = options || {};
|
519 | options.otherArgs = options.otherArgs || {};
|
520 | options.otherArgs.headers = options.otherArgs.headers || {};
|
521 | options.otherArgs.headers['x-goog-request-params'] =
|
522 | gax.routingHeader.fromParams({
|
523 | parent: request.parent || '',
|
524 | });
|
525 | const defaultCallSettings = this._defaults['listPhraseSet'];
|
526 | const callSettings = defaultCallSettings.merge(options);
|
527 | this.initialize();
|
528 | return this.descriptors.page.listPhraseSet.asyncIterate(this.innerApiCalls['listPhraseSet'], request, callSettings);
|
529 | }
|
530 | listCustomClasses(request, optionsOrCallback, callback) {
|
531 | request = request || {};
|
532 | let options;
|
533 | if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
534 | callback = optionsOrCallback;
|
535 | options = {};
|
536 | }
|
537 | else {
|
538 | options = optionsOrCallback;
|
539 | }
|
540 | options = options || {};
|
541 | options.otherArgs = options.otherArgs || {};
|
542 | options.otherArgs.headers = options.otherArgs.headers || {};
|
543 | options.otherArgs.headers['x-goog-request-params'] =
|
544 | gax.routingHeader.fromParams({
|
545 | parent: request.parent || '',
|
546 | });
|
547 | this.initialize();
|
548 | return this.innerApiCalls.listCustomClasses(request, options, callback);
|
549 | }
|
550 | /**
|
551 | * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object.
|
552 | * @param {Object} request
|
553 | * The request object that will be sent.
|
554 | * @param {string} request.parent
|
555 | * Required. The parent, which owns this collection of custom classes. Format:
|
556 | *
|
557 | * `projects/{project}/locations/{location}/customClasses`
|
558 | *
|
559 | * Speech-to-Text supports three locations: `global`, `us` (US North America),
|
560 | * and `eu` (Europe). If you are calling the `speech.googleapis.com`
|
561 | * endpoint, use the `global` location. To specify a region, use a
|
562 | * [regional endpoint](/speech-to-text/docs/endpoints) with matching `us` or
|
563 | * `eu` location value.
|
564 | * @param {number} request.pageSize
|
565 | * The maximum number of custom classes to return. The service may return
|
566 | * fewer than this value. If unspecified, at most 50 custom classes will be
|
567 | * returned. The maximum value is 1000; values above 1000 will be coerced to
|
568 | * 1000.
|
569 | * @param {string} request.pageToken
|
570 | * A page token, received from a previous `ListCustomClass` call.
|
571 | * Provide this to retrieve the subsequent page.
|
572 | *
|
573 | * When paginating, all other parameters provided to `ListCustomClass` must
|
574 | * match the call that provided the page token.
|
575 | * @param {object} [options]
|
576 | * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
|
577 | * @returns {Stream}
|
578 | * An object stream which emits an object representing [CustomClass]{@link google.cloud.speech.v1p1beta1.CustomClass} on 'data' event.
|
579 | * The client library will perform auto-pagination by default: it will call the API as many
|
580 | * times as needed. Note that it can affect your quota.
|
581 | * We recommend using `listCustomClassesAsync()`
|
582 | * method described below for async iteration which you can stop as needed.
|
583 | * Please see the
|
584 | * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination)
|
585 | * for more details and examples.
|
586 | */
|
587 | listCustomClassesStream(request, options) {
|
588 | request = request || {};
|
589 | options = options || {};
|
590 | options.otherArgs = options.otherArgs || {};
|
591 | options.otherArgs.headers = options.otherArgs.headers || {};
|
592 | options.otherArgs.headers['x-goog-request-params'] =
|
593 | gax.routingHeader.fromParams({
|
594 | parent: request.parent || '',
|
595 | });
|
596 | const defaultCallSettings = this._defaults['listCustomClasses'];
|
597 | const callSettings = defaultCallSettings.merge(options);
|
598 | this.initialize();
|
599 | return this.descriptors.page.listCustomClasses.createStream(this.innerApiCalls.listCustomClasses, request, callSettings);
|
600 | }
|
601 | /**
|
602 | * Equivalent to `listCustomClasses`, but returns an iterable object.
|
603 | *
|
604 | * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand.
|
605 | * @param {Object} request
|
606 | * The request object that will be sent.
|
607 | * @param {string} request.parent
|
608 | * Required. The parent, which owns this collection of custom classes. Format:
|
609 | *
|
610 | * `projects/{project}/locations/{location}/customClasses`
|
611 | *
|
612 | * Speech-to-Text supports three locations: `global`, `us` (US North America),
|
613 | * and `eu` (Europe). If you are calling the `speech.googleapis.com`
|
614 | * endpoint, use the `global` location. To specify a region, use a
|
615 | * [regional endpoint](/speech-to-text/docs/endpoints) with matching `us` or
|
616 | * `eu` location value.
|
617 | * @param {number} request.pageSize
|
618 | * The maximum number of custom classes to return. The service may return
|
619 | * fewer than this value. If unspecified, at most 50 custom classes will be
|
620 | * returned. The maximum value is 1000; values above 1000 will be coerced to
|
621 | * 1000.
|
622 | * @param {string} request.pageToken
|
623 | * A page token, received from a previous `ListCustomClass` call.
|
624 | * Provide this to retrieve the subsequent page.
|
625 | *
|
626 | * When paginating, all other parameters provided to `ListCustomClass` must
|
627 | * match the call that provided the page token.
|
628 | * @param {object} [options]
|
629 | * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
|
630 | * @returns {Object}
|
631 | * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols).
|
632 | * When you iterate the returned iterable, each element will be an object representing
|
633 | * [CustomClass]{@link google.cloud.speech.v1p1beta1.CustomClass}. The API will be called under the hood as needed, once per the page,
|
634 | * so you can stop the iteration when you don't need more results.
|
635 | * Please see the
|
636 | * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination)
|
637 | * for more details and examples.
|
638 | * @example <caption>include:samples/generated/v1p1beta1/adaptation.list_custom_classes.js</caption>
|
639 | * region_tag:speech_v1p1beta1_generated_Adaptation_ListCustomClasses_async
|
640 | */
|
641 | listCustomClassesAsync(request, options) {
|
642 | request = request || {};
|
643 | options = options || {};
|
644 | options.otherArgs = options.otherArgs || {};
|
645 | options.otherArgs.headers = options.otherArgs.headers || {};
|
646 | options.otherArgs.headers['x-goog-request-params'] =
|
647 | gax.routingHeader.fromParams({
|
648 | parent: request.parent || '',
|
649 | });
|
650 | const defaultCallSettings = this._defaults['listCustomClasses'];
|
651 | const callSettings = defaultCallSettings.merge(options);
|
652 | this.initialize();
|
653 | return this.descriptors.page.listCustomClasses.asyncIterate(this.innerApiCalls['listCustomClasses'], request, callSettings);
|
654 | }
|
655 | // --------------------
|
656 | // -- Path templates --
|
657 | // --------------------
|
658 | /**
|
659 | * Return a fully-qualified customClass resource name string.
|
660 | *
|
661 | * @param {string} project
|
662 | * @param {string} location
|
663 | * @param {string} custom_class
|
664 | * @returns {string} Resource name string.
|
665 | */
|
666 | customClassPath(project, location, customClass) {
|
667 | return this.pathTemplates.customClassPathTemplate.render({
|
668 | project: project,
|
669 | location: location,
|
670 | custom_class: customClass,
|
671 | });
|
672 | }
|
673 | /**
|
674 | * Parse the project from CustomClass resource.
|
675 | *
|
676 | * @param {string} customClassName
|
677 | * A fully-qualified path representing CustomClass resource.
|
678 | * @returns {string} A string representing the project.
|
679 | */
|
680 | matchProjectFromCustomClassName(customClassName) {
|
681 | return this.pathTemplates.customClassPathTemplate.match(customClassName)
|
682 | .project;
|
683 | }
|
684 | /**
|
685 | * Parse the location from CustomClass resource.
|
686 | *
|
687 | * @param {string} customClassName
|
688 | * A fully-qualified path representing CustomClass resource.
|
689 | * @returns {string} A string representing the location.
|
690 | */
|
691 | matchLocationFromCustomClassName(customClassName) {
|
692 | return this.pathTemplates.customClassPathTemplate.match(customClassName)
|
693 | .location;
|
694 | }
|
695 | /**
|
696 | * Parse the custom_class from CustomClass resource.
|
697 | *
|
698 | * @param {string} customClassName
|
699 | * A fully-qualified path representing CustomClass resource.
|
700 | * @returns {string} A string representing the custom_class.
|
701 | */
|
702 | matchCustomClassFromCustomClassName(customClassName) {
|
703 | return this.pathTemplates.customClassPathTemplate.match(customClassName)
|
704 | .custom_class;
|
705 | }
|
706 | /**
|
707 | * Return a fully-qualified location resource name string.
|
708 | *
|
709 | * @param {string} project
|
710 | * @param {string} location
|
711 | * @returns {string} Resource name string.
|
712 | */
|
713 | locationPath(project, location) {
|
714 | return this.pathTemplates.locationPathTemplate.render({
|
715 | project: project,
|
716 | location: location,
|
717 | });
|
718 | }
|
719 | /**
|
720 | * Parse the project from Location resource.
|
721 | *
|
722 | * @param {string} locationName
|
723 | * A fully-qualified path representing Location resource.
|
724 | * @returns {string} A string representing the project.
|
725 | */
|
726 | matchProjectFromLocationName(locationName) {
|
727 | return this.pathTemplates.locationPathTemplate.match(locationName).project;
|
728 | }
|
729 | /**
|
730 | * Parse the location from Location resource.
|
731 | *
|
732 | * @param {string} locationName
|
733 | * A fully-qualified path representing Location resource.
|
734 | * @returns {string} A string representing the location.
|
735 | */
|
736 | matchLocationFromLocationName(locationName) {
|
737 | return this.pathTemplates.locationPathTemplate.match(locationName).location;
|
738 | }
|
739 | /**
|
740 | * Return a fully-qualified phraseSet resource name string.
|
741 | *
|
742 | * @param {string} project
|
743 | * @param {string} location
|
744 | * @param {string} phrase_set
|
745 | * @returns {string} Resource name string.
|
746 | */
|
747 | phraseSetPath(project, location, phraseSet) {
|
748 | return this.pathTemplates.phraseSetPathTemplate.render({
|
749 | project: project,
|
750 | location: location,
|
751 | phrase_set: phraseSet,
|
752 | });
|
753 | }
|
754 | /**
|
755 | * Parse the project from PhraseSet resource.
|
756 | *
|
757 | * @param {string} phraseSetName
|
758 | * A fully-qualified path representing PhraseSet resource.
|
759 | * @returns {string} A string representing the project.
|
760 | */
|
761 | matchProjectFromPhraseSetName(phraseSetName) {
|
762 | return this.pathTemplates.phraseSetPathTemplate.match(phraseSetName)
|
763 | .project;
|
764 | }
|
765 | /**
|
766 | * Parse the location from PhraseSet resource.
|
767 | *
|
768 | * @param {string} phraseSetName
|
769 | * A fully-qualified path representing PhraseSet resource.
|
770 | * @returns {string} A string representing the location.
|
771 | */
|
772 | matchLocationFromPhraseSetName(phraseSetName) {
|
773 | return this.pathTemplates.phraseSetPathTemplate.match(phraseSetName)
|
774 | .location;
|
775 | }
|
776 | /**
|
777 | * Parse the phrase_set from PhraseSet resource.
|
778 | *
|
779 | * @param {string} phraseSetName
|
780 | * A fully-qualified path representing PhraseSet resource.
|
781 | * @returns {string} A string representing the phrase_set.
|
782 | */
|
783 | matchPhraseSetFromPhraseSetName(phraseSetName) {
|
784 | return this.pathTemplates.phraseSetPathTemplate.match(phraseSetName)
|
785 | .phrase_set;
|
786 | }
|
787 | /**
|
788 | * Return a fully-qualified project resource name string.
|
789 | *
|
790 | * @param {string} project
|
791 | * @returns {string} Resource name string.
|
792 | */
|
793 | projectPath(project) {
|
794 | return this.pathTemplates.projectPathTemplate.render({
|
795 | project: project,
|
796 | });
|
797 | }
|
798 | /**
|
799 | * Parse the project from Project resource.
|
800 | *
|
801 | * @param {string} projectName
|
802 | * A fully-qualified path representing Project resource.
|
803 | * @returns {string} A string representing the project.
|
804 | */
|
805 | matchProjectFromProjectName(projectName) {
|
806 | return this.pathTemplates.projectPathTemplate.match(projectName).project;
|
807 | }
|
808 | /**
|
809 | * Terminate the gRPC channel and close the client.
|
810 | *
|
811 | * The client will no longer be usable and all future behavior is undefined.
|
812 | * @returns {Promise} A promise that resolves when the client is closed.
|
813 | */
|
814 | close() {
|
815 | this.initialize();
|
816 | if (!this._terminated) {
|
817 | return this.adaptationStub.then(stub => {
|
818 | this._terminated = true;
|
819 | stub.close();
|
820 | });
|
821 | }
|
822 | return Promise.resolve();
|
823 | }
|
824 | }
|
825 | exports.AdaptationClient = AdaptationClient;
|
826 | //# sourceMappingURL=adaptation_client.js.map |
\ | No newline at end of file |