From a6a2d7860ec7dce150778b21fc273d1acc593e12 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Wed, 14 Sep 2022 20:24:49 +0000 Subject: [PATCH 1/2] chore: use gapic-generator-typescript v2.17.0 PiperOrigin-RevId: 474338479 Source-Link: https://github.com/googleapis/googleapis/commit/d5d35e0353b59719e8917103b1bc7df2782bf6ba Source-Link: https://github.com/googleapis/googleapis-gen/commit/efcd3f93962a103f68f003e2a1eecde6fa216a27 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZWZjZDNmOTM5NjJhMTAzZjY4ZjAwM2UyYTFlZWNkZTZmYTIxNmEyNyJ9 --- owl-bot-staging/v1/.eslintignore | 7 + owl-bot-staging/v1/.eslintrc.json | 3 + owl-bot-staging/v1/.gitignore | 14 + owl-bot-staging/v1/.jsdoc.js | 55 + owl-bot-staging/v1/.mocharc.js | 33 + owl-bot-staging/v1/.prettierrc.js | 22 + owl-bot-staging/v1/README.md | 1 + owl-bot-staging/v1/linkinator.config.json | 16 + owl-bot-staging/v1/package.json | 65 + .../google/cloud/speech/v1/cloud_speech.proto | 899 +++++++++ .../speech/v1/cloud_speech_adaptation.proto | 370 ++++ .../google/cloud/speech/v1/resource.proto | 138 ++ .../v1/adaptation.create_custom_class.js | 80 + .../v1/adaptation.create_phrase_set.js | 80 + .../v1/adaptation.delete_custom_class.js | 67 + .../v1/adaptation.delete_phrase_set.js | 62 + .../v1/adaptation.get_custom_class.js | 62 + .../generated/v1/adaptation.get_phrase_set.js | 67 + .../v1/adaptation.list_custom_classes.js | 83 + .../v1/adaptation.list_phrase_set.js | 83 + .../v1/adaptation.update_custom_class.js | 73 + .../v1/adaptation.update_phrase_set.js | 73 + ...ippet_metadata.google.cloud.speech.v1.json | 591 ++++++ .../v1/speech.long_running_recognize.js | 72 + .../samples/generated/v1/speech.recognize.js | 67 + .../v1/speech.streaming_recognize.js | 77 + owl-bot-staging/v1/src/index.ts | 27 + .../v1/src/v1/adaptation_client.ts | 1578 +++++++++++++++ .../v1/src/v1/adaptation_client_config.json | 66 + .../v1/src/v1/adaptation_proto_list.json | 5 + owl-bot-staging/v1/src/v1/gapic_metadata.json | 170 ++ owl-bot-staging/v1/src/v1/index.ts | 20 + owl-bot-staging/v1/src/v1/speech_client.ts | 649 +++++++ .../v1/src/v1/speech_client_config.json | 41 + .../v1/src/v1/speech_proto_list.json | 5 + .../system-test/fixtures/sample/src/index.js | 28 + .../system-test/fixtures/sample/src/index.ts | 38 + owl-bot-staging/v1/system-test/install.ts | 49 + .../v1/test/gapic_adaptation_v1.ts | 1722 +++++++++++++++++ owl-bot-staging/v1/test/gapic_speech_v1.ts | 525 +++++ owl-bot-staging/v1/tsconfig.json | 19 + owl-bot-staging/v1/webpack.config.js | 64 + owl-bot-staging/v1p1beta1/.eslintignore | 7 + owl-bot-staging/v1p1beta1/.eslintrc.json | 3 + owl-bot-staging/v1p1beta1/.gitignore | 14 + owl-bot-staging/v1p1beta1/.jsdoc.js | 55 + owl-bot-staging/v1p1beta1/.mocharc.js | 33 + owl-bot-staging/v1p1beta1/.prettierrc.js | 22 + owl-bot-staging/v1p1beta1/README.md | 1 + .../v1p1beta1/linkinator.config.json | 16 + owl-bot-staging/v1p1beta1/package.json | 65 + .../cloud/speech/v1p1beta1/cloud_speech.proto | 929 +++++++++ .../v1p1beta1/cloud_speech_adaptation.proto | 370 ++++ .../cloud/speech/v1p1beta1/resource.proto | 162 ++ .../adaptation.create_custom_class.js | 80 + .../v1p1beta1/adaptation.create_phrase_set.js | 80 + .../adaptation.delete_custom_class.js | 67 + .../v1p1beta1/adaptation.delete_phrase_set.js | 62 + .../v1p1beta1/adaptation.get_custom_class.js | 62 + .../v1p1beta1/adaptation.get_phrase_set.js | 67 + .../adaptation.list_custom_classes.js | 83 + .../v1p1beta1/adaptation.list_phrase_set.js | 83 + .../adaptation.update_custom_class.js | 73 + .../v1p1beta1/adaptation.update_phrase_set.js | 73 + ...etadata.google.cloud.speech.v1p1beta1.json | 591 ++++++ .../speech.long_running_recognize.js | 72 + .../generated/v1p1beta1/speech.recognize.js | 67 + .../v1p1beta1/speech.streaming_recognize.js | 77 + owl-bot-staging/v1p1beta1/src/index.ts | 27 + .../src/v1p1beta1/adaptation_client.ts | 1578 +++++++++++++++ .../v1p1beta1/adaptation_client_config.json | 66 + .../src/v1p1beta1/adaptation_proto_list.json | 5 + .../src/v1p1beta1/gapic_metadata.json | 170 ++ .../v1p1beta1/src/v1p1beta1/index.ts | 20 + .../v1p1beta1/src/v1p1beta1/speech_client.ts | 649 +++++++ .../src/v1p1beta1/speech_client_config.json | 41 + .../src/v1p1beta1/speech_proto_list.json | 5 + .../system-test/fixtures/sample/src/index.js | 28 + .../system-test/fixtures/sample/src/index.ts | 38 + .../v1p1beta1/system-test/install.ts | 49 + .../test/gapic_adaptation_v1p1beta1.ts | 1722 +++++++++++++++++ .../v1p1beta1/test/gapic_speech_v1p1beta1.ts | 525 +++++ owl-bot-staging/v1p1beta1/tsconfig.json | 19 + owl-bot-staging/v1p1beta1/webpack.config.js | 64 + 84 files changed, 16386 insertions(+) create mode 100644 owl-bot-staging/v1/.eslintignore create mode 100644 owl-bot-staging/v1/.eslintrc.json create mode 100644 owl-bot-staging/v1/.gitignore create mode 100644 owl-bot-staging/v1/.jsdoc.js create mode 100644 owl-bot-staging/v1/.mocharc.js create mode 100644 owl-bot-staging/v1/.prettierrc.js create mode 100644 owl-bot-staging/v1/README.md create mode 100644 owl-bot-staging/v1/linkinator.config.json create mode 100644 owl-bot-staging/v1/package.json create mode 100644 owl-bot-staging/v1/protos/google/cloud/speech/v1/cloud_speech.proto create mode 100644 owl-bot-staging/v1/protos/google/cloud/speech/v1/cloud_speech_adaptation.proto create mode 100644 owl-bot-staging/v1/protos/google/cloud/speech/v1/resource.proto create mode 100644 owl-bot-staging/v1/samples/generated/v1/adaptation.create_custom_class.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/adaptation.create_phrase_set.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/adaptation.delete_custom_class.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/adaptation.delete_phrase_set.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/adaptation.get_custom_class.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/adaptation.get_phrase_set.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/adaptation.list_custom_classes.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/adaptation.list_phrase_set.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/adaptation.update_custom_class.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/adaptation.update_phrase_set.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.speech.v1.json create mode 100644 owl-bot-staging/v1/samples/generated/v1/speech.long_running_recognize.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/speech.recognize.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/speech.streaming_recognize.js create mode 100644 owl-bot-staging/v1/src/index.ts create mode 100644 owl-bot-staging/v1/src/v1/adaptation_client.ts create mode 100644 owl-bot-staging/v1/src/v1/adaptation_client_config.json create mode 100644 owl-bot-staging/v1/src/v1/adaptation_proto_list.json create mode 100644 owl-bot-staging/v1/src/v1/gapic_metadata.json create mode 100644 owl-bot-staging/v1/src/v1/index.ts create mode 100644 owl-bot-staging/v1/src/v1/speech_client.ts create mode 100644 owl-bot-staging/v1/src/v1/speech_client_config.json create mode 100644 owl-bot-staging/v1/src/v1/speech_proto_list.json create mode 100644 owl-bot-staging/v1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/v1/system-test/install.ts create mode 100644 owl-bot-staging/v1/test/gapic_adaptation_v1.ts create mode 100644 owl-bot-staging/v1/test/gapic_speech_v1.ts create mode 100644 owl-bot-staging/v1/tsconfig.json create mode 100644 owl-bot-staging/v1/webpack.config.js create mode 100644 owl-bot-staging/v1p1beta1/.eslintignore create mode 100644 owl-bot-staging/v1p1beta1/.eslintrc.json create mode 100644 owl-bot-staging/v1p1beta1/.gitignore create mode 100644 owl-bot-staging/v1p1beta1/.jsdoc.js create mode 100644 owl-bot-staging/v1p1beta1/.mocharc.js create mode 100644 owl-bot-staging/v1p1beta1/.prettierrc.js create mode 100644 owl-bot-staging/v1p1beta1/README.md create mode 100644 owl-bot-staging/v1p1beta1/linkinator.config.json create mode 100644 owl-bot-staging/v1p1beta1/package.json create mode 100644 owl-bot-staging/v1p1beta1/protos/google/cloud/speech/v1p1beta1/cloud_speech.proto create mode 100644 owl-bot-staging/v1p1beta1/protos/google/cloud/speech/v1p1beta1/cloud_speech_adaptation.proto create mode 100644 owl-bot-staging/v1p1beta1/protos/google/cloud/speech/v1p1beta1/resource.proto create mode 100644 owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.create_custom_class.js create mode 100644 owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.create_phrase_set.js create mode 100644 owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.delete_custom_class.js create mode 100644 owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.delete_phrase_set.js create mode 100644 owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.get_custom_class.js create mode 100644 owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.get_phrase_set.js create mode 100644 owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.list_custom_classes.js create mode 100644 owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.list_phrase_set.js create mode 100644 owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.update_custom_class.js create mode 100644 owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.update_phrase_set.js create mode 100644 owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/snippet_metadata.google.cloud.speech.v1p1beta1.json create mode 100644 owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/speech.long_running_recognize.js create mode 100644 owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/speech.recognize.js create mode 100644 owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/speech.streaming_recognize.js create mode 100644 owl-bot-staging/v1p1beta1/src/index.ts create mode 100644 owl-bot-staging/v1p1beta1/src/v1p1beta1/adaptation_client.ts create mode 100644 owl-bot-staging/v1p1beta1/src/v1p1beta1/adaptation_client_config.json create mode 100644 owl-bot-staging/v1p1beta1/src/v1p1beta1/adaptation_proto_list.json create mode 100644 owl-bot-staging/v1p1beta1/src/v1p1beta1/gapic_metadata.json create mode 100644 owl-bot-staging/v1p1beta1/src/v1p1beta1/index.ts create mode 100644 owl-bot-staging/v1p1beta1/src/v1p1beta1/speech_client.ts create mode 100644 owl-bot-staging/v1p1beta1/src/v1p1beta1/speech_client_config.json create mode 100644 owl-bot-staging/v1p1beta1/src/v1p1beta1/speech_proto_list.json create mode 100644 owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/v1p1beta1/system-test/install.ts create mode 100644 owl-bot-staging/v1p1beta1/test/gapic_adaptation_v1p1beta1.ts create mode 100644 owl-bot-staging/v1p1beta1/test/gapic_speech_v1p1beta1.ts create mode 100644 owl-bot-staging/v1p1beta1/tsconfig.json create mode 100644 owl-bot-staging/v1p1beta1/webpack.config.js diff --git a/owl-bot-staging/v1/.eslintignore b/owl-bot-staging/v1/.eslintignore new file mode 100644 index 00000000..cfc348ec --- /dev/null +++ b/owl-bot-staging/v1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/v1/.eslintrc.json b/owl-bot-staging/v1/.eslintrc.json new file mode 100644 index 00000000..78215349 --- /dev/null +++ b/owl-bot-staging/v1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/v1/.gitignore b/owl-bot-staging/v1/.gitignore new file mode 100644 index 00000000..5d32b237 --- /dev/null +++ b/owl-bot-staging/v1/.gitignore @@ -0,0 +1,14 @@ +**/*.log +**/node_modules +.coverage +coverage +.nyc_output +docs/ +out/ +build/ +system-test/secrets.js +system-test/*key.json +*.lock +.DS_Store +package-lock.json +__pycache__ diff --git a/owl-bot-staging/v1/.jsdoc.js b/owl-bot-staging/v1/.jsdoc.js new file mode 100644 index 00000000..d2a7104e --- /dev/null +++ b/owl-bot-staging/v1/.jsdoc.js @@ -0,0 +1,55 @@ +// Copyright 2022 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. ** + +'use strict'; + +module.exports = { + opts: { + readme: './README.md', + package: './package.json', + template: './node_modules/jsdoc-fresh', + recurse: true, + verbose: true, + destination: './docs/' + }, + plugins: [ + 'plugins/markdown', + 'jsdoc-region-tag' + ], + source: { + excludePattern: '(^|\\/|\\\\)[._]', + include: [ + 'build/src', + 'protos' + ], + includePattern: '\\.js$' + }, + templates: { + copyright: 'Copyright 2022 Google LLC', + includeDate: false, + sourceFiles: false, + systemName: '@google-cloud/speech', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/v1/.mocharc.js b/owl-bot-staging/v1/.mocharc.js new file mode 100644 index 00000000..481c522b --- /dev/null +++ b/owl-bot-staging/v1/.mocharc.js @@ -0,0 +1,33 @@ +// Copyright 2022 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. ** + +const config = { + "enable-source-maps": true, + "throw-deprecation": true, + "timeout": 10000 +} +if (process.env.MOCHA_THROW_DEPRECATION === 'false') { + delete config['throw-deprecation']; +} +if (process.env.MOCHA_REPORTER) { + config.reporter = process.env.MOCHA_REPORTER; +} +if (process.env.MOCHA_REPORTER_OUTPUT) { + config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; +} +module.exports = config diff --git a/owl-bot-staging/v1/.prettierrc.js b/owl-bot-staging/v1/.prettierrc.js new file mode 100644 index 00000000..494e1478 --- /dev/null +++ b/owl-bot-staging/v1/.prettierrc.js @@ -0,0 +1,22 @@ +// Copyright 2022 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. ** + + +module.exports = { + ...require('gts/.prettierrc.json') +} diff --git a/owl-bot-staging/v1/README.md b/owl-bot-staging/v1/README.md new file mode 100644 index 00000000..45c3b2af --- /dev/null +++ b/owl-bot-staging/v1/README.md @@ -0,0 +1 @@ +Speech: Nodejs Client diff --git a/owl-bot-staging/v1/linkinator.config.json b/owl-bot-staging/v1/linkinator.config.json new file mode 100644 index 00000000..befd23c8 --- /dev/null +++ b/owl-bot-staging/v1/linkinator.config.json @@ -0,0 +1,16 @@ +{ + "recurse": true, + "skip": [ + "https://codecov.io/gh/googleapis/", + "www.googleapis.com", + "img.shields.io", + "https://console.cloud.google.com/cloudshell", + "https://support.google.com" + ], + "silent": true, + "concurrency": 5, + "retry": true, + "retryErrors": true, + "retryErrorsCount": 5, + "retryErrorsJitter": 3000 +} diff --git a/owl-bot-staging/v1/package.json b/owl-bot-staging/v1/package.json new file mode 100644 index 00000000..53356248 --- /dev/null +++ b/owl-bot-staging/v1/package.json @@ -0,0 +1,65 @@ +{ + "name": "@google-cloud/speech", + "version": "0.1.0", + "description": "Speech client for Node.js", + "repository": "googleapis/nodejs-speech", + "license": "Apache-2.0", + "author": "Google LLC", + "main": "build/src/index.js", + "files": [ + "build/src", + "build/protos" + ], + "keywords": [ + "google apis client", + "google api client", + "google apis", + "google api", + "google", + "google cloud platform", + "google cloud", + "cloud", + "google speech", + "speech", + "adaptation", + "speech" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "c8 mocha build/system-test", + "test": "c8 mocha build/test" + }, + "dependencies": { + "google-gax": "^3.5.1" + }, + "devDependencies": { + "@types/mocha": "^9.1.1", + "@types/node": "^16.11.59", + "@types/sinon": "^10.0.13", + "c8": "^7.12.0", + "gts": "^3.1.1", + "jsdoc": "^3.6.11", + "jsdoc-fresh": "^2.0.1", + "jsdoc-region-tag": "^2.0.1", + "linkinator": "^4.0.3", + "mocha": "^10.0.0", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^14.0.0", + "ts-loader": "^8.4.0", + "typescript": "^4.8.3", + "webpack": "^4.46.0", + "webpack-cli": "^4.10.0" + }, + "engines": { + "node": ">=v12" + } +} diff --git a/owl-bot-staging/v1/protos/google/cloud/speech/v1/cloud_speech.proto b/owl-bot-staging/v1/protos/google/cloud/speech/v1/cloud_speech.proto new file mode 100644 index 00000000..65aed983 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/cloud/speech/v1/cloud_speech.proto @@ -0,0 +1,899 @@ +// Copyright 2022 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 +// +// http://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. + +syntax = "proto3"; + +package google.cloud.speech.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/cloud/speech/v1/resource.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/wrappers.proto"; +import "google/rpc/status.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/speech/v1;speech"; +option java_multiple_files = true; +option java_outer_classname = "SpeechProto"; +option java_package = "com.google.cloud.speech.v1"; +option objc_class_prefix = "GCS"; + +// Service that implements Google Cloud Speech API. +service Speech { + option (google.api.default_host) = "speech.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // Performs synchronous speech recognition: receive results after all audio + // has been sent and processed. + rpc Recognize(RecognizeRequest) returns (RecognizeResponse) { + option (google.api.http) = { + post: "/v1/speech:recognize" + body: "*" + }; + option (google.api.method_signature) = "config,audio"; + } + + // Performs asynchronous speech recognition: receive results via the + // google.longrunning.Operations interface. Returns either an + // `Operation.error` or an `Operation.response` which contains + // a `LongRunningRecognizeResponse` message. + // For more information on asynchronous speech recognition, see the + // [how-to](https://cloud.google.com/speech-to-text/docs/async-recognize). + rpc LongRunningRecognize(LongRunningRecognizeRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/speech:longrunningrecognize" + body: "*" + }; + option (google.api.method_signature) = "config,audio"; + option (google.longrunning.operation_info) = { + response_type: "LongRunningRecognizeResponse" + metadata_type: "LongRunningRecognizeMetadata" + }; + } + + // Performs bidirectional streaming speech recognition: receive results while + // sending audio. This method is only available via the gRPC API (not REST). + rpc StreamingRecognize(stream StreamingRecognizeRequest) returns (stream StreamingRecognizeResponse) { + } +} + +// The top-level message sent by the client for the `Recognize` method. +message RecognizeRequest { + // Required. Provides information to the recognizer that specifies how to + // process the request. + RecognitionConfig config = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The audio data to be recognized. + RecognitionAudio audio = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// The top-level message sent by the client for the `LongRunningRecognize` +// method. +message LongRunningRecognizeRequest { + // Required. Provides information to the recognizer that specifies how to + // process the request. + RecognitionConfig config = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The audio data to be recognized. + RecognitionAudio audio = 2 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Specifies an optional destination for the recognition results. + TranscriptOutputConfig output_config = 4 [(google.api.field_behavior) = OPTIONAL]; +} + +// Specifies an optional destination for the recognition results. +message TranscriptOutputConfig { + oneof output_type { + // Specifies a Cloud Storage URI for the recognition results. Must be + // specified in the format: `gs://bucket_name/object_name`, and the bucket + // must already exist. + string gcs_uri = 1; + } +} + +// The top-level message sent by the client for the `StreamingRecognize` method. +// Multiple `StreamingRecognizeRequest` messages are sent. The first message +// must contain a `streaming_config` message and must not contain +// `audio_content`. All subsequent messages must contain `audio_content` and +// must not contain a `streaming_config` message. +message StreamingRecognizeRequest { + // The streaming request, which is either a streaming config or audio content. + oneof streaming_request { + // Provides information to the recognizer that specifies how to process the + // request. The first `StreamingRecognizeRequest` message must contain a + // `streaming_config` message. + StreamingRecognitionConfig streaming_config = 1; + + // The audio data to be recognized. Sequential chunks of audio data are sent + // in sequential `StreamingRecognizeRequest` messages. The first + // `StreamingRecognizeRequest` message must not contain `audio_content` data + // and all subsequent `StreamingRecognizeRequest` messages must contain + // `audio_content` data. The audio bytes must be encoded as specified in + // `RecognitionConfig`. Note: as with all bytes fields, proto buffers use a + // pure binary representation (not base64). See + // [content limits](https://cloud.google.com/speech-to-text/quotas#content). + bytes audio_content = 2; + } +} + +// Provides information to the recognizer that specifies how to process the +// request. +message StreamingRecognitionConfig { + // Required. Provides information to the recognizer that specifies how to + // process the request. + RecognitionConfig config = 1 [(google.api.field_behavior) = REQUIRED]; + + // If `false` or omitted, the recognizer will perform continuous + // recognition (continuing to wait for and process audio even if the user + // pauses speaking) until the client closes the input stream (gRPC API) or + // until the maximum time limit has been reached. May return multiple + // `StreamingRecognitionResult`s with the `is_final` flag set to `true`. + // + // If `true`, the recognizer will detect a single spoken utterance. When it + // detects that the user has paused or stopped speaking, it will return an + // `END_OF_SINGLE_UTTERANCE` event and cease recognition. It will return no + // more than one `StreamingRecognitionResult` with the `is_final` flag set to + // `true`. + // + // The `single_utterance` field can only be used with specified models, + // otherwise an error is thrown. The `model` field in [`RecognitionConfig`][] + // must be set to: + // + // * `command_and_search` + // * `phone_call` AND additional field `useEnhanced`=`true` + // * The `model` field is left undefined. In this case the API auto-selects + // a model based on any other parameters that you set in + // `RecognitionConfig`. + bool single_utterance = 2; + + // If `true`, interim results (tentative hypotheses) may be + // returned as they become available (these interim results are indicated with + // the `is_final=false` flag). + // If `false` or omitted, only `is_final=true` result(s) are returned. + bool interim_results = 3; +} + +// Provides information to the recognizer that specifies how to process the +// request. +message RecognitionConfig { + // The encoding of the audio data sent in the request. + // + // All encodings support only 1 channel (mono) audio, unless the + // `audio_channel_count` and `enable_separate_recognition_per_channel` fields + // are set. + // + // For best results, the audio source should be captured and transmitted using + // a lossless encoding (`FLAC` or `LINEAR16`). The accuracy of the speech + // recognition can be reduced if lossy codecs are used to capture or transmit + // audio, particularly if background noise is present. Lossy codecs include + // `MULAW`, `AMR`, `AMR_WB`, `OGG_OPUS`, `SPEEX_WITH_HEADER_BYTE`, `MP3`, + // and `WEBM_OPUS`. + // + // The `FLAC` and `WAV` audio file formats include a header that describes the + // included audio content. You can request recognition for `WAV` files that + // contain either `LINEAR16` or `MULAW` encoded audio. + // If you send `FLAC` or `WAV` audio file format in + // your request, you do not need to specify an `AudioEncoding`; the audio + // encoding format is determined from the file header. If you specify + // an `AudioEncoding` when you send send `FLAC` or `WAV` audio, the + // encoding configuration must match the encoding described in the audio + // header; otherwise the request returns an + // [google.rpc.Code.INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT] error code. + enum AudioEncoding { + // Not specified. + ENCODING_UNSPECIFIED = 0; + + // Uncompressed 16-bit signed little-endian samples (Linear PCM). + LINEAR16 = 1; + + // `FLAC` (Free Lossless Audio + // Codec) is the recommended encoding because it is + // lossless--therefore recognition is not compromised--and + // requires only about half the bandwidth of `LINEAR16`. `FLAC` stream + // encoding supports 16-bit and 24-bit samples, however, not all fields in + // `STREAMINFO` are supported. + FLAC = 2; + + // 8-bit samples that compand 14-bit audio samples using G.711 PCMU/mu-law. + MULAW = 3; + + // Adaptive Multi-Rate Narrowband codec. `sample_rate_hertz` must be 8000. + AMR = 4; + + // Adaptive Multi-Rate Wideband codec. `sample_rate_hertz` must be 16000. + AMR_WB = 5; + + // Opus encoded audio frames in Ogg container + // ([OggOpus](https://wiki.xiph.org/OggOpus)). + // `sample_rate_hertz` must be one of 8000, 12000, 16000, 24000, or 48000. + OGG_OPUS = 6; + + // Although the use of lossy encodings is not recommended, if a very low + // bitrate encoding is required, `OGG_OPUS` is highly preferred over + // Speex encoding. The [Speex](https://speex.org/) encoding supported by + // Cloud Speech API has a header byte in each block, as in MIME type + // `audio/x-speex-with-header-byte`. + // It is a variant of the RTP Speex encoding defined in + // [RFC 5574](https://tools.ietf.org/html/rfc5574). + // The stream is a sequence of blocks, one block per RTP packet. Each block + // starts with a byte containing the length of the block, in bytes, followed + // by one or more frames of Speex data, padded to an integral number of + // bytes (octets) as specified in RFC 5574. In other words, each RTP header + // is replaced with a single byte containing the block length. Only Speex + // wideband is supported. `sample_rate_hertz` must be 16000. + SPEEX_WITH_HEADER_BYTE = 7; + + // Opus encoded audio frames in WebM container + // ([OggOpus](https://wiki.xiph.org/OggOpus)). `sample_rate_hertz` must be + // one of 8000, 12000, 16000, 24000, or 48000. + WEBM_OPUS = 9; + } + + // Encoding of audio data sent in all `RecognitionAudio` messages. + // This field is optional for `FLAC` and `WAV` audio files and required + // for all other audio formats. For details, see [AudioEncoding][google.cloud.speech.v1.RecognitionConfig.AudioEncoding]. + AudioEncoding encoding = 1; + + // Sample rate in Hertz of the audio data sent in all + // `RecognitionAudio` messages. Valid values are: 8000-48000. + // 16000 is optimal. For best results, set the sampling rate of the audio + // source to 16000 Hz. If that's not possible, use the native sample rate of + // the audio source (instead of re-sampling). + // This field is optional for FLAC and WAV audio files, but is + // required for all other audio formats. For details, see [AudioEncoding][google.cloud.speech.v1.RecognitionConfig.AudioEncoding]. + int32 sample_rate_hertz = 2; + + // The number of channels in the input audio data. + // ONLY set this for MULTI-CHANNEL recognition. + // Valid values for LINEAR16 and FLAC are `1`-`8`. + // Valid values for OGG_OPUS are '1'-'254'. + // Valid value for MULAW, AMR, AMR_WB and SPEEX_WITH_HEADER_BYTE is only `1`. + // If `0` or omitted, defaults to one channel (mono). + // Note: We only recognize the first channel by default. + // To perform independent recognition on each channel set + // `enable_separate_recognition_per_channel` to 'true'. + int32 audio_channel_count = 7; + + // This needs to be set to `true` explicitly and `audio_channel_count` > 1 + // to get each channel recognized separately. The recognition result will + // contain a `channel_tag` field to state which channel that result belongs + // to. If this is not true, we will only recognize the first channel. The + // request is billed cumulatively for all channels recognized: + // `audio_channel_count` multiplied by the length of the audio. + bool enable_separate_recognition_per_channel = 12; + + // Required. The language of the supplied audio as a + // [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag. + // Example: "en-US". + // See [Language + // Support](https://cloud.google.com/speech-to-text/docs/languages) for a list + // of the currently supported language codes. + string language_code = 3 [(google.api.field_behavior) = REQUIRED]; + + // A list of up to 3 additional + // [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tags, + // listing possible alternative languages of the supplied audio. + // See [Language + // Support](https://cloud.google.com/speech-to-text/docs/languages) for a list + // of the currently supported language codes. If alternative languages are + // listed, recognition result will contain recognition in the most likely + // language detected including the main language_code. The recognition result + // will include the language tag of the language detected in the audio. Note: + // This feature is only supported for Voice Command and Voice Search use cases + // and performance may vary for other use cases (e.g., phone call + // transcription). + repeated string alternative_language_codes = 18; + + // Maximum number of recognition hypotheses to be returned. + // Specifically, the maximum number of `SpeechRecognitionAlternative` messages + // within each `SpeechRecognitionResult`. + // The server may return fewer than `max_alternatives`. + // Valid values are `0`-`30`. A value of `0` or `1` will return a maximum of + // one. If omitted, will return a maximum of one. + int32 max_alternatives = 4; + + // If set to `true`, the server will attempt to filter out + // profanities, replacing all but the initial character in each filtered word + // with asterisks, e.g. "f***". If set to `false` or omitted, profanities + // won't be filtered out. + bool profanity_filter = 5; + + // Speech adaptation configuration improves the accuracy of speech + // recognition. For more information, see the [speech + // adaptation](https://cloud.google.com/speech-to-text/docs/adaptation) + // documentation. + // When speech adaptation is set it supersedes the `speech_contexts` field. + SpeechAdaptation adaptation = 20; + + // Array of [SpeechContext][google.cloud.speech.v1.SpeechContext]. + // A means to provide context to assist the speech recognition. For more + // information, see + // [speech + // adaptation](https://cloud.google.com/speech-to-text/docs/adaptation). + repeated SpeechContext speech_contexts = 6; + + // If `true`, the top result includes a list of words and + // the start and end time offsets (timestamps) for those words. If + // `false`, no word-level time offset information is returned. The default is + // `false`. + bool enable_word_time_offsets = 8; + + // If `true`, the top result includes a list of words and the + // confidence for those words. If `false`, no word-level confidence + // information is returned. The default is `false`. + bool enable_word_confidence = 15; + + // If 'true', adds punctuation to recognition result hypotheses. + // This feature is only available in select languages. Setting this for + // requests in other languages has no effect at all. + // The default 'false' value does not add punctuation to result hypotheses. + bool enable_automatic_punctuation = 11; + + // The spoken punctuation behavior for the call + // If not set, uses default behavior based on model of choice + // e.g. command_and_search will enable spoken punctuation by default + // If 'true', replaces spoken punctuation with the corresponding symbols in + // the request. For example, "how are you question mark" becomes "how are + // you?". See https://cloud.google.com/speech-to-text/docs/spoken-punctuation + // for support. If 'false', spoken punctuation is not replaced. + google.protobuf.BoolValue enable_spoken_punctuation = 22; + + // The spoken emoji behavior for the call + // If not set, uses default behavior based on model of choice + // If 'true', adds spoken emoji formatting for the request. This will replace + // spoken emojis with the corresponding Unicode symbols in the final + // transcript. If 'false', spoken emojis are not replaced. + google.protobuf.BoolValue enable_spoken_emojis = 23; + + // Config to enable speaker diarization and set additional + // parameters to make diarization better suited for your application. + // Note: When this is enabled, we send all the words from the beginning of the + // audio for the top alternative in every consecutive STREAMING responses. + // This is done in order to improve our speaker tags as our models learn to + // identify the speakers in the conversation over time. + // For non-streaming requests, the diarization results will be provided only + // in the top alternative of the FINAL SpeechRecognitionResult. + SpeakerDiarizationConfig diarization_config = 19; + + // Metadata regarding this request. + RecognitionMetadata metadata = 9; + + // Which model to select for the given request. Select the model + // best suited to your domain to get best results. If a model is not + // explicitly specified, then we auto-select a model based on the parameters + // in the RecognitionConfig. + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + //
ModelDescription
latest_longBest for long form content like media or conversation.
latest_shortBest for short form content like commands or single shot directed + // speech.
command_and_searchBest for short queries such as voice commands or voice search.
phone_callBest for audio that originated from a phone call (typically + // recorded at an 8khz sampling rate).
videoBest for audio that originated from video or includes multiple + // speakers. Ideally the audio is recorded at a 16khz or greater + // sampling rate. This is a premium model that costs more than the + // standard rate.
defaultBest for audio that is not one of the specific audio models. + // For example, long-form audio. Ideally the audio is high-fidelity, + // recorded at a 16khz or greater sampling rate.
medical_conversationBest for audio that originated from a conversation between a + // medical provider and patient.
medical_dictationBest for audio that originated from dictation notes by a medical + // provider.
+ string model = 13; + + // Set to true to use an enhanced model for speech recognition. + // If `use_enhanced` is set to true and the `model` field is not set, then + // an appropriate enhanced model is chosen if an enhanced model exists for + // the audio. + // + // If `use_enhanced` is true and an enhanced version of the specified model + // does not exist, then the speech is recognized using the standard version + // of the specified model. + bool use_enhanced = 14; +} + +// Config to enable speaker diarization. +message SpeakerDiarizationConfig { + // If 'true', enables speaker detection for each recognized word in + // the top alternative of the recognition result using a speaker_tag provided + // in the WordInfo. + bool enable_speaker_diarization = 1; + + // Minimum number of speakers in the conversation. This range gives you more + // flexibility by allowing the system to automatically determine the correct + // number of speakers. If not set, the default value is 2. + int32 min_speaker_count = 2; + + // Maximum number of speakers in the conversation. This range gives you more + // flexibility by allowing the system to automatically determine the correct + // number of speakers. If not set, the default value is 6. + int32 max_speaker_count = 3; + + // Output only. Unused. + int32 speaker_tag = 5 [ + deprecated = true, + (google.api.field_behavior) = OUTPUT_ONLY + ]; +} + +// Description of audio data to be recognized. +message RecognitionMetadata { + option deprecated = true; + + // Use case categories that the audio recognition request can be described + // by. + enum InteractionType { + // Use case is either unknown or is something other than one of the other + // values below. + INTERACTION_TYPE_UNSPECIFIED = 0; + + // Multiple people in a conversation or discussion. For example in a + // meeting with two or more people actively participating. Typically + // all the primary people speaking would be in the same room (if not, + // see PHONE_CALL) + DISCUSSION = 1; + + // One or more persons lecturing or presenting to others, mostly + // uninterrupted. + PRESENTATION = 2; + + // A phone-call or video-conference in which two or more people, who are + // not in the same room, are actively participating. + PHONE_CALL = 3; + + // A recorded message intended for another person to listen to. + VOICEMAIL = 4; + + // Professionally produced audio (eg. TV Show, Podcast). + PROFESSIONALLY_PRODUCED = 5; + + // Transcribe spoken questions and queries into text. + VOICE_SEARCH = 6; + + // Transcribe voice commands, such as for controlling a device. + VOICE_COMMAND = 7; + + // Transcribe speech to text to create a written document, such as a + // text-message, email or report. + DICTATION = 8; + } + + // Enumerates the types of capture settings describing an audio file. + enum MicrophoneDistance { + // Audio type is not known. + MICROPHONE_DISTANCE_UNSPECIFIED = 0; + + // The audio was captured from a closely placed microphone. Eg. phone, + // dictaphone, or handheld microphone. Generally if there speaker is within + // 1 meter of the microphone. + NEARFIELD = 1; + + // The speaker if within 3 meters of the microphone. + MIDFIELD = 2; + + // The speaker is more than 3 meters away from the microphone. + FARFIELD = 3; + } + + // The original media the speech was recorded on. + enum OriginalMediaType { + // Unknown original media type. + ORIGINAL_MEDIA_TYPE_UNSPECIFIED = 0; + + // The speech data is an audio recording. + AUDIO = 1; + + // The speech data originally recorded on a video. + VIDEO = 2; + } + + // The type of device the speech was recorded with. + enum RecordingDeviceType { + // The recording device is unknown. + RECORDING_DEVICE_TYPE_UNSPECIFIED = 0; + + // Speech was recorded on a smartphone. + SMARTPHONE = 1; + + // Speech was recorded using a personal computer or tablet. + PC = 2; + + // Speech was recorded over a phone line. + PHONE_LINE = 3; + + // Speech was recorded in a vehicle. + VEHICLE = 4; + + // Speech was recorded outdoors. + OTHER_OUTDOOR_DEVICE = 5; + + // Speech was recorded indoors. + OTHER_INDOOR_DEVICE = 6; + } + + // The use case most closely describing the audio content to be recognized. + InteractionType interaction_type = 1; + + // The industry vertical to which this speech recognition request most + // closely applies. This is most indicative of the topics contained + // in the audio. Use the 6-digit NAICS code to identify the industry + // vertical - see https://www.naics.com/search/. + uint32 industry_naics_code_of_audio = 3; + + // The audio type that most closely describes the audio being recognized. + MicrophoneDistance microphone_distance = 4; + + // The original media the speech was recorded on. + OriginalMediaType original_media_type = 5; + + // The type of device the speech was recorded with. + RecordingDeviceType recording_device_type = 6; + + // The device used to make the recording. Examples 'Nexus 5X' or + // 'Polycom SoundStation IP 6000' or 'POTS' or 'VoIP' or + // 'Cardioid Microphone'. + string recording_device_name = 7; + + // Mime type of the original audio file. For example `audio/m4a`, + // `audio/x-alaw-basic`, `audio/mp3`, `audio/3gpp`. + // A list of possible audio mime types is maintained at + // http://www.iana.org/assignments/media-types/media-types.xhtml#audio + string original_mime_type = 8; + + // Description of the content. Eg. "Recordings of federal supreme court + // hearings from 2012". + string audio_topic = 10; +} + +// Provides "hints" to the speech recognizer to favor specific words and phrases +// in the results. +message SpeechContext { + // A list of strings containing words and phrases "hints" so that + // the speech recognition is more likely to recognize them. This can be used + // to improve the accuracy for specific words and phrases, for example, if + // specific commands are typically spoken by the user. This can also be used + // to add additional words to the vocabulary of the recognizer. See + // [usage limits](https://cloud.google.com/speech-to-text/quotas#content). + // + // List items can also be set to classes for groups of words that represent + // common concepts that occur in natural language. For example, rather than + // providing phrase hints for every month of the year, using the $MONTH class + // improves the likelihood of correctly transcribing audio that includes + // months. + repeated string phrases = 1; + + // Hint Boost. Positive value will increase the probability that a specific + // phrase will be recognized over other similar sounding phrases. The higher + // the boost, the higher the chance of false positive recognition as well. + // Negative boost values would correspond to anti-biasing. Anti-biasing is not + // enabled, so negative boost will simply be ignored. Though `boost` can + // accept a wide range of positive values, most use cases are best served with + // values between 0 and 20. We recommend using a binary search approach to + // finding the optimal value for your use case. + float boost = 4; +} + +// Contains audio data in the encoding specified in the `RecognitionConfig`. +// Either `content` or `uri` must be supplied. Supplying both or neither +// returns [google.rpc.Code.INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT]. See +// [content limits](https://cloud.google.com/speech-to-text/quotas#content). +message RecognitionAudio { + // The audio source, which is either inline content or a Google Cloud + // Storage uri. + oneof audio_source { + // The audio data bytes encoded as specified in + // `RecognitionConfig`. Note: as with all bytes fields, proto buffers use a + // pure binary representation, whereas JSON representations use base64. + bytes content = 1; + + // URI that points to a file that contains audio data bytes as specified in + // `RecognitionConfig`. The file must not be compressed (for example, gzip). + // Currently, only Google Cloud Storage URIs are + // supported, which must be specified in the following format: + // `gs://bucket_name/object_name` (other URI formats return + // [google.rpc.Code.INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT]). For more information, see + // [Request URIs](https://cloud.google.com/storage/docs/reference-uris). + string uri = 2; + } +} + +// The only message returned to the client by the `Recognize` method. It +// contains the result as zero or more sequential `SpeechRecognitionResult` +// messages. +message RecognizeResponse { + // Sequential list of transcription results corresponding to + // sequential portions of audio. + repeated SpeechRecognitionResult results = 2; + + // When available, billed audio seconds for the corresponding request. + google.protobuf.Duration total_billed_time = 3; +} + +// The only message returned to the client by the `LongRunningRecognize` method. +// It contains the result as zero or more sequential `SpeechRecognitionResult` +// messages. It is included in the `result.response` field of the `Operation` +// returned by the `GetOperation` call of the `google::longrunning::Operations` +// service. +message LongRunningRecognizeResponse { + // Sequential list of transcription results corresponding to + // sequential portions of audio. + repeated SpeechRecognitionResult results = 2; + + // When available, billed audio seconds for the corresponding request. + google.protobuf.Duration total_billed_time = 3; + + // Original output config if present in the request. + TranscriptOutputConfig output_config = 6; + + // If the transcript output fails this field contains the relevant error. + google.rpc.Status output_error = 7; +} + +// Describes the progress of a long-running `LongRunningRecognize` call. It is +// included in the `metadata` field of the `Operation` returned by the +// `GetOperation` call of the `google::longrunning::Operations` service. +message LongRunningRecognizeMetadata { + // Approximate percentage of audio processed thus far. Guaranteed to be 100 + // when the audio is fully processed and the results are available. + int32 progress_percent = 1; + + // Time when the request was received. + google.protobuf.Timestamp start_time = 2; + + // Time of the most recent processing update. + google.protobuf.Timestamp last_update_time = 3; + + // Output only. The URI of the audio file being transcribed. Empty if the audio was sent + // as byte content. + string uri = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// `StreamingRecognizeResponse` is the only message returned to the client by +// `StreamingRecognize`. A series of zero or more `StreamingRecognizeResponse` +// messages are streamed back to the client. If there is no recognizable +// audio, and `single_utterance` is set to false, then no messages are streamed +// back to the client. +// +// Here's an example of a series of `StreamingRecognizeResponse`s that might be +// returned while processing audio: +// +// 1. results { alternatives { transcript: "tube" } stability: 0.01 } +// +// 2. results { alternatives { transcript: "to be a" } stability: 0.01 } +// +// 3. results { alternatives { transcript: "to be" } stability: 0.9 } +// results { alternatives { transcript: " or not to be" } stability: 0.01 } +// +// 4. results { alternatives { transcript: "to be or not to be" +// confidence: 0.92 } +// alternatives { transcript: "to bee or not to bee" } +// is_final: true } +// +// 5. results { alternatives { transcript: " that's" } stability: 0.01 } +// +// 6. results { alternatives { transcript: " that is" } stability: 0.9 } +// results { alternatives { transcript: " the question" } stability: 0.01 } +// +// 7. results { alternatives { transcript: " that is the question" +// confidence: 0.98 } +// alternatives { transcript: " that was the question" } +// is_final: true } +// +// Notes: +// +// - Only two of the above responses #4 and #7 contain final results; they are +// indicated by `is_final: true`. Concatenating these together generates the +// full transcript: "to be or not to be that is the question". +// +// - The others contain interim `results`. #3 and #6 contain two interim +// `results`: the first portion has a high stability and is less likely to +// change; the second portion has a low stability and is very likely to +// change. A UI designer might choose to show only high stability `results`. +// +// - The specific `stability` and `confidence` values shown above are only for +// illustrative purposes. Actual values may vary. +// +// - In each response, only one of these fields will be set: +// `error`, +// `speech_event_type`, or +// one or more (repeated) `results`. +message StreamingRecognizeResponse { + // Indicates the type of speech event. + enum SpeechEventType { + // No speech event specified. + SPEECH_EVENT_UNSPECIFIED = 0; + + // This event indicates that the server has detected the end of the user's + // speech utterance and expects no additional speech. Therefore, the server + // will not process additional audio (although it may subsequently return + // additional results). The client should stop sending additional audio + // data, half-close the gRPC connection, and wait for any additional results + // until the server closes the gRPC connection. This event is only sent if + // `single_utterance` was set to `true`, and is not used otherwise. + END_OF_SINGLE_UTTERANCE = 1; + } + + // If set, returns a [google.rpc.Status][google.rpc.Status] message that + // specifies the error for the operation. + google.rpc.Status error = 1; + + // This repeated list contains zero or more results that + // correspond to consecutive portions of the audio currently being processed. + // It contains zero or one `is_final=true` result (the newly settled portion), + // followed by zero or more `is_final=false` results (the interim results). + repeated StreamingRecognitionResult results = 2; + + // Indicates the type of speech event. + SpeechEventType speech_event_type = 4; + + // When available, billed audio seconds for the stream. + // Set only if this is the last response in the stream. + google.protobuf.Duration total_billed_time = 5; +} + +// A streaming speech recognition result corresponding to a portion of the audio +// that is currently being processed. +message StreamingRecognitionResult { + // May contain one or more recognition hypotheses (up to the + // maximum specified in `max_alternatives`). + // These alternatives are ordered in terms of accuracy, with the top (first) + // alternative being the most probable, as ranked by the recognizer. + repeated SpeechRecognitionAlternative alternatives = 1; + + // If `false`, this `StreamingRecognitionResult` represents an + // interim result that may change. If `true`, this is the final time the + // speech service will return this particular `StreamingRecognitionResult`, + // the recognizer will not return any further hypotheses for this portion of + // the transcript and corresponding audio. + bool is_final = 2; + + // An estimate of the likelihood that the recognizer will not + // change its guess about this interim result. Values range from 0.0 + // (completely unstable) to 1.0 (completely stable). + // This field is only provided for interim results (`is_final=false`). + // The default of 0.0 is a sentinel value indicating `stability` was not set. + float stability = 3; + + // Time offset of the end of this result relative to the + // beginning of the audio. + google.protobuf.Duration result_end_time = 4; + + // For multi-channel audio, this is the channel number corresponding to the + // recognized result for the audio from that channel. + // For audio_channel_count = N, its output values can range from '1' to 'N'. + int32 channel_tag = 5; + + // Output only. The [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag + // of the language in this result. This language code was detected to have + // the most likelihood of being spoken in the audio. + string language_code = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// A speech recognition result corresponding to a portion of the audio. +message SpeechRecognitionResult { + // May contain one or more recognition hypotheses (up to the + // maximum specified in `max_alternatives`). + // These alternatives are ordered in terms of accuracy, with the top (first) + // alternative being the most probable, as ranked by the recognizer. + repeated SpeechRecognitionAlternative alternatives = 1; + + // For multi-channel audio, this is the channel number corresponding to the + // recognized result for the audio from that channel. + // For audio_channel_count = N, its output values can range from '1' to 'N'. + int32 channel_tag = 2; + + // Time offset of the end of this result relative to the + // beginning of the audio. + google.protobuf.Duration result_end_time = 4; + + // Output only. The [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag + // of the language in this result. This language code was detected to have + // the most likelihood of being spoken in the audio. + string language_code = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Alternative hypotheses (a.k.a. n-best list). +message SpeechRecognitionAlternative { + // Transcript text representing the words that the user spoke. + // In languages that use spaces to separate words, the transcript might have a + // leading space if it isn't the first result. You can concatenate each result + // to obtain the full transcript without using a separator. + string transcript = 1; + + // The confidence estimate between 0.0 and 1.0. A higher number + // indicates an estimated greater likelihood that the recognized words are + // correct. This field is set only for the top alternative of a non-streaming + // result or, of a streaming result where `is_final=true`. + // This field is not guaranteed to be accurate and users should not rely on it + // to be always provided. + // The default of 0.0 is a sentinel value indicating `confidence` was not set. + float confidence = 2; + + // A list of word-specific information for each recognized word. + // Note: When `enable_speaker_diarization` is true, you will see all the words + // from the beginning of the audio. + repeated WordInfo words = 3; +} + +// Word-specific information for recognized words. +message WordInfo { + // Time offset relative to the beginning of the audio, + // and corresponding to the start of the spoken word. + // This field is only set if `enable_word_time_offsets=true` and only + // in the top hypothesis. + // This is an experimental feature and the accuracy of the time offset can + // vary. + google.protobuf.Duration start_time = 1; + + // Time offset relative to the beginning of the audio, + // and corresponding to the end of the spoken word. + // This field is only set if `enable_word_time_offsets=true` and only + // in the top hypothesis. + // This is an experimental feature and the accuracy of the time offset can + // vary. + google.protobuf.Duration end_time = 2; + + // The word corresponding to this set of information. + string word = 3; + + // The confidence estimate between 0.0 and 1.0. A higher number + // indicates an estimated greater likelihood that the recognized words are + // correct. This field is set only for the top alternative of a non-streaming + // result or, of a streaming result where `is_final=true`. + // This field is not guaranteed to be accurate and users should not rely on it + // to be always provided. + // The default of 0.0 is a sentinel value indicating `confidence` was not set. + float confidence = 4; + + // Output only. A distinct integer value is assigned for every speaker within + // the audio. This field specifies which one of those speakers was detected to + // have spoken this word. Value ranges from '1' to diarization_speaker_count. + // speaker_tag is set if enable_speaker_diarization = 'true' and only in the + // top alternative. + int32 speaker_tag = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; +} diff --git a/owl-bot-staging/v1/protos/google/cloud/speech/v1/cloud_speech_adaptation.proto b/owl-bot-staging/v1/protos/google/cloud/speech/v1/cloud_speech_adaptation.proto new file mode 100644 index 00000000..b0d60ab4 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/cloud/speech/v1/cloud_speech_adaptation.proto @@ -0,0 +1,370 @@ +// Copyright 2022 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 +// +// http://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. + +syntax = "proto3"; + +package google.cloud.speech.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/speech/v1/resource.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/speech/v1;speech"; +option java_multiple_files = true; +option java_outer_classname = "SpeechAdaptationProto"; +option java_package = "com.google.cloud.speech.v1"; +option objc_class_prefix = "GCS"; + +// Service that implements Google Cloud Speech Adaptation API. +service Adaptation { + option (google.api.default_host) = "speech.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // 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. + rpc CreatePhraseSet(CreatePhraseSetRequest) returns (PhraseSet) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*}/phraseSets" + body: "*" + }; + option (google.api.method_signature) = "parent,phrase_set,phrase_set_id"; + } + + // Get a phrase set. + rpc GetPhraseSet(GetPhraseSetRequest) returns (PhraseSet) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/phraseSets/*}" + }; + option (google.api.method_signature) = "name"; + } + + // List phrase sets. + rpc ListPhraseSet(ListPhraseSetRequest) returns (ListPhraseSetResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*}/phraseSets" + }; + option (google.api.method_signature) = "parent"; + } + + // Update a phrase set. + rpc UpdatePhraseSet(UpdatePhraseSetRequest) returns (PhraseSet) { + option (google.api.http) = { + patch: "/v1/{phrase_set.name=projects/*/locations/*/phraseSets/*}" + body: "phrase_set" + }; + option (google.api.method_signature) = "phrase_set,update_mask"; + } + + // Delete a phrase set. + rpc DeletePhraseSet(DeletePhraseSetRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/locations/*/phraseSets/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Create a custom class. + rpc CreateCustomClass(CreateCustomClassRequest) returns (CustomClass) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*}/customClasses" + body: "*" + }; + option (google.api.method_signature) = "parent,custom_class,custom_class_id"; + } + + // Get a custom class. + rpc GetCustomClass(GetCustomClassRequest) returns (CustomClass) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/customClasses/*}" + }; + option (google.api.method_signature) = "name"; + } + + // List custom classes. + rpc ListCustomClasses(ListCustomClassesRequest) returns (ListCustomClassesResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*}/customClasses" + }; + option (google.api.method_signature) = "parent"; + } + + // Update a custom class. + rpc UpdateCustomClass(UpdateCustomClassRequest) returns (CustomClass) { + option (google.api.http) = { + patch: "/v1/{custom_class.name=projects/*/locations/*/customClasses/*}" + body: "custom_class" + }; + option (google.api.method_signature) = "custom_class,update_mask"; + } + + // Delete a custom class. + rpc DeleteCustomClass(DeleteCustomClassRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/locations/*/customClasses/*}" + }; + option (google.api.method_signature) = "name"; + } +} + +// Message sent by the client for the `CreatePhraseSet` method. +message CreatePhraseSetRequest { + // Required. The parent resource where this phrase set will be created. Format: + // + // `projects/{project}/locations/{location}/phraseSets` + // + // Speech-to-Text supports three locations: `global`, `us` (US North America), + // and `eu` (Europe). If you are calling the `speech.googleapis.com` + // endpoint, use the `global` location. To specify a region, use a + // [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + // with matching `us` or `eu` location value. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "speech.googleapis.com/PhraseSet" + } + ]; + + // Required. The ID to use for the phrase set, which will become the final + // component of the phrase set's resource name. + // + // This value should restrict to letters, numbers, and hyphens, with the first + // character a letter, the last a letter or a number, and be 4-63 characters. + string phrase_set_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The phrase set to create. + PhraseSet phrase_set = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Message sent by the client for the `UpdatePhraseSet` method. +message UpdatePhraseSetRequest { + // Required. The phrase set to update. + // + // The phrase set's `name` field is used to identify the set to be + // updated. Format: + // + // `projects/{project}/locations/{location}/phraseSets/{phrase_set}` + // + // Speech-to-Text supports three locations: `global`, `us` (US North America), + // and `eu` (Europe). If you are calling the `speech.googleapis.com` + // endpoint, use the `global` location. To specify a region, use a + // [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + // with matching `us` or `eu` location value. + PhraseSet phrase_set = 1 [(google.api.field_behavior) = REQUIRED]; + + // The list of fields to be updated. + google.protobuf.FieldMask update_mask = 2; +} + +// Message sent by the client for the `GetPhraseSet` method. +message GetPhraseSetRequest { + // Required. The name of the phrase set to retrieve. Format: + // + // `projects/{project}/locations/{location}/phraseSets/{phrase_set}` + // + // Speech-to-Text supports three locations: `global`, `us` (US North America), + // and `eu` (Europe). If you are calling the `speech.googleapis.com` + // endpoint, use the `global` location. To specify a region, use a + // [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + // with matching `us` or `eu` location value. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "speech.googleapis.com/PhraseSet" + } + ]; +} + +// Message sent by the client for the `ListPhraseSet` method. +message ListPhraseSetRequest { + // Required. The parent, which owns this collection of phrase set. Format: + // + // `projects/{project}/locations/{location}` + // + // Speech-to-Text supports three locations: `global`, `us` (US North America), + // and `eu` (Europe). If you are calling the `speech.googleapis.com` + // endpoint, use the `global` location. To specify a region, use a + // [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + // with matching `us` or `eu` location value. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "speech.googleapis.com/PhraseSet" + } + ]; + + // 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. + int32 page_size = 2; + + // 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. + string page_token = 3; +} + +// Message returned to the client by the `ListPhraseSet` method. +message ListPhraseSetResponse { + // The phrase set. + repeated PhraseSet phrase_sets = 1; + + // A token, which can be sent as `page_token` to retrieve the next page. + // If this field is omitted, there are no subsequent pages. + string next_page_token = 2; +} + +// Message sent by the client for the `DeletePhraseSet` method. +message DeletePhraseSetRequest { + // Required. The name of the phrase set to delete. Format: + // + // `projects/{project}/locations/{location}/phraseSets/{phrase_set}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "speech.googleapis.com/PhraseSet" + } + ]; +} + +// Message sent by the client for the `CreateCustomClass` method. +message CreateCustomClassRequest { + // Required. The parent resource where this custom class will be created. Format: + // + // `projects/{project}/locations/{location}/customClasses` + // + // Speech-to-Text supports three locations: `global`, `us` (US North America), + // and `eu` (Europe). If you are calling the `speech.googleapis.com` + // endpoint, use the `global` location. To specify a region, use a + // [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + // with matching `us` or `eu` location value. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "speech.googleapis.com/CustomClass" + } + ]; + + // Required. The ID to use for the custom class, which will become the final + // component of the custom class' resource name. + // + // This value should restrict to letters, numbers, and hyphens, with the first + // character a letter, the last a letter or a number, and be 4-63 characters. + string custom_class_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The custom class to create. + CustomClass custom_class = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Message sent by the client for the `UpdateCustomClass` method. +message UpdateCustomClassRequest { + // Required. The custom class to update. + // + // The custom class's `name` field is used to identify the custom class to be + // updated. Format: + // + // `projects/{project}/locations/{location}/customClasses/{custom_class}` + // + // Speech-to-Text supports three locations: `global`, `us` (US North America), + // and `eu` (Europe). If you are calling the `speech.googleapis.com` + // endpoint, use the `global` location. To specify a region, use a + // [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + // with matching `us` or `eu` location value. + CustomClass custom_class = 1 [(google.api.field_behavior) = REQUIRED]; + + // The list of fields to be updated. + google.protobuf.FieldMask update_mask = 2; +} + +// Message sent by the client for the `GetCustomClass` method. +message GetCustomClassRequest { + // Required. The name of the custom class to retrieve. Format: + // + // `projects/{project}/locations/{location}/customClasses/{custom_class}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "speech.googleapis.com/CustomClass" + } + ]; +} + +// Message sent by the client for the `ListCustomClasses` method. +message ListCustomClassesRequest { + // Required. The parent, which owns this collection of custom classes. Format: + // + // `projects/{project}/locations/{location}/customClasses` + // + // Speech-to-Text supports three locations: `global`, `us` (US North America), + // and `eu` (Europe). If you are calling the `speech.googleapis.com` + // endpoint, use the `global` location. To specify a region, use a + // [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + // with matching `us` or `eu` location value. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "speech.googleapis.com/CustomClass" + } + ]; + + // 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. + int32 page_size = 2; + + // 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. + string page_token = 3; +} + +// Message returned to the client by the `ListCustomClasses` method. +message ListCustomClassesResponse { + // The custom classes. + repeated CustomClass custom_classes = 1; + + // A token, which can be sent as `page_token` to retrieve the next page. + // If this field is omitted, there are no subsequent pages. + string next_page_token = 2; +} + +// Message sent by the client for the `DeleteCustomClass` method. +message DeleteCustomClassRequest { + // Required. The name of the custom class to delete. Format: + // + // `projects/{project}/locations/{location}/customClasses/{custom_class}` + // + // Speech-to-Text supports three locations: `global`, `us` (US North America), + // and `eu` (Europe). If you are calling the `speech.googleapis.com` + // endpoint, use the `global` location. To specify a region, use a + // [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + // with matching `us` or `eu` location value. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "speech.googleapis.com/CustomClass" + } + ]; +} diff --git a/owl-bot-staging/v1/protos/google/cloud/speech/v1/resource.proto b/owl-bot-staging/v1/protos/google/cloud/speech/v1/resource.proto new file mode 100644 index 00000000..0ae5caa9 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/cloud/speech/v1/resource.proto @@ -0,0 +1,138 @@ +// Copyright 2022 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 +// +// http://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. + +syntax = "proto3"; + +package google.cloud.speech.v1; + +import "google/api/resource.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/speech/v1;speech"; +option java_multiple_files = true; +option java_outer_classname = "SpeechResourceProto"; +option java_package = "com.google.cloud.speech.v1"; +option objc_class_prefix = "GCS"; + +// A set of words or phrases that represents a common concept likely to appear +// in your audio, for example a list of passenger ship names. CustomClass items +// can be substituted into placeholders that you set in PhraseSet phrases. +message CustomClass { + option (google.api.resource) = { + type: "speech.googleapis.com/CustomClass" + pattern: "projects/{project}/locations/{location}/customClasses/{custom_class}" + }; + + // An item of the class. + message ClassItem { + // The class item's value. + string value = 1; + } + + // The resource name of the custom class. + string name = 1; + + // If this custom class is a resource, the custom_class_id is the resource id + // of the CustomClass. Case sensitive. + string custom_class_id = 2; + + // A collection of class items. + repeated ClassItem items = 3; +} + +// Provides "hints" to the speech recognizer to favor specific words and phrases +// in the results. +message PhraseSet { + option (google.api.resource) = { + type: "speech.googleapis.com/PhraseSet" + pattern: "projects/{project}/locations/{location}/phraseSets/{phrase_set}" + }; + + // A phrases containing words and phrase "hints" so that + // the speech recognition is more likely to recognize them. This can be used + // to improve the accuracy for specific words and phrases, for example, if + // specific commands are typically spoken by the user. This can also be used + // to add additional words to the vocabulary of the recognizer. See + // [usage limits](https://cloud.google.com/speech-to-text/quotas#content). + // + // List items can also include pre-built or custom classes containing groups + // of words that represent common concepts that occur in natural language. For + // example, rather than providing a phrase hint for every month of the + // year (e.g. "i was born in january", "i was born in febuary", ...), use the + // pre-built `$MONTH` class improves the likelihood of correctly transcribing + // audio that includes months (e.g. "i was born in $month"). + // To refer to pre-built classes, use the class' symbol prepended with `$` + // e.g. `$MONTH`. To refer to custom classes that were defined inline in the + // request, set the class's `custom_class_id` to a string unique to all class + // resources and inline classes. Then use the class' id wrapped in $`{...}` + // e.g. "${my-months}". To refer to custom classes resources, use the class' + // id wrapped in `${}` (e.g. `${my-months}`). + // + // Speech-to-Text supports three locations: `global`, `us` (US North America), + // and `eu` (Europe). If you are calling the `speech.googleapis.com` + // endpoint, use the `global` location. To specify a region, use a + // [regional endpoint](/speech-to-text/docs/endpoints) with matching `us` or + // `eu` location value. + message Phrase { + // The phrase itself. + string value = 1; + + // Hint Boost. Overrides the boost set at the phrase set level. + // Positive value will increase the probability that a specific phrase will + // be recognized over other similar sounding phrases. The higher the boost, + // the higher the chance of false positive recognition as well. Negative + // boost will simply be ignored. Though `boost` can accept a wide range of + // positive values, most use cases are best served + // with values between 0 and 20. We recommend using a binary search approach + // to finding the optimal value for your use case. Speech recognition + // will skip PhraseSets with a boost value of 0. + float boost = 2; + } + + // The resource name of the phrase set. + string name = 1; + + // A list of word and phrases. + repeated Phrase phrases = 2; + + // Hint Boost. Positive value will increase the probability that a specific + // phrase will be recognized over other similar sounding phrases. The higher + // the boost, the higher the chance of false positive recognition as well. + // Negative boost values would correspond to anti-biasing. Anti-biasing is not + // enabled, so negative boost will simply be ignored. Though `boost` can + // accept a wide range of positive values, most use cases are best served with + // values between 0 (exclusive) and 20. We recommend using a binary search + // approach to finding the optimal value for your use case. Speech recognition + // will skip PhraseSets with a boost value of 0. + float boost = 4; +} + +// Speech adaptation configuration. +message SpeechAdaptation { + // A collection of phrase sets. To specify the hints inline, leave the + // phrase set's `name` blank and fill in the rest of its fields. Any + // phrase set can use any custom class. + repeated PhraseSet phrase_sets = 1; + + // A collection of phrase set resource names to use. + repeated string phrase_set_references = 2 [(google.api.resource_reference) = { + type: "speech.googleapis.com/PhraseSet" + }]; + + // A collection of custom classes. To specify the classes inline, leave the + // class' `name` blank and fill in the rest of its fields, giving it a unique + // `custom_class_id`. Refer to the inline defined class in phrase hints by its + // `custom_class_id`. + repeated CustomClass custom_classes = 3; +} diff --git a/owl-bot-staging/v1/samples/generated/v1/adaptation.create_custom_class.js b/owl-bot-staging/v1/samples/generated/v1/adaptation.create_custom_class.js new file mode 100644 index 00000000..ebc4d9be --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/adaptation.create_custom_class.js @@ -0,0 +1,80 @@ +// Copyright 2022 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. ** + + + +'use strict'; + +function main(parent, customClassId, customClass) { + // [START speech_v1_generated_Adaptation_CreateCustomClass_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent resource where this custom class will be created. Format: + * `projects/{project}/locations/{location}/customClasses` + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * regional endpoint (https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + */ + // const parent = 'abc123' + /** + * Required. The ID to use for the custom class, which will become the final + * component of the custom class' resource name. + * This value should restrict to letters, numbers, and hyphens, with the first + * character a letter, the last a letter or a number, and be 4-63 characters. + */ + // const customClassId = 'abc123' + /** + * Required. The custom class to create. + */ + // const customClass = {} + + // Imports the Speech library + const {AdaptationClient} = require('@google-cloud/speech').v1; + + // Instantiates a client + const speechClient = new AdaptationClient(); + + async function callCreateCustomClass() { + // Construct request + const request = { + parent, + customClassId, + customClass, + }; + + // Run request + const response = await speechClient.createCustomClass(request); + console.log(response); + } + + callCreateCustomClass(); + // [END speech_v1_generated_Adaptation_CreateCustomClass_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/adaptation.create_phrase_set.js b/owl-bot-staging/v1/samples/generated/v1/adaptation.create_phrase_set.js new file mode 100644 index 00000000..7aedc67a --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/adaptation.create_phrase_set.js @@ -0,0 +1,80 @@ +// Copyright 2022 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. ** + + + +'use strict'; + +function main(parent, phraseSetId, phraseSet) { + // [START speech_v1_generated_Adaptation_CreatePhraseSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent resource where this phrase set will be created. Format: + * `projects/{project}/locations/{location}/phraseSets` + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * regional endpoint (https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + */ + // const parent = 'abc123' + /** + * Required. The ID to use for the phrase set, which will become the final + * component of the phrase set's resource name. + * This value should restrict to letters, numbers, and hyphens, with the first + * character a letter, the last a letter or a number, and be 4-63 characters. + */ + // const phraseSetId = 'abc123' + /** + * Required. The phrase set to create. + */ + // const phraseSet = {} + + // Imports the Speech library + const {AdaptationClient} = require('@google-cloud/speech').v1; + + // Instantiates a client + const speechClient = new AdaptationClient(); + + async function callCreatePhraseSet() { + // Construct request + const request = { + parent, + phraseSetId, + phraseSet, + }; + + // Run request + const response = await speechClient.createPhraseSet(request); + console.log(response); + } + + callCreatePhraseSet(); + // [END speech_v1_generated_Adaptation_CreatePhraseSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/adaptation.delete_custom_class.js b/owl-bot-staging/v1/samples/generated/v1/adaptation.delete_custom_class.js new file mode 100644 index 00000000..09105820 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/adaptation.delete_custom_class.js @@ -0,0 +1,67 @@ +// Copyright 2022 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. ** + + + +'use strict'; + +function main(name) { + // [START speech_v1_generated_Adaptation_DeleteCustomClass_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the custom class to delete. Format: + * `projects/{project}/locations/{location}/customClasses/{custom_class}` + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * regional endpoint (https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + */ + // const name = 'abc123' + + // Imports the Speech library + const {AdaptationClient} = require('@google-cloud/speech').v1; + + // Instantiates a client + const speechClient = new AdaptationClient(); + + async function callDeleteCustomClass() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await speechClient.deleteCustomClass(request); + console.log(response); + } + + callDeleteCustomClass(); + // [END speech_v1_generated_Adaptation_DeleteCustomClass_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/adaptation.delete_phrase_set.js b/owl-bot-staging/v1/samples/generated/v1/adaptation.delete_phrase_set.js new file mode 100644 index 00000000..18e7f7ff --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/adaptation.delete_phrase_set.js @@ -0,0 +1,62 @@ +// Copyright 2022 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. ** + + + +'use strict'; + +function main(name) { + // [START speech_v1_generated_Adaptation_DeletePhraseSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the phrase set to delete. Format: + * `projects/{project}/locations/{location}/phraseSets/{phrase_set}` + */ + // const name = 'abc123' + + // Imports the Speech library + const {AdaptationClient} = require('@google-cloud/speech').v1; + + // Instantiates a client + const speechClient = new AdaptationClient(); + + async function callDeletePhraseSet() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await speechClient.deletePhraseSet(request); + console.log(response); + } + + callDeletePhraseSet(); + // [END speech_v1_generated_Adaptation_DeletePhraseSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/adaptation.get_custom_class.js b/owl-bot-staging/v1/samples/generated/v1/adaptation.get_custom_class.js new file mode 100644 index 00000000..40cffe02 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/adaptation.get_custom_class.js @@ -0,0 +1,62 @@ +// Copyright 2022 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. ** + + + +'use strict'; + +function main(name) { + // [START speech_v1_generated_Adaptation_GetCustomClass_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the custom class to retrieve. Format: + * `projects/{project}/locations/{location}/customClasses/{custom_class}` + */ + // const name = 'abc123' + + // Imports the Speech library + const {AdaptationClient} = require('@google-cloud/speech').v1; + + // Instantiates a client + const speechClient = new AdaptationClient(); + + async function callGetCustomClass() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await speechClient.getCustomClass(request); + console.log(response); + } + + callGetCustomClass(); + // [END speech_v1_generated_Adaptation_GetCustomClass_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/adaptation.get_phrase_set.js b/owl-bot-staging/v1/samples/generated/v1/adaptation.get_phrase_set.js new file mode 100644 index 00000000..65ccaa4b --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/adaptation.get_phrase_set.js @@ -0,0 +1,67 @@ +// Copyright 2022 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. ** + + + +'use strict'; + +function main(name) { + // [START speech_v1_generated_Adaptation_GetPhraseSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the phrase set to retrieve. Format: + * `projects/{project}/locations/{location}/phraseSets/{phrase_set}` + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * regional endpoint (https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + */ + // const name = 'abc123' + + // Imports the Speech library + const {AdaptationClient} = require('@google-cloud/speech').v1; + + // Instantiates a client + const speechClient = new AdaptationClient(); + + async function callGetPhraseSet() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await speechClient.getPhraseSet(request); + console.log(response); + } + + callGetPhraseSet(); + // [END speech_v1_generated_Adaptation_GetPhraseSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/adaptation.list_custom_classes.js b/owl-bot-staging/v1/samples/generated/v1/adaptation.list_custom_classes.js new file mode 100644 index 00000000..bb2692b8 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/adaptation.list_custom_classes.js @@ -0,0 +1,83 @@ +// Copyright 2022 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. ** + + + +'use strict'; + +function main(parent) { + // [START speech_v1_generated_Adaptation_ListCustomClasses_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent, which owns this collection of custom classes. Format: + * `projects/{project}/locations/{location}/customClasses` + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * regional endpoint (https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + */ + // const parent = 'abc123' + /** + * 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. + */ + // const pageSize = 1234 + /** + * 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. + */ + // const pageToken = 'abc123' + + // Imports the Speech library + const {AdaptationClient} = require('@google-cloud/speech').v1; + + // Instantiates a client + const speechClient = new AdaptationClient(); + + async function callListCustomClasses() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await speechClient.listCustomClassesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListCustomClasses(); + // [END speech_v1_generated_Adaptation_ListCustomClasses_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/adaptation.list_phrase_set.js b/owl-bot-staging/v1/samples/generated/v1/adaptation.list_phrase_set.js new file mode 100644 index 00000000..14f715d8 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/adaptation.list_phrase_set.js @@ -0,0 +1,83 @@ +// Copyright 2022 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. ** + + + +'use strict'; + +function main(parent) { + // [START speech_v1_generated_Adaptation_ListPhraseSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent, which owns this collection of phrase set. Format: + * `projects/{project}/locations/{location}` + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * regional endpoint (https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + */ + // const parent = 'abc123' + /** + * 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. + */ + // const pageSize = 1234 + /** + * 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. + */ + // const pageToken = 'abc123' + + // Imports the Speech library + const {AdaptationClient} = require('@google-cloud/speech').v1; + + // Instantiates a client + const speechClient = new AdaptationClient(); + + async function callListPhraseSet() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await speechClient.listPhraseSetAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListPhraseSet(); + // [END speech_v1_generated_Adaptation_ListPhraseSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/adaptation.update_custom_class.js b/owl-bot-staging/v1/samples/generated/v1/adaptation.update_custom_class.js new file mode 100644 index 00000000..a5b6946e --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/adaptation.update_custom_class.js @@ -0,0 +1,73 @@ +// Copyright 2022 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. ** + + + +'use strict'; + +function main(customClass) { + // [START speech_v1_generated_Adaptation_UpdateCustomClass_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The custom class to update. + * The custom class's `name` field is used to identify the custom class to be + * updated. Format: + * `projects/{project}/locations/{location}/customClasses/{custom_class}` + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * regional endpoint (https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + */ + // const customClass = {} + /** + * The list of fields to be updated. + */ + // const updateMask = {} + + // Imports the Speech library + const {AdaptationClient} = require('@google-cloud/speech').v1; + + // Instantiates a client + const speechClient = new AdaptationClient(); + + async function callUpdateCustomClass() { + // Construct request + const request = { + customClass, + }; + + // Run request + const response = await speechClient.updateCustomClass(request); + console.log(response); + } + + callUpdateCustomClass(); + // [END speech_v1_generated_Adaptation_UpdateCustomClass_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/adaptation.update_phrase_set.js b/owl-bot-staging/v1/samples/generated/v1/adaptation.update_phrase_set.js new file mode 100644 index 00000000..076453a9 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/adaptation.update_phrase_set.js @@ -0,0 +1,73 @@ +// Copyright 2022 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. ** + + + +'use strict'; + +function main(phraseSet) { + // [START speech_v1_generated_Adaptation_UpdatePhraseSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The phrase set to update. + * The phrase set's `name` field is used to identify the set to be + * updated. Format: + * `projects/{project}/locations/{location}/phraseSets/{phrase_set}` + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * regional endpoint (https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + */ + // const phraseSet = {} + /** + * The list of fields to be updated. + */ + // const updateMask = {} + + // Imports the Speech library + const {AdaptationClient} = require('@google-cloud/speech').v1; + + // Instantiates a client + const speechClient = new AdaptationClient(); + + async function callUpdatePhraseSet() { + // Construct request + const request = { + phraseSet, + }; + + // Run request + const response = await speechClient.updatePhraseSet(request); + console.log(response); + } + + callUpdatePhraseSet(); + // [END speech_v1_generated_Adaptation_UpdatePhraseSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.speech.v1.json b/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.speech.v1.json new file mode 100644 index 00000000..11747e69 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.speech.v1.json @@ -0,0 +1,591 @@ +{ + "clientLibrary": { + "name": "nodejs-speech", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.speech.v1", + "version": "v1" + } + ] + }, + "snippets": [ + { + "regionTag": "speech_v1_generated_Adaptation_CreatePhraseSet_async", + "title": "Adaptation createPhraseSet Sample", + "origin": "API_DEFINITION", + "description": " 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.", + "canonical": true, + "file": "adaptation.create_phrase_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreatePhraseSet", + "fullName": "google.cloud.speech.v1.Adaptation.CreatePhraseSet", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "phrase_set_id", + "type": "TYPE_STRING" + }, + { + "name": "phrase_set", + "type": ".google.cloud.speech.v1.PhraseSet" + } + ], + "resultType": ".google.cloud.speech.v1.PhraseSet", + "client": { + "shortName": "AdaptationClient", + "fullName": "google.cloud.speech.v1.AdaptationClient" + }, + "method": { + "shortName": "CreatePhraseSet", + "fullName": "google.cloud.speech.v1.Adaptation.CreatePhraseSet", + "service": { + "shortName": "Adaptation", + "fullName": "google.cloud.speech.v1.Adaptation" + } + } + } + }, + { + "regionTag": "speech_v1_generated_Adaptation_GetPhraseSet_async", + "title": "Adaptation getPhraseSet Sample", + "origin": "API_DEFINITION", + "description": " Get a phrase set.", + "canonical": true, + "file": "adaptation.get_phrase_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetPhraseSet", + "fullName": "google.cloud.speech.v1.Adaptation.GetPhraseSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.speech.v1.PhraseSet", + "client": { + "shortName": "AdaptationClient", + "fullName": "google.cloud.speech.v1.AdaptationClient" + }, + "method": { + "shortName": "GetPhraseSet", + "fullName": "google.cloud.speech.v1.Adaptation.GetPhraseSet", + "service": { + "shortName": "Adaptation", + "fullName": "google.cloud.speech.v1.Adaptation" + } + } + } + }, + { + "regionTag": "speech_v1_generated_Adaptation_ListPhraseSet_async", + "title": "Adaptation listPhraseSet Sample", + "origin": "API_DEFINITION", + "description": " List phrase sets.", + "canonical": true, + "file": "adaptation.list_phrase_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListPhraseSet", + "fullName": "google.cloud.speech.v1.Adaptation.ListPhraseSet", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.speech.v1.ListPhraseSetResponse", + "client": { + "shortName": "AdaptationClient", + "fullName": "google.cloud.speech.v1.AdaptationClient" + }, + "method": { + "shortName": "ListPhraseSet", + "fullName": "google.cloud.speech.v1.Adaptation.ListPhraseSet", + "service": { + "shortName": "Adaptation", + "fullName": "google.cloud.speech.v1.Adaptation" + } + } + } + }, + { + "regionTag": "speech_v1_generated_Adaptation_UpdatePhraseSet_async", + "title": "Adaptation updatePhraseSet Sample", + "origin": "API_DEFINITION", + "description": " Update a phrase set.", + "canonical": true, + "file": "adaptation.update_phrase_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdatePhraseSet", + "fullName": "google.cloud.speech.v1.Adaptation.UpdatePhraseSet", + "async": true, + "parameters": [ + { + "name": "phrase_set", + "type": ".google.cloud.speech.v1.PhraseSet" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.speech.v1.PhraseSet", + "client": { + "shortName": "AdaptationClient", + "fullName": "google.cloud.speech.v1.AdaptationClient" + }, + "method": { + "shortName": "UpdatePhraseSet", + "fullName": "google.cloud.speech.v1.Adaptation.UpdatePhraseSet", + "service": { + "shortName": "Adaptation", + "fullName": "google.cloud.speech.v1.Adaptation" + } + } + } + }, + { + "regionTag": "speech_v1_generated_Adaptation_DeletePhraseSet_async", + "title": "Adaptation deletePhraseSet Sample", + "origin": "API_DEFINITION", + "description": " Delete a phrase set.", + "canonical": true, + "file": "adaptation.delete_phrase_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeletePhraseSet", + "fullName": "google.cloud.speech.v1.Adaptation.DeletePhraseSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "AdaptationClient", + "fullName": "google.cloud.speech.v1.AdaptationClient" + }, + "method": { + "shortName": "DeletePhraseSet", + "fullName": "google.cloud.speech.v1.Adaptation.DeletePhraseSet", + "service": { + "shortName": "Adaptation", + "fullName": "google.cloud.speech.v1.Adaptation" + } + } + } + }, + { + "regionTag": "speech_v1_generated_Adaptation_CreateCustomClass_async", + "title": "Adaptation createCustomClass Sample", + "origin": "API_DEFINITION", + "description": " Create a custom class.", + "canonical": true, + "file": "adaptation.create_custom_class.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateCustomClass", + "fullName": "google.cloud.speech.v1.Adaptation.CreateCustomClass", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "custom_class_id", + "type": "TYPE_STRING" + }, + { + "name": "custom_class", + "type": ".google.cloud.speech.v1.CustomClass" + } + ], + "resultType": ".google.cloud.speech.v1.CustomClass", + "client": { + "shortName": "AdaptationClient", + "fullName": "google.cloud.speech.v1.AdaptationClient" + }, + "method": { + "shortName": "CreateCustomClass", + "fullName": "google.cloud.speech.v1.Adaptation.CreateCustomClass", + "service": { + "shortName": "Adaptation", + "fullName": "google.cloud.speech.v1.Adaptation" + } + } + } + }, + { + "regionTag": "speech_v1_generated_Adaptation_GetCustomClass_async", + "title": "Adaptation getCustomClass Sample", + "origin": "API_DEFINITION", + "description": " Get a custom class.", + "canonical": true, + "file": "adaptation.get_custom_class.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetCustomClass", + "fullName": "google.cloud.speech.v1.Adaptation.GetCustomClass", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.speech.v1.CustomClass", + "client": { + "shortName": "AdaptationClient", + "fullName": "google.cloud.speech.v1.AdaptationClient" + }, + "method": { + "shortName": "GetCustomClass", + "fullName": "google.cloud.speech.v1.Adaptation.GetCustomClass", + "service": { + "shortName": "Adaptation", + "fullName": "google.cloud.speech.v1.Adaptation" + } + } + } + }, + { + "regionTag": "speech_v1_generated_Adaptation_ListCustomClasses_async", + "title": "Adaptation listCustomClasses Sample", + "origin": "API_DEFINITION", + "description": " List custom classes.", + "canonical": true, + "file": "adaptation.list_custom_classes.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListCustomClasses", + "fullName": "google.cloud.speech.v1.Adaptation.ListCustomClasses", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.speech.v1.ListCustomClassesResponse", + "client": { + "shortName": "AdaptationClient", + "fullName": "google.cloud.speech.v1.AdaptationClient" + }, + "method": { + "shortName": "ListCustomClasses", + "fullName": "google.cloud.speech.v1.Adaptation.ListCustomClasses", + "service": { + "shortName": "Adaptation", + "fullName": "google.cloud.speech.v1.Adaptation" + } + } + } + }, + { + "regionTag": "speech_v1_generated_Adaptation_UpdateCustomClass_async", + "title": "Adaptation updateCustomClass Sample", + "origin": "API_DEFINITION", + "description": " Update a custom class.", + "canonical": true, + "file": "adaptation.update_custom_class.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateCustomClass", + "fullName": "google.cloud.speech.v1.Adaptation.UpdateCustomClass", + "async": true, + "parameters": [ + { + "name": "custom_class", + "type": ".google.cloud.speech.v1.CustomClass" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.speech.v1.CustomClass", + "client": { + "shortName": "AdaptationClient", + "fullName": "google.cloud.speech.v1.AdaptationClient" + }, + "method": { + "shortName": "UpdateCustomClass", + "fullName": "google.cloud.speech.v1.Adaptation.UpdateCustomClass", + "service": { + "shortName": "Adaptation", + "fullName": "google.cloud.speech.v1.Adaptation" + } + } + } + }, + { + "regionTag": "speech_v1_generated_Adaptation_DeleteCustomClass_async", + "title": "Adaptation deleteCustomClass Sample", + "origin": "API_DEFINITION", + "description": " Delete a custom class.", + "canonical": true, + "file": "adaptation.delete_custom_class.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteCustomClass", + "fullName": "google.cloud.speech.v1.Adaptation.DeleteCustomClass", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "AdaptationClient", + "fullName": "google.cloud.speech.v1.AdaptationClient" + }, + "method": { + "shortName": "DeleteCustomClass", + "fullName": "google.cloud.speech.v1.Adaptation.DeleteCustomClass", + "service": { + "shortName": "Adaptation", + "fullName": "google.cloud.speech.v1.Adaptation" + } + } + } + }, + { + "regionTag": "speech_v1_generated_Speech_Recognize_async", + "title": "Adaptation recognize Sample", + "origin": "API_DEFINITION", + "description": " Performs synchronous speech recognition: receive results after all audio has been sent and processed.", + "canonical": true, + "file": "speech.recognize.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Recognize", + "fullName": "google.cloud.speech.v1.Speech.Recognize", + "async": true, + "parameters": [ + { + "name": "config", + "type": ".google.cloud.speech.v1.RecognitionConfig" + }, + { + "name": "audio", + "type": ".google.cloud.speech.v1.RecognitionAudio" + } + ], + "resultType": ".google.cloud.speech.v1.RecognizeResponse", + "client": { + "shortName": "SpeechClient", + "fullName": "google.cloud.speech.v1.SpeechClient" + }, + "method": { + "shortName": "Recognize", + "fullName": "google.cloud.speech.v1.Speech.Recognize", + "service": { + "shortName": "Speech", + "fullName": "google.cloud.speech.v1.Speech" + } + } + } + }, + { + "regionTag": "speech_v1_generated_Speech_LongRunningRecognize_async", + "title": "Adaptation longRunningRecognize Sample", + "origin": "API_DEFINITION", + "description": " Performs asynchronous speech recognition: receive results via the google.longrunning.Operations interface. Returns either an `Operation.error` or an `Operation.response` which contains a `LongRunningRecognizeResponse` message. For more information on asynchronous speech recognition, see the [how-to](https://cloud.google.com/speech-to-text/docs/async-recognize).", + "canonical": true, + "file": "speech.long_running_recognize.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 64, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "LongRunningRecognize", + "fullName": "google.cloud.speech.v1.Speech.LongRunningRecognize", + "async": true, + "parameters": [ + { + "name": "config", + "type": ".google.cloud.speech.v1.RecognitionConfig" + }, + { + "name": "audio", + "type": ".google.cloud.speech.v1.RecognitionAudio" + }, + { + "name": "output_config", + "type": ".google.cloud.speech.v1.TranscriptOutputConfig" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "SpeechClient", + "fullName": "google.cloud.speech.v1.SpeechClient" + }, + "method": { + "shortName": "LongRunningRecognize", + "fullName": "google.cloud.speech.v1.Speech.LongRunningRecognize", + "service": { + "shortName": "Speech", + "fullName": "google.cloud.speech.v1.Speech" + } + } + } + }, + { + "regionTag": "speech_v1_generated_Speech_StreamingRecognize_async", + "title": "Adaptation streamingRecognize Sample", + "origin": "API_DEFINITION", + "description": " Performs bidirectional streaming speech recognition: receive results while sending audio. This method is only available via the gRPC API (not REST).", + "canonical": true, + "file": "speech.streaming_recognize.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 69, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "StreamingRecognize", + "fullName": "google.cloud.speech.v1.Speech.StreamingRecognize", + "async": true, + "parameters": [ + { + "name": "streaming_config", + "type": ".google.cloud.speech.v1.StreamingRecognitionConfig" + }, + { + "name": "audio_content", + "type": "TYPE_BYTES" + } + ], + "resultType": ".google.cloud.speech.v1.StreamingRecognizeResponse", + "client": { + "shortName": "SpeechClient", + "fullName": "google.cloud.speech.v1.SpeechClient" + }, + "method": { + "shortName": "StreamingRecognize", + "fullName": "google.cloud.speech.v1.Speech.StreamingRecognize", + "service": { + "shortName": "Speech", + "fullName": "google.cloud.speech.v1.Speech" + } + } + } + } + ] +} diff --git a/owl-bot-staging/v1/samples/generated/v1/speech.long_running_recognize.js b/owl-bot-staging/v1/samples/generated/v1/speech.long_running_recognize.js new file mode 100644 index 00000000..0400a955 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/speech.long_running_recognize.js @@ -0,0 +1,72 @@ +// Copyright 2022 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. ** + + + +'use strict'; + +function main(config, audio) { + // [START speech_v1_generated_Speech_LongRunningRecognize_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Provides information to the recognizer that specifies how to + * process the request. + */ + // const config = {} + /** + * Required. The audio data to be recognized. + */ + // const audio = {} + /** + * Optional. Specifies an optional destination for the recognition results. + */ + // const outputConfig = {} + + // Imports the Speech library + const {SpeechClient} = require('@google-cloud/speech').v1; + + // Instantiates a client + const speechClient = new SpeechClient(); + + async function callLongRunningRecognize() { + // Construct request + const request = { + config, + audio, + }; + + // Run request + const [operation] = await speechClient.longRunningRecognize(request); + const [response] = await operation.promise(); + console.log(response); + } + + callLongRunningRecognize(); + // [END speech_v1_generated_Speech_LongRunningRecognize_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/speech.recognize.js b/owl-bot-staging/v1/samples/generated/v1/speech.recognize.js new file mode 100644 index 00000000..4d3d67cd --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/speech.recognize.js @@ -0,0 +1,67 @@ +// Copyright 2022 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. ** + + + +'use strict'; + +function main(config, audio) { + // [START speech_v1_generated_Speech_Recognize_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Provides information to the recognizer that specifies how to + * process the request. + */ + // const config = {} + /** + * Required. The audio data to be recognized. + */ + // const audio = {} + + // Imports the Speech library + const {SpeechClient} = require('@google-cloud/speech').v1; + + // Instantiates a client + const speechClient = new SpeechClient(); + + async function callRecognize() { + // Construct request + const request = { + config, + audio, + }; + + // Run request + const response = await speechClient.recognize(request); + console.log(response); + } + + callRecognize(); + // [END speech_v1_generated_Speech_Recognize_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/speech.streaming_recognize.js b/owl-bot-staging/v1/samples/generated/v1/speech.streaming_recognize.js new file mode 100644 index 00000000..39205be9 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/speech.streaming_recognize.js @@ -0,0 +1,77 @@ +// Copyright 2022 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. ** + + + +'use strict'; + +function main() { + // [START speech_v1_generated_Speech_StreamingRecognize_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Provides information to the recognizer that specifies how to process the + * request. The first `StreamingRecognizeRequest` message must contain a + * `streaming_config` message. + */ + // const streamingConfig = {} + /** + * The audio data to be recognized. Sequential chunks of audio data are sent + * in sequential `StreamingRecognizeRequest` messages. The first + * `StreamingRecognizeRequest` message must not contain `audio_content` data + * and all subsequent `StreamingRecognizeRequest` messages must contain + * `audio_content` data. The audio bytes must be encoded as specified in + * `RecognitionConfig`. Note: as with all bytes fields, proto buffers use a + * pure binary representation (not base64). See + * content limits (https://cloud.google.com/speech-to-text/quotas#content). + */ + // const audioContent = 'Buffer.from('string')' + + // Imports the Speech library + const {SpeechClient} = require('@google-cloud/speech').v1; + + // Instantiates a client + const speechClient = new SpeechClient(); + + async function callStreamingRecognize() { + // Construct request + const request = { + }; + + // Run request + const stream = await speechClient.streamingRecognize(); + stream.on('data', (response) => { console.log(response) }); + stream.on('error', (err) => { throw(err) }); + stream.on('end', () => { /* API call completed */ }); + stream.write(request); + stream.end(); + } + + callStreamingRecognize(); + // [END speech_v1_generated_Speech_StreamingRecognize_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/src/index.ts b/owl-bot-staging/v1/src/index.ts new file mode 100644 index 00000000..5ea8dd11 --- /dev/null +++ b/owl-bot-staging/v1/src/index.ts @@ -0,0 +1,27 @@ +// Copyright 2022 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. ** + +import * as v1 from './v1'; +const AdaptationClient = v1.AdaptationClient; +type AdaptationClient = v1.AdaptationClient; +const SpeechClient = v1.SpeechClient; +type SpeechClient = v1.SpeechClient; +export {v1, AdaptationClient, SpeechClient}; +export default {v1, AdaptationClient, SpeechClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/v1/src/v1/adaptation_client.ts b/owl-bot-staging/v1/src/v1/adaptation_client.ts new file mode 100644 index 00000000..f7f3f0aa --- /dev/null +++ b/owl-bot-staging/v1/src/v1/adaptation_client.ts @@ -0,0 +1,1578 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/adaptation_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './adaptation_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service that implements Google Cloud Speech Adaptation API. + * @class + * @memberof v1 + */ +export class AdaptationClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + adaptationStub?: Promise<{[name: string]: Function}>; + + /** + * 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/main/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new AdaptationClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof AdaptationClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // 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.v1.Adaptation', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = this._gaxModule.warn; + } + + /** + * 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.v1.Adaptation. + this.adaptationStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.speech.v1.Adaptation') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.speech.v1.Adaptation, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // 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: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + 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' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * 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: + * + * `projects/{project}/locations/{location}/phraseSets` + * + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + * @param {string} request.phraseSetId + * Required. The ID to use for the phrase set, which will become the final + * component of the phrase set's resource name. + * + * This value should restrict to letters, numbers, and hyphens, with the first + * character a letter, the last a letter or a number, and be 4-63 characters. + * @param {google.cloud.speech.v1.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.v1.PhraseSet}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/adaptation.create_phrase_set.js + * region_tag:speech_v1_generated_Adaptation_CreatePhraseSet_async + */ + createPhraseSet( + request?: protos.google.cloud.speech.v1.ICreatePhraseSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.speech.v1.IPhraseSet, + protos.google.cloud.speech.v1.ICreatePhraseSetRequest|undefined, {}|undefined + ]>; + createPhraseSet( + request: protos.google.cloud.speech.v1.ICreatePhraseSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.speech.v1.IPhraseSet, + protos.google.cloud.speech.v1.ICreatePhraseSetRequest|null|undefined, + {}|null|undefined>): void; + createPhraseSet( + request: protos.google.cloud.speech.v1.ICreatePhraseSetRequest, + callback: Callback< + protos.google.cloud.speech.v1.IPhraseSet, + protos.google.cloud.speech.v1.ICreatePhraseSetRequest|null|undefined, + {}|null|undefined>): void; + createPhraseSet( + request?: protos.google.cloud.speech.v1.ICreatePhraseSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.speech.v1.IPhraseSet, + protos.google.cloud.speech.v1.ICreatePhraseSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.speech.v1.IPhraseSet, + protos.google.cloud.speech.v1.ICreatePhraseSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.speech.v1.IPhraseSet, + protos.google.cloud.speech.v1.ICreatePhraseSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.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: + * + * `projects/{project}/locations/{location}/phraseSets/{phrase_set}` + * + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + * @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.v1.PhraseSet}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/adaptation.get_phrase_set.js + * region_tag:speech_v1_generated_Adaptation_GetPhraseSet_async + */ + getPhraseSet( + request?: protos.google.cloud.speech.v1.IGetPhraseSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.speech.v1.IPhraseSet, + protos.google.cloud.speech.v1.IGetPhraseSetRequest|undefined, {}|undefined + ]>; + getPhraseSet( + request: protos.google.cloud.speech.v1.IGetPhraseSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.speech.v1.IPhraseSet, + protos.google.cloud.speech.v1.IGetPhraseSetRequest|null|undefined, + {}|null|undefined>): void; + getPhraseSet( + request: protos.google.cloud.speech.v1.IGetPhraseSetRequest, + callback: Callback< + protos.google.cloud.speech.v1.IPhraseSet, + protos.google.cloud.speech.v1.IGetPhraseSetRequest|null|undefined, + {}|null|undefined>): void; + getPhraseSet( + request?: protos.google.cloud.speech.v1.IGetPhraseSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.speech.v1.IPhraseSet, + protos.google.cloud.speech.v1.IGetPhraseSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.speech.v1.IPhraseSet, + protos.google.cloud.speech.v1.IGetPhraseSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.speech.v1.IPhraseSet, + protos.google.cloud.speech.v1.IGetPhraseSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.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.v1.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: + * + * `projects/{project}/locations/{location}/phraseSets/{phrase_set}` + * + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + * @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.v1.PhraseSet}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/adaptation.update_phrase_set.js + * region_tag:speech_v1_generated_Adaptation_UpdatePhraseSet_async + */ + updatePhraseSet( + request?: protos.google.cloud.speech.v1.IUpdatePhraseSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.speech.v1.IPhraseSet, + protos.google.cloud.speech.v1.IUpdatePhraseSetRequest|undefined, {}|undefined + ]>; + updatePhraseSet( + request: protos.google.cloud.speech.v1.IUpdatePhraseSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.speech.v1.IPhraseSet, + protos.google.cloud.speech.v1.IUpdatePhraseSetRequest|null|undefined, + {}|null|undefined>): void; + updatePhraseSet( + request: protos.google.cloud.speech.v1.IUpdatePhraseSetRequest, + callback: Callback< + protos.google.cloud.speech.v1.IPhraseSet, + protos.google.cloud.speech.v1.IUpdatePhraseSetRequest|null|undefined, + {}|null|undefined>): void; + updatePhraseSet( + request?: protos.google.cloud.speech.v1.IUpdatePhraseSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.speech.v1.IPhraseSet, + protos.google.cloud.speech.v1.IUpdatePhraseSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.speech.v1.IPhraseSet, + protos.google.cloud.speech.v1.IUpdatePhraseSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.speech.v1.IPhraseSet, + protos.google.cloud.speech.v1.IUpdatePhraseSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.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: + * + * `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 include:samples/generated/v1/adaptation.delete_phrase_set.js + * region_tag:speech_v1_generated_Adaptation_DeletePhraseSet_async + */ + deletePhraseSet( + request?: protos.google.cloud.speech.v1.IDeletePhraseSetRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.speech.v1.IDeletePhraseSetRequest|undefined, {}|undefined + ]>; + deletePhraseSet( + request: protos.google.cloud.speech.v1.IDeletePhraseSetRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.speech.v1.IDeletePhraseSetRequest|null|undefined, + {}|null|undefined>): void; + deletePhraseSet( + request: protos.google.cloud.speech.v1.IDeletePhraseSetRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.speech.v1.IDeletePhraseSetRequest|null|undefined, + {}|null|undefined>): void; + deletePhraseSet( + request?: protos.google.cloud.speech.v1.IDeletePhraseSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.speech.v1.IDeletePhraseSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.speech.v1.IDeletePhraseSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.speech.v1.IDeletePhraseSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.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: + * + * `projects/{project}/locations/{location}/customClasses` + * + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + * @param {string} request.customClassId + * Required. The ID to use for the custom class, which will become the final + * component of the custom class' resource name. + * + * This value should restrict to letters, numbers, and hyphens, with the first + * character a letter, the last a letter or a number, and be 4-63 characters. + * @param {google.cloud.speech.v1.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.v1.CustomClass}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/adaptation.create_custom_class.js + * region_tag:speech_v1_generated_Adaptation_CreateCustomClass_async + */ + createCustomClass( + request?: protos.google.cloud.speech.v1.ICreateCustomClassRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.speech.v1.ICustomClass, + protos.google.cloud.speech.v1.ICreateCustomClassRequest|undefined, {}|undefined + ]>; + createCustomClass( + request: protos.google.cloud.speech.v1.ICreateCustomClassRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.speech.v1.ICustomClass, + protos.google.cloud.speech.v1.ICreateCustomClassRequest|null|undefined, + {}|null|undefined>): void; + createCustomClass( + request: protos.google.cloud.speech.v1.ICreateCustomClassRequest, + callback: Callback< + protos.google.cloud.speech.v1.ICustomClass, + protos.google.cloud.speech.v1.ICreateCustomClassRequest|null|undefined, + {}|null|undefined>): void; + createCustomClass( + request?: protos.google.cloud.speech.v1.ICreateCustomClassRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.speech.v1.ICustomClass, + protos.google.cloud.speech.v1.ICreateCustomClassRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.speech.v1.ICustomClass, + protos.google.cloud.speech.v1.ICreateCustomClassRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.speech.v1.ICustomClass, + protos.google.cloud.speech.v1.ICreateCustomClassRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.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: + * + * `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.v1.CustomClass}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/adaptation.get_custom_class.js + * region_tag:speech_v1_generated_Adaptation_GetCustomClass_async + */ + getCustomClass( + request?: protos.google.cloud.speech.v1.IGetCustomClassRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.speech.v1.ICustomClass, + protos.google.cloud.speech.v1.IGetCustomClassRequest|undefined, {}|undefined + ]>; + getCustomClass( + request: protos.google.cloud.speech.v1.IGetCustomClassRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.speech.v1.ICustomClass, + protos.google.cloud.speech.v1.IGetCustomClassRequest|null|undefined, + {}|null|undefined>): void; + getCustomClass( + request: protos.google.cloud.speech.v1.IGetCustomClassRequest, + callback: Callback< + protos.google.cloud.speech.v1.ICustomClass, + protos.google.cloud.speech.v1.IGetCustomClassRequest|null|undefined, + {}|null|undefined>): void; + getCustomClass( + request?: protos.google.cloud.speech.v1.IGetCustomClassRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.speech.v1.ICustomClass, + protos.google.cloud.speech.v1.IGetCustomClassRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.speech.v1.ICustomClass, + protos.google.cloud.speech.v1.IGetCustomClassRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.speech.v1.ICustomClass, + protos.google.cloud.speech.v1.IGetCustomClassRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.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.v1.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: + * + * `projects/{project}/locations/{location}/customClasses/{custom_class}` + * + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + * @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.v1.CustomClass}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/adaptation.update_custom_class.js + * region_tag:speech_v1_generated_Adaptation_UpdateCustomClass_async + */ + updateCustomClass( + request?: protos.google.cloud.speech.v1.IUpdateCustomClassRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.speech.v1.ICustomClass, + protos.google.cloud.speech.v1.IUpdateCustomClassRequest|undefined, {}|undefined + ]>; + updateCustomClass( + request: protos.google.cloud.speech.v1.IUpdateCustomClassRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.speech.v1.ICustomClass, + protos.google.cloud.speech.v1.IUpdateCustomClassRequest|null|undefined, + {}|null|undefined>): void; + updateCustomClass( + request: protos.google.cloud.speech.v1.IUpdateCustomClassRequest, + callback: Callback< + protos.google.cloud.speech.v1.ICustomClass, + protos.google.cloud.speech.v1.IUpdateCustomClassRequest|null|undefined, + {}|null|undefined>): void; + updateCustomClass( + request?: protos.google.cloud.speech.v1.IUpdateCustomClassRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.speech.v1.ICustomClass, + protos.google.cloud.speech.v1.IUpdateCustomClassRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.speech.v1.ICustomClass, + protos.google.cloud.speech.v1.IUpdateCustomClassRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.speech.v1.ICustomClass, + protos.google.cloud.speech.v1.IUpdateCustomClassRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.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: + * + * `projects/{project}/locations/{location}/customClasses/{custom_class}` + * + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + * @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 include:samples/generated/v1/adaptation.delete_custom_class.js + * region_tag:speech_v1_generated_Adaptation_DeleteCustomClass_async + */ + deleteCustomClass( + request?: protos.google.cloud.speech.v1.IDeleteCustomClassRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.speech.v1.IDeleteCustomClassRequest|undefined, {}|undefined + ]>; + deleteCustomClass( + request: protos.google.cloud.speech.v1.IDeleteCustomClassRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.speech.v1.IDeleteCustomClassRequest|null|undefined, + {}|null|undefined>): void; + deleteCustomClass( + request: protos.google.cloud.speech.v1.IDeleteCustomClassRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.speech.v1.IDeleteCustomClassRequest|null|undefined, + {}|null|undefined>): void; + deleteCustomClass( + request?: protos.google.cloud.speech.v1.IDeleteCustomClassRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.speech.v1.IDeleteCustomClassRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.speech.v1.IDeleteCustomClassRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.speech.v1.IDeleteCustomClassRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.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}` + * + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + * @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.v1.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?: protos.google.cloud.speech.v1.IListPhraseSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.speech.v1.IPhraseSet[], + protos.google.cloud.speech.v1.IListPhraseSetRequest|null, + protos.google.cloud.speech.v1.IListPhraseSetResponse + ]>; + listPhraseSet( + request: protos.google.cloud.speech.v1.IListPhraseSetRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.speech.v1.IListPhraseSetRequest, + protos.google.cloud.speech.v1.IListPhraseSetResponse|null|undefined, + protos.google.cloud.speech.v1.IPhraseSet>): void; + listPhraseSet( + request: protos.google.cloud.speech.v1.IListPhraseSetRequest, + callback: PaginationCallback< + protos.google.cloud.speech.v1.IListPhraseSetRequest, + protos.google.cloud.speech.v1.IListPhraseSetResponse|null|undefined, + protos.google.cloud.speech.v1.IPhraseSet>): void; + listPhraseSet( + request?: protos.google.cloud.speech.v1.IListPhraseSetRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.speech.v1.IListPhraseSetRequest, + protos.google.cloud.speech.v1.IListPhraseSetResponse|null|undefined, + protos.google.cloud.speech.v1.IPhraseSet>, + callback?: PaginationCallback< + protos.google.cloud.speech.v1.IListPhraseSetRequest, + protos.google.cloud.speech.v1.IListPhraseSetResponse|null|undefined, + protos.google.cloud.speech.v1.IPhraseSet>): + Promise<[ + protos.google.cloud.speech.v1.IPhraseSet[], + protos.google.cloud.speech.v1.IListPhraseSetRequest|null, + protos.google.cloud.speech.v1.IListPhraseSetResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.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}` + * + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + * @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.v1.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?: protos.google.cloud.speech.v1.IListPhraseSetRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listPhraseSet']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listPhraseSet.createStream( + this.innerApiCalls.listPhraseSet as GaxCall, + 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}` + * + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + * @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.v1.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 include:samples/generated/v1/adaptation.list_phrase_set.js + * region_tag:speech_v1_generated_Adaptation_ListPhraseSet_async + */ + listPhraseSetAsync( + request?: protos.google.cloud.speech.v1.IListPhraseSetRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listPhraseSet']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listPhraseSet.asyncIterate( + this.innerApiCalls['listPhraseSet'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * 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: + * + * `projects/{project}/locations/{location}/customClasses` + * + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + * @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.v1.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?: protos.google.cloud.speech.v1.IListCustomClassesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.speech.v1.ICustomClass[], + protos.google.cloud.speech.v1.IListCustomClassesRequest|null, + protos.google.cloud.speech.v1.IListCustomClassesResponse + ]>; + listCustomClasses( + request: protos.google.cloud.speech.v1.IListCustomClassesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.speech.v1.IListCustomClassesRequest, + protos.google.cloud.speech.v1.IListCustomClassesResponse|null|undefined, + protos.google.cloud.speech.v1.ICustomClass>): void; + listCustomClasses( + request: protos.google.cloud.speech.v1.IListCustomClassesRequest, + callback: PaginationCallback< + protos.google.cloud.speech.v1.IListCustomClassesRequest, + protos.google.cloud.speech.v1.IListCustomClassesResponse|null|undefined, + protos.google.cloud.speech.v1.ICustomClass>): void; + listCustomClasses( + request?: protos.google.cloud.speech.v1.IListCustomClassesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.speech.v1.IListCustomClassesRequest, + protos.google.cloud.speech.v1.IListCustomClassesResponse|null|undefined, + protos.google.cloud.speech.v1.ICustomClass>, + callback?: PaginationCallback< + protos.google.cloud.speech.v1.IListCustomClassesRequest, + protos.google.cloud.speech.v1.IListCustomClassesResponse|null|undefined, + protos.google.cloud.speech.v1.ICustomClass>): + Promise<[ + protos.google.cloud.speech.v1.ICustomClass[], + protos.google.cloud.speech.v1.IListCustomClassesRequest|null, + protos.google.cloud.speech.v1.IListCustomClassesResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.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: + * + * `projects/{project}/locations/{location}/customClasses` + * + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + * @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.v1.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?: protos.google.cloud.speech.v1.IListCustomClassesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listCustomClasses']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listCustomClasses.createStream( + this.innerApiCalls.listCustomClasses as GaxCall, + 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: + * + * `projects/{project}/locations/{location}/customClasses` + * + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + * @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.v1.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 include:samples/generated/v1/adaptation.list_custom_classes.js + * region_tag:speech_v1_generated_Adaptation_ListCustomClasses_async + */ + listCustomClassesAsync( + request?: protos.google.cloud.speech.v1.IListCustomClassesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listCustomClasses']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listCustomClasses.asyncIterate( + this.innerApiCalls['listCustomClasses'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- 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:string,location:string,customClass:string) { + 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: string) { + 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: string) { + 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: string) { + 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:string,location:string) { + 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: string) { + 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: string) { + 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:string,location:string,phraseSet:string) { + 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: string) { + 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: string) { + 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: string) { + 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:string) { + 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: string) { + 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(): Promise { + if (this.adaptationStub && !this._terminated) { + return this.adaptationStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1/src/v1/adaptation_client_config.json b/owl-bot-staging/v1/src/v1/adaptation_client_config.json new file mode 100644 index 00000000..029e9b88 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/adaptation_client_config.json @@ -0,0 +1,66 @@ +{ + "interfaces": { + "google.cloud.speech.v1.Adaptation": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "CreatePhraseSet": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetPhraseSet": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListPhraseSet": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdatePhraseSet": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeletePhraseSet": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateCustomClass": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetCustomClass": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListCustomClasses": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateCustomClass": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteCustomClass": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1/src/v1/adaptation_proto_list.json b/owl-bot-staging/v1/src/v1/adaptation_proto_list.json new file mode 100644 index 00000000..46afac3f --- /dev/null +++ b/owl-bot-staging/v1/src/v1/adaptation_proto_list.json @@ -0,0 +1,5 @@ +[ + "../../protos/google/cloud/speech/v1/cloud_speech.proto", + "../../protos/google/cloud/speech/v1/cloud_speech_adaptation.proto", + "../../protos/google/cloud/speech/v1/resource.proto" +] diff --git a/owl-bot-staging/v1/src/v1/gapic_metadata.json b/owl-bot-staging/v1/src/v1/gapic_metadata.json new file mode 100644 index 00000000..96f60b3c --- /dev/null +++ b/owl-bot-staging/v1/src/v1/gapic_metadata.json @@ -0,0 +1,170 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.speech.v1", + "libraryPackage": "@google-cloud/speech", + "services": { + "Adaptation": { + "clients": { + "grpc": { + "libraryClient": "AdaptationClient", + "rpcs": { + "CreatePhraseSet": { + "methods": [ + "createPhraseSet" + ] + }, + "GetPhraseSet": { + "methods": [ + "getPhraseSet" + ] + }, + "UpdatePhraseSet": { + "methods": [ + "updatePhraseSet" + ] + }, + "DeletePhraseSet": { + "methods": [ + "deletePhraseSet" + ] + }, + "CreateCustomClass": { + "methods": [ + "createCustomClass" + ] + }, + "GetCustomClass": { + "methods": [ + "getCustomClass" + ] + }, + "UpdateCustomClass": { + "methods": [ + "updateCustomClass" + ] + }, + "DeleteCustomClass": { + "methods": [ + "deleteCustomClass" + ] + }, + "ListPhraseSet": { + "methods": [ + "listPhraseSet", + "listPhraseSetStream", + "listPhraseSetAsync" + ] + }, + "ListCustomClasses": { + "methods": [ + "listCustomClasses", + "listCustomClassesStream", + "listCustomClassesAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "AdaptationClient", + "rpcs": { + "CreatePhraseSet": { + "methods": [ + "createPhraseSet" + ] + }, + "GetPhraseSet": { + "methods": [ + "getPhraseSet" + ] + }, + "UpdatePhraseSet": { + "methods": [ + "updatePhraseSet" + ] + }, + "DeletePhraseSet": { + "methods": [ + "deletePhraseSet" + ] + }, + "CreateCustomClass": { + "methods": [ + "createCustomClass" + ] + }, + "GetCustomClass": { + "methods": [ + "getCustomClass" + ] + }, + "UpdateCustomClass": { + "methods": [ + "updateCustomClass" + ] + }, + "DeleteCustomClass": { + "methods": [ + "deleteCustomClass" + ] + }, + "ListPhraseSet": { + "methods": [ + "listPhraseSet", + "listPhraseSetStream", + "listPhraseSetAsync" + ] + }, + "ListCustomClasses": { + "methods": [ + "listCustomClasses", + "listCustomClassesStream", + "listCustomClassesAsync" + ] + } + } + } + } + }, + "Speech": { + "clients": { + "grpc": { + "libraryClient": "SpeechClient", + "rpcs": { + "Recognize": { + "methods": [ + "recognize" + ] + }, + "StreamingRecognize": { + "methods": [ + "streamingRecognize" + ] + }, + "LongRunningRecognize": { + "methods": [ + "longRunningRecognize" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "SpeechClient", + "rpcs": { + "Recognize": { + "methods": [ + "recognize" + ] + }, + "LongRunningRecognize": { + "methods": [ + "longRunningRecognize" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v1/src/v1/index.ts b/owl-bot-staging/v1/src/v1/index.ts new file mode 100644 index 00000000..5b4cfbf4 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/index.ts @@ -0,0 +1,20 @@ +// Copyright 2022 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. ** + +export {AdaptationClient} from './adaptation_client'; +export {SpeechClient} from './speech_client'; diff --git a/owl-bot-staging/v1/src/v1/speech_client.ts b/owl-bot-staging/v1/src/v1/speech_client.ts new file mode 100644 index 00000000..b79549d7 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/speech_client.ts @@ -0,0 +1,649 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation} from 'google-gax'; +import {PassThrough} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/speech_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './speech_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service that implements Google Cloud Speech API. + * @class + * @memberof v1 + */ +export class SpeechClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + speechStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of SpeechClient. + * + * @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/main/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new SpeechClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof SpeechClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // 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}' + ), + phraseSetPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/phraseSets/{phrase_set}' + ), + }; + + // Some of the methods on this service provide streaming responses. + // Provide descriptors for these. + this.descriptors.stream = { + streamingRecognize: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.BIDI_STREAMING, opts.fallback === 'rest') + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/operations/{name=**}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1/operations',}]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const longRunningRecognizeResponse = protoFilesRoot.lookup( + '.google.cloud.speech.v1.LongRunningRecognizeResponse') as gax.protobuf.Type; + const longRunningRecognizeMetadata = protoFilesRoot.lookup( + '.google.cloud.speech.v1.LongRunningRecognizeMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + longRunningRecognize: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + longRunningRecognizeResponse.decode.bind(longRunningRecognizeResponse), + longRunningRecognizeMetadata.decode.bind(longRunningRecognizeMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.speech.v1.Speech', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = this._gaxModule.warn; + } + + /** + * 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.speechStub) { + return this.speechStub; + } + + // Put together the "service stub" for + // google.cloud.speech.v1.Speech. + this.speechStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.speech.v1.Speech') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.speech.v1.Speech, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const speechStubMethods = + ['recognize', 'longRunningRecognize', 'streamingRecognize']; + for (const methodName of speechStubMethods) { + const callPromise = this.speechStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + if (methodName in this.descriptors.stream) { + const stream = new PassThrough(); + setImmediate(() => { + stream.emit('error', new this._gaxModule.GoogleError('The client has already been closed.')); + }); + return stream; + } + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.stream[methodName] || + this.descriptors.longrunning[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.speechStub; + } + + /** + * 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' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Performs synchronous speech recognition: receive results after all audio + * has been sent and processed. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.speech.v1.RecognitionConfig} request.config + * Required. Provides information to the recognizer that specifies how to + * process the request. + * @param {google.cloud.speech.v1.RecognitionAudio} request.audio + * Required. The audio data to be recognized. + * @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 [RecognizeResponse]{@link google.cloud.speech.v1.RecognizeResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/speech.recognize.js + * region_tag:speech_v1_generated_Speech_Recognize_async + */ + recognize( + request?: protos.google.cloud.speech.v1.IRecognizeRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.speech.v1.IRecognizeResponse, + protos.google.cloud.speech.v1.IRecognizeRequest|undefined, {}|undefined + ]>; + recognize( + request: protos.google.cloud.speech.v1.IRecognizeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.speech.v1.IRecognizeResponse, + protos.google.cloud.speech.v1.IRecognizeRequest|null|undefined, + {}|null|undefined>): void; + recognize( + request: protos.google.cloud.speech.v1.IRecognizeRequest, + callback: Callback< + protos.google.cloud.speech.v1.IRecognizeResponse, + protos.google.cloud.speech.v1.IRecognizeRequest|null|undefined, + {}|null|undefined>): void; + recognize( + request?: protos.google.cloud.speech.v1.IRecognizeRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.speech.v1.IRecognizeResponse, + protos.google.cloud.speech.v1.IRecognizeRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.speech.v1.IRecognizeResponse, + protos.google.cloud.speech.v1.IRecognizeRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.speech.v1.IRecognizeResponse, + protos.google.cloud.speech.v1.IRecognizeRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + this.initialize(); + return this.innerApiCalls.recognize(request, options, callback); + } + +/** + * Performs bidirectional streaming speech recognition: receive results while + * sending audio. This method is only available via the gRPC API (not REST). + * + * @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 is both readable and writable. It accepts objects + * representing [StreamingRecognizeRequest]{@link google.cloud.speech.v1.StreamingRecognizeRequest} for write() method, and + * will emit objects representing [StreamingRecognizeResponse]{@link google.cloud.speech.v1.StreamingRecognizeResponse} on 'data' event asynchronously. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#bi-directional-streaming) + * for more details and examples. + * @example include:samples/generated/v1/speech.streaming_recognize.js + * region_tag:speech_v1_generated_Speech_StreamingRecognize_async + */ + streamingRecognize( + options?: CallOptions): + gax.CancellableStream { + this.initialize(); + return this.innerApiCalls.streamingRecognize(null, options); + } + +/** + * Performs asynchronous speech recognition: receive results via the + * google.longrunning.Operations interface. Returns either an + * `Operation.error` or an `Operation.response` which contains + * a `LongRunningRecognizeResponse` message. + * For more information on asynchronous speech recognition, see the + * [how-to](https://cloud.google.com/speech-to-text/docs/async-recognize). + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.speech.v1.RecognitionConfig} request.config + * Required. Provides information to the recognizer that specifies how to + * process the request. + * @param {google.cloud.speech.v1.RecognitionAudio} request.audio + * Required. The audio data to be recognized. + * @param {google.cloud.speech.v1.TranscriptOutputConfig} [request.outputConfig] + * Optional. Specifies an optional destination for the recognition results. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/speech.long_running_recognize.js + * region_tag:speech_v1_generated_Speech_LongRunningRecognize_async + */ + longRunningRecognize( + request?: protos.google.cloud.speech.v1.ILongRunningRecognizeRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + longRunningRecognize( + request: protos.google.cloud.speech.v1.ILongRunningRecognizeRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + longRunningRecognize( + request: protos.google.cloud.speech.v1.ILongRunningRecognizeRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + longRunningRecognize( + request?: protos.google.cloud.speech.v1.ILongRunningRecognizeRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + this.initialize(); + return this.innerApiCalls.longRunningRecognize(request, options, callback); + } +/** + * Check the status of the long running operation returned by `longRunningRecognize()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/speech.long_running_recognize.js + * region_tag:speech_v1_generated_Speech_LongRunningRecognize_async + */ + async checkLongRunningRecognizeProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.longRunningRecognize, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + // -------------------- + // -- 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:string,location:string,customClass:string) { + 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: string) { + 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: string) { + 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: string) { + return this.pathTemplates.customClassPathTemplate.match(customClassName).custom_class; + } + + /** + * 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:string,location:string,phraseSet:string) { + 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: string) { + 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: string) { + 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: string) { + return this.pathTemplates.phraseSetPathTemplate.match(phraseSetName).phrase_set; + } + + /** + * 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(): Promise { + if (this.speechStub && !this._terminated) { + return this.speechStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1/src/v1/speech_client_config.json b/owl-bot-staging/v1/src/v1/speech_client_config.json new file mode 100644 index 00000000..35b04f64 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/speech_client_config.json @@ -0,0 +1,41 @@ +{ + "interfaces": { + "google.cloud.speech.v1.Speech": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "Recognize": { + "timeout_millis": 5000000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "LongRunningRecognize": { + "timeout_millis": 5000000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "StreamingRecognize": { + "timeout_millis": 5000000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1/src/v1/speech_proto_list.json b/owl-bot-staging/v1/src/v1/speech_proto_list.json new file mode 100644 index 00000000..46afac3f --- /dev/null +++ b/owl-bot-staging/v1/src/v1/speech_proto_list.json @@ -0,0 +1,5 @@ +[ + "../../protos/google/cloud/speech/v1/cloud_speech.proto", + "../../protos/google/cloud/speech/v1/cloud_speech_adaptation.proto", + "../../protos/google/cloud/speech/v1/resource.proto" +] diff --git a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000..36731b35 --- /dev/null +++ b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js @@ -0,0 +1,28 @@ +// Copyright 2022 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. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const speech = require('@google-cloud/speech'); + +function main() { + const adaptationClient = new speech.AdaptationClient(); + const speechClient = new speech.SpeechClient(); +} + +main(); diff --git a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000..1c746cf8 --- /dev/null +++ b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,38 @@ +// Copyright 2022 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. ** + +import {AdaptationClient, SpeechClient} from '@google-cloud/speech'; + +// check that the client class type name can be used +function doStuffWithAdaptationClient(client: AdaptationClient) { + client.close(); +} +function doStuffWithSpeechClient(client: SpeechClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const adaptationClient = new AdaptationClient(); + doStuffWithAdaptationClient(adaptationClient); + // check that the client instance can be created + const speechClient = new SpeechClient(); + doStuffWithSpeechClient(speechClient); +} + +main(); diff --git a/owl-bot-staging/v1/system-test/install.ts b/owl-bot-staging/v1/system-test/install.ts new file mode 100644 index 00000000..557a5755 --- /dev/null +++ b/owl-bot-staging/v1/system-test/install.ts @@ -0,0 +1,49 @@ +// Copyright 2022 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. ** + +import {packNTest} from 'pack-n-play'; +import {readFileSync} from 'fs'; +import {describe, it} from 'mocha'; + +describe('📦 pack-n-play test', () => { + + it('TypeScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'TypeScript user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() + } + }; + await packNTest(options); + }); + + it('JavaScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'JavaScript user can use the library', + ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() + } + }; + await packNTest(options); + }); + +}); diff --git a/owl-bot-staging/v1/test/gapic_adaptation_v1.ts b/owl-bot-staging/v1/test/gapic_adaptation_v1.ts new file mode 100644 index 00000000..45fdade1 --- /dev/null +++ b/owl-bot-staging/v1/test/gapic_adaptation_v1.ts @@ -0,0 +1,1722 @@ +// Copyright 2022 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. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as adaptationModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1.AdaptationClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = adaptationModule.v1.AdaptationClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = adaptationModule.v1.AdaptationClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = adaptationModule.v1.AdaptationClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new adaptationModule.v1.AdaptationClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new adaptationModule.v1.AdaptationClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.adaptationStub, undefined); + await client.initialize(); + assert(client.adaptationStub); + }); + + it('has close method for the initialized client', done => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.adaptationStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.adaptationStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new adaptationModule.v1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new adaptationModule.v1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('createPhraseSet', () => { + it('invokes createPhraseSet without error', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.CreatePhraseSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('CreatePhraseSetRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1.PhraseSet() + ); + client.innerApiCalls.createPhraseSet = stubSimpleCall(expectedResponse); + const [response] = await client.createPhraseSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createPhraseSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createPhraseSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createPhraseSet without error using callback', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.CreatePhraseSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('CreatePhraseSetRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1.PhraseSet() + ); + client.innerApiCalls.createPhraseSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createPhraseSet( + request, + (err?: Error|null, result?: protos.google.cloud.speech.v1.IPhraseSet|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createPhraseSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createPhraseSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createPhraseSet with error', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.CreatePhraseSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('CreatePhraseSetRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createPhraseSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createPhraseSet(request), expectedError); + const actualRequest = (client.innerApiCalls.createPhraseSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createPhraseSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createPhraseSet with closed client', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.CreatePhraseSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('CreatePhraseSetRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createPhraseSet(request), expectedError); + }); + }); + + describe('getPhraseSet', () => { + it('invokes getPhraseSet without error', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.GetPhraseSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('GetPhraseSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1.PhraseSet() + ); + client.innerApiCalls.getPhraseSet = stubSimpleCall(expectedResponse); + const [response] = await client.getPhraseSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getPhraseSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getPhraseSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getPhraseSet without error using callback', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.GetPhraseSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('GetPhraseSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1.PhraseSet() + ); + client.innerApiCalls.getPhraseSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getPhraseSet( + request, + (err?: Error|null, result?: protos.google.cloud.speech.v1.IPhraseSet|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getPhraseSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getPhraseSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getPhraseSet with error', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.GetPhraseSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('GetPhraseSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getPhraseSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getPhraseSet(request), expectedError); + const actualRequest = (client.innerApiCalls.getPhraseSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getPhraseSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getPhraseSet with closed client', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.GetPhraseSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('GetPhraseSetRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getPhraseSet(request), expectedError); + }); + }); + + describe('updatePhraseSet', () => { + it('invokes updatePhraseSet without error', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.UpdatePhraseSetRequest() + ); + request.phraseSet ??= {}; + const defaultValue1 = + getTypeDefaultValue('UpdatePhraseSetRequest', ['phraseSet', 'name']); + request.phraseSet.name = defaultValue1; + const expectedHeaderRequestParams = `phrase_set.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1.PhraseSet() + ); + client.innerApiCalls.updatePhraseSet = stubSimpleCall(expectedResponse); + const [response] = await client.updatePhraseSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updatePhraseSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updatePhraseSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updatePhraseSet without error using callback', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.UpdatePhraseSetRequest() + ); + request.phraseSet ??= {}; + const defaultValue1 = + getTypeDefaultValue('UpdatePhraseSetRequest', ['phraseSet', 'name']); + request.phraseSet.name = defaultValue1; + const expectedHeaderRequestParams = `phrase_set.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1.PhraseSet() + ); + client.innerApiCalls.updatePhraseSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updatePhraseSet( + request, + (err?: Error|null, result?: protos.google.cloud.speech.v1.IPhraseSet|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updatePhraseSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updatePhraseSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updatePhraseSet with error', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.UpdatePhraseSetRequest() + ); + request.phraseSet ??= {}; + const defaultValue1 = + getTypeDefaultValue('UpdatePhraseSetRequest', ['phraseSet', 'name']); + request.phraseSet.name = defaultValue1; + const expectedHeaderRequestParams = `phrase_set.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updatePhraseSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updatePhraseSet(request), expectedError); + const actualRequest = (client.innerApiCalls.updatePhraseSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updatePhraseSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updatePhraseSet with closed client', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.UpdatePhraseSetRequest() + ); + request.phraseSet ??= {}; + const defaultValue1 = + getTypeDefaultValue('UpdatePhraseSetRequest', ['phraseSet', 'name']); + request.phraseSet.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updatePhraseSet(request), expectedError); + }); + }); + + describe('deletePhraseSet', () => { + it('invokes deletePhraseSet without error', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.DeletePhraseSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('DeletePhraseSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deletePhraseSet = stubSimpleCall(expectedResponse); + const [response] = await client.deletePhraseSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deletePhraseSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deletePhraseSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deletePhraseSet without error using callback', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.DeletePhraseSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('DeletePhraseSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deletePhraseSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deletePhraseSet( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deletePhraseSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deletePhraseSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deletePhraseSet with error', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.DeletePhraseSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('DeletePhraseSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deletePhraseSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deletePhraseSet(request), expectedError); + const actualRequest = (client.innerApiCalls.deletePhraseSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deletePhraseSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deletePhraseSet with closed client', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.DeletePhraseSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('DeletePhraseSetRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deletePhraseSet(request), expectedError); + }); + }); + + describe('createCustomClass', () => { + it('invokes createCustomClass without error', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.CreateCustomClassRequest() + ); + const defaultValue1 = + getTypeDefaultValue('CreateCustomClassRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1.CustomClass() + ); + client.innerApiCalls.createCustomClass = stubSimpleCall(expectedResponse); + const [response] = await client.createCustomClass(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createCustomClass as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createCustomClass as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createCustomClass without error using callback', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.CreateCustomClassRequest() + ); + const defaultValue1 = + getTypeDefaultValue('CreateCustomClassRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1.CustomClass() + ); + client.innerApiCalls.createCustomClass = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createCustomClass( + request, + (err?: Error|null, result?: protos.google.cloud.speech.v1.ICustomClass|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createCustomClass as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createCustomClass as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createCustomClass with error', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.CreateCustomClassRequest() + ); + const defaultValue1 = + getTypeDefaultValue('CreateCustomClassRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createCustomClass = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createCustomClass(request), expectedError); + const actualRequest = (client.innerApiCalls.createCustomClass as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createCustomClass as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createCustomClass with closed client', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.CreateCustomClassRequest() + ); + const defaultValue1 = + getTypeDefaultValue('CreateCustomClassRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createCustomClass(request), expectedError); + }); + }); + + describe('getCustomClass', () => { + it('invokes getCustomClass without error', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.GetCustomClassRequest() + ); + const defaultValue1 = + getTypeDefaultValue('GetCustomClassRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1.CustomClass() + ); + client.innerApiCalls.getCustomClass = stubSimpleCall(expectedResponse); + const [response] = await client.getCustomClass(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getCustomClass as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getCustomClass as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getCustomClass without error using callback', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.GetCustomClassRequest() + ); + const defaultValue1 = + getTypeDefaultValue('GetCustomClassRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1.CustomClass() + ); + client.innerApiCalls.getCustomClass = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getCustomClass( + request, + (err?: Error|null, result?: protos.google.cloud.speech.v1.ICustomClass|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getCustomClass as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getCustomClass as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getCustomClass with error', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.GetCustomClassRequest() + ); + const defaultValue1 = + getTypeDefaultValue('GetCustomClassRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getCustomClass = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getCustomClass(request), expectedError); + const actualRequest = (client.innerApiCalls.getCustomClass as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getCustomClass as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getCustomClass with closed client', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.GetCustomClassRequest() + ); + const defaultValue1 = + getTypeDefaultValue('GetCustomClassRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getCustomClass(request), expectedError); + }); + }); + + describe('updateCustomClass', () => { + it('invokes updateCustomClass without error', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.UpdateCustomClassRequest() + ); + request.customClass ??= {}; + const defaultValue1 = + getTypeDefaultValue('UpdateCustomClassRequest', ['customClass', 'name']); + request.customClass.name = defaultValue1; + const expectedHeaderRequestParams = `custom_class.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1.CustomClass() + ); + client.innerApiCalls.updateCustomClass = stubSimpleCall(expectedResponse); + const [response] = await client.updateCustomClass(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateCustomClass as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateCustomClass as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateCustomClass without error using callback', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.UpdateCustomClassRequest() + ); + request.customClass ??= {}; + const defaultValue1 = + getTypeDefaultValue('UpdateCustomClassRequest', ['customClass', 'name']); + request.customClass.name = defaultValue1; + const expectedHeaderRequestParams = `custom_class.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1.CustomClass() + ); + client.innerApiCalls.updateCustomClass = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateCustomClass( + request, + (err?: Error|null, result?: protos.google.cloud.speech.v1.ICustomClass|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateCustomClass as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateCustomClass as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateCustomClass with error', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.UpdateCustomClassRequest() + ); + request.customClass ??= {}; + const defaultValue1 = + getTypeDefaultValue('UpdateCustomClassRequest', ['customClass', 'name']); + request.customClass.name = defaultValue1; + const expectedHeaderRequestParams = `custom_class.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateCustomClass = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateCustomClass(request), expectedError); + const actualRequest = (client.innerApiCalls.updateCustomClass as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateCustomClass as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateCustomClass with closed client', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.UpdateCustomClassRequest() + ); + request.customClass ??= {}; + const defaultValue1 = + getTypeDefaultValue('UpdateCustomClassRequest', ['customClass', 'name']); + request.customClass.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateCustomClass(request), expectedError); + }); + }); + + describe('deleteCustomClass', () => { + it('invokes deleteCustomClass without error', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.DeleteCustomClassRequest() + ); + const defaultValue1 = + getTypeDefaultValue('DeleteCustomClassRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteCustomClass = stubSimpleCall(expectedResponse); + const [response] = await client.deleteCustomClass(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteCustomClass as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteCustomClass as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteCustomClass without error using callback', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.DeleteCustomClassRequest() + ); + const defaultValue1 = + getTypeDefaultValue('DeleteCustomClassRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteCustomClass = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteCustomClass( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteCustomClass as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteCustomClass as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteCustomClass with error', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.DeleteCustomClassRequest() + ); + const defaultValue1 = + getTypeDefaultValue('DeleteCustomClassRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteCustomClass = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteCustomClass(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteCustomClass as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteCustomClass as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteCustomClass with closed client', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.DeleteCustomClassRequest() + ); + const defaultValue1 = + getTypeDefaultValue('DeleteCustomClassRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteCustomClass(request), expectedError); + }); + }); + + describe('listPhraseSet', () => { + it('invokes listPhraseSet without error', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.ListPhraseSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListPhraseSetRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.speech.v1.PhraseSet()), + generateSampleMessage(new protos.google.cloud.speech.v1.PhraseSet()), + generateSampleMessage(new protos.google.cloud.speech.v1.PhraseSet()), + ]; + client.innerApiCalls.listPhraseSet = stubSimpleCall(expectedResponse); + const [response] = await client.listPhraseSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listPhraseSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listPhraseSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listPhraseSet without error using callback', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.ListPhraseSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListPhraseSetRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.speech.v1.PhraseSet()), + generateSampleMessage(new protos.google.cloud.speech.v1.PhraseSet()), + generateSampleMessage(new protos.google.cloud.speech.v1.PhraseSet()), + ]; + client.innerApiCalls.listPhraseSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listPhraseSet( + request, + (err?: Error|null, result?: protos.google.cloud.speech.v1.IPhraseSet[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listPhraseSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listPhraseSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listPhraseSet with error', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.ListPhraseSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListPhraseSetRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listPhraseSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listPhraseSet(request), expectedError); + const actualRequest = (client.innerApiCalls.listPhraseSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listPhraseSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listPhraseSetStream without error', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.ListPhraseSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListPhraseSetRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.speech.v1.PhraseSet()), + generateSampleMessage(new protos.google.cloud.speech.v1.PhraseSet()), + generateSampleMessage(new protos.google.cloud.speech.v1.PhraseSet()), + ]; + client.descriptors.page.listPhraseSet.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listPhraseSetStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.speech.v1.PhraseSet[] = []; + stream.on('data', (response: protos.google.cloud.speech.v1.PhraseSet) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listPhraseSet.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listPhraseSet, request)); + assert( + (client.descriptors.page.listPhraseSet.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listPhraseSetStream with error', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.ListPhraseSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListPhraseSetRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listPhraseSet.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listPhraseSetStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.speech.v1.PhraseSet[] = []; + stream.on('data', (response: protos.google.cloud.speech.v1.PhraseSet) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listPhraseSet.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listPhraseSet, request)); + assert( + (client.descriptors.page.listPhraseSet.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listPhraseSet without error', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.ListPhraseSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListPhraseSetRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.speech.v1.PhraseSet()), + generateSampleMessage(new protos.google.cloud.speech.v1.PhraseSet()), + generateSampleMessage(new protos.google.cloud.speech.v1.PhraseSet()), + ]; + client.descriptors.page.listPhraseSet.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.speech.v1.IPhraseSet[] = []; + const iterable = client.listPhraseSetAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listPhraseSet.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listPhraseSet.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listPhraseSet with error', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.ListPhraseSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListPhraseSetRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listPhraseSet.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listPhraseSetAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.speech.v1.IPhraseSet[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listPhraseSet.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listPhraseSet.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listCustomClasses', () => { + it('invokes listCustomClasses without error', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.ListCustomClassesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListCustomClassesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.speech.v1.CustomClass()), + generateSampleMessage(new protos.google.cloud.speech.v1.CustomClass()), + generateSampleMessage(new protos.google.cloud.speech.v1.CustomClass()), + ]; + client.innerApiCalls.listCustomClasses = stubSimpleCall(expectedResponse); + const [response] = await client.listCustomClasses(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listCustomClasses as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listCustomClasses as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listCustomClasses without error using callback', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.ListCustomClassesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListCustomClassesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.speech.v1.CustomClass()), + generateSampleMessage(new protos.google.cloud.speech.v1.CustomClass()), + generateSampleMessage(new protos.google.cloud.speech.v1.CustomClass()), + ]; + client.innerApiCalls.listCustomClasses = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listCustomClasses( + request, + (err?: Error|null, result?: protos.google.cloud.speech.v1.ICustomClass[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listCustomClasses as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listCustomClasses as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listCustomClasses with error', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.ListCustomClassesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListCustomClassesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listCustomClasses = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listCustomClasses(request), expectedError); + const actualRequest = (client.innerApiCalls.listCustomClasses as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listCustomClasses as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listCustomClassesStream without error', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.ListCustomClassesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListCustomClassesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.speech.v1.CustomClass()), + generateSampleMessage(new protos.google.cloud.speech.v1.CustomClass()), + generateSampleMessage(new protos.google.cloud.speech.v1.CustomClass()), + ]; + client.descriptors.page.listCustomClasses.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listCustomClassesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.speech.v1.CustomClass[] = []; + stream.on('data', (response: protos.google.cloud.speech.v1.CustomClass) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listCustomClasses.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listCustomClasses, request)); + assert( + (client.descriptors.page.listCustomClasses.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listCustomClassesStream with error', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.ListCustomClassesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListCustomClassesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listCustomClasses.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listCustomClassesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.speech.v1.CustomClass[] = []; + stream.on('data', (response: protos.google.cloud.speech.v1.CustomClass) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listCustomClasses.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listCustomClasses, request)); + assert( + (client.descriptors.page.listCustomClasses.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listCustomClasses without error', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.ListCustomClassesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListCustomClassesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.speech.v1.CustomClass()), + generateSampleMessage(new protos.google.cloud.speech.v1.CustomClass()), + generateSampleMessage(new protos.google.cloud.speech.v1.CustomClass()), + ]; + client.descriptors.page.listCustomClasses.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.speech.v1.ICustomClass[] = []; + const iterable = client.listCustomClassesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listCustomClasses.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listCustomClasses.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listCustomClasses with error', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.ListCustomClassesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListCustomClassesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listCustomClasses.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listCustomClassesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.speech.v1.ICustomClass[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listCustomClasses.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listCustomClasses.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('Path templates', () => { + + describe('customClass', () => { + const fakePath = "/rendered/path/customClass"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + custom_class: "customClassValue", + }; + const client = new adaptationModule.v1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.customClassPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.customClassPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('customClassPath', () => { + const result = client.customClassPath("projectValue", "locationValue", "customClassValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.customClassPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCustomClassName', () => { + const result = client.matchProjectFromCustomClassName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.customClassPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCustomClassName', () => { + const result = client.matchLocationFromCustomClassName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.customClassPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCustomClassFromCustomClassName', () => { + const result = client.matchCustomClassFromCustomClassName(fakePath); + assert.strictEqual(result, "customClassValue"); + assert((client.pathTemplates.customClassPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('location', () => { + const fakePath = "/rendered/path/location"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + }; + const client = new adaptationModule.v1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.locationPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.locationPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath("projectValue", "locationValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('phraseSet', () => { + const fakePath = "/rendered/path/phraseSet"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + phrase_set: "phraseSetValue", + }; + const client = new adaptationModule.v1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.phraseSetPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.phraseSetPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('phraseSetPath', () => { + const result = client.phraseSetPath("projectValue", "locationValue", "phraseSetValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.phraseSetPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromPhraseSetName', () => { + const result = client.matchProjectFromPhraseSetName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.phraseSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromPhraseSetName', () => { + const result = client.matchLocationFromPhraseSetName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.phraseSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchPhraseSetFromPhraseSetName', () => { + const result = client.matchPhraseSetFromPhraseSetName(fakePath); + assert.strictEqual(result, "phraseSetValue"); + assert((client.pathTemplates.phraseSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('project', () => { + const fakePath = "/rendered/path/project"; + const expectedParameters = { + project: "projectValue", + }; + const client = new adaptationModule.v1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath("projectValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v1/test/gapic_speech_v1.ts b/owl-bot-staging/v1/test/gapic_speech_v1.ts new file mode 100644 index 00000000..c7d0b9fb --- /dev/null +++ b/owl-bot-staging/v1/test/gapic_speech_v1.ts @@ -0,0 +1,525 @@ +// Copyright 2022 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. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as speechModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubBidiStreamingCall(response?: ResponseType, error?: Error) { + const transformStub = error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + return sinon.stub().returns(mockStream); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +describe('v1.SpeechClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = speechModule.v1.SpeechClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = speechModule.v1.SpeechClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = speechModule.v1.SpeechClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new speechModule.v1.SpeechClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new speechModule.v1.SpeechClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new speechModule.v1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.speechStub, undefined); + await client.initialize(); + assert(client.speechStub); + }); + + it('has close method for the initialized client', done => { + const client = new speechModule.v1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.speechStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new speechModule.v1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.speechStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new speechModule.v1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new speechModule.v1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('recognize', () => { + it('invokes recognize without error', async () => { + const client = new speechModule.v1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.RecognizeRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1.RecognizeResponse() + ); + client.innerApiCalls.recognize = stubSimpleCall(expectedResponse); + const [response] = await client.recognize(request); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes recognize without error using callback', async () => { + const client = new speechModule.v1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.RecognizeRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1.RecognizeResponse() + ); + client.innerApiCalls.recognize = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.recognize( + request, + (err?: Error|null, result?: protos.google.cloud.speech.v1.IRecognizeResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes recognize with error', async () => { + const client = new speechModule.v1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.RecognizeRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.recognize = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.recognize(request), expectedError); + }); + + it('invokes recognize with closed client', async () => { + const client = new speechModule.v1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.RecognizeRequest() + ); + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.recognize(request), expectedError); + }); + }); + + describe('longRunningRecognize', () => { + it('invokes longRunningRecognize without error', async () => { + const client = new speechModule.v1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.LongRunningRecognizeRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.longRunningRecognize = stubLongRunningCall(expectedResponse); + const [operation] = await client.longRunningRecognize(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes longRunningRecognize without error using callback', async () => { + const client = new speechModule.v1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.LongRunningRecognizeRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.longRunningRecognize = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.longRunningRecognize( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes longRunningRecognize with call error', async () => { + const client = new speechModule.v1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.LongRunningRecognizeRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.longRunningRecognize = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.longRunningRecognize(request), expectedError); + }); + + it('invokes longRunningRecognize with LRO error', async () => { + const client = new speechModule.v1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.LongRunningRecognizeRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.longRunningRecognize = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.longRunningRecognize(request); + await assert.rejects(operation.promise(), expectedError); + }); + + it('invokes checkLongRunningRecognizeProgress without error', async () => { + const client = new speechModule.v1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkLongRunningRecognizeProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkLongRunningRecognizeProgress with error', async () => { + const client = new speechModule.v1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkLongRunningRecognizeProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('streamingRecognize', () => { + it('invokes streamingRecognize without error', async () => { + const client = new speechModule.v1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.StreamingRecognizeRequest() + ); + + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1.StreamingRecognizeResponse() + ); + client.innerApiCalls.streamingRecognize = stubBidiStreamingCall(expectedResponse); + const stream = client.streamingRecognize(); + const promise = new Promise((resolve, reject) => { + stream.on('data', (response: protos.google.cloud.speech.v1.StreamingRecognizeResponse) => { + resolve(response); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + stream.write(request); + stream.end(); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.streamingRecognize as SinonStub) + .getCall(0).calledWith(null)); + assert.deepStrictEqual(((stream as unknown as PassThrough) + ._transform as SinonStub).getCall(0).args[0], request); + }); + + it('invokes streamingRecognize with error', async () => { + const client = new speechModule.v1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.StreamingRecognizeRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.streamingRecognize = stubBidiStreamingCall(undefined, expectedError); + const stream = client.streamingRecognize(); + const promise = new Promise((resolve, reject) => { + stream.on('data', (response: protos.google.cloud.speech.v1.StreamingRecognizeResponse) => { + resolve(response); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + stream.write(request); + stream.end(); + }); + await assert.rejects(promise, expectedError); + assert((client.innerApiCalls.streamingRecognize as SinonStub) + .getCall(0).calledWith(null)); + assert.deepStrictEqual(((stream as unknown as PassThrough) + ._transform as SinonStub).getCall(0).args[0], request); + }); + }); + + describe('Path templates', () => { + + describe('customClass', () => { + const fakePath = "/rendered/path/customClass"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + custom_class: "customClassValue", + }; + const client = new speechModule.v1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.customClassPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.customClassPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('customClassPath', () => { + const result = client.customClassPath("projectValue", "locationValue", "customClassValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.customClassPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCustomClassName', () => { + const result = client.matchProjectFromCustomClassName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.customClassPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCustomClassName', () => { + const result = client.matchLocationFromCustomClassName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.customClassPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCustomClassFromCustomClassName', () => { + const result = client.matchCustomClassFromCustomClassName(fakePath); + assert.strictEqual(result, "customClassValue"); + assert((client.pathTemplates.customClassPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('phraseSet', () => { + const fakePath = "/rendered/path/phraseSet"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + phrase_set: "phraseSetValue", + }; + const client = new speechModule.v1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.phraseSetPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.phraseSetPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('phraseSetPath', () => { + const result = client.phraseSetPath("projectValue", "locationValue", "phraseSetValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.phraseSetPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromPhraseSetName', () => { + const result = client.matchProjectFromPhraseSetName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.phraseSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromPhraseSetName', () => { + const result = client.matchLocationFromPhraseSetName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.phraseSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchPhraseSetFromPhraseSetName', () => { + const result = client.matchPhraseSetFromPhraseSetName(fakePath); + assert.strictEqual(result, "phraseSetValue"); + assert((client.pathTemplates.phraseSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v1/tsconfig.json b/owl-bot-staging/v1/tsconfig.json new file mode 100644 index 00000000..c78f1c88 --- /dev/null +++ b/owl-bot-staging/v1/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2018", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/owl-bot-staging/v1/webpack.config.js b/owl-bot-staging/v1/webpack.config.js new file mode 100644 index 00000000..50273cca --- /dev/null +++ b/owl-bot-staging/v1/webpack.config.js @@ -0,0 +1,64 @@ +// 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. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'Adaptation', + filename: './adaptation.js', + }, + node: { + child_process: 'empty', + fs: 'empty', + crypto: 'empty', + }, + resolve: { + alias: { + '../../../package.json': path.resolve(__dirname, 'package.json'), + }, + extensions: ['.js', '.json', '.ts'], + }, + module: { + rules: [ + { + test: /\.tsx?$/, + use: 'ts-loader', + exclude: /node_modules/ + }, + { + test: /node_modules[\\/]@grpc[\\/]grpc-js/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]grpc/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]retry-request/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]https?-proxy-agent/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]gtoken/, + use: 'null-loader' + }, + ], + }, + mode: 'production', +}; diff --git a/owl-bot-staging/v1p1beta1/.eslintignore b/owl-bot-staging/v1p1beta1/.eslintignore new file mode 100644 index 00000000..cfc348ec --- /dev/null +++ b/owl-bot-staging/v1p1beta1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/v1p1beta1/.eslintrc.json b/owl-bot-staging/v1p1beta1/.eslintrc.json new file mode 100644 index 00000000..78215349 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/v1p1beta1/.gitignore b/owl-bot-staging/v1p1beta1/.gitignore new file mode 100644 index 00000000..5d32b237 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/.gitignore @@ -0,0 +1,14 @@ +**/*.log +**/node_modules +.coverage +coverage +.nyc_output +docs/ +out/ +build/ +system-test/secrets.js +system-test/*key.json +*.lock +.DS_Store +package-lock.json +__pycache__ diff --git a/owl-bot-staging/v1p1beta1/.jsdoc.js b/owl-bot-staging/v1p1beta1/.jsdoc.js new file mode 100644 index 00000000..d2a7104e --- /dev/null +++ b/owl-bot-staging/v1p1beta1/.jsdoc.js @@ -0,0 +1,55 @@ +// Copyright 2022 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. ** + +'use strict'; + +module.exports = { + opts: { + readme: './README.md', + package: './package.json', + template: './node_modules/jsdoc-fresh', + recurse: true, + verbose: true, + destination: './docs/' + }, + plugins: [ + 'plugins/markdown', + 'jsdoc-region-tag' + ], + source: { + excludePattern: '(^|\\/|\\\\)[._]', + include: [ + 'build/src', + 'protos' + ], + includePattern: '\\.js$' + }, + templates: { + copyright: 'Copyright 2022 Google LLC', + includeDate: false, + sourceFiles: false, + systemName: '@google-cloud/speech', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/v1p1beta1/.mocharc.js b/owl-bot-staging/v1p1beta1/.mocharc.js new file mode 100644 index 00000000..481c522b --- /dev/null +++ b/owl-bot-staging/v1p1beta1/.mocharc.js @@ -0,0 +1,33 @@ +// Copyright 2022 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. ** + +const config = { + "enable-source-maps": true, + "throw-deprecation": true, + "timeout": 10000 +} +if (process.env.MOCHA_THROW_DEPRECATION === 'false') { + delete config['throw-deprecation']; +} +if (process.env.MOCHA_REPORTER) { + config.reporter = process.env.MOCHA_REPORTER; +} +if (process.env.MOCHA_REPORTER_OUTPUT) { + config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; +} +module.exports = config diff --git a/owl-bot-staging/v1p1beta1/.prettierrc.js b/owl-bot-staging/v1p1beta1/.prettierrc.js new file mode 100644 index 00000000..494e1478 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/.prettierrc.js @@ -0,0 +1,22 @@ +// Copyright 2022 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. ** + + +module.exports = { + ...require('gts/.prettierrc.json') +} diff --git a/owl-bot-staging/v1p1beta1/README.md b/owl-bot-staging/v1p1beta1/README.md new file mode 100644 index 00000000..45c3b2af --- /dev/null +++ b/owl-bot-staging/v1p1beta1/README.md @@ -0,0 +1 @@ +Speech: Nodejs Client diff --git a/owl-bot-staging/v1p1beta1/linkinator.config.json b/owl-bot-staging/v1p1beta1/linkinator.config.json new file mode 100644 index 00000000..befd23c8 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/linkinator.config.json @@ -0,0 +1,16 @@ +{ + "recurse": true, + "skip": [ + "https://codecov.io/gh/googleapis/", + "www.googleapis.com", + "img.shields.io", + "https://console.cloud.google.com/cloudshell", + "https://support.google.com" + ], + "silent": true, + "concurrency": 5, + "retry": true, + "retryErrors": true, + "retryErrorsCount": 5, + "retryErrorsJitter": 3000 +} diff --git a/owl-bot-staging/v1p1beta1/package.json b/owl-bot-staging/v1p1beta1/package.json new file mode 100644 index 00000000..53356248 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/package.json @@ -0,0 +1,65 @@ +{ + "name": "@google-cloud/speech", + "version": "0.1.0", + "description": "Speech client for Node.js", + "repository": "googleapis/nodejs-speech", + "license": "Apache-2.0", + "author": "Google LLC", + "main": "build/src/index.js", + "files": [ + "build/src", + "build/protos" + ], + "keywords": [ + "google apis client", + "google api client", + "google apis", + "google api", + "google", + "google cloud platform", + "google cloud", + "cloud", + "google speech", + "speech", + "adaptation", + "speech" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "c8 mocha build/system-test", + "test": "c8 mocha build/test" + }, + "dependencies": { + "google-gax": "^3.5.1" + }, + "devDependencies": { + "@types/mocha": "^9.1.1", + "@types/node": "^16.11.59", + "@types/sinon": "^10.0.13", + "c8": "^7.12.0", + "gts": "^3.1.1", + "jsdoc": "^3.6.11", + "jsdoc-fresh": "^2.0.1", + "jsdoc-region-tag": "^2.0.1", + "linkinator": "^4.0.3", + "mocha": "^10.0.0", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^14.0.0", + "ts-loader": "^8.4.0", + "typescript": "^4.8.3", + "webpack": "^4.46.0", + "webpack-cli": "^4.10.0" + }, + "engines": { + "node": ">=v12" + } +} diff --git a/owl-bot-staging/v1p1beta1/protos/google/cloud/speech/v1p1beta1/cloud_speech.proto b/owl-bot-staging/v1p1beta1/protos/google/cloud/speech/v1p1beta1/cloud_speech.proto new file mode 100644 index 00000000..9bf36fcc --- /dev/null +++ b/owl-bot-staging/v1p1beta1/protos/google/cloud/speech/v1p1beta1/cloud_speech.proto @@ -0,0 +1,929 @@ +// Copyright 2022 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 +// +// http://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. + +syntax = "proto3"; + +package google.cloud.speech.v1p1beta1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/cloud/speech/v1p1beta1/resource.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/wrappers.proto"; +import "google/rpc/status.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/speech/v1p1beta1;speech"; +option java_multiple_files = true; +option java_outer_classname = "SpeechProto"; +option java_package = "com.google.cloud.speech.v1p1beta1"; +option objc_class_prefix = "GCS"; + +// Service that implements Google Cloud Speech API. +service Speech { + option (google.api.default_host) = "speech.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // Performs synchronous speech recognition: receive results after all audio + // has been sent and processed. + rpc Recognize(RecognizeRequest) returns (RecognizeResponse) { + option (google.api.http) = { + post: "/v1p1beta1/speech:recognize" + body: "*" + }; + option (google.api.method_signature) = "config,audio"; + } + + // Performs asynchronous speech recognition: receive results via the + // google.longrunning.Operations interface. Returns either an + // `Operation.error` or an `Operation.response` which contains + // a `LongRunningRecognizeResponse` message. + // For more information on asynchronous speech recognition, see the + // [how-to](https://cloud.google.com/speech-to-text/docs/async-recognize). + rpc LongRunningRecognize(LongRunningRecognizeRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1p1beta1/speech:longrunningrecognize" + body: "*" + }; + option (google.api.method_signature) = "config,audio"; + option (google.longrunning.operation_info) = { + response_type: "LongRunningRecognizeResponse" + metadata_type: "LongRunningRecognizeMetadata" + }; + } + + // Performs bidirectional streaming speech recognition: receive results while + // sending audio. This method is only available via the gRPC API (not REST). + rpc StreamingRecognize(stream StreamingRecognizeRequest) returns (stream StreamingRecognizeResponse) { + } +} + +// The top-level message sent by the client for the `Recognize` method. +message RecognizeRequest { + // Required. Provides information to the recognizer that specifies how to + // process the request. + RecognitionConfig config = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The audio data to be recognized. + RecognitionAudio audio = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// The top-level message sent by the client for the `LongRunningRecognize` +// method. +message LongRunningRecognizeRequest { + // Required. Provides information to the recognizer that specifies how to + // process the request. + RecognitionConfig config = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The audio data to be recognized. + RecognitionAudio audio = 2 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Specifies an optional destination for the recognition results. + TranscriptOutputConfig output_config = 4 [(google.api.field_behavior) = OPTIONAL]; +} + +// Specifies an optional destination for the recognition results. +message TranscriptOutputConfig { + oneof output_type { + // Specifies a Cloud Storage URI for the recognition results. Must be + // specified in the format: `gs://bucket_name/object_name`, and the bucket + // must already exist. + string gcs_uri = 1; + } +} + +// The top-level message sent by the client for the `StreamingRecognize` method. +// Multiple `StreamingRecognizeRequest` messages are sent. The first message +// must contain a `streaming_config` message and must not contain +// `audio_content`. All subsequent messages must contain `audio_content` and +// must not contain a `streaming_config` message. +message StreamingRecognizeRequest { + // The streaming request, which is either a streaming config or audio content. + oneof streaming_request { + // Provides information to the recognizer that specifies how to process the + // request. The first `StreamingRecognizeRequest` message must contain a + // `streaming_config` message. + StreamingRecognitionConfig streaming_config = 1; + + // The audio data to be recognized. Sequential chunks of audio data are sent + // in sequential `StreamingRecognizeRequest` messages. The first + // `StreamingRecognizeRequest` message must not contain `audio_content` data + // and all subsequent `StreamingRecognizeRequest` messages must contain + // `audio_content` data. The audio bytes must be encoded as specified in + // `RecognitionConfig`. Note: as with all bytes fields, proto buffers use a + // pure binary representation (not base64). See + // [content limits](https://cloud.google.com/speech-to-text/quotas#content). + bytes audio_content = 2; + } +} + +// Provides information to the recognizer that specifies how to process the +// request. +message StreamingRecognitionConfig { + // Required. Provides information to the recognizer that specifies how to + // process the request. + RecognitionConfig config = 1 [(google.api.field_behavior) = REQUIRED]; + + // If `false` or omitted, the recognizer will perform continuous + // recognition (continuing to wait for and process audio even if the user + // pauses speaking) until the client closes the input stream (gRPC API) or + // until the maximum time limit has been reached. May return multiple + // `StreamingRecognitionResult`s with the `is_final` flag set to `true`. + // + // If `true`, the recognizer will detect a single spoken utterance. When it + // detects that the user has paused or stopped speaking, it will return an + // `END_OF_SINGLE_UTTERANCE` event and cease recognition. It will return no + // more than one `StreamingRecognitionResult` with the `is_final` flag set to + // `true`. + // + // The `single_utterance` field can only be used with specified models, + // otherwise an error is thrown. The `model` field in [`RecognitionConfig`][] + // must be set to: + // + // * `command_and_search` + // * `phone_call` AND additional field `useEnhanced`=`true` + // * The `model` field is left undefined. In this case the API auto-selects + // a model based on any other parameters that you set in + // `RecognitionConfig`. + bool single_utterance = 2; + + // If `true`, interim results (tentative hypotheses) may be + // returned as they become available (these interim results are indicated with + // the `is_final=false` flag). + // If `false` or omitted, only `is_final=true` result(s) are returned. + bool interim_results = 3; +} + +// Provides information to the recognizer that specifies how to process the +// request. +message RecognitionConfig { + // The encoding of the audio data sent in the request. + // + // All encodings support only 1 channel (mono) audio, unless the + // `audio_channel_count` and `enable_separate_recognition_per_channel` fields + // are set. + // + // For best results, the audio source should be captured and transmitted using + // a lossless encoding (`FLAC` or `LINEAR16`). The accuracy of the speech + // recognition can be reduced if lossy codecs are used to capture or transmit + // audio, particularly if background noise is present. Lossy codecs include + // `MULAW`, `AMR`, `AMR_WB`, `OGG_OPUS`, `SPEEX_WITH_HEADER_BYTE`, `MP3`, + // and `WEBM_OPUS`. + // + // The `FLAC` and `WAV` audio file formats include a header that describes the + // included audio content. You can request recognition for `WAV` files that + // contain either `LINEAR16` or `MULAW` encoded audio. + // If you send `FLAC` or `WAV` audio file format in + // your request, you do not need to specify an `AudioEncoding`; the audio + // encoding format is determined from the file header. If you specify + // an `AudioEncoding` when you send send `FLAC` or `WAV` audio, the + // encoding configuration must match the encoding described in the audio + // header; otherwise the request returns an + // [google.rpc.Code.INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT] error code. + enum AudioEncoding { + // Not specified. + ENCODING_UNSPECIFIED = 0; + + // Uncompressed 16-bit signed little-endian samples (Linear PCM). + LINEAR16 = 1; + + // `FLAC` (Free Lossless Audio + // Codec) is the recommended encoding because it is + // lossless--therefore recognition is not compromised--and + // requires only about half the bandwidth of `LINEAR16`. `FLAC` stream + // encoding supports 16-bit and 24-bit samples, however, not all fields in + // `STREAMINFO` are supported. + FLAC = 2; + + // 8-bit samples that compand 14-bit audio samples using G.711 PCMU/mu-law. + MULAW = 3; + + // Adaptive Multi-Rate Narrowband codec. `sample_rate_hertz` must be 8000. + AMR = 4; + + // Adaptive Multi-Rate Wideband codec. `sample_rate_hertz` must be 16000. + AMR_WB = 5; + + // Opus encoded audio frames in Ogg container + // ([OggOpus](https://wiki.xiph.org/OggOpus)). + // `sample_rate_hertz` must be one of 8000, 12000, 16000, 24000, or 48000. + OGG_OPUS = 6; + + // Although the use of lossy encodings is not recommended, if a very low + // bitrate encoding is required, `OGG_OPUS` is highly preferred over + // Speex encoding. The [Speex](https://speex.org/) encoding supported by + // Cloud Speech API has a header byte in each block, as in MIME type + // `audio/x-speex-with-header-byte`. + // It is a variant of the RTP Speex encoding defined in + // [RFC 5574](https://tools.ietf.org/html/rfc5574). + // The stream is a sequence of blocks, one block per RTP packet. Each block + // starts with a byte containing the length of the block, in bytes, followed + // by one or more frames of Speex data, padded to an integral number of + // bytes (octets) as specified in RFC 5574. In other words, each RTP header + // is replaced with a single byte containing the block length. Only Speex + // wideband is supported. `sample_rate_hertz` must be 16000. + SPEEX_WITH_HEADER_BYTE = 7; + + // MP3 audio. MP3 encoding is a Beta feature and only available in + // v1p1beta1. Support all standard MP3 bitrates (which range from 32-320 + // kbps). When using this encoding, `sample_rate_hertz` has to match the + // sample rate of the file being used. + MP3 = 8; + + // Opus encoded audio frames in WebM container + // ([OggOpus](https://wiki.xiph.org/OggOpus)). `sample_rate_hertz` must be + // one of 8000, 12000, 16000, 24000, or 48000. + WEBM_OPUS = 9; + } + + // Encoding of audio data sent in all `RecognitionAudio` messages. + // This field is optional for `FLAC` and `WAV` audio files and required + // for all other audio formats. For details, see [AudioEncoding][google.cloud.speech.v1p1beta1.RecognitionConfig.AudioEncoding]. + AudioEncoding encoding = 1; + + // Sample rate in Hertz of the audio data sent in all + // `RecognitionAudio` messages. Valid values are: 8000-48000. + // 16000 is optimal. For best results, set the sampling rate of the audio + // source to 16000 Hz. If that's not possible, use the native sample rate of + // the audio source (instead of re-sampling). + // This field is optional for FLAC and WAV audio files, but is + // required for all other audio formats. For details, see [AudioEncoding][google.cloud.speech.v1p1beta1.RecognitionConfig.AudioEncoding]. + int32 sample_rate_hertz = 2; + + // The number of channels in the input audio data. + // ONLY set this for MULTI-CHANNEL recognition. + // Valid values for LINEAR16 and FLAC are `1`-`8`. + // Valid values for OGG_OPUS are '1'-'254'. + // Valid value for MULAW, AMR, AMR_WB and SPEEX_WITH_HEADER_BYTE is only `1`. + // If `0` or omitted, defaults to one channel (mono). + // Note: We only recognize the first channel by default. + // To perform independent recognition on each channel set + // `enable_separate_recognition_per_channel` to 'true'. + int32 audio_channel_count = 7; + + // This needs to be set to `true` explicitly and `audio_channel_count` > 1 + // to get each channel recognized separately. The recognition result will + // contain a `channel_tag` field to state which channel that result belongs + // to. If this is not true, we will only recognize the first channel. The + // request is billed cumulatively for all channels recognized: + // `audio_channel_count` multiplied by the length of the audio. + bool enable_separate_recognition_per_channel = 12; + + // Required. The language of the supplied audio as a + // [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag. + // Example: "en-US". + // See [Language + // Support](https://cloud.google.com/speech-to-text/docs/languages) for a list + // of the currently supported language codes. + string language_code = 3 [(google.api.field_behavior) = REQUIRED]; + + // A list of up to 3 additional + // [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tags, + // listing possible alternative languages of the supplied audio. + // See [Language + // Support](https://cloud.google.com/speech-to-text/docs/languages) for a list + // of the currently supported language codes. If alternative languages are + // listed, recognition result will contain recognition in the most likely + // language detected including the main language_code. The recognition result + // will include the language tag of the language detected in the audio. Note: + // This feature is only supported for Voice Command and Voice Search use cases + // and performance may vary for other use cases (e.g., phone call + // transcription). + repeated string alternative_language_codes = 18; + + // Maximum number of recognition hypotheses to be returned. + // Specifically, the maximum number of `SpeechRecognitionAlternative` messages + // within each `SpeechRecognitionResult`. + // The server may return fewer than `max_alternatives`. + // Valid values are `0`-`30`. A value of `0` or `1` will return a maximum of + // one. If omitted, will return a maximum of one. + int32 max_alternatives = 4; + + // If set to `true`, the server will attempt to filter out + // profanities, replacing all but the initial character in each filtered word + // with asterisks, e.g. "f***". If set to `false` or omitted, profanities + // won't be filtered out. + bool profanity_filter = 5; + + // Speech adaptation configuration improves the accuracy of speech + // recognition. For more information, see the [speech + // adaptation](https://cloud.google.com/speech-to-text/docs/adaptation) + // documentation. + // When speech adaptation is set it supersedes the `speech_contexts` field. + SpeechAdaptation adaptation = 20; + + // Use transcription normalization to automatically replace parts of the + // transcript with phrases of your choosing. For StreamingRecognize, this + // normalization only applies to stable partial transcripts (stability > 0.8) + // and final transcripts. + TranscriptNormalization transcript_normalization = 24; + + // Array of [SpeechContext][google.cloud.speech.v1p1beta1.SpeechContext]. + // A means to provide context to assist the speech recognition. For more + // information, see + // [speech + // adaptation](https://cloud.google.com/speech-to-text/docs/adaptation). + repeated SpeechContext speech_contexts = 6; + + // If `true`, the top result includes a list of words and + // the start and end time offsets (timestamps) for those words. If + // `false`, no word-level time offset information is returned. The default is + // `false`. + bool enable_word_time_offsets = 8; + + // If `true`, the top result includes a list of words and the + // confidence for those words. If `false`, no word-level confidence + // information is returned. The default is `false`. + bool enable_word_confidence = 15; + + // If 'true', adds punctuation to recognition result hypotheses. + // This feature is only available in select languages. Setting this for + // requests in other languages has no effect at all. + // The default 'false' value does not add punctuation to result hypotheses. + bool enable_automatic_punctuation = 11; + + // The spoken punctuation behavior for the call + // If not set, uses default behavior based on model of choice + // e.g. command_and_search will enable spoken punctuation by default + // If 'true', replaces spoken punctuation with the corresponding symbols in + // the request. For example, "how are you question mark" becomes "how are + // you?". See https://cloud.google.com/speech-to-text/docs/spoken-punctuation + // for support. If 'false', spoken punctuation is not replaced. + google.protobuf.BoolValue enable_spoken_punctuation = 22; + + // The spoken emoji behavior for the call + // If not set, uses default behavior based on model of choice + // If 'true', adds spoken emoji formatting for the request. This will replace + // spoken emojis with the corresponding Unicode symbols in the final + // transcript. If 'false', spoken emojis are not replaced. + google.protobuf.BoolValue enable_spoken_emojis = 23; + + // If 'true', enables speaker detection for each recognized word in + // the top alternative of the recognition result using a speaker_tag provided + // in the WordInfo. + // Note: Use diarization_config instead. + bool enable_speaker_diarization = 16 [deprecated = true]; + + // If set, specifies the estimated number of speakers in the conversation. + // Defaults to '2'. Ignored unless enable_speaker_diarization is set to true. + // Note: Use diarization_config instead. + int32 diarization_speaker_count = 17 [deprecated = true]; + + // Config to enable speaker diarization and set additional + // parameters to make diarization better suited for your application. + // Note: When this is enabled, we send all the words from the beginning of the + // audio for the top alternative in every consecutive STREAMING responses. + // This is done in order to improve our speaker tags as our models learn to + // identify the speakers in the conversation over time. + // For non-streaming requests, the diarization results will be provided only + // in the top alternative of the FINAL SpeechRecognitionResult. + SpeakerDiarizationConfig diarization_config = 19; + + // Metadata regarding this request. + RecognitionMetadata metadata = 9; + + // Which model to select for the given request. Select the model + // best suited to your domain to get best results. If a model is not + // explicitly specified, then we auto-select a model based on the parameters + // in the RecognitionConfig. + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + //
ModelDescription
latest_longBest for long form content like media or conversation.
latest_shortBest for short form content like commands or single shot directed + // speech.
command_and_searchBest for short queries such as voice commands or voice search.
phone_callBest for audio that originated from a phone call (typically + // recorded at an 8khz sampling rate).
videoBest for audio that originated from video or includes multiple + // speakers. Ideally the audio is recorded at a 16khz or greater + // sampling rate. This is a premium model that costs more than the + // standard rate.
defaultBest for audio that is not one of the specific audio models. + // For example, long-form audio. Ideally the audio is high-fidelity, + // recorded at a 16khz or greater sampling rate.
medical_conversationBest for audio that originated from a conversation between a + // medical provider and patient.
medical_dictationBest for audio that originated from dictation notes by a medical + // provider.
+ string model = 13; + + // Set to true to use an enhanced model for speech recognition. + // If `use_enhanced` is set to true and the `model` field is not set, then + // an appropriate enhanced model is chosen if an enhanced model exists for + // the audio. + // + // If `use_enhanced` is true and an enhanced version of the specified model + // does not exist, then the speech is recognized using the standard version + // of the specified model. + bool use_enhanced = 14; +} + +// Config to enable speaker diarization. +message SpeakerDiarizationConfig { + // If 'true', enables speaker detection for each recognized word in + // the top alternative of the recognition result using a speaker_tag provided + // in the WordInfo. + bool enable_speaker_diarization = 1; + + // Minimum number of speakers in the conversation. This range gives you more + // flexibility by allowing the system to automatically determine the correct + // number of speakers. If not set, the default value is 2. + int32 min_speaker_count = 2; + + // Maximum number of speakers in the conversation. This range gives you more + // flexibility by allowing the system to automatically determine the correct + // number of speakers. If not set, the default value is 6. + int32 max_speaker_count = 3; + + // Output only. Unused. + int32 speaker_tag = 5 [ + deprecated = true, + (google.api.field_behavior) = OUTPUT_ONLY + ]; +} + +// Description of audio data to be recognized. +message RecognitionMetadata { + option deprecated = true; + + // Use case categories that the audio recognition request can be described + // by. + enum InteractionType { + // Use case is either unknown or is something other than one of the other + // values below. + INTERACTION_TYPE_UNSPECIFIED = 0; + + // Multiple people in a conversation or discussion. For example in a + // meeting with two or more people actively participating. Typically + // all the primary people speaking would be in the same room (if not, + // see PHONE_CALL) + DISCUSSION = 1; + + // One or more persons lecturing or presenting to others, mostly + // uninterrupted. + PRESENTATION = 2; + + // A phone-call or video-conference in which two or more people, who are + // not in the same room, are actively participating. + PHONE_CALL = 3; + + // A recorded message intended for another person to listen to. + VOICEMAIL = 4; + + // Professionally produced audio (eg. TV Show, Podcast). + PROFESSIONALLY_PRODUCED = 5; + + // Transcribe spoken questions and queries into text. + VOICE_SEARCH = 6; + + // Transcribe voice commands, such as for controlling a device. + VOICE_COMMAND = 7; + + // Transcribe speech to text to create a written document, such as a + // text-message, email or report. + DICTATION = 8; + } + + // Enumerates the types of capture settings describing an audio file. + enum MicrophoneDistance { + // Audio type is not known. + MICROPHONE_DISTANCE_UNSPECIFIED = 0; + + // The audio was captured from a closely placed microphone. Eg. phone, + // dictaphone, or handheld microphone. Generally if there speaker is within + // 1 meter of the microphone. + NEARFIELD = 1; + + // The speaker if within 3 meters of the microphone. + MIDFIELD = 2; + + // The speaker is more than 3 meters away from the microphone. + FARFIELD = 3; + } + + // The original media the speech was recorded on. + enum OriginalMediaType { + // Unknown original media type. + ORIGINAL_MEDIA_TYPE_UNSPECIFIED = 0; + + // The speech data is an audio recording. + AUDIO = 1; + + // The speech data originally recorded on a video. + VIDEO = 2; + } + + // The type of device the speech was recorded with. + enum RecordingDeviceType { + // The recording device is unknown. + RECORDING_DEVICE_TYPE_UNSPECIFIED = 0; + + // Speech was recorded on a smartphone. + SMARTPHONE = 1; + + // Speech was recorded using a personal computer or tablet. + PC = 2; + + // Speech was recorded over a phone line. + PHONE_LINE = 3; + + // Speech was recorded in a vehicle. + VEHICLE = 4; + + // Speech was recorded outdoors. + OTHER_OUTDOOR_DEVICE = 5; + + // Speech was recorded indoors. + OTHER_INDOOR_DEVICE = 6; + } + + // The use case most closely describing the audio content to be recognized. + InteractionType interaction_type = 1; + + // The industry vertical to which this speech recognition request most + // closely applies. This is most indicative of the topics contained + // in the audio. Use the 6-digit NAICS code to identify the industry + // vertical - see https://www.naics.com/search/. + uint32 industry_naics_code_of_audio = 3; + + // The audio type that most closely describes the audio being recognized. + MicrophoneDistance microphone_distance = 4; + + // The original media the speech was recorded on. + OriginalMediaType original_media_type = 5; + + // The type of device the speech was recorded with. + RecordingDeviceType recording_device_type = 6; + + // The device used to make the recording. Examples 'Nexus 5X' or + // 'Polycom SoundStation IP 6000' or 'POTS' or 'VoIP' or + // 'Cardioid Microphone'. + string recording_device_name = 7; + + // Mime type of the original audio file. For example `audio/m4a`, + // `audio/x-alaw-basic`, `audio/mp3`, `audio/3gpp`. + // A list of possible audio mime types is maintained at + // http://www.iana.org/assignments/media-types/media-types.xhtml#audio + string original_mime_type = 8; + + // Obfuscated (privacy-protected) ID of the user, to identify number of + // unique users using the service. + int64 obfuscated_id = 9 [deprecated = true]; + + // Description of the content. Eg. "Recordings of federal supreme court + // hearings from 2012". + string audio_topic = 10; +} + +// Provides "hints" to the speech recognizer to favor specific words and phrases +// in the results. +message SpeechContext { + // A list of strings containing words and phrases "hints" so that + // the speech recognition is more likely to recognize them. This can be used + // to improve the accuracy for specific words and phrases, for example, if + // specific commands are typically spoken by the user. This can also be used + // to add additional words to the vocabulary of the recognizer. See + // [usage limits](https://cloud.google.com/speech-to-text/quotas#content). + // + // List items can also be set to classes for groups of words that represent + // common concepts that occur in natural language. For example, rather than + // providing phrase hints for every month of the year, using the $MONTH class + // improves the likelihood of correctly transcribing audio that includes + // months. + repeated string phrases = 1; + + // Hint Boost. Positive value will increase the probability that a specific + // phrase will be recognized over other similar sounding phrases. The higher + // the boost, the higher the chance of false positive recognition as well. + // Negative boost values would correspond to anti-biasing. Anti-biasing is not + // enabled, so negative boost will simply be ignored. Though `boost` can + // accept a wide range of positive values, most use cases are best served with + // values between 0 and 20. We recommend using a binary search approach to + // finding the optimal value for your use case. + float boost = 4; +} + +// Contains audio data in the encoding specified in the `RecognitionConfig`. +// Either `content` or `uri` must be supplied. Supplying both or neither +// returns [google.rpc.Code.INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT]. See +// [content limits](https://cloud.google.com/speech-to-text/quotas#content). +message RecognitionAudio { + // The audio source, which is either inline content or a Google Cloud + // Storage uri. + oneof audio_source { + // The audio data bytes encoded as specified in + // `RecognitionConfig`. Note: as with all bytes fields, proto buffers use a + // pure binary representation, whereas JSON representations use base64. + bytes content = 1; + + // URI that points to a file that contains audio data bytes as specified in + // `RecognitionConfig`. The file must not be compressed (for example, gzip). + // Currently, only Google Cloud Storage URIs are + // supported, which must be specified in the following format: + // `gs://bucket_name/object_name` (other URI formats return + // [google.rpc.Code.INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT]). For more information, see + // [Request URIs](https://cloud.google.com/storage/docs/reference-uris). + string uri = 2; + } +} + +// The only message returned to the client by the `Recognize` method. It +// contains the result as zero or more sequential `SpeechRecognitionResult` +// messages. +message RecognizeResponse { + // Sequential list of transcription results corresponding to + // sequential portions of audio. + repeated SpeechRecognitionResult results = 2; + + // When available, billed audio seconds for the corresponding request. + google.protobuf.Duration total_billed_time = 3; +} + +// The only message returned to the client by the `LongRunningRecognize` method. +// It contains the result as zero or more sequential `SpeechRecognitionResult` +// messages. It is included in the `result.response` field of the `Operation` +// returned by the `GetOperation` call of the `google::longrunning::Operations` +// service. +message LongRunningRecognizeResponse { + // Sequential list of transcription results corresponding to + // sequential portions of audio. + repeated SpeechRecognitionResult results = 2; + + // When available, billed audio seconds for the corresponding request. + google.protobuf.Duration total_billed_time = 3; + + // Original output config if present in the request. + TranscriptOutputConfig output_config = 6; + + // If the transcript output fails this field contains the relevant error. + google.rpc.Status output_error = 7; +} + +// Describes the progress of a long-running `LongRunningRecognize` call. It is +// included in the `metadata` field of the `Operation` returned by the +// `GetOperation` call of the `google::longrunning::Operations` service. +message LongRunningRecognizeMetadata { + // Approximate percentage of audio processed thus far. Guaranteed to be 100 + // when the audio is fully processed and the results are available. + int32 progress_percent = 1; + + // Time when the request was received. + google.protobuf.Timestamp start_time = 2; + + // Time of the most recent processing update. + google.protobuf.Timestamp last_update_time = 3; + + // Output only. The URI of the audio file being transcribed. Empty if the audio was sent + // as byte content. + string uri = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. A copy of the TranscriptOutputConfig if it was set in the request. + TranscriptOutputConfig output_config = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// `StreamingRecognizeResponse` is the only message returned to the client by +// `StreamingRecognize`. A series of zero or more `StreamingRecognizeResponse` +// messages are streamed back to the client. If there is no recognizable +// audio, and `single_utterance` is set to false, then no messages are streamed +// back to the client. +// +// Here's an example of a series of `StreamingRecognizeResponse`s that might be +// returned while processing audio: +// +// 1. results { alternatives { transcript: "tube" } stability: 0.01 } +// +// 2. results { alternatives { transcript: "to be a" } stability: 0.01 } +// +// 3. results { alternatives { transcript: "to be" } stability: 0.9 } +// results { alternatives { transcript: " or not to be" } stability: 0.01 } +// +// 4. results { alternatives { transcript: "to be or not to be" +// confidence: 0.92 } +// alternatives { transcript: "to bee or not to bee" } +// is_final: true } +// +// 5. results { alternatives { transcript: " that's" } stability: 0.01 } +// +// 6. results { alternatives { transcript: " that is" } stability: 0.9 } +// results { alternatives { transcript: " the question" } stability: 0.01 } +// +// 7. results { alternatives { transcript: " that is the question" +// confidence: 0.98 } +// alternatives { transcript: " that was the question" } +// is_final: true } +// +// Notes: +// +// - Only two of the above responses #4 and #7 contain final results; they are +// indicated by `is_final: true`. Concatenating these together generates the +// full transcript: "to be or not to be that is the question". +// +// - The others contain interim `results`. #3 and #6 contain two interim +// `results`: the first portion has a high stability and is less likely to +// change; the second portion has a low stability and is very likely to +// change. A UI designer might choose to show only high stability `results`. +// +// - The specific `stability` and `confidence` values shown above are only for +// illustrative purposes. Actual values may vary. +// +// - In each response, only one of these fields will be set: +// `error`, +// `speech_event_type`, or +// one or more (repeated) `results`. +message StreamingRecognizeResponse { + // Indicates the type of speech event. + enum SpeechEventType { + // No speech event specified. + SPEECH_EVENT_UNSPECIFIED = 0; + + // This event indicates that the server has detected the end of the user's + // speech utterance and expects no additional speech. Therefore, the server + // will not process additional audio (although it may subsequently return + // additional results). The client should stop sending additional audio + // data, half-close the gRPC connection, and wait for any additional results + // until the server closes the gRPC connection. This event is only sent if + // `single_utterance` was set to `true`, and is not used otherwise. + END_OF_SINGLE_UTTERANCE = 1; + } + + // If set, returns a [google.rpc.Status][google.rpc.Status] message that + // specifies the error for the operation. + google.rpc.Status error = 1; + + // This repeated list contains zero or more results that + // correspond to consecutive portions of the audio currently being processed. + // It contains zero or one `is_final=true` result (the newly settled portion), + // followed by zero or more `is_final=false` results (the interim results). + repeated StreamingRecognitionResult results = 2; + + // Indicates the type of speech event. + SpeechEventType speech_event_type = 4; + + // When available, billed audio seconds for the stream. + // Set only if this is the last response in the stream. + google.protobuf.Duration total_billed_time = 5; +} + +// A streaming speech recognition result corresponding to a portion of the audio +// that is currently being processed. +message StreamingRecognitionResult { + // May contain one or more recognition hypotheses (up to the + // maximum specified in `max_alternatives`). + // These alternatives are ordered in terms of accuracy, with the top (first) + // alternative being the most probable, as ranked by the recognizer. + repeated SpeechRecognitionAlternative alternatives = 1; + + // If `false`, this `StreamingRecognitionResult` represents an + // interim result that may change. If `true`, this is the final time the + // speech service will return this particular `StreamingRecognitionResult`, + // the recognizer will not return any further hypotheses for this portion of + // the transcript and corresponding audio. + bool is_final = 2; + + // An estimate of the likelihood that the recognizer will not + // change its guess about this interim result. Values range from 0.0 + // (completely unstable) to 1.0 (completely stable). + // This field is only provided for interim results (`is_final=false`). + // The default of 0.0 is a sentinel value indicating `stability` was not set. + float stability = 3; + + // Time offset of the end of this result relative to the + // beginning of the audio. + google.protobuf.Duration result_end_time = 4; + + // For multi-channel audio, this is the channel number corresponding to the + // recognized result for the audio from that channel. + // For audio_channel_count = N, its output values can range from '1' to 'N'. + int32 channel_tag = 5; + + // Output only. The [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag + // of the language in this result. This language code was detected to have + // the most likelihood of being spoken in the audio. + string language_code = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// A speech recognition result corresponding to a portion of the audio. +message SpeechRecognitionResult { + // May contain one or more recognition hypotheses (up to the + // maximum specified in `max_alternatives`). + // These alternatives are ordered in terms of accuracy, with the top (first) + // alternative being the most probable, as ranked by the recognizer. + repeated SpeechRecognitionAlternative alternatives = 1; + + // For multi-channel audio, this is the channel number corresponding to the + // recognized result for the audio from that channel. + // For audio_channel_count = N, its output values can range from '1' to 'N'. + int32 channel_tag = 2; + + // Time offset of the end of this result relative to the + // beginning of the audio. + google.protobuf.Duration result_end_time = 4; + + // Output only. The [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag + // of the language in this result. This language code was detected to have + // the most likelihood of being spoken in the audio. + string language_code = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Alternative hypotheses (a.k.a. n-best list). +message SpeechRecognitionAlternative { + // Transcript text representing the words that the user spoke. + // In languages that use spaces to separate words, the transcript might have a + // leading space if it isn't the first result. You can concatenate each result + // to obtain the full transcript without using a separator. + string transcript = 1; + + // The confidence estimate between 0.0 and 1.0. A higher number + // indicates an estimated greater likelihood that the recognized words are + // correct. This field is set only for the top alternative of a non-streaming + // result or, of a streaming result where `is_final=true`. + // This field is not guaranteed to be accurate and users should not rely on it + // to be always provided. + // The default of 0.0 is a sentinel value indicating `confidence` was not set. + float confidence = 2; + + // A list of word-specific information for each recognized word. + // Note: When `enable_speaker_diarization` is true, you will see all the words + // from the beginning of the audio. + repeated WordInfo words = 3; +} + +// Word-specific information for recognized words. +message WordInfo { + // Time offset relative to the beginning of the audio, + // and corresponding to the start of the spoken word. + // This field is only set if `enable_word_time_offsets=true` and only + // in the top hypothesis. + // This is an experimental feature and the accuracy of the time offset can + // vary. + google.protobuf.Duration start_time = 1; + + // Time offset relative to the beginning of the audio, + // and corresponding to the end of the spoken word. + // This field is only set if `enable_word_time_offsets=true` and only + // in the top hypothesis. + // This is an experimental feature and the accuracy of the time offset can + // vary. + google.protobuf.Duration end_time = 2; + + // The word corresponding to this set of information. + string word = 3; + + // The confidence estimate between 0.0 and 1.0. A higher number + // indicates an estimated greater likelihood that the recognized words are + // correct. This field is set only for the top alternative of a non-streaming + // result or, of a streaming result where `is_final=true`. + // This field is not guaranteed to be accurate and users should not rely on it + // to be always provided. + // The default of 0.0 is a sentinel value indicating `confidence` was not set. + float confidence = 4; + + // Output only. A distinct integer value is assigned for every speaker within + // the audio. This field specifies which one of those speakers was detected to + // have spoken this word. Value ranges from '1' to diarization_speaker_count. + // speaker_tag is set if enable_speaker_diarization = 'true' and only in the + // top alternative. + int32 speaker_tag = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; +} diff --git a/owl-bot-staging/v1p1beta1/protos/google/cloud/speech/v1p1beta1/cloud_speech_adaptation.proto b/owl-bot-staging/v1p1beta1/protos/google/cloud/speech/v1p1beta1/cloud_speech_adaptation.proto new file mode 100644 index 00000000..45ca97f2 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/protos/google/cloud/speech/v1p1beta1/cloud_speech_adaptation.proto @@ -0,0 +1,370 @@ +// Copyright 2022 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 +// +// http://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. + +syntax = "proto3"; + +package google.cloud.speech.v1p1beta1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/speech/v1p1beta1/resource.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/speech/v1p1beta1;speech"; +option java_multiple_files = true; +option java_outer_classname = "SpeechAdaptationProto"; +option java_package = "com.google.cloud.speech.v1p1beta1"; +option objc_class_prefix = "GCS"; + +// Service that implements Google Cloud Speech Adaptation API. +service Adaptation { + option (google.api.default_host) = "speech.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // 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. + rpc CreatePhraseSet(CreatePhraseSetRequest) returns (PhraseSet) { + option (google.api.http) = { + post: "/v1p1beta1/{parent=projects/*/locations/*}/phraseSets" + body: "*" + }; + option (google.api.method_signature) = "parent,phrase_set,phrase_set_id"; + } + + // Get a phrase set. + rpc GetPhraseSet(GetPhraseSetRequest) returns (PhraseSet) { + option (google.api.http) = { + get: "/v1p1beta1/{name=projects/*/locations/*/phraseSets/*}" + }; + option (google.api.method_signature) = "name"; + } + + // List phrase sets. + rpc ListPhraseSet(ListPhraseSetRequest) returns (ListPhraseSetResponse) { + option (google.api.http) = { + get: "/v1p1beta1/{parent=projects/*/locations/*}/phraseSets" + }; + option (google.api.method_signature) = "parent"; + } + + // Update a phrase set. + rpc UpdatePhraseSet(UpdatePhraseSetRequest) returns (PhraseSet) { + option (google.api.http) = { + patch: "/v1p1beta1/{phrase_set.name=projects/*/locations/*/phraseSets/*}" + body: "phrase_set" + }; + option (google.api.method_signature) = "phrase_set,update_mask"; + } + + // Delete a phrase set. + rpc DeletePhraseSet(DeletePhraseSetRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1p1beta1/{name=projects/*/locations/*/phraseSets/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Create a custom class. + rpc CreateCustomClass(CreateCustomClassRequest) returns (CustomClass) { + option (google.api.http) = { + post: "/v1p1beta1/{parent=projects/*/locations/*}/customClasses" + body: "*" + }; + option (google.api.method_signature) = "parent,custom_class,custom_class_id"; + } + + // Get a custom class. + rpc GetCustomClass(GetCustomClassRequest) returns (CustomClass) { + option (google.api.http) = { + get: "/v1p1beta1/{name=projects/*/locations/*/customClasses/*}" + }; + option (google.api.method_signature) = "name"; + } + + // List custom classes. + rpc ListCustomClasses(ListCustomClassesRequest) returns (ListCustomClassesResponse) { + option (google.api.http) = { + get: "/v1p1beta1/{parent=projects/*/locations/*}/customClasses" + }; + option (google.api.method_signature) = "parent"; + } + + // Update a custom class. + rpc UpdateCustomClass(UpdateCustomClassRequest) returns (CustomClass) { + option (google.api.http) = { + patch: "/v1p1beta1/{custom_class.name=projects/*/locations/*/customClasses/*}" + body: "custom_class" + }; + option (google.api.method_signature) = "custom_class,update_mask"; + } + + // Delete a custom class. + rpc DeleteCustomClass(DeleteCustomClassRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1p1beta1/{name=projects/*/locations/*/customClasses/*}" + }; + option (google.api.method_signature) = "name"; + } +} + +// Message sent by the client for the `CreatePhraseSet` method. +message CreatePhraseSetRequest { + // Required. The parent resource where this phrase set will be created. Format: + // + // `projects/{project}/locations/{location}/phraseSets` + // + // Speech-to-Text supports three locations: `global`, `us` (US North America), + // and `eu` (Europe). If you are calling the `speech.googleapis.com` + // endpoint, use the `global` location. To specify a region, use a + // [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + // with matching `us` or `eu` location value. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "speech.googleapis.com/PhraseSet" + } + ]; + + // Required. The ID to use for the phrase set, which will become the final + // component of the phrase set's resource name. + // + // This value should restrict to letters, numbers, and hyphens, with the first + // character a letter, the last a letter or a number, and be 4-63 characters. + string phrase_set_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The phrase set to create. + PhraseSet phrase_set = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Message sent by the client for the `UpdatePhraseSet` method. +message UpdatePhraseSetRequest { + // Required. The phrase set to update. + // + // The phrase set's `name` field is used to identify the set to be + // updated. Format: + // + // `projects/{project}/locations/{location}/phraseSets/{phrase_set}` + // + // Speech-to-Text supports three locations: `global`, `us` (US North America), + // and `eu` (Europe). If you are calling the `speech.googleapis.com` + // endpoint, use the `global` location. To specify a region, use a + // [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + // with matching `us` or `eu` location value. + PhraseSet phrase_set = 1 [(google.api.field_behavior) = REQUIRED]; + + // The list of fields to be updated. + google.protobuf.FieldMask update_mask = 2; +} + +// Message sent by the client for the `GetPhraseSet` method. +message GetPhraseSetRequest { + // Required. The name of the phrase set to retrieve. Format: + // + // `projects/{project}/locations/{location}/phraseSets/{phrase_set}` + // + // Speech-to-Text supports three locations: `global`, `us` (US North America), + // and `eu` (Europe). If you are calling the `speech.googleapis.com` + // endpoint, use the `global` location. To specify a region, use a + // [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + // with matching `us` or `eu` location value. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "speech.googleapis.com/PhraseSet" + } + ]; +} + +// Message sent by the client for the `ListPhraseSet` method. +message ListPhraseSetRequest { + // Required. The parent, which owns this collection of phrase set. Format: + // + // `projects/{project}/locations/{location}` + // + // Speech-to-Text supports three locations: `global`, `us` (US North America), + // and `eu` (Europe). If you are calling the `speech.googleapis.com` + // endpoint, use the `global` location. To specify a region, use a + // [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + // with matching `us` or `eu` location value. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "speech.googleapis.com/PhraseSet" + } + ]; + + // 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. + int32 page_size = 2; + + // 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. + string page_token = 3; +} + +// Message returned to the client by the `ListPhraseSet` method. +message ListPhraseSetResponse { + // The phrase set. + repeated PhraseSet phrase_sets = 1; + + // A token, which can be sent as `page_token` to retrieve the next page. + // If this field is omitted, there are no subsequent pages. + string next_page_token = 2; +} + +// Message sent by the client for the `DeletePhraseSet` method. +message DeletePhraseSetRequest { + // Required. The name of the phrase set to delete. Format: + // + // `projects/{project}/locations/{location}/phraseSets/{phrase_set}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "speech.googleapis.com/PhraseSet" + } + ]; +} + +// Message sent by the client for the `CreateCustomClass` method. +message CreateCustomClassRequest { + // Required. The parent resource where this custom class will be created. Format: + // + // `projects/{project}/locations/{location}/customClasses` + // + // Speech-to-Text supports three locations: `global`, `us` (US North America), + // and `eu` (Europe). If you are calling the `speech.googleapis.com` + // endpoint, use the `global` location. To specify a region, use a + // [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + // with matching `us` or `eu` location value. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "speech.googleapis.com/CustomClass" + } + ]; + + // Required. The ID to use for the custom class, which will become the final + // component of the custom class' resource name. + // + // This value should restrict to letters, numbers, and hyphens, with the first + // character a letter, the last a letter or a number, and be 4-63 characters. + string custom_class_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The custom class to create. + CustomClass custom_class = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Message sent by the client for the `UpdateCustomClass` method. +message UpdateCustomClassRequest { + // Required. The custom class to update. + // + // The custom class's `name` field is used to identify the custom class to be + // updated. Format: + // + // `projects/{project}/locations/{location}/customClasses/{custom_class}` + // + // Speech-to-Text supports three locations: `global`, `us` (US North America), + // and `eu` (Europe). If you are calling the `speech.googleapis.com` + // endpoint, use the `global` location. To specify a region, use a + // [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + // with matching `us` or `eu` location value. + CustomClass custom_class = 1 [(google.api.field_behavior) = REQUIRED]; + + // The list of fields to be updated. + google.protobuf.FieldMask update_mask = 2; +} + +// Message sent by the client for the `GetCustomClass` method. +message GetCustomClassRequest { + // Required. The name of the custom class to retrieve. Format: + // + // `projects/{project}/locations/{location}/customClasses/{custom_class}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "speech.googleapis.com/CustomClass" + } + ]; +} + +// Message sent by the client for the `ListCustomClasses` method. +message ListCustomClassesRequest { + // Required. The parent, which owns this collection of custom classes. Format: + // + // `projects/{project}/locations/{location}/customClasses` + // + // Speech-to-Text supports three locations: `global`, `us` (US North America), + // and `eu` (Europe). If you are calling the `speech.googleapis.com` + // endpoint, use the `global` location. To specify a region, use a + // [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + // with matching `us` or `eu` location value. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "speech.googleapis.com/CustomClass" + } + ]; + + // 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. + int32 page_size = 2; + + // 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. + string page_token = 3; +} + +// Message returned to the client by the `ListCustomClasses` method. +message ListCustomClassesResponse { + // The custom classes. + repeated CustomClass custom_classes = 1; + + // A token, which can be sent as `page_token` to retrieve the next page. + // If this field is omitted, there are no subsequent pages. + string next_page_token = 2; +} + +// Message sent by the client for the `DeleteCustomClass` method. +message DeleteCustomClassRequest { + // Required. The name of the custom class to delete. Format: + // + // `projects/{project}/locations/{location}/customClasses/{custom_class}` + // + // Speech-to-Text supports three locations: `global`, `us` (US North America), + // and `eu` (Europe). If you are calling the `speech.googleapis.com` + // endpoint, use the `global` location. To specify a region, use a + // [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + // with matching `us` or `eu` location value. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "speech.googleapis.com/CustomClass" + } + ]; +} diff --git a/owl-bot-staging/v1p1beta1/protos/google/cloud/speech/v1p1beta1/resource.proto b/owl-bot-staging/v1p1beta1/protos/google/cloud/speech/v1p1beta1/resource.proto new file mode 100644 index 00000000..0323b19e --- /dev/null +++ b/owl-bot-staging/v1p1beta1/protos/google/cloud/speech/v1p1beta1/resource.proto @@ -0,0 +1,162 @@ +// Copyright 2022 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 +// +// http://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. + +syntax = "proto3"; + +package google.cloud.speech.v1p1beta1; + +import "google/api/resource.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/speech/v1p1beta1;speech"; +option java_multiple_files = true; +option java_outer_classname = "SpeechResourceProto"; +option java_package = "com.google.cloud.speech.v1p1beta1"; +option objc_class_prefix = "GCS"; + +// A set of words or phrases that represents a common concept likely to appear +// in your audio, for example a list of passenger ship names. CustomClass items +// can be substituted into placeholders that you set in PhraseSet phrases. +message CustomClass { + option (google.api.resource) = { + type: "speech.googleapis.com/CustomClass" + pattern: "projects/{project}/locations/{location}/customClasses/{custom_class}" + }; + + // An item of the class. + message ClassItem { + // The class item's value. + string value = 1; + } + + // The resource name of the custom class. + string name = 1; + + // If this custom class is a resource, the custom_class_id is the resource id + // of the CustomClass. Case sensitive. + string custom_class_id = 2; + + // A collection of class items. + repeated ClassItem items = 3; +} + +// Provides "hints" to the speech recognizer to favor specific words and phrases +// in the results. +message PhraseSet { + option (google.api.resource) = { + type: "speech.googleapis.com/PhraseSet" + pattern: "projects/{project}/locations/{location}/phraseSets/{phrase_set}" + }; + + // A phrases containing words and phrase "hints" so that + // the speech recognition is more likely to recognize them. This can be used + // to improve the accuracy for specific words and phrases, for example, if + // specific commands are typically spoken by the user. This can also be used + // to add additional words to the vocabulary of the recognizer. See + // [usage limits](https://cloud.google.com/speech-to-text/quotas#content). + // + // List items can also include pre-built or custom classes containing groups + // of words that represent common concepts that occur in natural language. For + // example, rather than providing a phrase hint for every month of the + // year (e.g. "i was born in january", "i was born in febuary", ...), use the + // pre-built `$MONTH` class improves the likelihood of correctly transcribing + // audio that includes months (e.g. "i was born in $month"). + // To refer to pre-built classes, use the class' symbol prepended with `$` + // e.g. `$MONTH`. To refer to custom classes that were defined inline in the + // request, set the class's `custom_class_id` to a string unique to all class + // resources and inline classes. Then use the class' id wrapped in $`{...}` + // e.g. "${my-months}". To refer to custom classes resources, use the class' + // id wrapped in `${}` (e.g. `${my-months}`). + // + // Speech-to-Text supports three locations: `global`, `us` (US North America), + // and `eu` (Europe). If you are calling the `speech.googleapis.com` + // endpoint, use the `global` location. To specify a region, use a + // [regional endpoint](/speech-to-text/docs/endpoints) with matching `us` or + // `eu` location value. + message Phrase { + // The phrase itself. + string value = 1; + + // Hint Boost. Overrides the boost set at the phrase set level. + // Positive value will increase the probability that a specific phrase will + // be recognized over other similar sounding phrases. The higher the boost, + // the higher the chance of false positive recognition as well. Negative + // boost will simply be ignored. Though `boost` can accept a wide range of + // positive values, most use cases are best served + // with values between 0 and 20. We recommend using a binary search approach + // to finding the optimal value for your use case. Speech recognition + // will skip PhraseSets with a boost value of 0. + float boost = 2; + } + + // The resource name of the phrase set. + string name = 1; + + // A list of word and phrases. + repeated Phrase phrases = 2; + + // Hint Boost. Positive value will increase the probability that a specific + // phrase will be recognized over other similar sounding phrases. The higher + // the boost, the higher the chance of false positive recognition as well. + // Negative boost values would correspond to anti-biasing. Anti-biasing is not + // enabled, so negative boost will simply be ignored. Though `boost` can + // accept a wide range of positive values, most use cases are best served with + // values between 0 (exclusive) and 20. We recommend using a binary search + // approach to finding the optimal value for your use case. Speech recognition + // will skip PhraseSets with a boost value of 0. + float boost = 4; +} + +// Speech adaptation configuration. +message SpeechAdaptation { + // A collection of phrase sets. To specify the hints inline, leave the + // phrase set's `name` blank and fill in the rest of its fields. Any + // phrase set can use any custom class. + repeated PhraseSet phrase_sets = 1; + + // A collection of phrase set resource names to use. + repeated string phrase_set_references = 2 [(google.api.resource_reference) = { + type: "speech.googleapis.com/PhraseSet" + }]; + + // A collection of custom classes. To specify the classes inline, leave the + // class' `name` blank and fill in the rest of its fields, giving it a unique + // `custom_class_id`. Refer to the inline defined class in phrase hints by its + // `custom_class_id`. + repeated CustomClass custom_classes = 3; +} + +// Transcription normalization configuration. Use transcription normalization +// to automatically replace parts of the transcript with phrases of your +// choosing. For StreamingRecognize, this normalization only applies to stable +// partial transcripts (stability > 0.8) and final transcripts. +message TranscriptNormalization { + // A single replacement configuration. + message Entry { + // What to replace. Max length is 100 characters. + string search = 1; + + // What to replace with. Max length is 100 characters. + string replace = 2; + + // Whether the search is case sensitive. + bool case_sensitive = 3; + } + + // A list of replacement entries. We will perform replacement with one entry + // at a time. For example, the second entry in ["cat" => "dog", "mountain cat" + // => "mountain dog"] will never be applied because we will always process the + // first entry before it. At most 100 entries. + repeated Entry entries = 1; +} diff --git a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.create_custom_class.js b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.create_custom_class.js new file mode 100644 index 00000000..0429b977 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.create_custom_class.js @@ -0,0 +1,80 @@ +// Copyright 2022 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. ** + + + +'use strict'; + +function main(parent, customClassId, customClass) { + // [START speech_v1p1beta1_generated_Adaptation_CreateCustomClass_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent resource where this custom class will be created. Format: + * `projects/{project}/locations/{location}/customClasses` + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * regional endpoint (https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + */ + // const parent = 'abc123' + /** + * Required. The ID to use for the custom class, which will become the final + * component of the custom class' resource name. + * This value should restrict to letters, numbers, and hyphens, with the first + * character a letter, the last a letter or a number, and be 4-63 characters. + */ + // const customClassId = 'abc123' + /** + * Required. The custom class to create. + */ + // const customClass = {} + + // Imports the Speech library + const {AdaptationClient} = require('@google-cloud/speech').v1p1beta1; + + // Instantiates a client + const speechClient = new AdaptationClient(); + + async function callCreateCustomClass() { + // Construct request + const request = { + parent, + customClassId, + customClass, + }; + + // Run request + const response = await speechClient.createCustomClass(request); + console.log(response); + } + + callCreateCustomClass(); + // [END speech_v1p1beta1_generated_Adaptation_CreateCustomClass_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.create_phrase_set.js b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.create_phrase_set.js new file mode 100644 index 00000000..4025a95d --- /dev/null +++ b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.create_phrase_set.js @@ -0,0 +1,80 @@ +// Copyright 2022 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. ** + + + +'use strict'; + +function main(parent, phraseSetId, phraseSet) { + // [START speech_v1p1beta1_generated_Adaptation_CreatePhraseSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent resource where this phrase set will be created. Format: + * `projects/{project}/locations/{location}/phraseSets` + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * regional endpoint (https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + */ + // const parent = 'abc123' + /** + * Required. The ID to use for the phrase set, which will become the final + * component of the phrase set's resource name. + * This value should restrict to letters, numbers, and hyphens, with the first + * character a letter, the last a letter or a number, and be 4-63 characters. + */ + // const phraseSetId = 'abc123' + /** + * Required. The phrase set to create. + */ + // const phraseSet = {} + + // Imports the Speech library + const {AdaptationClient} = require('@google-cloud/speech').v1p1beta1; + + // Instantiates a client + const speechClient = new AdaptationClient(); + + async function callCreatePhraseSet() { + // Construct request + const request = { + parent, + phraseSetId, + phraseSet, + }; + + // Run request + const response = await speechClient.createPhraseSet(request); + console.log(response); + } + + callCreatePhraseSet(); + // [END speech_v1p1beta1_generated_Adaptation_CreatePhraseSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.delete_custom_class.js b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.delete_custom_class.js new file mode 100644 index 00000000..47693ff1 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.delete_custom_class.js @@ -0,0 +1,67 @@ +// Copyright 2022 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. ** + + + +'use strict'; + +function main(name) { + // [START speech_v1p1beta1_generated_Adaptation_DeleteCustomClass_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the custom class to delete. Format: + * `projects/{project}/locations/{location}/customClasses/{custom_class}` + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * regional endpoint (https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + */ + // const name = 'abc123' + + // Imports the Speech library + const {AdaptationClient} = require('@google-cloud/speech').v1p1beta1; + + // Instantiates a client + const speechClient = new AdaptationClient(); + + async function callDeleteCustomClass() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await speechClient.deleteCustomClass(request); + console.log(response); + } + + callDeleteCustomClass(); + // [END speech_v1p1beta1_generated_Adaptation_DeleteCustomClass_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.delete_phrase_set.js b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.delete_phrase_set.js new file mode 100644 index 00000000..76aed0d0 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.delete_phrase_set.js @@ -0,0 +1,62 @@ +// Copyright 2022 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. ** + + + +'use strict'; + +function main(name) { + // [START speech_v1p1beta1_generated_Adaptation_DeletePhraseSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the phrase set to delete. Format: + * `projects/{project}/locations/{location}/phraseSets/{phrase_set}` + */ + // const name = 'abc123' + + // Imports the Speech library + const {AdaptationClient} = require('@google-cloud/speech').v1p1beta1; + + // Instantiates a client + const speechClient = new AdaptationClient(); + + async function callDeletePhraseSet() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await speechClient.deletePhraseSet(request); + console.log(response); + } + + callDeletePhraseSet(); + // [END speech_v1p1beta1_generated_Adaptation_DeletePhraseSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.get_custom_class.js b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.get_custom_class.js new file mode 100644 index 00000000..2e4208b9 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.get_custom_class.js @@ -0,0 +1,62 @@ +// Copyright 2022 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. ** + + + +'use strict'; + +function main(name) { + // [START speech_v1p1beta1_generated_Adaptation_GetCustomClass_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the custom class to retrieve. Format: + * `projects/{project}/locations/{location}/customClasses/{custom_class}` + */ + // const name = 'abc123' + + // Imports the Speech library + const {AdaptationClient} = require('@google-cloud/speech').v1p1beta1; + + // Instantiates a client + const speechClient = new AdaptationClient(); + + async function callGetCustomClass() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await speechClient.getCustomClass(request); + console.log(response); + } + + callGetCustomClass(); + // [END speech_v1p1beta1_generated_Adaptation_GetCustomClass_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.get_phrase_set.js b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.get_phrase_set.js new file mode 100644 index 00000000..b94463a1 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.get_phrase_set.js @@ -0,0 +1,67 @@ +// Copyright 2022 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. ** + + + +'use strict'; + +function main(name) { + // [START speech_v1p1beta1_generated_Adaptation_GetPhraseSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the phrase set to retrieve. Format: + * `projects/{project}/locations/{location}/phraseSets/{phrase_set}` + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * regional endpoint (https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + */ + // const name = 'abc123' + + // Imports the Speech library + const {AdaptationClient} = require('@google-cloud/speech').v1p1beta1; + + // Instantiates a client + const speechClient = new AdaptationClient(); + + async function callGetPhraseSet() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await speechClient.getPhraseSet(request); + console.log(response); + } + + callGetPhraseSet(); + // [END speech_v1p1beta1_generated_Adaptation_GetPhraseSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.list_custom_classes.js b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.list_custom_classes.js new file mode 100644 index 00000000..8a935c16 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.list_custom_classes.js @@ -0,0 +1,83 @@ +// Copyright 2022 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. ** + + + +'use strict'; + +function main(parent) { + // [START speech_v1p1beta1_generated_Adaptation_ListCustomClasses_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent, which owns this collection of custom classes. Format: + * `projects/{project}/locations/{location}/customClasses` + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * regional endpoint (https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + */ + // const parent = 'abc123' + /** + * 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. + */ + // const pageSize = 1234 + /** + * 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. + */ + // const pageToken = 'abc123' + + // Imports the Speech library + const {AdaptationClient} = require('@google-cloud/speech').v1p1beta1; + + // Instantiates a client + const speechClient = new AdaptationClient(); + + async function callListCustomClasses() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await speechClient.listCustomClassesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListCustomClasses(); + // [END speech_v1p1beta1_generated_Adaptation_ListCustomClasses_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.list_phrase_set.js b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.list_phrase_set.js new file mode 100644 index 00000000..0912eb8f --- /dev/null +++ b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.list_phrase_set.js @@ -0,0 +1,83 @@ +// Copyright 2022 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. ** + + + +'use strict'; + +function main(parent) { + // [START speech_v1p1beta1_generated_Adaptation_ListPhraseSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent, which owns this collection of phrase set. Format: + * `projects/{project}/locations/{location}` + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * regional endpoint (https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + */ + // const parent = 'abc123' + /** + * 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. + */ + // const pageSize = 1234 + /** + * 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. + */ + // const pageToken = 'abc123' + + // Imports the Speech library + const {AdaptationClient} = require('@google-cloud/speech').v1p1beta1; + + // Instantiates a client + const speechClient = new AdaptationClient(); + + async function callListPhraseSet() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await speechClient.listPhraseSetAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListPhraseSet(); + // [END speech_v1p1beta1_generated_Adaptation_ListPhraseSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.update_custom_class.js b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.update_custom_class.js new file mode 100644 index 00000000..7676ed2a --- /dev/null +++ b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.update_custom_class.js @@ -0,0 +1,73 @@ +// Copyright 2022 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. ** + + + +'use strict'; + +function main(customClass) { + // [START speech_v1p1beta1_generated_Adaptation_UpdateCustomClass_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The custom class to update. + * The custom class's `name` field is used to identify the custom class to be + * updated. Format: + * `projects/{project}/locations/{location}/customClasses/{custom_class}` + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * regional endpoint (https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + */ + // const customClass = {} + /** + * The list of fields to be updated. + */ + // const updateMask = {} + + // Imports the Speech library + const {AdaptationClient} = require('@google-cloud/speech').v1p1beta1; + + // Instantiates a client + const speechClient = new AdaptationClient(); + + async function callUpdateCustomClass() { + // Construct request + const request = { + customClass, + }; + + // Run request + const response = await speechClient.updateCustomClass(request); + console.log(response); + } + + callUpdateCustomClass(); + // [END speech_v1p1beta1_generated_Adaptation_UpdateCustomClass_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.update_phrase_set.js b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.update_phrase_set.js new file mode 100644 index 00000000..8a8b15a3 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.update_phrase_set.js @@ -0,0 +1,73 @@ +// Copyright 2022 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. ** + + + +'use strict'; + +function main(phraseSet) { + // [START speech_v1p1beta1_generated_Adaptation_UpdatePhraseSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The phrase set to update. + * The phrase set's `name` field is used to identify the set to be + * updated. Format: + * `projects/{project}/locations/{location}/phraseSets/{phrase_set}` + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * regional endpoint (https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + */ + // const phraseSet = {} + /** + * The list of fields to be updated. + */ + // const updateMask = {} + + // Imports the Speech library + const {AdaptationClient} = require('@google-cloud/speech').v1p1beta1; + + // Instantiates a client + const speechClient = new AdaptationClient(); + + async function callUpdatePhraseSet() { + // Construct request + const request = { + phraseSet, + }; + + // Run request + const response = await speechClient.updatePhraseSet(request); + console.log(response); + } + + callUpdatePhraseSet(); + // [END speech_v1p1beta1_generated_Adaptation_UpdatePhraseSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/snippet_metadata.google.cloud.speech.v1p1beta1.json b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/snippet_metadata.google.cloud.speech.v1p1beta1.json new file mode 100644 index 00000000..5e3b27e4 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/snippet_metadata.google.cloud.speech.v1p1beta1.json @@ -0,0 +1,591 @@ +{ + "clientLibrary": { + "name": "nodejs-speech", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.speech.v1p1beta1", + "version": "v1p1beta1" + } + ] + }, + "snippets": [ + { + "regionTag": "speech_v1p1beta1_generated_Adaptation_CreatePhraseSet_async", + "title": "Adaptation createPhraseSet Sample", + "origin": "API_DEFINITION", + "description": " 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.", + "canonical": true, + "file": "adaptation.create_phrase_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreatePhraseSet", + "fullName": "google.cloud.speech.v1p1beta1.Adaptation.CreatePhraseSet", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "phrase_set_id", + "type": "TYPE_STRING" + }, + { + "name": "phrase_set", + "type": ".google.cloud.speech.v1p1beta1.PhraseSet" + } + ], + "resultType": ".google.cloud.speech.v1p1beta1.PhraseSet", + "client": { + "shortName": "AdaptationClient", + "fullName": "google.cloud.speech.v1p1beta1.AdaptationClient" + }, + "method": { + "shortName": "CreatePhraseSet", + "fullName": "google.cloud.speech.v1p1beta1.Adaptation.CreatePhraseSet", + "service": { + "shortName": "Adaptation", + "fullName": "google.cloud.speech.v1p1beta1.Adaptation" + } + } + } + }, + { + "regionTag": "speech_v1p1beta1_generated_Adaptation_GetPhraseSet_async", + "title": "Adaptation getPhraseSet Sample", + "origin": "API_DEFINITION", + "description": " Get a phrase set.", + "canonical": true, + "file": "adaptation.get_phrase_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetPhraseSet", + "fullName": "google.cloud.speech.v1p1beta1.Adaptation.GetPhraseSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.speech.v1p1beta1.PhraseSet", + "client": { + "shortName": "AdaptationClient", + "fullName": "google.cloud.speech.v1p1beta1.AdaptationClient" + }, + "method": { + "shortName": "GetPhraseSet", + "fullName": "google.cloud.speech.v1p1beta1.Adaptation.GetPhraseSet", + "service": { + "shortName": "Adaptation", + "fullName": "google.cloud.speech.v1p1beta1.Adaptation" + } + } + } + }, + { + "regionTag": "speech_v1p1beta1_generated_Adaptation_ListPhraseSet_async", + "title": "Adaptation listPhraseSet Sample", + "origin": "API_DEFINITION", + "description": " List phrase sets.", + "canonical": true, + "file": "adaptation.list_phrase_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListPhraseSet", + "fullName": "google.cloud.speech.v1p1beta1.Adaptation.ListPhraseSet", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.speech.v1p1beta1.ListPhraseSetResponse", + "client": { + "shortName": "AdaptationClient", + "fullName": "google.cloud.speech.v1p1beta1.AdaptationClient" + }, + "method": { + "shortName": "ListPhraseSet", + "fullName": "google.cloud.speech.v1p1beta1.Adaptation.ListPhraseSet", + "service": { + "shortName": "Adaptation", + "fullName": "google.cloud.speech.v1p1beta1.Adaptation" + } + } + } + }, + { + "regionTag": "speech_v1p1beta1_generated_Adaptation_UpdatePhraseSet_async", + "title": "Adaptation updatePhraseSet Sample", + "origin": "API_DEFINITION", + "description": " Update a phrase set.", + "canonical": true, + "file": "adaptation.update_phrase_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdatePhraseSet", + "fullName": "google.cloud.speech.v1p1beta1.Adaptation.UpdatePhraseSet", + "async": true, + "parameters": [ + { + "name": "phrase_set", + "type": ".google.cloud.speech.v1p1beta1.PhraseSet" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.speech.v1p1beta1.PhraseSet", + "client": { + "shortName": "AdaptationClient", + "fullName": "google.cloud.speech.v1p1beta1.AdaptationClient" + }, + "method": { + "shortName": "UpdatePhraseSet", + "fullName": "google.cloud.speech.v1p1beta1.Adaptation.UpdatePhraseSet", + "service": { + "shortName": "Adaptation", + "fullName": "google.cloud.speech.v1p1beta1.Adaptation" + } + } + } + }, + { + "regionTag": "speech_v1p1beta1_generated_Adaptation_DeletePhraseSet_async", + "title": "Adaptation deletePhraseSet Sample", + "origin": "API_DEFINITION", + "description": " Delete a phrase set.", + "canonical": true, + "file": "adaptation.delete_phrase_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeletePhraseSet", + "fullName": "google.cloud.speech.v1p1beta1.Adaptation.DeletePhraseSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "AdaptationClient", + "fullName": "google.cloud.speech.v1p1beta1.AdaptationClient" + }, + "method": { + "shortName": "DeletePhraseSet", + "fullName": "google.cloud.speech.v1p1beta1.Adaptation.DeletePhraseSet", + "service": { + "shortName": "Adaptation", + "fullName": "google.cloud.speech.v1p1beta1.Adaptation" + } + } + } + }, + { + "regionTag": "speech_v1p1beta1_generated_Adaptation_CreateCustomClass_async", + "title": "Adaptation createCustomClass Sample", + "origin": "API_DEFINITION", + "description": " Create a custom class.", + "canonical": true, + "file": "adaptation.create_custom_class.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateCustomClass", + "fullName": "google.cloud.speech.v1p1beta1.Adaptation.CreateCustomClass", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "custom_class_id", + "type": "TYPE_STRING" + }, + { + "name": "custom_class", + "type": ".google.cloud.speech.v1p1beta1.CustomClass" + } + ], + "resultType": ".google.cloud.speech.v1p1beta1.CustomClass", + "client": { + "shortName": "AdaptationClient", + "fullName": "google.cloud.speech.v1p1beta1.AdaptationClient" + }, + "method": { + "shortName": "CreateCustomClass", + "fullName": "google.cloud.speech.v1p1beta1.Adaptation.CreateCustomClass", + "service": { + "shortName": "Adaptation", + "fullName": "google.cloud.speech.v1p1beta1.Adaptation" + } + } + } + }, + { + "regionTag": "speech_v1p1beta1_generated_Adaptation_GetCustomClass_async", + "title": "Adaptation getCustomClass Sample", + "origin": "API_DEFINITION", + "description": " Get a custom class.", + "canonical": true, + "file": "adaptation.get_custom_class.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetCustomClass", + "fullName": "google.cloud.speech.v1p1beta1.Adaptation.GetCustomClass", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.speech.v1p1beta1.CustomClass", + "client": { + "shortName": "AdaptationClient", + "fullName": "google.cloud.speech.v1p1beta1.AdaptationClient" + }, + "method": { + "shortName": "GetCustomClass", + "fullName": "google.cloud.speech.v1p1beta1.Adaptation.GetCustomClass", + "service": { + "shortName": "Adaptation", + "fullName": "google.cloud.speech.v1p1beta1.Adaptation" + } + } + } + }, + { + "regionTag": "speech_v1p1beta1_generated_Adaptation_ListCustomClasses_async", + "title": "Adaptation listCustomClasses Sample", + "origin": "API_DEFINITION", + "description": " List custom classes.", + "canonical": true, + "file": "adaptation.list_custom_classes.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListCustomClasses", + "fullName": "google.cloud.speech.v1p1beta1.Adaptation.ListCustomClasses", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.speech.v1p1beta1.ListCustomClassesResponse", + "client": { + "shortName": "AdaptationClient", + "fullName": "google.cloud.speech.v1p1beta1.AdaptationClient" + }, + "method": { + "shortName": "ListCustomClasses", + "fullName": "google.cloud.speech.v1p1beta1.Adaptation.ListCustomClasses", + "service": { + "shortName": "Adaptation", + "fullName": "google.cloud.speech.v1p1beta1.Adaptation" + } + } + } + }, + { + "regionTag": "speech_v1p1beta1_generated_Adaptation_UpdateCustomClass_async", + "title": "Adaptation updateCustomClass Sample", + "origin": "API_DEFINITION", + "description": " Update a custom class.", + "canonical": true, + "file": "adaptation.update_custom_class.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateCustomClass", + "fullName": "google.cloud.speech.v1p1beta1.Adaptation.UpdateCustomClass", + "async": true, + "parameters": [ + { + "name": "custom_class", + "type": ".google.cloud.speech.v1p1beta1.CustomClass" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.speech.v1p1beta1.CustomClass", + "client": { + "shortName": "AdaptationClient", + "fullName": "google.cloud.speech.v1p1beta1.AdaptationClient" + }, + "method": { + "shortName": "UpdateCustomClass", + "fullName": "google.cloud.speech.v1p1beta1.Adaptation.UpdateCustomClass", + "service": { + "shortName": "Adaptation", + "fullName": "google.cloud.speech.v1p1beta1.Adaptation" + } + } + } + }, + { + "regionTag": "speech_v1p1beta1_generated_Adaptation_DeleteCustomClass_async", + "title": "Adaptation deleteCustomClass Sample", + "origin": "API_DEFINITION", + "description": " Delete a custom class.", + "canonical": true, + "file": "adaptation.delete_custom_class.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteCustomClass", + "fullName": "google.cloud.speech.v1p1beta1.Adaptation.DeleteCustomClass", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "AdaptationClient", + "fullName": "google.cloud.speech.v1p1beta1.AdaptationClient" + }, + "method": { + "shortName": "DeleteCustomClass", + "fullName": "google.cloud.speech.v1p1beta1.Adaptation.DeleteCustomClass", + "service": { + "shortName": "Adaptation", + "fullName": "google.cloud.speech.v1p1beta1.Adaptation" + } + } + } + }, + { + "regionTag": "speech_v1p1beta1_generated_Speech_Recognize_async", + "title": "Adaptation recognize Sample", + "origin": "API_DEFINITION", + "description": " Performs synchronous speech recognition: receive results after all audio has been sent and processed.", + "canonical": true, + "file": "speech.recognize.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Recognize", + "fullName": "google.cloud.speech.v1p1beta1.Speech.Recognize", + "async": true, + "parameters": [ + { + "name": "config", + "type": ".google.cloud.speech.v1p1beta1.RecognitionConfig" + }, + { + "name": "audio", + "type": ".google.cloud.speech.v1p1beta1.RecognitionAudio" + } + ], + "resultType": ".google.cloud.speech.v1p1beta1.RecognizeResponse", + "client": { + "shortName": "SpeechClient", + "fullName": "google.cloud.speech.v1p1beta1.SpeechClient" + }, + "method": { + "shortName": "Recognize", + "fullName": "google.cloud.speech.v1p1beta1.Speech.Recognize", + "service": { + "shortName": "Speech", + "fullName": "google.cloud.speech.v1p1beta1.Speech" + } + } + } + }, + { + "regionTag": "speech_v1p1beta1_generated_Speech_LongRunningRecognize_async", + "title": "Adaptation longRunningRecognize Sample", + "origin": "API_DEFINITION", + "description": " Performs asynchronous speech recognition: receive results via the google.longrunning.Operations interface. Returns either an `Operation.error` or an `Operation.response` which contains a `LongRunningRecognizeResponse` message. For more information on asynchronous speech recognition, see the [how-to](https://cloud.google.com/speech-to-text/docs/async-recognize).", + "canonical": true, + "file": "speech.long_running_recognize.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 64, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "LongRunningRecognize", + "fullName": "google.cloud.speech.v1p1beta1.Speech.LongRunningRecognize", + "async": true, + "parameters": [ + { + "name": "config", + "type": ".google.cloud.speech.v1p1beta1.RecognitionConfig" + }, + { + "name": "audio", + "type": ".google.cloud.speech.v1p1beta1.RecognitionAudio" + }, + { + "name": "output_config", + "type": ".google.cloud.speech.v1p1beta1.TranscriptOutputConfig" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "SpeechClient", + "fullName": "google.cloud.speech.v1p1beta1.SpeechClient" + }, + "method": { + "shortName": "LongRunningRecognize", + "fullName": "google.cloud.speech.v1p1beta1.Speech.LongRunningRecognize", + "service": { + "shortName": "Speech", + "fullName": "google.cloud.speech.v1p1beta1.Speech" + } + } + } + }, + { + "regionTag": "speech_v1p1beta1_generated_Speech_StreamingRecognize_async", + "title": "Adaptation streamingRecognize Sample", + "origin": "API_DEFINITION", + "description": " Performs bidirectional streaming speech recognition: receive results while sending audio. This method is only available via the gRPC API (not REST).", + "canonical": true, + "file": "speech.streaming_recognize.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 69, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "StreamingRecognize", + "fullName": "google.cloud.speech.v1p1beta1.Speech.StreamingRecognize", + "async": true, + "parameters": [ + { + "name": "streaming_config", + "type": ".google.cloud.speech.v1p1beta1.StreamingRecognitionConfig" + }, + { + "name": "audio_content", + "type": "TYPE_BYTES" + } + ], + "resultType": ".google.cloud.speech.v1p1beta1.StreamingRecognizeResponse", + "client": { + "shortName": "SpeechClient", + "fullName": "google.cloud.speech.v1p1beta1.SpeechClient" + }, + "method": { + "shortName": "StreamingRecognize", + "fullName": "google.cloud.speech.v1p1beta1.Speech.StreamingRecognize", + "service": { + "shortName": "Speech", + "fullName": "google.cloud.speech.v1p1beta1.Speech" + } + } + } + } + ] +} diff --git a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/speech.long_running_recognize.js b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/speech.long_running_recognize.js new file mode 100644 index 00000000..5521bfb8 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/speech.long_running_recognize.js @@ -0,0 +1,72 @@ +// Copyright 2022 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. ** + + + +'use strict'; + +function main(config, audio) { + // [START speech_v1p1beta1_generated_Speech_LongRunningRecognize_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Provides information to the recognizer that specifies how to + * process the request. + */ + // const config = {} + /** + * Required. The audio data to be recognized. + */ + // const audio = {} + /** + * Optional. Specifies an optional destination for the recognition results. + */ + // const outputConfig = {} + + // Imports the Speech library + const {SpeechClient} = require('@google-cloud/speech').v1p1beta1; + + // Instantiates a client + const speechClient = new SpeechClient(); + + async function callLongRunningRecognize() { + // Construct request + const request = { + config, + audio, + }; + + // Run request + const [operation] = await speechClient.longRunningRecognize(request); + const [response] = await operation.promise(); + console.log(response); + } + + callLongRunningRecognize(); + // [END speech_v1p1beta1_generated_Speech_LongRunningRecognize_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/speech.recognize.js b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/speech.recognize.js new file mode 100644 index 00000000..8d1ba6b1 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/speech.recognize.js @@ -0,0 +1,67 @@ +// Copyright 2022 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. ** + + + +'use strict'; + +function main(config, audio) { + // [START speech_v1p1beta1_generated_Speech_Recognize_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Provides information to the recognizer that specifies how to + * process the request. + */ + // const config = {} + /** + * Required. The audio data to be recognized. + */ + // const audio = {} + + // Imports the Speech library + const {SpeechClient} = require('@google-cloud/speech').v1p1beta1; + + // Instantiates a client + const speechClient = new SpeechClient(); + + async function callRecognize() { + // Construct request + const request = { + config, + audio, + }; + + // Run request + const response = await speechClient.recognize(request); + console.log(response); + } + + callRecognize(); + // [END speech_v1p1beta1_generated_Speech_Recognize_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/speech.streaming_recognize.js b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/speech.streaming_recognize.js new file mode 100644 index 00000000..5cd87845 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/speech.streaming_recognize.js @@ -0,0 +1,77 @@ +// Copyright 2022 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. ** + + + +'use strict'; + +function main() { + // [START speech_v1p1beta1_generated_Speech_StreamingRecognize_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Provides information to the recognizer that specifies how to process the + * request. The first `StreamingRecognizeRequest` message must contain a + * `streaming_config` message. + */ + // const streamingConfig = {} + /** + * The audio data to be recognized. Sequential chunks of audio data are sent + * in sequential `StreamingRecognizeRequest` messages. The first + * `StreamingRecognizeRequest` message must not contain `audio_content` data + * and all subsequent `StreamingRecognizeRequest` messages must contain + * `audio_content` data. The audio bytes must be encoded as specified in + * `RecognitionConfig`. Note: as with all bytes fields, proto buffers use a + * pure binary representation (not base64). See + * content limits (https://cloud.google.com/speech-to-text/quotas#content). + */ + // const audioContent = 'Buffer.from('string')' + + // Imports the Speech library + const {SpeechClient} = require('@google-cloud/speech').v1p1beta1; + + // Instantiates a client + const speechClient = new SpeechClient(); + + async function callStreamingRecognize() { + // Construct request + const request = { + }; + + // Run request + const stream = await speechClient.streamingRecognize(); + stream.on('data', (response) => { console.log(response) }); + stream.on('error', (err) => { throw(err) }); + stream.on('end', () => { /* API call completed */ }); + stream.write(request); + stream.end(); + } + + callStreamingRecognize(); + // [END speech_v1p1beta1_generated_Speech_StreamingRecognize_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p1beta1/src/index.ts b/owl-bot-staging/v1p1beta1/src/index.ts new file mode 100644 index 00000000..86112770 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/src/index.ts @@ -0,0 +1,27 @@ +// Copyright 2022 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. ** + +import * as v1p1beta1 from './v1p1beta1'; +const AdaptationClient = v1p1beta1.AdaptationClient; +type AdaptationClient = v1p1beta1.AdaptationClient; +const SpeechClient = v1p1beta1.SpeechClient; +type SpeechClient = v1p1beta1.SpeechClient; +export {v1p1beta1, AdaptationClient, SpeechClient}; +export default {v1p1beta1, AdaptationClient, SpeechClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/v1p1beta1/src/v1p1beta1/adaptation_client.ts b/owl-bot-staging/v1p1beta1/src/v1p1beta1/adaptation_client.ts new file mode 100644 index 00000000..7dbdeafb --- /dev/null +++ b/owl-bot-staging/v1p1beta1/src/v1p1beta1/adaptation_client.ts @@ -0,0 +1,1578 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import 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. + */ +import * as gapicConfig from './adaptation_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service that implements Google Cloud Speech Adaptation API. + * @class + * @memberof v1p1beta1 + */ +export class AdaptationClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + adaptationStub?: Promise<{[name: string]: Function}>; + + /** + * 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/main/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new AdaptationClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof AdaptationClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // 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 as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = this._gaxModule.warn; + } + + /** + * 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 as protobuf.Root).lookupService('google.cloud.speech.v1p1beta1.Adaptation') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.speech.v1p1beta1.Adaptation, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // 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: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + 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' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * 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: + * + * `projects/{project}/locations/{location}/phraseSets` + * + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + * @param {string} request.phraseSetId + * Required. The ID to use for the phrase set, which will become the final + * component of the phrase set's resource name. + * + * This value should restrict to letters, numbers, and hyphens, with the first + * character a letter, the last a letter or a number, and be 4-63 characters. + * @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 include:samples/generated/v1p1beta1/adaptation.create_phrase_set.js + * region_tag:speech_v1p1beta1_generated_Adaptation_CreatePhraseSet_async + */ + createPhraseSet( + request?: protos.google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + protos.google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest|undefined, {}|undefined + ]>; + createPhraseSet( + request: protos.google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + protos.google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest|null|undefined, + {}|null|undefined>): void; + createPhraseSet( + request: protos.google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest, + callback: Callback< + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + protos.google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest|null|undefined, + {}|null|undefined>): void; + createPhraseSet( + request?: protos.google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + protos.google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + protos.google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + protos.google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.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: + * + * `projects/{project}/locations/{location}/phraseSets/{phrase_set}` + * + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + * @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 include:samples/generated/v1p1beta1/adaptation.get_phrase_set.js + * region_tag:speech_v1p1beta1_generated_Adaptation_GetPhraseSet_async + */ + getPhraseSet( + request?: protos.google.cloud.speech.v1p1beta1.IGetPhraseSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + protos.google.cloud.speech.v1p1beta1.IGetPhraseSetRequest|undefined, {}|undefined + ]>; + getPhraseSet( + request: protos.google.cloud.speech.v1p1beta1.IGetPhraseSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + protos.google.cloud.speech.v1p1beta1.IGetPhraseSetRequest|null|undefined, + {}|null|undefined>): void; + getPhraseSet( + request: protos.google.cloud.speech.v1p1beta1.IGetPhraseSetRequest, + callback: Callback< + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + protos.google.cloud.speech.v1p1beta1.IGetPhraseSetRequest|null|undefined, + {}|null|undefined>): void; + getPhraseSet( + request?: protos.google.cloud.speech.v1p1beta1.IGetPhraseSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + protos.google.cloud.speech.v1p1beta1.IGetPhraseSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + protos.google.cloud.speech.v1p1beta1.IGetPhraseSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + protos.google.cloud.speech.v1p1beta1.IGetPhraseSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.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: + * + * `projects/{project}/locations/{location}/phraseSets/{phrase_set}` + * + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + * @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 include:samples/generated/v1p1beta1/adaptation.update_phrase_set.js + * region_tag:speech_v1p1beta1_generated_Adaptation_UpdatePhraseSet_async + */ + updatePhraseSet( + request?: protos.google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + protos.google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest|undefined, {}|undefined + ]>; + updatePhraseSet( + request: protos.google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + protos.google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest|null|undefined, + {}|null|undefined>): void; + updatePhraseSet( + request: protos.google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest, + callback: Callback< + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + protos.google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest|null|undefined, + {}|null|undefined>): void; + updatePhraseSet( + request?: protos.google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + protos.google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + protos.google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + protos.google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.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: + * + * `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 include:samples/generated/v1p1beta1/adaptation.delete_phrase_set.js + * region_tag:speech_v1p1beta1_generated_Adaptation_DeletePhraseSet_async + */ + deletePhraseSet( + request?: protos.google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest|undefined, {}|undefined + ]>; + deletePhraseSet( + request: protos.google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest|null|undefined, + {}|null|undefined>): void; + deletePhraseSet( + request: protos.google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest|null|undefined, + {}|null|undefined>): void; + deletePhraseSet( + request?: protos.google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.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: + * + * `projects/{project}/locations/{location}/customClasses` + * + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + * @param {string} request.customClassId + * Required. The ID to use for the custom class, which will become the final + * component of the custom class' resource name. + * + * This value should restrict to letters, numbers, and hyphens, with the first + * character a letter, the last a letter or a number, and be 4-63 characters. + * @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 include:samples/generated/v1p1beta1/adaptation.create_custom_class.js + * region_tag:speech_v1p1beta1_generated_Adaptation_CreateCustomClass_async + */ + createCustomClass( + request?: protos.google.cloud.speech.v1p1beta1.ICreateCustomClassRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.speech.v1p1beta1.ICustomClass, + protos.google.cloud.speech.v1p1beta1.ICreateCustomClassRequest|undefined, {}|undefined + ]>; + createCustomClass( + request: protos.google.cloud.speech.v1p1beta1.ICreateCustomClassRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.speech.v1p1beta1.ICustomClass, + protos.google.cloud.speech.v1p1beta1.ICreateCustomClassRequest|null|undefined, + {}|null|undefined>): void; + createCustomClass( + request: protos.google.cloud.speech.v1p1beta1.ICreateCustomClassRequest, + callback: Callback< + protos.google.cloud.speech.v1p1beta1.ICustomClass, + protos.google.cloud.speech.v1p1beta1.ICreateCustomClassRequest|null|undefined, + {}|null|undefined>): void; + createCustomClass( + request?: protos.google.cloud.speech.v1p1beta1.ICreateCustomClassRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.speech.v1p1beta1.ICustomClass, + protos.google.cloud.speech.v1p1beta1.ICreateCustomClassRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.speech.v1p1beta1.ICustomClass, + protos.google.cloud.speech.v1p1beta1.ICreateCustomClassRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.speech.v1p1beta1.ICustomClass, + protos.google.cloud.speech.v1p1beta1.ICreateCustomClassRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.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: + * + * `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 include:samples/generated/v1p1beta1/adaptation.get_custom_class.js + * region_tag:speech_v1p1beta1_generated_Adaptation_GetCustomClass_async + */ + getCustomClass( + request?: protos.google.cloud.speech.v1p1beta1.IGetCustomClassRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.speech.v1p1beta1.ICustomClass, + protos.google.cloud.speech.v1p1beta1.IGetCustomClassRequest|undefined, {}|undefined + ]>; + getCustomClass( + request: protos.google.cloud.speech.v1p1beta1.IGetCustomClassRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.speech.v1p1beta1.ICustomClass, + protos.google.cloud.speech.v1p1beta1.IGetCustomClassRequest|null|undefined, + {}|null|undefined>): void; + getCustomClass( + request: protos.google.cloud.speech.v1p1beta1.IGetCustomClassRequest, + callback: Callback< + protos.google.cloud.speech.v1p1beta1.ICustomClass, + protos.google.cloud.speech.v1p1beta1.IGetCustomClassRequest|null|undefined, + {}|null|undefined>): void; + getCustomClass( + request?: protos.google.cloud.speech.v1p1beta1.IGetCustomClassRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.speech.v1p1beta1.ICustomClass, + protos.google.cloud.speech.v1p1beta1.IGetCustomClassRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.speech.v1p1beta1.ICustomClass, + protos.google.cloud.speech.v1p1beta1.IGetCustomClassRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.speech.v1p1beta1.ICustomClass, + protos.google.cloud.speech.v1p1beta1.IGetCustomClassRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.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: + * + * `projects/{project}/locations/{location}/customClasses/{custom_class}` + * + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + * @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 include:samples/generated/v1p1beta1/adaptation.update_custom_class.js + * region_tag:speech_v1p1beta1_generated_Adaptation_UpdateCustomClass_async + */ + updateCustomClass( + request?: protos.google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.speech.v1p1beta1.ICustomClass, + protos.google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest|undefined, {}|undefined + ]>; + updateCustomClass( + request: protos.google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.speech.v1p1beta1.ICustomClass, + protos.google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest|null|undefined, + {}|null|undefined>): void; + updateCustomClass( + request: protos.google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest, + callback: Callback< + protos.google.cloud.speech.v1p1beta1.ICustomClass, + protos.google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest|null|undefined, + {}|null|undefined>): void; + updateCustomClass( + request?: protos.google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.speech.v1p1beta1.ICustomClass, + protos.google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.speech.v1p1beta1.ICustomClass, + protos.google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.speech.v1p1beta1.ICustomClass, + protos.google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.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: + * + * `projects/{project}/locations/{location}/customClasses/{custom_class}` + * + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + * @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 include:samples/generated/v1p1beta1/adaptation.delete_custom_class.js + * region_tag:speech_v1p1beta1_generated_Adaptation_DeleteCustomClass_async + */ + deleteCustomClass( + request?: protos.google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest|undefined, {}|undefined + ]>; + deleteCustomClass( + request: protos.google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest|null|undefined, + {}|null|undefined>): void; + deleteCustomClass( + request: protos.google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest|null|undefined, + {}|null|undefined>): void; + deleteCustomClass( + request?: protos.google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.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}` + * + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + * @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?: protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.speech.v1p1beta1.IPhraseSet[], + protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest|null, + protos.google.cloud.speech.v1p1beta1.IListPhraseSetResponse + ]>; + listPhraseSet( + request: protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest, + protos.google.cloud.speech.v1p1beta1.IListPhraseSetResponse|null|undefined, + protos.google.cloud.speech.v1p1beta1.IPhraseSet>): void; + listPhraseSet( + request: protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest, + callback: PaginationCallback< + protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest, + protos.google.cloud.speech.v1p1beta1.IListPhraseSetResponse|null|undefined, + protos.google.cloud.speech.v1p1beta1.IPhraseSet>): void; + listPhraseSet( + request?: protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest, + protos.google.cloud.speech.v1p1beta1.IListPhraseSetResponse|null|undefined, + protos.google.cloud.speech.v1p1beta1.IPhraseSet>, + callback?: PaginationCallback< + protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest, + protos.google.cloud.speech.v1p1beta1.IListPhraseSetResponse|null|undefined, + protos.google.cloud.speech.v1p1beta1.IPhraseSet>): + Promise<[ + protos.google.cloud.speech.v1p1beta1.IPhraseSet[], + protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest|null, + protos.google.cloud.speech.v1p1beta1.IListPhraseSetResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.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}` + * + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + * @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?: protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listPhraseSet']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listPhraseSet.createStream( + this.innerApiCalls.listPhraseSet as GaxCall, + 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}` + * + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + * @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 include:samples/generated/v1p1beta1/adaptation.list_phrase_set.js + * region_tag:speech_v1p1beta1_generated_Adaptation_ListPhraseSet_async + */ + listPhraseSetAsync( + request?: protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listPhraseSet']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listPhraseSet.asyncIterate( + this.innerApiCalls['listPhraseSet'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * 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: + * + * `projects/{project}/locations/{location}/customClasses` + * + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + * @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?: protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.speech.v1p1beta1.ICustomClass[], + protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest|null, + protos.google.cloud.speech.v1p1beta1.IListCustomClassesResponse + ]>; + listCustomClasses( + request: protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest, + protos.google.cloud.speech.v1p1beta1.IListCustomClassesResponse|null|undefined, + protos.google.cloud.speech.v1p1beta1.ICustomClass>): void; + listCustomClasses( + request: protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest, + callback: PaginationCallback< + protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest, + protos.google.cloud.speech.v1p1beta1.IListCustomClassesResponse|null|undefined, + protos.google.cloud.speech.v1p1beta1.ICustomClass>): void; + listCustomClasses( + request?: protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest, + protos.google.cloud.speech.v1p1beta1.IListCustomClassesResponse|null|undefined, + protos.google.cloud.speech.v1p1beta1.ICustomClass>, + callback?: PaginationCallback< + protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest, + protos.google.cloud.speech.v1p1beta1.IListCustomClassesResponse|null|undefined, + protos.google.cloud.speech.v1p1beta1.ICustomClass>): + Promise<[ + protos.google.cloud.speech.v1p1beta1.ICustomClass[], + protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest|null, + protos.google.cloud.speech.v1p1beta1.IListCustomClassesResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.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: + * + * `projects/{project}/locations/{location}/customClasses` + * + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + * @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?: protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listCustomClasses']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listCustomClasses.createStream( + this.innerApiCalls.listCustomClasses as GaxCall, + 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: + * + * `projects/{project}/locations/{location}/customClasses` + * + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + * @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 include:samples/generated/v1p1beta1/adaptation.list_custom_classes.js + * region_tag:speech_v1p1beta1_generated_Adaptation_ListCustomClasses_async + */ + listCustomClassesAsync( + request?: protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listCustomClasses']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listCustomClasses.asyncIterate( + this.innerApiCalls['listCustomClasses'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- 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:string,location:string,customClass:string) { + 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: string) { + 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: string) { + 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: string) { + 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:string,location:string) { + 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: string) { + 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: string) { + 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:string,location:string,phraseSet:string) { + 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: string) { + 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: string) { + 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: string) { + 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:string) { + 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: string) { + 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(): Promise { + if (this.adaptationStub && !this._terminated) { + return this.adaptationStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1p1beta1/src/v1p1beta1/adaptation_client_config.json b/owl-bot-staging/v1p1beta1/src/v1p1beta1/adaptation_client_config.json new file mode 100644 index 00000000..9de68447 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/src/v1p1beta1/adaptation_client_config.json @@ -0,0 +1,66 @@ +{ + "interfaces": { + "google.cloud.speech.v1p1beta1.Adaptation": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "CreatePhraseSet": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetPhraseSet": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListPhraseSet": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdatePhraseSet": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeletePhraseSet": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateCustomClass": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetCustomClass": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListCustomClasses": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateCustomClass": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteCustomClass": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1p1beta1/src/v1p1beta1/adaptation_proto_list.json b/owl-bot-staging/v1p1beta1/src/v1p1beta1/adaptation_proto_list.json new file mode 100644 index 00000000..d05ded22 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/src/v1p1beta1/adaptation_proto_list.json @@ -0,0 +1,5 @@ +[ + "../../protos/google/cloud/speech/v1p1beta1/cloud_speech.proto", + "../../protos/google/cloud/speech/v1p1beta1/cloud_speech_adaptation.proto", + "../../protos/google/cloud/speech/v1p1beta1/resource.proto" +] diff --git a/owl-bot-staging/v1p1beta1/src/v1p1beta1/gapic_metadata.json b/owl-bot-staging/v1p1beta1/src/v1p1beta1/gapic_metadata.json new file mode 100644 index 00000000..deb25a92 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/src/v1p1beta1/gapic_metadata.json @@ -0,0 +1,170 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.speech.v1p1beta1", + "libraryPackage": "@google-cloud/speech", + "services": { + "Adaptation": { + "clients": { + "grpc": { + "libraryClient": "AdaptationClient", + "rpcs": { + "CreatePhraseSet": { + "methods": [ + "createPhraseSet" + ] + }, + "GetPhraseSet": { + "methods": [ + "getPhraseSet" + ] + }, + "UpdatePhraseSet": { + "methods": [ + "updatePhraseSet" + ] + }, + "DeletePhraseSet": { + "methods": [ + "deletePhraseSet" + ] + }, + "CreateCustomClass": { + "methods": [ + "createCustomClass" + ] + }, + "GetCustomClass": { + "methods": [ + "getCustomClass" + ] + }, + "UpdateCustomClass": { + "methods": [ + "updateCustomClass" + ] + }, + "DeleteCustomClass": { + "methods": [ + "deleteCustomClass" + ] + }, + "ListPhraseSet": { + "methods": [ + "listPhraseSet", + "listPhraseSetStream", + "listPhraseSetAsync" + ] + }, + "ListCustomClasses": { + "methods": [ + "listCustomClasses", + "listCustomClassesStream", + "listCustomClassesAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "AdaptationClient", + "rpcs": { + "CreatePhraseSet": { + "methods": [ + "createPhraseSet" + ] + }, + "GetPhraseSet": { + "methods": [ + "getPhraseSet" + ] + }, + "UpdatePhraseSet": { + "methods": [ + "updatePhraseSet" + ] + }, + "DeletePhraseSet": { + "methods": [ + "deletePhraseSet" + ] + }, + "CreateCustomClass": { + "methods": [ + "createCustomClass" + ] + }, + "GetCustomClass": { + "methods": [ + "getCustomClass" + ] + }, + "UpdateCustomClass": { + "methods": [ + "updateCustomClass" + ] + }, + "DeleteCustomClass": { + "methods": [ + "deleteCustomClass" + ] + }, + "ListPhraseSet": { + "methods": [ + "listPhraseSet", + "listPhraseSetStream", + "listPhraseSetAsync" + ] + }, + "ListCustomClasses": { + "methods": [ + "listCustomClasses", + "listCustomClassesStream", + "listCustomClassesAsync" + ] + } + } + } + } + }, + "Speech": { + "clients": { + "grpc": { + "libraryClient": "SpeechClient", + "rpcs": { + "Recognize": { + "methods": [ + "recognize" + ] + }, + "StreamingRecognize": { + "methods": [ + "streamingRecognize" + ] + }, + "LongRunningRecognize": { + "methods": [ + "longRunningRecognize" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "SpeechClient", + "rpcs": { + "Recognize": { + "methods": [ + "recognize" + ] + }, + "LongRunningRecognize": { + "methods": [ + "longRunningRecognize" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v1p1beta1/src/v1p1beta1/index.ts b/owl-bot-staging/v1p1beta1/src/v1p1beta1/index.ts new file mode 100644 index 00000000..5b4cfbf4 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/src/v1p1beta1/index.ts @@ -0,0 +1,20 @@ +// Copyright 2022 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. ** + +export {AdaptationClient} from './adaptation_client'; +export {SpeechClient} from './speech_client'; diff --git a/owl-bot-staging/v1p1beta1/src/v1p1beta1/speech_client.ts b/owl-bot-staging/v1p1beta1/src/v1p1beta1/speech_client.ts new file mode 100644 index 00000000..4eac2179 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/src/v1p1beta1/speech_client.ts @@ -0,0 +1,649 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation} from 'google-gax'; +import {PassThrough} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1p1beta1/speech_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './speech_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service that implements Google Cloud Speech API. + * @class + * @memberof v1p1beta1 + */ +export class SpeechClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + speechStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of SpeechClient. + * + * @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/main/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new SpeechClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof SpeechClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // 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}' + ), + phraseSetPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/phraseSets/{phrase_set}' + ), + }; + + // Some of the methods on this service provide streaming responses. + // Provide descriptors for these. + this.descriptors.stream = { + streamingRecognize: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.BIDI_STREAMING, opts.fallback === 'rest') + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v1p1beta1/operations/{name=**}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1p1beta1/operations',}]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const longRunningRecognizeResponse = protoFilesRoot.lookup( + '.google.cloud.speech.v1p1beta1.LongRunningRecognizeResponse') as gax.protobuf.Type; + const longRunningRecognizeMetadata = protoFilesRoot.lookup( + '.google.cloud.speech.v1p1beta1.LongRunningRecognizeMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + longRunningRecognize: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + longRunningRecognizeResponse.decode.bind(longRunningRecognizeResponse), + longRunningRecognizeMetadata.decode.bind(longRunningRecognizeMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.speech.v1p1beta1.Speech', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = this._gaxModule.warn; + } + + /** + * 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.speechStub) { + return this.speechStub; + } + + // Put together the "service stub" for + // google.cloud.speech.v1p1beta1.Speech. + this.speechStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.speech.v1p1beta1.Speech') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.speech.v1p1beta1.Speech, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const speechStubMethods = + ['recognize', 'longRunningRecognize', 'streamingRecognize']; + for (const methodName of speechStubMethods) { + const callPromise = this.speechStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + if (methodName in this.descriptors.stream) { + const stream = new PassThrough(); + setImmediate(() => { + stream.emit('error', new this._gaxModule.GoogleError('The client has already been closed.')); + }); + return stream; + } + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.stream[methodName] || + this.descriptors.longrunning[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.speechStub; + } + + /** + * 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' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Performs synchronous speech recognition: receive results after all audio + * has been sent and processed. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.speech.v1p1beta1.RecognitionConfig} request.config + * Required. Provides information to the recognizer that specifies how to + * process the request. + * @param {google.cloud.speech.v1p1beta1.RecognitionAudio} request.audio + * Required. The audio data to be recognized. + * @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 [RecognizeResponse]{@link google.cloud.speech.v1p1beta1.RecognizeResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1p1beta1/speech.recognize.js + * region_tag:speech_v1p1beta1_generated_Speech_Recognize_async + */ + recognize( + request?: protos.google.cloud.speech.v1p1beta1.IRecognizeRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.speech.v1p1beta1.IRecognizeResponse, + protos.google.cloud.speech.v1p1beta1.IRecognizeRequest|undefined, {}|undefined + ]>; + recognize( + request: protos.google.cloud.speech.v1p1beta1.IRecognizeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.speech.v1p1beta1.IRecognizeResponse, + protos.google.cloud.speech.v1p1beta1.IRecognizeRequest|null|undefined, + {}|null|undefined>): void; + recognize( + request: protos.google.cloud.speech.v1p1beta1.IRecognizeRequest, + callback: Callback< + protos.google.cloud.speech.v1p1beta1.IRecognizeResponse, + protos.google.cloud.speech.v1p1beta1.IRecognizeRequest|null|undefined, + {}|null|undefined>): void; + recognize( + request?: protos.google.cloud.speech.v1p1beta1.IRecognizeRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.speech.v1p1beta1.IRecognizeResponse, + protos.google.cloud.speech.v1p1beta1.IRecognizeRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.speech.v1p1beta1.IRecognizeResponse, + protos.google.cloud.speech.v1p1beta1.IRecognizeRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.speech.v1p1beta1.IRecognizeResponse, + protos.google.cloud.speech.v1p1beta1.IRecognizeRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + this.initialize(); + return this.innerApiCalls.recognize(request, options, callback); + } + +/** + * Performs bidirectional streaming speech recognition: receive results while + * sending audio. This method is only available via the gRPC API (not REST). + * + * @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 is both readable and writable. It accepts objects + * representing [StreamingRecognizeRequest]{@link google.cloud.speech.v1p1beta1.StreamingRecognizeRequest} for write() method, and + * will emit objects representing [StreamingRecognizeResponse]{@link google.cloud.speech.v1p1beta1.StreamingRecognizeResponse} on 'data' event asynchronously. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#bi-directional-streaming) + * for more details and examples. + * @example include:samples/generated/v1p1beta1/speech.streaming_recognize.js + * region_tag:speech_v1p1beta1_generated_Speech_StreamingRecognize_async + */ + streamingRecognize( + options?: CallOptions): + gax.CancellableStream { + this.initialize(); + return this.innerApiCalls.streamingRecognize(null, options); + } + +/** + * Performs asynchronous speech recognition: receive results via the + * google.longrunning.Operations interface. Returns either an + * `Operation.error` or an `Operation.response` which contains + * a `LongRunningRecognizeResponse` message. + * For more information on asynchronous speech recognition, see the + * [how-to](https://cloud.google.com/speech-to-text/docs/async-recognize). + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.speech.v1p1beta1.RecognitionConfig} request.config + * Required. Provides information to the recognizer that specifies how to + * process the request. + * @param {google.cloud.speech.v1p1beta1.RecognitionAudio} request.audio + * Required. The audio data to be recognized. + * @param {google.cloud.speech.v1p1beta1.TranscriptOutputConfig} [request.outputConfig] + * Optional. Specifies an optional destination for the recognition results. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1p1beta1/speech.long_running_recognize.js + * region_tag:speech_v1p1beta1_generated_Speech_LongRunningRecognize_async + */ + longRunningRecognize( + request?: protos.google.cloud.speech.v1p1beta1.ILongRunningRecognizeRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + longRunningRecognize( + request: protos.google.cloud.speech.v1p1beta1.ILongRunningRecognizeRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + longRunningRecognize( + request: protos.google.cloud.speech.v1p1beta1.ILongRunningRecognizeRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + longRunningRecognize( + request?: protos.google.cloud.speech.v1p1beta1.ILongRunningRecognizeRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + this.initialize(); + return this.innerApiCalls.longRunningRecognize(request, options, callback); + } +/** + * Check the status of the long running operation returned by `longRunningRecognize()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1p1beta1/speech.long_running_recognize.js + * region_tag:speech_v1p1beta1_generated_Speech_LongRunningRecognize_async + */ + async checkLongRunningRecognizeProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.longRunningRecognize, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + // -------------------- + // -- 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:string,location:string,customClass:string) { + 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: string) { + 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: string) { + 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: string) { + return this.pathTemplates.customClassPathTemplate.match(customClassName).custom_class; + } + + /** + * 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:string,location:string,phraseSet:string) { + 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: string) { + 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: string) { + 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: string) { + return this.pathTemplates.phraseSetPathTemplate.match(phraseSetName).phrase_set; + } + + /** + * 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(): Promise { + if (this.speechStub && !this._terminated) { + return this.speechStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1p1beta1/src/v1p1beta1/speech_client_config.json b/owl-bot-staging/v1p1beta1/src/v1p1beta1/speech_client_config.json new file mode 100644 index 00000000..c5e1b104 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/src/v1p1beta1/speech_client_config.json @@ -0,0 +1,41 @@ +{ + "interfaces": { + "google.cloud.speech.v1p1beta1.Speech": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "Recognize": { + "timeout_millis": 5000000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "LongRunningRecognize": { + "timeout_millis": 5000000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "StreamingRecognize": { + "timeout_millis": 5000000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1p1beta1/src/v1p1beta1/speech_proto_list.json b/owl-bot-staging/v1p1beta1/src/v1p1beta1/speech_proto_list.json new file mode 100644 index 00000000..d05ded22 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/src/v1p1beta1/speech_proto_list.json @@ -0,0 +1,5 @@ +[ + "../../protos/google/cloud/speech/v1p1beta1/cloud_speech.proto", + "../../protos/google/cloud/speech/v1p1beta1/cloud_speech_adaptation.proto", + "../../protos/google/cloud/speech/v1p1beta1/resource.proto" +] diff --git a/owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000..36731b35 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.js @@ -0,0 +1,28 @@ +// Copyright 2022 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. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const speech = require('@google-cloud/speech'); + +function main() { + const adaptationClient = new speech.AdaptationClient(); + const speechClient = new speech.SpeechClient(); +} + +main(); diff --git a/owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000..1c746cf8 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,38 @@ +// Copyright 2022 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. ** + +import {AdaptationClient, SpeechClient} from '@google-cloud/speech'; + +// check that the client class type name can be used +function doStuffWithAdaptationClient(client: AdaptationClient) { + client.close(); +} +function doStuffWithSpeechClient(client: SpeechClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const adaptationClient = new AdaptationClient(); + doStuffWithAdaptationClient(adaptationClient); + // check that the client instance can be created + const speechClient = new SpeechClient(); + doStuffWithSpeechClient(speechClient); +} + +main(); diff --git a/owl-bot-staging/v1p1beta1/system-test/install.ts b/owl-bot-staging/v1p1beta1/system-test/install.ts new file mode 100644 index 00000000..557a5755 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/system-test/install.ts @@ -0,0 +1,49 @@ +// Copyright 2022 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. ** + +import {packNTest} from 'pack-n-play'; +import {readFileSync} from 'fs'; +import {describe, it} from 'mocha'; + +describe('📦 pack-n-play test', () => { + + it('TypeScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'TypeScript user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() + } + }; + await packNTest(options); + }); + + it('JavaScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'JavaScript user can use the library', + ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() + } + }; + await packNTest(options); + }); + +}); diff --git a/owl-bot-staging/v1p1beta1/test/gapic_adaptation_v1p1beta1.ts b/owl-bot-staging/v1p1beta1/test/gapic_adaptation_v1p1beta1.ts new file mode 100644 index 00000000..634f2f6b --- /dev/null +++ b/owl-bot-staging/v1p1beta1/test/gapic_adaptation_v1p1beta1.ts @@ -0,0 +1,1722 @@ +// Copyright 2022 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. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as adaptationModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1p1beta1.AdaptationClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = adaptationModule.v1p1beta1.AdaptationClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = adaptationModule.v1p1beta1.AdaptationClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = adaptationModule.v1p1beta1.AdaptationClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.adaptationStub, undefined); + await client.initialize(); + assert(client.adaptationStub); + }); + + it('has close method for the initialized client', done => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.adaptationStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.adaptationStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('createPhraseSet', () => { + it('invokes createPhraseSet without error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CreatePhraseSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('CreatePhraseSetRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.PhraseSet() + ); + client.innerApiCalls.createPhraseSet = stubSimpleCall(expectedResponse); + const [response] = await client.createPhraseSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createPhraseSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createPhraseSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createPhraseSet without error using callback', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CreatePhraseSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('CreatePhraseSetRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.PhraseSet() + ); + client.innerApiCalls.createPhraseSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createPhraseSet( + request, + (err?: Error|null, result?: protos.google.cloud.speech.v1p1beta1.IPhraseSet|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createPhraseSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createPhraseSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createPhraseSet with error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CreatePhraseSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('CreatePhraseSetRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createPhraseSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createPhraseSet(request), expectedError); + const actualRequest = (client.innerApiCalls.createPhraseSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createPhraseSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createPhraseSet with closed client', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CreatePhraseSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('CreatePhraseSetRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createPhraseSet(request), expectedError); + }); + }); + + describe('getPhraseSet', () => { + it('invokes getPhraseSet without error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.GetPhraseSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('GetPhraseSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.PhraseSet() + ); + client.innerApiCalls.getPhraseSet = stubSimpleCall(expectedResponse); + const [response] = await client.getPhraseSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getPhraseSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getPhraseSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getPhraseSet without error using callback', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.GetPhraseSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('GetPhraseSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.PhraseSet() + ); + client.innerApiCalls.getPhraseSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getPhraseSet( + request, + (err?: Error|null, result?: protos.google.cloud.speech.v1p1beta1.IPhraseSet|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getPhraseSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getPhraseSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getPhraseSet with error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.GetPhraseSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('GetPhraseSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getPhraseSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getPhraseSet(request), expectedError); + const actualRequest = (client.innerApiCalls.getPhraseSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getPhraseSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getPhraseSet with closed client', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.GetPhraseSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('GetPhraseSetRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getPhraseSet(request), expectedError); + }); + }); + + describe('updatePhraseSet', () => { + it('invokes updatePhraseSet without error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest() + ); + request.phraseSet ??= {}; + const defaultValue1 = + getTypeDefaultValue('UpdatePhraseSetRequest', ['phraseSet', 'name']); + request.phraseSet.name = defaultValue1; + const expectedHeaderRequestParams = `phrase_set.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.PhraseSet() + ); + client.innerApiCalls.updatePhraseSet = stubSimpleCall(expectedResponse); + const [response] = await client.updatePhraseSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updatePhraseSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updatePhraseSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updatePhraseSet without error using callback', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest() + ); + request.phraseSet ??= {}; + const defaultValue1 = + getTypeDefaultValue('UpdatePhraseSetRequest', ['phraseSet', 'name']); + request.phraseSet.name = defaultValue1; + const expectedHeaderRequestParams = `phrase_set.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.PhraseSet() + ); + client.innerApiCalls.updatePhraseSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updatePhraseSet( + request, + (err?: Error|null, result?: protos.google.cloud.speech.v1p1beta1.IPhraseSet|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updatePhraseSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updatePhraseSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updatePhraseSet with error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest() + ); + request.phraseSet ??= {}; + const defaultValue1 = + getTypeDefaultValue('UpdatePhraseSetRequest', ['phraseSet', 'name']); + request.phraseSet.name = defaultValue1; + const expectedHeaderRequestParams = `phrase_set.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updatePhraseSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updatePhraseSet(request), expectedError); + const actualRequest = (client.innerApiCalls.updatePhraseSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updatePhraseSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updatePhraseSet with closed client', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest() + ); + request.phraseSet ??= {}; + const defaultValue1 = + getTypeDefaultValue('UpdatePhraseSetRequest', ['phraseSet', 'name']); + request.phraseSet.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updatePhraseSet(request), expectedError); + }); + }); + + describe('deletePhraseSet', () => { + it('invokes deletePhraseSet without error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.DeletePhraseSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('DeletePhraseSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deletePhraseSet = stubSimpleCall(expectedResponse); + const [response] = await client.deletePhraseSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deletePhraseSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deletePhraseSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deletePhraseSet without error using callback', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.DeletePhraseSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('DeletePhraseSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deletePhraseSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deletePhraseSet( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deletePhraseSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deletePhraseSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deletePhraseSet with error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.DeletePhraseSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('DeletePhraseSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deletePhraseSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deletePhraseSet(request), expectedError); + const actualRequest = (client.innerApiCalls.deletePhraseSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deletePhraseSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deletePhraseSet with closed client', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.DeletePhraseSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('DeletePhraseSetRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deletePhraseSet(request), expectedError); + }); + }); + + describe('createCustomClass', () => { + it('invokes createCustomClass without error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CreateCustomClassRequest() + ); + const defaultValue1 = + getTypeDefaultValue('CreateCustomClassRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CustomClass() + ); + client.innerApiCalls.createCustomClass = stubSimpleCall(expectedResponse); + const [response] = await client.createCustomClass(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createCustomClass as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createCustomClass as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createCustomClass without error using callback', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CreateCustomClassRequest() + ); + const defaultValue1 = + getTypeDefaultValue('CreateCustomClassRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CustomClass() + ); + client.innerApiCalls.createCustomClass = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createCustomClass( + request, + (err?: Error|null, result?: protos.google.cloud.speech.v1p1beta1.ICustomClass|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createCustomClass as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createCustomClass as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createCustomClass with error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CreateCustomClassRequest() + ); + const defaultValue1 = + getTypeDefaultValue('CreateCustomClassRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createCustomClass = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createCustomClass(request), expectedError); + const actualRequest = (client.innerApiCalls.createCustomClass as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createCustomClass as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createCustomClass with closed client', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CreateCustomClassRequest() + ); + const defaultValue1 = + getTypeDefaultValue('CreateCustomClassRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createCustomClass(request), expectedError); + }); + }); + + describe('getCustomClass', () => { + it('invokes getCustomClass without error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.GetCustomClassRequest() + ); + const defaultValue1 = + getTypeDefaultValue('GetCustomClassRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CustomClass() + ); + client.innerApiCalls.getCustomClass = stubSimpleCall(expectedResponse); + const [response] = await client.getCustomClass(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getCustomClass as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getCustomClass as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getCustomClass without error using callback', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.GetCustomClassRequest() + ); + const defaultValue1 = + getTypeDefaultValue('GetCustomClassRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CustomClass() + ); + client.innerApiCalls.getCustomClass = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getCustomClass( + request, + (err?: Error|null, result?: protos.google.cloud.speech.v1p1beta1.ICustomClass|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getCustomClass as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getCustomClass as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getCustomClass with error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.GetCustomClassRequest() + ); + const defaultValue1 = + getTypeDefaultValue('GetCustomClassRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getCustomClass = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getCustomClass(request), expectedError); + const actualRequest = (client.innerApiCalls.getCustomClass as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getCustomClass as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getCustomClass with closed client', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.GetCustomClassRequest() + ); + const defaultValue1 = + getTypeDefaultValue('GetCustomClassRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getCustomClass(request), expectedError); + }); + }); + + describe('updateCustomClass', () => { + it('invokes updateCustomClass without error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.UpdateCustomClassRequest() + ); + request.customClass ??= {}; + const defaultValue1 = + getTypeDefaultValue('UpdateCustomClassRequest', ['customClass', 'name']); + request.customClass.name = defaultValue1; + const expectedHeaderRequestParams = `custom_class.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CustomClass() + ); + client.innerApiCalls.updateCustomClass = stubSimpleCall(expectedResponse); + const [response] = await client.updateCustomClass(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateCustomClass as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateCustomClass as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateCustomClass without error using callback', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.UpdateCustomClassRequest() + ); + request.customClass ??= {}; + const defaultValue1 = + getTypeDefaultValue('UpdateCustomClassRequest', ['customClass', 'name']); + request.customClass.name = defaultValue1; + const expectedHeaderRequestParams = `custom_class.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CustomClass() + ); + client.innerApiCalls.updateCustomClass = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateCustomClass( + request, + (err?: Error|null, result?: protos.google.cloud.speech.v1p1beta1.ICustomClass|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateCustomClass as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateCustomClass as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateCustomClass with error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.UpdateCustomClassRequest() + ); + request.customClass ??= {}; + const defaultValue1 = + getTypeDefaultValue('UpdateCustomClassRequest', ['customClass', 'name']); + request.customClass.name = defaultValue1; + const expectedHeaderRequestParams = `custom_class.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateCustomClass = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateCustomClass(request), expectedError); + const actualRequest = (client.innerApiCalls.updateCustomClass as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateCustomClass as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateCustomClass with closed client', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.UpdateCustomClassRequest() + ); + request.customClass ??= {}; + const defaultValue1 = + getTypeDefaultValue('UpdateCustomClassRequest', ['customClass', 'name']); + request.customClass.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateCustomClass(request), expectedError); + }); + }); + + describe('deleteCustomClass', () => { + it('invokes deleteCustomClass without error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.DeleteCustomClassRequest() + ); + const defaultValue1 = + getTypeDefaultValue('DeleteCustomClassRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteCustomClass = stubSimpleCall(expectedResponse); + const [response] = await client.deleteCustomClass(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteCustomClass as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteCustomClass as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteCustomClass without error using callback', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.DeleteCustomClassRequest() + ); + const defaultValue1 = + getTypeDefaultValue('DeleteCustomClassRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteCustomClass = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteCustomClass( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteCustomClass as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteCustomClass as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteCustomClass with error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.DeleteCustomClassRequest() + ); + const defaultValue1 = + getTypeDefaultValue('DeleteCustomClassRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteCustomClass = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteCustomClass(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteCustomClass as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteCustomClass as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteCustomClass with closed client', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.DeleteCustomClassRequest() + ); + const defaultValue1 = + getTypeDefaultValue('DeleteCustomClassRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteCustomClass(request), expectedError); + }); + }); + + describe('listPhraseSet', () => { + it('invokes listPhraseSet without error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.ListPhraseSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListPhraseSetRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.PhraseSet()), + generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.PhraseSet()), + generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.PhraseSet()), + ]; + client.innerApiCalls.listPhraseSet = stubSimpleCall(expectedResponse); + const [response] = await client.listPhraseSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listPhraseSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listPhraseSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listPhraseSet without error using callback', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.ListPhraseSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListPhraseSetRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.PhraseSet()), + generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.PhraseSet()), + generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.PhraseSet()), + ]; + client.innerApiCalls.listPhraseSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listPhraseSet( + request, + (err?: Error|null, result?: protos.google.cloud.speech.v1p1beta1.IPhraseSet[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listPhraseSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listPhraseSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listPhraseSet with error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.ListPhraseSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListPhraseSetRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listPhraseSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listPhraseSet(request), expectedError); + const actualRequest = (client.innerApiCalls.listPhraseSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listPhraseSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listPhraseSetStream without error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.ListPhraseSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListPhraseSetRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.PhraseSet()), + generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.PhraseSet()), + generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.PhraseSet()), + ]; + client.descriptors.page.listPhraseSet.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listPhraseSetStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.speech.v1p1beta1.PhraseSet[] = []; + stream.on('data', (response: protos.google.cloud.speech.v1p1beta1.PhraseSet) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listPhraseSet.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listPhraseSet, request)); + assert( + (client.descriptors.page.listPhraseSet.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listPhraseSetStream with error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.ListPhraseSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListPhraseSetRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listPhraseSet.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listPhraseSetStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.speech.v1p1beta1.PhraseSet[] = []; + stream.on('data', (response: protos.google.cloud.speech.v1p1beta1.PhraseSet) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listPhraseSet.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listPhraseSet, request)); + assert( + (client.descriptors.page.listPhraseSet.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listPhraseSet without error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.ListPhraseSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListPhraseSetRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.PhraseSet()), + generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.PhraseSet()), + generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.PhraseSet()), + ]; + client.descriptors.page.listPhraseSet.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.speech.v1p1beta1.IPhraseSet[] = []; + const iterable = client.listPhraseSetAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listPhraseSet.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listPhraseSet.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listPhraseSet with error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.ListPhraseSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListPhraseSetRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listPhraseSet.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listPhraseSetAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.speech.v1p1beta1.IPhraseSet[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listPhraseSet.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listPhraseSet.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listCustomClasses', () => { + it('invokes listCustomClasses without error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.ListCustomClassesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListCustomClassesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.CustomClass()), + generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.CustomClass()), + generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.CustomClass()), + ]; + client.innerApiCalls.listCustomClasses = stubSimpleCall(expectedResponse); + const [response] = await client.listCustomClasses(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listCustomClasses as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listCustomClasses as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listCustomClasses without error using callback', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.ListCustomClassesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListCustomClassesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.CustomClass()), + generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.CustomClass()), + generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.CustomClass()), + ]; + client.innerApiCalls.listCustomClasses = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listCustomClasses( + request, + (err?: Error|null, result?: protos.google.cloud.speech.v1p1beta1.ICustomClass[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listCustomClasses as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listCustomClasses as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listCustomClasses with error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.ListCustomClassesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListCustomClassesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listCustomClasses = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listCustomClasses(request), expectedError); + const actualRequest = (client.innerApiCalls.listCustomClasses as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listCustomClasses as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listCustomClassesStream without error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.ListCustomClassesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListCustomClassesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.CustomClass()), + generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.CustomClass()), + generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.CustomClass()), + ]; + client.descriptors.page.listCustomClasses.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listCustomClassesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.speech.v1p1beta1.CustomClass[] = []; + stream.on('data', (response: protos.google.cloud.speech.v1p1beta1.CustomClass) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listCustomClasses.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listCustomClasses, request)); + assert( + (client.descriptors.page.listCustomClasses.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listCustomClassesStream with error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.ListCustomClassesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListCustomClassesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listCustomClasses.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listCustomClassesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.speech.v1p1beta1.CustomClass[] = []; + stream.on('data', (response: protos.google.cloud.speech.v1p1beta1.CustomClass) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listCustomClasses.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listCustomClasses, request)); + assert( + (client.descriptors.page.listCustomClasses.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listCustomClasses without error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.ListCustomClassesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListCustomClassesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.CustomClass()), + generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.CustomClass()), + generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.CustomClass()), + ]; + client.descriptors.page.listCustomClasses.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.speech.v1p1beta1.ICustomClass[] = []; + const iterable = client.listCustomClassesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listCustomClasses.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listCustomClasses.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listCustomClasses with error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.ListCustomClassesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('ListCustomClassesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listCustomClasses.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listCustomClassesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.speech.v1p1beta1.ICustomClass[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listCustomClasses.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listCustomClasses.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('Path templates', () => { + + describe('customClass', () => { + const fakePath = "/rendered/path/customClass"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + custom_class: "customClassValue", + }; + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.customClassPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.customClassPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('customClassPath', () => { + const result = client.customClassPath("projectValue", "locationValue", "customClassValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.customClassPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCustomClassName', () => { + const result = client.matchProjectFromCustomClassName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.customClassPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCustomClassName', () => { + const result = client.matchLocationFromCustomClassName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.customClassPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCustomClassFromCustomClassName', () => { + const result = client.matchCustomClassFromCustomClassName(fakePath); + assert.strictEqual(result, "customClassValue"); + assert((client.pathTemplates.customClassPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('location', () => { + const fakePath = "/rendered/path/location"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + }; + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.locationPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.locationPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath("projectValue", "locationValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('phraseSet', () => { + const fakePath = "/rendered/path/phraseSet"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + phrase_set: "phraseSetValue", + }; + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.phraseSetPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.phraseSetPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('phraseSetPath', () => { + const result = client.phraseSetPath("projectValue", "locationValue", "phraseSetValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.phraseSetPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromPhraseSetName', () => { + const result = client.matchProjectFromPhraseSetName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.phraseSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromPhraseSetName', () => { + const result = client.matchLocationFromPhraseSetName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.phraseSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchPhraseSetFromPhraseSetName', () => { + const result = client.matchPhraseSetFromPhraseSetName(fakePath); + assert.strictEqual(result, "phraseSetValue"); + assert((client.pathTemplates.phraseSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('project', () => { + const fakePath = "/rendered/path/project"; + const expectedParameters = { + project: "projectValue", + }; + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath("projectValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v1p1beta1/test/gapic_speech_v1p1beta1.ts b/owl-bot-staging/v1p1beta1/test/gapic_speech_v1p1beta1.ts new file mode 100644 index 00000000..0149c0af --- /dev/null +++ b/owl-bot-staging/v1p1beta1/test/gapic_speech_v1p1beta1.ts @@ -0,0 +1,525 @@ +// Copyright 2022 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. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as speechModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubBidiStreamingCall(response?: ResponseType, error?: Error) { + const transformStub = error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + return sinon.stub().returns(mockStream); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +describe('v1p1beta1.SpeechClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = speechModule.v1p1beta1.SpeechClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = speechModule.v1p1beta1.SpeechClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = speechModule.v1p1beta1.SpeechClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new speechModule.v1p1beta1.SpeechClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new speechModule.v1p1beta1.SpeechClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new speechModule.v1p1beta1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.speechStub, undefined); + await client.initialize(); + assert(client.speechStub); + }); + + it('has close method for the initialized client', done => { + const client = new speechModule.v1p1beta1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.speechStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new speechModule.v1p1beta1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.speechStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new speechModule.v1p1beta1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new speechModule.v1p1beta1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('recognize', () => { + it('invokes recognize without error', async () => { + const client = new speechModule.v1p1beta1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.RecognizeRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.RecognizeResponse() + ); + client.innerApiCalls.recognize = stubSimpleCall(expectedResponse); + const [response] = await client.recognize(request); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes recognize without error using callback', async () => { + const client = new speechModule.v1p1beta1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.RecognizeRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.RecognizeResponse() + ); + client.innerApiCalls.recognize = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.recognize( + request, + (err?: Error|null, result?: protos.google.cloud.speech.v1p1beta1.IRecognizeResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes recognize with error', async () => { + const client = new speechModule.v1p1beta1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.RecognizeRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.recognize = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.recognize(request), expectedError); + }); + + it('invokes recognize with closed client', async () => { + const client = new speechModule.v1p1beta1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.RecognizeRequest() + ); + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.recognize(request), expectedError); + }); + }); + + describe('longRunningRecognize', () => { + it('invokes longRunningRecognize without error', async () => { + const client = new speechModule.v1p1beta1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.LongRunningRecognizeRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.longRunningRecognize = stubLongRunningCall(expectedResponse); + const [operation] = await client.longRunningRecognize(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes longRunningRecognize without error using callback', async () => { + const client = new speechModule.v1p1beta1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.LongRunningRecognizeRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.longRunningRecognize = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.longRunningRecognize( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes longRunningRecognize with call error', async () => { + const client = new speechModule.v1p1beta1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.LongRunningRecognizeRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.longRunningRecognize = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.longRunningRecognize(request), expectedError); + }); + + it('invokes longRunningRecognize with LRO error', async () => { + const client = new speechModule.v1p1beta1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.LongRunningRecognizeRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.longRunningRecognize = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.longRunningRecognize(request); + await assert.rejects(operation.promise(), expectedError); + }); + + it('invokes checkLongRunningRecognizeProgress without error', async () => { + const client = new speechModule.v1p1beta1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkLongRunningRecognizeProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkLongRunningRecognizeProgress with error', async () => { + const client = new speechModule.v1p1beta1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkLongRunningRecognizeProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('streamingRecognize', () => { + it('invokes streamingRecognize without error', async () => { + const client = new speechModule.v1p1beta1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.StreamingRecognizeRequest() + ); + + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.StreamingRecognizeResponse() + ); + client.innerApiCalls.streamingRecognize = stubBidiStreamingCall(expectedResponse); + const stream = client.streamingRecognize(); + const promise = new Promise((resolve, reject) => { + stream.on('data', (response: protos.google.cloud.speech.v1p1beta1.StreamingRecognizeResponse) => { + resolve(response); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + stream.write(request); + stream.end(); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.streamingRecognize as SinonStub) + .getCall(0).calledWith(null)); + assert.deepStrictEqual(((stream as unknown as PassThrough) + ._transform as SinonStub).getCall(0).args[0], request); + }); + + it('invokes streamingRecognize with error', async () => { + const client = new speechModule.v1p1beta1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.StreamingRecognizeRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.streamingRecognize = stubBidiStreamingCall(undefined, expectedError); + const stream = client.streamingRecognize(); + const promise = new Promise((resolve, reject) => { + stream.on('data', (response: protos.google.cloud.speech.v1p1beta1.StreamingRecognizeResponse) => { + resolve(response); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + stream.write(request); + stream.end(); + }); + await assert.rejects(promise, expectedError); + assert((client.innerApiCalls.streamingRecognize as SinonStub) + .getCall(0).calledWith(null)); + assert.deepStrictEqual(((stream as unknown as PassThrough) + ._transform as SinonStub).getCall(0).args[0], request); + }); + }); + + describe('Path templates', () => { + + describe('customClass', () => { + const fakePath = "/rendered/path/customClass"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + custom_class: "customClassValue", + }; + const client = new speechModule.v1p1beta1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.customClassPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.customClassPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('customClassPath', () => { + const result = client.customClassPath("projectValue", "locationValue", "customClassValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.customClassPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCustomClassName', () => { + const result = client.matchProjectFromCustomClassName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.customClassPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromCustomClassName', () => { + const result = client.matchLocationFromCustomClassName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.customClassPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCustomClassFromCustomClassName', () => { + const result = client.matchCustomClassFromCustomClassName(fakePath); + assert.strictEqual(result, "customClassValue"); + assert((client.pathTemplates.customClassPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('phraseSet', () => { + const fakePath = "/rendered/path/phraseSet"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + phrase_set: "phraseSetValue", + }; + const client = new speechModule.v1p1beta1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.phraseSetPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.phraseSetPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('phraseSetPath', () => { + const result = client.phraseSetPath("projectValue", "locationValue", "phraseSetValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.phraseSetPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromPhraseSetName', () => { + const result = client.matchProjectFromPhraseSetName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.phraseSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromPhraseSetName', () => { + const result = client.matchLocationFromPhraseSetName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.phraseSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchPhraseSetFromPhraseSetName', () => { + const result = client.matchPhraseSetFromPhraseSetName(fakePath); + assert.strictEqual(result, "phraseSetValue"); + assert((client.pathTemplates.phraseSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v1p1beta1/tsconfig.json b/owl-bot-staging/v1p1beta1/tsconfig.json new file mode 100644 index 00000000..c78f1c88 --- /dev/null +++ b/owl-bot-staging/v1p1beta1/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2018", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/owl-bot-staging/v1p1beta1/webpack.config.js b/owl-bot-staging/v1p1beta1/webpack.config.js new file mode 100644 index 00000000..50273cca --- /dev/null +++ b/owl-bot-staging/v1p1beta1/webpack.config.js @@ -0,0 +1,64 @@ +// 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. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'Adaptation', + filename: './adaptation.js', + }, + node: { + child_process: 'empty', + fs: 'empty', + crypto: 'empty', + }, + resolve: { + alias: { + '../../../package.json': path.resolve(__dirname, 'package.json'), + }, + extensions: ['.js', '.json', '.ts'], + }, + module: { + rules: [ + { + test: /\.tsx?$/, + use: 'ts-loader', + exclude: /node_modules/ + }, + { + test: /node_modules[\\/]@grpc[\\/]grpc-js/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]grpc/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]retry-request/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]https?-proxy-agent/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]gtoken/, + use: 'null-loader' + }, + ], + }, + mode: 'production', +}; From c7242510bd663afd4d1965a30806556898848c43 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Wed, 14 Sep 2022 20:26:43 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20po?= =?UTF-8?q?st-processor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- owl-bot-staging/v1/.eslintignore | 7 - owl-bot-staging/v1/.eslintrc.json | 3 - owl-bot-staging/v1/.gitignore | 14 - owl-bot-staging/v1/.jsdoc.js | 55 - owl-bot-staging/v1/.mocharc.js | 33 - owl-bot-staging/v1/.prettierrc.js | 22 - owl-bot-staging/v1/README.md | 1 - owl-bot-staging/v1/linkinator.config.json | 16 - owl-bot-staging/v1/package.json | 65 - .../google/cloud/speech/v1/cloud_speech.proto | 899 --------- .../speech/v1/cloud_speech_adaptation.proto | 370 ---- .../google/cloud/speech/v1/resource.proto | 138 -- .../v1/adaptation.create_custom_class.js | 80 - .../v1/adaptation.create_phrase_set.js | 80 - .../v1/adaptation.delete_custom_class.js | 67 - .../v1/adaptation.delete_phrase_set.js | 62 - .../v1/adaptation.get_custom_class.js | 62 - .../generated/v1/adaptation.get_phrase_set.js | 67 - .../v1/adaptation.list_custom_classes.js | 83 - .../v1/adaptation.list_phrase_set.js | 83 - .../v1/adaptation.update_custom_class.js | 73 - .../v1/adaptation.update_phrase_set.js | 73 - ...ippet_metadata.google.cloud.speech.v1.json | 591 ------ .../v1/speech.long_running_recognize.js | 72 - .../samples/generated/v1/speech.recognize.js | 67 - .../v1/speech.streaming_recognize.js | 77 - owl-bot-staging/v1/src/index.ts | 27 - .../v1/src/v1/adaptation_client.ts | 1578 --------------- .../v1/src/v1/adaptation_client_config.json | 66 - .../v1/src/v1/adaptation_proto_list.json | 5 - owl-bot-staging/v1/src/v1/gapic_metadata.json | 170 -- owl-bot-staging/v1/src/v1/index.ts | 20 - owl-bot-staging/v1/src/v1/speech_client.ts | 649 ------- .../v1/src/v1/speech_client_config.json | 41 - .../v1/src/v1/speech_proto_list.json | 5 - .../system-test/fixtures/sample/src/index.js | 28 - .../system-test/fixtures/sample/src/index.ts | 38 - owl-bot-staging/v1/system-test/install.ts | 49 - .../v1/test/gapic_adaptation_v1.ts | 1722 ----------------- owl-bot-staging/v1/test/gapic_speech_v1.ts | 525 ----- owl-bot-staging/v1/tsconfig.json | 19 - owl-bot-staging/v1/webpack.config.js | 64 - owl-bot-staging/v1p1beta1/.eslintignore | 7 - owl-bot-staging/v1p1beta1/.eslintrc.json | 3 - owl-bot-staging/v1p1beta1/.gitignore | 14 - owl-bot-staging/v1p1beta1/.jsdoc.js | 55 - owl-bot-staging/v1p1beta1/.mocharc.js | 33 - owl-bot-staging/v1p1beta1/.prettierrc.js | 22 - owl-bot-staging/v1p1beta1/README.md | 1 - .../v1p1beta1/linkinator.config.json | 16 - owl-bot-staging/v1p1beta1/package.json | 65 - .../cloud/speech/v1p1beta1/cloud_speech.proto | 929 --------- .../v1p1beta1/cloud_speech_adaptation.proto | 370 ---- .../cloud/speech/v1p1beta1/resource.proto | 162 -- .../adaptation.create_custom_class.js | 80 - .../v1p1beta1/adaptation.create_phrase_set.js | 80 - .../adaptation.delete_custom_class.js | 67 - .../v1p1beta1/adaptation.delete_phrase_set.js | 62 - .../v1p1beta1/adaptation.get_custom_class.js | 62 - .../v1p1beta1/adaptation.get_phrase_set.js | 67 - .../adaptation.list_custom_classes.js | 83 - .../v1p1beta1/adaptation.list_phrase_set.js | 83 - .../adaptation.update_custom_class.js | 73 - .../v1p1beta1/adaptation.update_phrase_set.js | 73 - ...etadata.google.cloud.speech.v1p1beta1.json | 591 ------ .../speech.long_running_recognize.js | 72 - .../generated/v1p1beta1/speech.recognize.js | 67 - .../v1p1beta1/speech.streaming_recognize.js | 77 - owl-bot-staging/v1p1beta1/src/index.ts | 27 - .../src/v1p1beta1/adaptation_client.ts | 1578 --------------- .../v1p1beta1/adaptation_client_config.json | 66 - .../src/v1p1beta1/adaptation_proto_list.json | 5 - .../src/v1p1beta1/gapic_metadata.json | 170 -- .../v1p1beta1/src/v1p1beta1/index.ts | 20 - .../v1p1beta1/src/v1p1beta1/speech_client.ts | 649 ------- .../src/v1p1beta1/speech_client_config.json | 41 - .../src/v1p1beta1/speech_proto_list.json | 5 - .../system-test/fixtures/sample/src/index.js | 28 - .../system-test/fixtures/sample/src/index.ts | 38 - .../v1p1beta1/system-test/install.ts | 49 - .../test/gapic_adaptation_v1p1beta1.ts | 1722 ----------------- .../v1p1beta1/test/gapic_speech_v1p1beta1.ts | 525 ----- owl-bot-staging/v1p1beta1/tsconfig.json | 19 - owl-bot-staging/v1p1beta1/webpack.config.js | 64 - src/v1/adaptation_client.ts | 28 +- src/v1p1beta1/adaptation_client.ts | 28 +- test/gapic_adaptation_v1.ts | 1033 +++++----- test/gapic_adaptation_v1p1beta1.ts | 1033 +++++----- test/gapic_speech_v1.ts | 58 +- test/gapic_speech_v1p1beta1.ts | 58 +- 90 files changed, 1142 insertions(+), 17482 deletions(-) delete mode 100644 owl-bot-staging/v1/.eslintignore delete mode 100644 owl-bot-staging/v1/.eslintrc.json delete mode 100644 owl-bot-staging/v1/.gitignore delete mode 100644 owl-bot-staging/v1/.jsdoc.js delete mode 100644 owl-bot-staging/v1/.mocharc.js delete mode 100644 owl-bot-staging/v1/.prettierrc.js delete mode 100644 owl-bot-staging/v1/README.md delete mode 100644 owl-bot-staging/v1/linkinator.config.json delete mode 100644 owl-bot-staging/v1/package.json delete mode 100644 owl-bot-staging/v1/protos/google/cloud/speech/v1/cloud_speech.proto delete mode 100644 owl-bot-staging/v1/protos/google/cloud/speech/v1/cloud_speech_adaptation.proto delete mode 100644 owl-bot-staging/v1/protos/google/cloud/speech/v1/resource.proto delete mode 100644 owl-bot-staging/v1/samples/generated/v1/adaptation.create_custom_class.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/adaptation.create_phrase_set.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/adaptation.delete_custom_class.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/adaptation.delete_phrase_set.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/adaptation.get_custom_class.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/adaptation.get_phrase_set.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/adaptation.list_custom_classes.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/adaptation.list_phrase_set.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/adaptation.update_custom_class.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/adaptation.update_phrase_set.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.speech.v1.json delete mode 100644 owl-bot-staging/v1/samples/generated/v1/speech.long_running_recognize.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/speech.recognize.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/speech.streaming_recognize.js delete mode 100644 owl-bot-staging/v1/src/index.ts delete mode 100644 owl-bot-staging/v1/src/v1/adaptation_client.ts delete mode 100644 owl-bot-staging/v1/src/v1/adaptation_client_config.json delete mode 100644 owl-bot-staging/v1/src/v1/adaptation_proto_list.json delete mode 100644 owl-bot-staging/v1/src/v1/gapic_metadata.json delete mode 100644 owl-bot-staging/v1/src/v1/index.ts delete mode 100644 owl-bot-staging/v1/src/v1/speech_client.ts delete mode 100644 owl-bot-staging/v1/src/v1/speech_client_config.json delete mode 100644 owl-bot-staging/v1/src/v1/speech_proto_list.json delete mode 100644 owl-bot-staging/v1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/v1/system-test/install.ts delete mode 100644 owl-bot-staging/v1/test/gapic_adaptation_v1.ts delete mode 100644 owl-bot-staging/v1/test/gapic_speech_v1.ts delete mode 100644 owl-bot-staging/v1/tsconfig.json delete mode 100644 owl-bot-staging/v1/webpack.config.js delete mode 100644 owl-bot-staging/v1p1beta1/.eslintignore delete mode 100644 owl-bot-staging/v1p1beta1/.eslintrc.json delete mode 100644 owl-bot-staging/v1p1beta1/.gitignore delete mode 100644 owl-bot-staging/v1p1beta1/.jsdoc.js delete mode 100644 owl-bot-staging/v1p1beta1/.mocharc.js delete mode 100644 owl-bot-staging/v1p1beta1/.prettierrc.js delete mode 100644 owl-bot-staging/v1p1beta1/README.md delete mode 100644 owl-bot-staging/v1p1beta1/linkinator.config.json delete mode 100644 owl-bot-staging/v1p1beta1/package.json delete mode 100644 owl-bot-staging/v1p1beta1/protos/google/cloud/speech/v1p1beta1/cloud_speech.proto delete mode 100644 owl-bot-staging/v1p1beta1/protos/google/cloud/speech/v1p1beta1/cloud_speech_adaptation.proto delete mode 100644 owl-bot-staging/v1p1beta1/protos/google/cloud/speech/v1p1beta1/resource.proto delete mode 100644 owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.create_custom_class.js delete mode 100644 owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.create_phrase_set.js delete mode 100644 owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.delete_custom_class.js delete mode 100644 owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.delete_phrase_set.js delete mode 100644 owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.get_custom_class.js delete mode 100644 owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.get_phrase_set.js delete mode 100644 owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.list_custom_classes.js delete mode 100644 owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.list_phrase_set.js delete mode 100644 owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.update_custom_class.js delete mode 100644 owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.update_phrase_set.js delete mode 100644 owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/snippet_metadata.google.cloud.speech.v1p1beta1.json delete mode 100644 owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/speech.long_running_recognize.js delete mode 100644 owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/speech.recognize.js delete mode 100644 owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/speech.streaming_recognize.js delete mode 100644 owl-bot-staging/v1p1beta1/src/index.ts delete mode 100644 owl-bot-staging/v1p1beta1/src/v1p1beta1/adaptation_client.ts delete mode 100644 owl-bot-staging/v1p1beta1/src/v1p1beta1/adaptation_client_config.json delete mode 100644 owl-bot-staging/v1p1beta1/src/v1p1beta1/adaptation_proto_list.json delete mode 100644 owl-bot-staging/v1p1beta1/src/v1p1beta1/gapic_metadata.json delete mode 100644 owl-bot-staging/v1p1beta1/src/v1p1beta1/index.ts delete mode 100644 owl-bot-staging/v1p1beta1/src/v1p1beta1/speech_client.ts delete mode 100644 owl-bot-staging/v1p1beta1/src/v1p1beta1/speech_client_config.json delete mode 100644 owl-bot-staging/v1p1beta1/src/v1p1beta1/speech_proto_list.json delete mode 100644 owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/v1p1beta1/system-test/install.ts delete mode 100644 owl-bot-staging/v1p1beta1/test/gapic_adaptation_v1p1beta1.ts delete mode 100644 owl-bot-staging/v1p1beta1/test/gapic_speech_v1p1beta1.ts delete mode 100644 owl-bot-staging/v1p1beta1/tsconfig.json delete mode 100644 owl-bot-staging/v1p1beta1/webpack.config.js diff --git a/owl-bot-staging/v1/.eslintignore b/owl-bot-staging/v1/.eslintignore deleted file mode 100644 index cfc348ec..00000000 --- a/owl-bot-staging/v1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/v1/.eslintrc.json b/owl-bot-staging/v1/.eslintrc.json deleted file mode 100644 index 78215349..00000000 --- a/owl-bot-staging/v1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/v1/.gitignore b/owl-bot-staging/v1/.gitignore deleted file mode 100644 index 5d32b237..00000000 --- a/owl-bot-staging/v1/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -**/*.log -**/node_modules -.coverage -coverage -.nyc_output -docs/ -out/ -build/ -system-test/secrets.js -system-test/*key.json -*.lock -.DS_Store -package-lock.json -__pycache__ diff --git a/owl-bot-staging/v1/.jsdoc.js b/owl-bot-staging/v1/.jsdoc.js deleted file mode 100644 index d2a7104e..00000000 --- a/owl-bot-staging/v1/.jsdoc.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2022 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. ** - -'use strict'; - -module.exports = { - opts: { - readme: './README.md', - package: './package.json', - template: './node_modules/jsdoc-fresh', - recurse: true, - verbose: true, - destination: './docs/' - }, - plugins: [ - 'plugins/markdown', - 'jsdoc-region-tag' - ], - source: { - excludePattern: '(^|\\/|\\\\)[._]', - include: [ - 'build/src', - 'protos' - ], - includePattern: '\\.js$' - }, - templates: { - copyright: 'Copyright 2022 Google LLC', - includeDate: false, - sourceFiles: false, - systemName: '@google-cloud/speech', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/v1/.mocharc.js b/owl-bot-staging/v1/.mocharc.js deleted file mode 100644 index 481c522b..00000000 --- a/owl-bot-staging/v1/.mocharc.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2022 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. ** - -const config = { - "enable-source-maps": true, - "throw-deprecation": true, - "timeout": 10000 -} -if (process.env.MOCHA_THROW_DEPRECATION === 'false') { - delete config['throw-deprecation']; -} -if (process.env.MOCHA_REPORTER) { - config.reporter = process.env.MOCHA_REPORTER; -} -if (process.env.MOCHA_REPORTER_OUTPUT) { - config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; -} -module.exports = config diff --git a/owl-bot-staging/v1/.prettierrc.js b/owl-bot-staging/v1/.prettierrc.js deleted file mode 100644 index 494e1478..00000000 --- a/owl-bot-staging/v1/.prettierrc.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2022 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. ** - - -module.exports = { - ...require('gts/.prettierrc.json') -} diff --git a/owl-bot-staging/v1/README.md b/owl-bot-staging/v1/README.md deleted file mode 100644 index 45c3b2af..00000000 --- a/owl-bot-staging/v1/README.md +++ /dev/null @@ -1 +0,0 @@ -Speech: Nodejs Client diff --git a/owl-bot-staging/v1/linkinator.config.json b/owl-bot-staging/v1/linkinator.config.json deleted file mode 100644 index befd23c8..00000000 --- a/owl-bot-staging/v1/linkinator.config.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "recurse": true, - "skip": [ - "https://codecov.io/gh/googleapis/", - "www.googleapis.com", - "img.shields.io", - "https://console.cloud.google.com/cloudshell", - "https://support.google.com" - ], - "silent": true, - "concurrency": 5, - "retry": true, - "retryErrors": true, - "retryErrorsCount": 5, - "retryErrorsJitter": 3000 -} diff --git a/owl-bot-staging/v1/package.json b/owl-bot-staging/v1/package.json deleted file mode 100644 index 53356248..00000000 --- a/owl-bot-staging/v1/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@google-cloud/speech", - "version": "0.1.0", - "description": "Speech client for Node.js", - "repository": "googleapis/nodejs-speech", - "license": "Apache-2.0", - "author": "Google LLC", - "main": "build/src/index.js", - "files": [ - "build/src", - "build/protos" - ], - "keywords": [ - "google apis client", - "google api client", - "google apis", - "google api", - "google", - "google cloud platform", - "google cloud", - "cloud", - "google speech", - "speech", - "adaptation", - "speech" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "predocs-test": "npm run docs", - "docs-test": "linkinator docs", - "fix": "gts fix", - "lint": "gts check", - "prepare": "npm run compile-protos && npm run compile", - "system-test": "c8 mocha build/system-test", - "test": "c8 mocha build/test" - }, - "dependencies": { - "google-gax": "^3.5.1" - }, - "devDependencies": { - "@types/mocha": "^9.1.1", - "@types/node": "^16.11.59", - "@types/sinon": "^10.0.13", - "c8": "^7.12.0", - "gts": "^3.1.1", - "jsdoc": "^3.6.11", - "jsdoc-fresh": "^2.0.1", - "jsdoc-region-tag": "^2.0.1", - "linkinator": "^4.0.3", - "mocha": "^10.0.0", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^14.0.0", - "ts-loader": "^8.4.0", - "typescript": "^4.8.3", - "webpack": "^4.46.0", - "webpack-cli": "^4.10.0" - }, - "engines": { - "node": ">=v12" - } -} diff --git a/owl-bot-staging/v1/protos/google/cloud/speech/v1/cloud_speech.proto b/owl-bot-staging/v1/protos/google/cloud/speech/v1/cloud_speech.proto deleted file mode 100644 index 65aed983..00000000 --- a/owl-bot-staging/v1/protos/google/cloud/speech/v1/cloud_speech.proto +++ /dev/null @@ -1,899 +0,0 @@ -// Copyright 2022 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 -// -// http://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. - -syntax = "proto3"; - -package google.cloud.speech.v1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/cloud/speech/v1/resource.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/timestamp.proto"; -import "google/protobuf/wrappers.proto"; -import "google/rpc/status.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/speech/v1;speech"; -option java_multiple_files = true; -option java_outer_classname = "SpeechProto"; -option java_package = "com.google.cloud.speech.v1"; -option objc_class_prefix = "GCS"; - -// Service that implements Google Cloud Speech API. -service Speech { - option (google.api.default_host) = "speech.googleapis.com"; - option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; - - // Performs synchronous speech recognition: receive results after all audio - // has been sent and processed. - rpc Recognize(RecognizeRequest) returns (RecognizeResponse) { - option (google.api.http) = { - post: "/v1/speech:recognize" - body: "*" - }; - option (google.api.method_signature) = "config,audio"; - } - - // Performs asynchronous speech recognition: receive results via the - // google.longrunning.Operations interface. Returns either an - // `Operation.error` or an `Operation.response` which contains - // a `LongRunningRecognizeResponse` message. - // For more information on asynchronous speech recognition, see the - // [how-to](https://cloud.google.com/speech-to-text/docs/async-recognize). - rpc LongRunningRecognize(LongRunningRecognizeRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/speech:longrunningrecognize" - body: "*" - }; - option (google.api.method_signature) = "config,audio"; - option (google.longrunning.operation_info) = { - response_type: "LongRunningRecognizeResponse" - metadata_type: "LongRunningRecognizeMetadata" - }; - } - - // Performs bidirectional streaming speech recognition: receive results while - // sending audio. This method is only available via the gRPC API (not REST). - rpc StreamingRecognize(stream StreamingRecognizeRequest) returns (stream StreamingRecognizeResponse) { - } -} - -// The top-level message sent by the client for the `Recognize` method. -message RecognizeRequest { - // Required. Provides information to the recognizer that specifies how to - // process the request. - RecognitionConfig config = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. The audio data to be recognized. - RecognitionAudio audio = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// The top-level message sent by the client for the `LongRunningRecognize` -// method. -message LongRunningRecognizeRequest { - // Required. Provides information to the recognizer that specifies how to - // process the request. - RecognitionConfig config = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. The audio data to be recognized. - RecognitionAudio audio = 2 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Specifies an optional destination for the recognition results. - TranscriptOutputConfig output_config = 4 [(google.api.field_behavior) = OPTIONAL]; -} - -// Specifies an optional destination for the recognition results. -message TranscriptOutputConfig { - oneof output_type { - // Specifies a Cloud Storage URI for the recognition results. Must be - // specified in the format: `gs://bucket_name/object_name`, and the bucket - // must already exist. - string gcs_uri = 1; - } -} - -// The top-level message sent by the client for the `StreamingRecognize` method. -// Multiple `StreamingRecognizeRequest` messages are sent. The first message -// must contain a `streaming_config` message and must not contain -// `audio_content`. All subsequent messages must contain `audio_content` and -// must not contain a `streaming_config` message. -message StreamingRecognizeRequest { - // The streaming request, which is either a streaming config or audio content. - oneof streaming_request { - // Provides information to the recognizer that specifies how to process the - // request. The first `StreamingRecognizeRequest` message must contain a - // `streaming_config` message. - StreamingRecognitionConfig streaming_config = 1; - - // The audio data to be recognized. Sequential chunks of audio data are sent - // in sequential `StreamingRecognizeRequest` messages. The first - // `StreamingRecognizeRequest` message must not contain `audio_content` data - // and all subsequent `StreamingRecognizeRequest` messages must contain - // `audio_content` data. The audio bytes must be encoded as specified in - // `RecognitionConfig`. Note: as with all bytes fields, proto buffers use a - // pure binary representation (not base64). See - // [content limits](https://cloud.google.com/speech-to-text/quotas#content). - bytes audio_content = 2; - } -} - -// Provides information to the recognizer that specifies how to process the -// request. -message StreamingRecognitionConfig { - // Required. Provides information to the recognizer that specifies how to - // process the request. - RecognitionConfig config = 1 [(google.api.field_behavior) = REQUIRED]; - - // If `false` or omitted, the recognizer will perform continuous - // recognition (continuing to wait for and process audio even if the user - // pauses speaking) until the client closes the input stream (gRPC API) or - // until the maximum time limit has been reached. May return multiple - // `StreamingRecognitionResult`s with the `is_final` flag set to `true`. - // - // If `true`, the recognizer will detect a single spoken utterance. When it - // detects that the user has paused or stopped speaking, it will return an - // `END_OF_SINGLE_UTTERANCE` event and cease recognition. It will return no - // more than one `StreamingRecognitionResult` with the `is_final` flag set to - // `true`. - // - // The `single_utterance` field can only be used with specified models, - // otherwise an error is thrown. The `model` field in [`RecognitionConfig`][] - // must be set to: - // - // * `command_and_search` - // * `phone_call` AND additional field `useEnhanced`=`true` - // * The `model` field is left undefined. In this case the API auto-selects - // a model based on any other parameters that you set in - // `RecognitionConfig`. - bool single_utterance = 2; - - // If `true`, interim results (tentative hypotheses) may be - // returned as they become available (these interim results are indicated with - // the `is_final=false` flag). - // If `false` or omitted, only `is_final=true` result(s) are returned. - bool interim_results = 3; -} - -// Provides information to the recognizer that specifies how to process the -// request. -message RecognitionConfig { - // The encoding of the audio data sent in the request. - // - // All encodings support only 1 channel (mono) audio, unless the - // `audio_channel_count` and `enable_separate_recognition_per_channel` fields - // are set. - // - // For best results, the audio source should be captured and transmitted using - // a lossless encoding (`FLAC` or `LINEAR16`). The accuracy of the speech - // recognition can be reduced if lossy codecs are used to capture or transmit - // audio, particularly if background noise is present. Lossy codecs include - // `MULAW`, `AMR`, `AMR_WB`, `OGG_OPUS`, `SPEEX_WITH_HEADER_BYTE`, `MP3`, - // and `WEBM_OPUS`. - // - // The `FLAC` and `WAV` audio file formats include a header that describes the - // included audio content. You can request recognition for `WAV` files that - // contain either `LINEAR16` or `MULAW` encoded audio. - // If you send `FLAC` or `WAV` audio file format in - // your request, you do not need to specify an `AudioEncoding`; the audio - // encoding format is determined from the file header. If you specify - // an `AudioEncoding` when you send send `FLAC` or `WAV` audio, the - // encoding configuration must match the encoding described in the audio - // header; otherwise the request returns an - // [google.rpc.Code.INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT] error code. - enum AudioEncoding { - // Not specified. - ENCODING_UNSPECIFIED = 0; - - // Uncompressed 16-bit signed little-endian samples (Linear PCM). - LINEAR16 = 1; - - // `FLAC` (Free Lossless Audio - // Codec) is the recommended encoding because it is - // lossless--therefore recognition is not compromised--and - // requires only about half the bandwidth of `LINEAR16`. `FLAC` stream - // encoding supports 16-bit and 24-bit samples, however, not all fields in - // `STREAMINFO` are supported. - FLAC = 2; - - // 8-bit samples that compand 14-bit audio samples using G.711 PCMU/mu-law. - MULAW = 3; - - // Adaptive Multi-Rate Narrowband codec. `sample_rate_hertz` must be 8000. - AMR = 4; - - // Adaptive Multi-Rate Wideband codec. `sample_rate_hertz` must be 16000. - AMR_WB = 5; - - // Opus encoded audio frames in Ogg container - // ([OggOpus](https://wiki.xiph.org/OggOpus)). - // `sample_rate_hertz` must be one of 8000, 12000, 16000, 24000, or 48000. - OGG_OPUS = 6; - - // Although the use of lossy encodings is not recommended, if a very low - // bitrate encoding is required, `OGG_OPUS` is highly preferred over - // Speex encoding. The [Speex](https://speex.org/) encoding supported by - // Cloud Speech API has a header byte in each block, as in MIME type - // `audio/x-speex-with-header-byte`. - // It is a variant of the RTP Speex encoding defined in - // [RFC 5574](https://tools.ietf.org/html/rfc5574). - // The stream is a sequence of blocks, one block per RTP packet. Each block - // starts with a byte containing the length of the block, in bytes, followed - // by one or more frames of Speex data, padded to an integral number of - // bytes (octets) as specified in RFC 5574. In other words, each RTP header - // is replaced with a single byte containing the block length. Only Speex - // wideband is supported. `sample_rate_hertz` must be 16000. - SPEEX_WITH_HEADER_BYTE = 7; - - // Opus encoded audio frames in WebM container - // ([OggOpus](https://wiki.xiph.org/OggOpus)). `sample_rate_hertz` must be - // one of 8000, 12000, 16000, 24000, or 48000. - WEBM_OPUS = 9; - } - - // Encoding of audio data sent in all `RecognitionAudio` messages. - // This field is optional for `FLAC` and `WAV` audio files and required - // for all other audio formats. For details, see [AudioEncoding][google.cloud.speech.v1.RecognitionConfig.AudioEncoding]. - AudioEncoding encoding = 1; - - // Sample rate in Hertz of the audio data sent in all - // `RecognitionAudio` messages. Valid values are: 8000-48000. - // 16000 is optimal. For best results, set the sampling rate of the audio - // source to 16000 Hz. If that's not possible, use the native sample rate of - // the audio source (instead of re-sampling). - // This field is optional for FLAC and WAV audio files, but is - // required for all other audio formats. For details, see [AudioEncoding][google.cloud.speech.v1.RecognitionConfig.AudioEncoding]. - int32 sample_rate_hertz = 2; - - // The number of channels in the input audio data. - // ONLY set this for MULTI-CHANNEL recognition. - // Valid values for LINEAR16 and FLAC are `1`-`8`. - // Valid values for OGG_OPUS are '1'-'254'. - // Valid value for MULAW, AMR, AMR_WB and SPEEX_WITH_HEADER_BYTE is only `1`. - // If `0` or omitted, defaults to one channel (mono). - // Note: We only recognize the first channel by default. - // To perform independent recognition on each channel set - // `enable_separate_recognition_per_channel` to 'true'. - int32 audio_channel_count = 7; - - // This needs to be set to `true` explicitly and `audio_channel_count` > 1 - // to get each channel recognized separately. The recognition result will - // contain a `channel_tag` field to state which channel that result belongs - // to. If this is not true, we will only recognize the first channel. The - // request is billed cumulatively for all channels recognized: - // `audio_channel_count` multiplied by the length of the audio. - bool enable_separate_recognition_per_channel = 12; - - // Required. The language of the supplied audio as a - // [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag. - // Example: "en-US". - // See [Language - // Support](https://cloud.google.com/speech-to-text/docs/languages) for a list - // of the currently supported language codes. - string language_code = 3 [(google.api.field_behavior) = REQUIRED]; - - // A list of up to 3 additional - // [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tags, - // listing possible alternative languages of the supplied audio. - // See [Language - // Support](https://cloud.google.com/speech-to-text/docs/languages) for a list - // of the currently supported language codes. If alternative languages are - // listed, recognition result will contain recognition in the most likely - // language detected including the main language_code. The recognition result - // will include the language tag of the language detected in the audio. Note: - // This feature is only supported for Voice Command and Voice Search use cases - // and performance may vary for other use cases (e.g., phone call - // transcription). - repeated string alternative_language_codes = 18; - - // Maximum number of recognition hypotheses to be returned. - // Specifically, the maximum number of `SpeechRecognitionAlternative` messages - // within each `SpeechRecognitionResult`. - // The server may return fewer than `max_alternatives`. - // Valid values are `0`-`30`. A value of `0` or `1` will return a maximum of - // one. If omitted, will return a maximum of one. - int32 max_alternatives = 4; - - // If set to `true`, the server will attempt to filter out - // profanities, replacing all but the initial character in each filtered word - // with asterisks, e.g. "f***". If set to `false` or omitted, profanities - // won't be filtered out. - bool profanity_filter = 5; - - // Speech adaptation configuration improves the accuracy of speech - // recognition. For more information, see the [speech - // adaptation](https://cloud.google.com/speech-to-text/docs/adaptation) - // documentation. - // When speech adaptation is set it supersedes the `speech_contexts` field. - SpeechAdaptation adaptation = 20; - - // Array of [SpeechContext][google.cloud.speech.v1.SpeechContext]. - // A means to provide context to assist the speech recognition. For more - // information, see - // [speech - // adaptation](https://cloud.google.com/speech-to-text/docs/adaptation). - repeated SpeechContext speech_contexts = 6; - - // If `true`, the top result includes a list of words and - // the start and end time offsets (timestamps) for those words. If - // `false`, no word-level time offset information is returned. The default is - // `false`. - bool enable_word_time_offsets = 8; - - // If `true`, the top result includes a list of words and the - // confidence for those words. If `false`, no word-level confidence - // information is returned. The default is `false`. - bool enable_word_confidence = 15; - - // If 'true', adds punctuation to recognition result hypotheses. - // This feature is only available in select languages. Setting this for - // requests in other languages has no effect at all. - // The default 'false' value does not add punctuation to result hypotheses. - bool enable_automatic_punctuation = 11; - - // The spoken punctuation behavior for the call - // If not set, uses default behavior based on model of choice - // e.g. command_and_search will enable spoken punctuation by default - // If 'true', replaces spoken punctuation with the corresponding symbols in - // the request. For example, "how are you question mark" becomes "how are - // you?". See https://cloud.google.com/speech-to-text/docs/spoken-punctuation - // for support. If 'false', spoken punctuation is not replaced. - google.protobuf.BoolValue enable_spoken_punctuation = 22; - - // The spoken emoji behavior for the call - // If not set, uses default behavior based on model of choice - // If 'true', adds spoken emoji formatting for the request. This will replace - // spoken emojis with the corresponding Unicode symbols in the final - // transcript. If 'false', spoken emojis are not replaced. - google.protobuf.BoolValue enable_spoken_emojis = 23; - - // Config to enable speaker diarization and set additional - // parameters to make diarization better suited for your application. - // Note: When this is enabled, we send all the words from the beginning of the - // audio for the top alternative in every consecutive STREAMING responses. - // This is done in order to improve our speaker tags as our models learn to - // identify the speakers in the conversation over time. - // For non-streaming requests, the diarization results will be provided only - // in the top alternative of the FINAL SpeechRecognitionResult. - SpeakerDiarizationConfig diarization_config = 19; - - // Metadata regarding this request. - RecognitionMetadata metadata = 9; - - // Which model to select for the given request. Select the model - // best suited to your domain to get best results. If a model is not - // explicitly specified, then we auto-select a model based on the parameters - // in the RecognitionConfig. - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - //
ModelDescription
latest_longBest for long form content like media or conversation.
latest_shortBest for short form content like commands or single shot directed - // speech.
command_and_searchBest for short queries such as voice commands or voice search.
phone_callBest for audio that originated from a phone call (typically - // recorded at an 8khz sampling rate).
videoBest for audio that originated from video or includes multiple - // speakers. Ideally the audio is recorded at a 16khz or greater - // sampling rate. This is a premium model that costs more than the - // standard rate.
defaultBest for audio that is not one of the specific audio models. - // For example, long-form audio. Ideally the audio is high-fidelity, - // recorded at a 16khz or greater sampling rate.
medical_conversationBest for audio that originated from a conversation between a - // medical provider and patient.
medical_dictationBest for audio that originated from dictation notes by a medical - // provider.
- string model = 13; - - // Set to true to use an enhanced model for speech recognition. - // If `use_enhanced` is set to true and the `model` field is not set, then - // an appropriate enhanced model is chosen if an enhanced model exists for - // the audio. - // - // If `use_enhanced` is true and an enhanced version of the specified model - // does not exist, then the speech is recognized using the standard version - // of the specified model. - bool use_enhanced = 14; -} - -// Config to enable speaker diarization. -message SpeakerDiarizationConfig { - // If 'true', enables speaker detection for each recognized word in - // the top alternative of the recognition result using a speaker_tag provided - // in the WordInfo. - bool enable_speaker_diarization = 1; - - // Minimum number of speakers in the conversation. This range gives you more - // flexibility by allowing the system to automatically determine the correct - // number of speakers. If not set, the default value is 2. - int32 min_speaker_count = 2; - - // Maximum number of speakers in the conversation. This range gives you more - // flexibility by allowing the system to automatically determine the correct - // number of speakers. If not set, the default value is 6. - int32 max_speaker_count = 3; - - // Output only. Unused. - int32 speaker_tag = 5 [ - deprecated = true, - (google.api.field_behavior) = OUTPUT_ONLY - ]; -} - -// Description of audio data to be recognized. -message RecognitionMetadata { - option deprecated = true; - - // Use case categories that the audio recognition request can be described - // by. - enum InteractionType { - // Use case is either unknown or is something other than one of the other - // values below. - INTERACTION_TYPE_UNSPECIFIED = 0; - - // Multiple people in a conversation or discussion. For example in a - // meeting with two or more people actively participating. Typically - // all the primary people speaking would be in the same room (if not, - // see PHONE_CALL) - DISCUSSION = 1; - - // One or more persons lecturing or presenting to others, mostly - // uninterrupted. - PRESENTATION = 2; - - // A phone-call or video-conference in which two or more people, who are - // not in the same room, are actively participating. - PHONE_CALL = 3; - - // A recorded message intended for another person to listen to. - VOICEMAIL = 4; - - // Professionally produced audio (eg. TV Show, Podcast). - PROFESSIONALLY_PRODUCED = 5; - - // Transcribe spoken questions and queries into text. - VOICE_SEARCH = 6; - - // Transcribe voice commands, such as for controlling a device. - VOICE_COMMAND = 7; - - // Transcribe speech to text to create a written document, such as a - // text-message, email or report. - DICTATION = 8; - } - - // Enumerates the types of capture settings describing an audio file. - enum MicrophoneDistance { - // Audio type is not known. - MICROPHONE_DISTANCE_UNSPECIFIED = 0; - - // The audio was captured from a closely placed microphone. Eg. phone, - // dictaphone, or handheld microphone. Generally if there speaker is within - // 1 meter of the microphone. - NEARFIELD = 1; - - // The speaker if within 3 meters of the microphone. - MIDFIELD = 2; - - // The speaker is more than 3 meters away from the microphone. - FARFIELD = 3; - } - - // The original media the speech was recorded on. - enum OriginalMediaType { - // Unknown original media type. - ORIGINAL_MEDIA_TYPE_UNSPECIFIED = 0; - - // The speech data is an audio recording. - AUDIO = 1; - - // The speech data originally recorded on a video. - VIDEO = 2; - } - - // The type of device the speech was recorded with. - enum RecordingDeviceType { - // The recording device is unknown. - RECORDING_DEVICE_TYPE_UNSPECIFIED = 0; - - // Speech was recorded on a smartphone. - SMARTPHONE = 1; - - // Speech was recorded using a personal computer or tablet. - PC = 2; - - // Speech was recorded over a phone line. - PHONE_LINE = 3; - - // Speech was recorded in a vehicle. - VEHICLE = 4; - - // Speech was recorded outdoors. - OTHER_OUTDOOR_DEVICE = 5; - - // Speech was recorded indoors. - OTHER_INDOOR_DEVICE = 6; - } - - // The use case most closely describing the audio content to be recognized. - InteractionType interaction_type = 1; - - // The industry vertical to which this speech recognition request most - // closely applies. This is most indicative of the topics contained - // in the audio. Use the 6-digit NAICS code to identify the industry - // vertical - see https://www.naics.com/search/. - uint32 industry_naics_code_of_audio = 3; - - // The audio type that most closely describes the audio being recognized. - MicrophoneDistance microphone_distance = 4; - - // The original media the speech was recorded on. - OriginalMediaType original_media_type = 5; - - // The type of device the speech was recorded with. - RecordingDeviceType recording_device_type = 6; - - // The device used to make the recording. Examples 'Nexus 5X' or - // 'Polycom SoundStation IP 6000' or 'POTS' or 'VoIP' or - // 'Cardioid Microphone'. - string recording_device_name = 7; - - // Mime type of the original audio file. For example `audio/m4a`, - // `audio/x-alaw-basic`, `audio/mp3`, `audio/3gpp`. - // A list of possible audio mime types is maintained at - // http://www.iana.org/assignments/media-types/media-types.xhtml#audio - string original_mime_type = 8; - - // Description of the content. Eg. "Recordings of federal supreme court - // hearings from 2012". - string audio_topic = 10; -} - -// Provides "hints" to the speech recognizer to favor specific words and phrases -// in the results. -message SpeechContext { - // A list of strings containing words and phrases "hints" so that - // the speech recognition is more likely to recognize them. This can be used - // to improve the accuracy for specific words and phrases, for example, if - // specific commands are typically spoken by the user. This can also be used - // to add additional words to the vocabulary of the recognizer. See - // [usage limits](https://cloud.google.com/speech-to-text/quotas#content). - // - // List items can also be set to classes for groups of words that represent - // common concepts that occur in natural language. For example, rather than - // providing phrase hints for every month of the year, using the $MONTH class - // improves the likelihood of correctly transcribing audio that includes - // months. - repeated string phrases = 1; - - // Hint Boost. Positive value will increase the probability that a specific - // phrase will be recognized over other similar sounding phrases. The higher - // the boost, the higher the chance of false positive recognition as well. - // Negative boost values would correspond to anti-biasing. Anti-biasing is not - // enabled, so negative boost will simply be ignored. Though `boost` can - // accept a wide range of positive values, most use cases are best served with - // values between 0 and 20. We recommend using a binary search approach to - // finding the optimal value for your use case. - float boost = 4; -} - -// Contains audio data in the encoding specified in the `RecognitionConfig`. -// Either `content` or `uri` must be supplied. Supplying both or neither -// returns [google.rpc.Code.INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT]. See -// [content limits](https://cloud.google.com/speech-to-text/quotas#content). -message RecognitionAudio { - // The audio source, which is either inline content or a Google Cloud - // Storage uri. - oneof audio_source { - // The audio data bytes encoded as specified in - // `RecognitionConfig`. Note: as with all bytes fields, proto buffers use a - // pure binary representation, whereas JSON representations use base64. - bytes content = 1; - - // URI that points to a file that contains audio data bytes as specified in - // `RecognitionConfig`. The file must not be compressed (for example, gzip). - // Currently, only Google Cloud Storage URIs are - // supported, which must be specified in the following format: - // `gs://bucket_name/object_name` (other URI formats return - // [google.rpc.Code.INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT]). For more information, see - // [Request URIs](https://cloud.google.com/storage/docs/reference-uris). - string uri = 2; - } -} - -// The only message returned to the client by the `Recognize` method. It -// contains the result as zero or more sequential `SpeechRecognitionResult` -// messages. -message RecognizeResponse { - // Sequential list of transcription results corresponding to - // sequential portions of audio. - repeated SpeechRecognitionResult results = 2; - - // When available, billed audio seconds for the corresponding request. - google.protobuf.Duration total_billed_time = 3; -} - -// The only message returned to the client by the `LongRunningRecognize` method. -// It contains the result as zero or more sequential `SpeechRecognitionResult` -// messages. It is included in the `result.response` field of the `Operation` -// returned by the `GetOperation` call of the `google::longrunning::Operations` -// service. -message LongRunningRecognizeResponse { - // Sequential list of transcription results corresponding to - // sequential portions of audio. - repeated SpeechRecognitionResult results = 2; - - // When available, billed audio seconds for the corresponding request. - google.protobuf.Duration total_billed_time = 3; - - // Original output config if present in the request. - TranscriptOutputConfig output_config = 6; - - // If the transcript output fails this field contains the relevant error. - google.rpc.Status output_error = 7; -} - -// Describes the progress of a long-running `LongRunningRecognize` call. It is -// included in the `metadata` field of the `Operation` returned by the -// `GetOperation` call of the `google::longrunning::Operations` service. -message LongRunningRecognizeMetadata { - // Approximate percentage of audio processed thus far. Guaranteed to be 100 - // when the audio is fully processed and the results are available. - int32 progress_percent = 1; - - // Time when the request was received. - google.protobuf.Timestamp start_time = 2; - - // Time of the most recent processing update. - google.protobuf.Timestamp last_update_time = 3; - - // Output only. The URI of the audio file being transcribed. Empty if the audio was sent - // as byte content. - string uri = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// `StreamingRecognizeResponse` is the only message returned to the client by -// `StreamingRecognize`. A series of zero or more `StreamingRecognizeResponse` -// messages are streamed back to the client. If there is no recognizable -// audio, and `single_utterance` is set to false, then no messages are streamed -// back to the client. -// -// Here's an example of a series of `StreamingRecognizeResponse`s that might be -// returned while processing audio: -// -// 1. results { alternatives { transcript: "tube" } stability: 0.01 } -// -// 2. results { alternatives { transcript: "to be a" } stability: 0.01 } -// -// 3. results { alternatives { transcript: "to be" } stability: 0.9 } -// results { alternatives { transcript: " or not to be" } stability: 0.01 } -// -// 4. results { alternatives { transcript: "to be or not to be" -// confidence: 0.92 } -// alternatives { transcript: "to bee or not to bee" } -// is_final: true } -// -// 5. results { alternatives { transcript: " that's" } stability: 0.01 } -// -// 6. results { alternatives { transcript: " that is" } stability: 0.9 } -// results { alternatives { transcript: " the question" } stability: 0.01 } -// -// 7. results { alternatives { transcript: " that is the question" -// confidence: 0.98 } -// alternatives { transcript: " that was the question" } -// is_final: true } -// -// Notes: -// -// - Only two of the above responses #4 and #7 contain final results; they are -// indicated by `is_final: true`. Concatenating these together generates the -// full transcript: "to be or not to be that is the question". -// -// - The others contain interim `results`. #3 and #6 contain two interim -// `results`: the first portion has a high stability and is less likely to -// change; the second portion has a low stability and is very likely to -// change. A UI designer might choose to show only high stability `results`. -// -// - The specific `stability` and `confidence` values shown above are only for -// illustrative purposes. Actual values may vary. -// -// - In each response, only one of these fields will be set: -// `error`, -// `speech_event_type`, or -// one or more (repeated) `results`. -message StreamingRecognizeResponse { - // Indicates the type of speech event. - enum SpeechEventType { - // No speech event specified. - SPEECH_EVENT_UNSPECIFIED = 0; - - // This event indicates that the server has detected the end of the user's - // speech utterance and expects no additional speech. Therefore, the server - // will not process additional audio (although it may subsequently return - // additional results). The client should stop sending additional audio - // data, half-close the gRPC connection, and wait for any additional results - // until the server closes the gRPC connection. This event is only sent if - // `single_utterance` was set to `true`, and is not used otherwise. - END_OF_SINGLE_UTTERANCE = 1; - } - - // If set, returns a [google.rpc.Status][google.rpc.Status] message that - // specifies the error for the operation. - google.rpc.Status error = 1; - - // This repeated list contains zero or more results that - // correspond to consecutive portions of the audio currently being processed. - // It contains zero or one `is_final=true` result (the newly settled portion), - // followed by zero or more `is_final=false` results (the interim results). - repeated StreamingRecognitionResult results = 2; - - // Indicates the type of speech event. - SpeechEventType speech_event_type = 4; - - // When available, billed audio seconds for the stream. - // Set only if this is the last response in the stream. - google.protobuf.Duration total_billed_time = 5; -} - -// A streaming speech recognition result corresponding to a portion of the audio -// that is currently being processed. -message StreamingRecognitionResult { - // May contain one or more recognition hypotheses (up to the - // maximum specified in `max_alternatives`). - // These alternatives are ordered in terms of accuracy, with the top (first) - // alternative being the most probable, as ranked by the recognizer. - repeated SpeechRecognitionAlternative alternatives = 1; - - // If `false`, this `StreamingRecognitionResult` represents an - // interim result that may change. If `true`, this is the final time the - // speech service will return this particular `StreamingRecognitionResult`, - // the recognizer will not return any further hypotheses for this portion of - // the transcript and corresponding audio. - bool is_final = 2; - - // An estimate of the likelihood that the recognizer will not - // change its guess about this interim result. Values range from 0.0 - // (completely unstable) to 1.0 (completely stable). - // This field is only provided for interim results (`is_final=false`). - // The default of 0.0 is a sentinel value indicating `stability` was not set. - float stability = 3; - - // Time offset of the end of this result relative to the - // beginning of the audio. - google.protobuf.Duration result_end_time = 4; - - // For multi-channel audio, this is the channel number corresponding to the - // recognized result for the audio from that channel. - // For audio_channel_count = N, its output values can range from '1' to 'N'. - int32 channel_tag = 5; - - // Output only. The [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag - // of the language in this result. This language code was detected to have - // the most likelihood of being spoken in the audio. - string language_code = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// A speech recognition result corresponding to a portion of the audio. -message SpeechRecognitionResult { - // May contain one or more recognition hypotheses (up to the - // maximum specified in `max_alternatives`). - // These alternatives are ordered in terms of accuracy, with the top (first) - // alternative being the most probable, as ranked by the recognizer. - repeated SpeechRecognitionAlternative alternatives = 1; - - // For multi-channel audio, this is the channel number corresponding to the - // recognized result for the audio from that channel. - // For audio_channel_count = N, its output values can range from '1' to 'N'. - int32 channel_tag = 2; - - // Time offset of the end of this result relative to the - // beginning of the audio. - google.protobuf.Duration result_end_time = 4; - - // Output only. The [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag - // of the language in this result. This language code was detected to have - // the most likelihood of being spoken in the audio. - string language_code = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// Alternative hypotheses (a.k.a. n-best list). -message SpeechRecognitionAlternative { - // Transcript text representing the words that the user spoke. - // In languages that use spaces to separate words, the transcript might have a - // leading space if it isn't the first result. You can concatenate each result - // to obtain the full transcript without using a separator. - string transcript = 1; - - // The confidence estimate between 0.0 and 1.0. A higher number - // indicates an estimated greater likelihood that the recognized words are - // correct. This field is set only for the top alternative of a non-streaming - // result or, of a streaming result where `is_final=true`. - // This field is not guaranteed to be accurate and users should not rely on it - // to be always provided. - // The default of 0.0 is a sentinel value indicating `confidence` was not set. - float confidence = 2; - - // A list of word-specific information for each recognized word. - // Note: When `enable_speaker_diarization` is true, you will see all the words - // from the beginning of the audio. - repeated WordInfo words = 3; -} - -// Word-specific information for recognized words. -message WordInfo { - // Time offset relative to the beginning of the audio, - // and corresponding to the start of the spoken word. - // This field is only set if `enable_word_time_offsets=true` and only - // in the top hypothesis. - // This is an experimental feature and the accuracy of the time offset can - // vary. - google.protobuf.Duration start_time = 1; - - // Time offset relative to the beginning of the audio, - // and corresponding to the end of the spoken word. - // This field is only set if `enable_word_time_offsets=true` and only - // in the top hypothesis. - // This is an experimental feature and the accuracy of the time offset can - // vary. - google.protobuf.Duration end_time = 2; - - // The word corresponding to this set of information. - string word = 3; - - // The confidence estimate between 0.0 and 1.0. A higher number - // indicates an estimated greater likelihood that the recognized words are - // correct. This field is set only for the top alternative of a non-streaming - // result or, of a streaming result where `is_final=true`. - // This field is not guaranteed to be accurate and users should not rely on it - // to be always provided. - // The default of 0.0 is a sentinel value indicating `confidence` was not set. - float confidence = 4; - - // Output only. A distinct integer value is assigned for every speaker within - // the audio. This field specifies which one of those speakers was detected to - // have spoken this word. Value ranges from '1' to diarization_speaker_count. - // speaker_tag is set if enable_speaker_diarization = 'true' and only in the - // top alternative. - int32 speaker_tag = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; -} diff --git a/owl-bot-staging/v1/protos/google/cloud/speech/v1/cloud_speech_adaptation.proto b/owl-bot-staging/v1/protos/google/cloud/speech/v1/cloud_speech_adaptation.proto deleted file mode 100644 index b0d60ab4..00000000 --- a/owl-bot-staging/v1/protos/google/cloud/speech/v1/cloud_speech_adaptation.proto +++ /dev/null @@ -1,370 +0,0 @@ -// Copyright 2022 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 -// -// http://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. - -syntax = "proto3"; - -package google.cloud.speech.v1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/speech/v1/resource.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/speech/v1;speech"; -option java_multiple_files = true; -option java_outer_classname = "SpeechAdaptationProto"; -option java_package = "com.google.cloud.speech.v1"; -option objc_class_prefix = "GCS"; - -// Service that implements Google Cloud Speech Adaptation API. -service Adaptation { - option (google.api.default_host) = "speech.googleapis.com"; - option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; - - // 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. - rpc CreatePhraseSet(CreatePhraseSetRequest) returns (PhraseSet) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*}/phraseSets" - body: "*" - }; - option (google.api.method_signature) = "parent,phrase_set,phrase_set_id"; - } - - // Get a phrase set. - rpc GetPhraseSet(GetPhraseSetRequest) returns (PhraseSet) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/phraseSets/*}" - }; - option (google.api.method_signature) = "name"; - } - - // List phrase sets. - rpc ListPhraseSet(ListPhraseSetRequest) returns (ListPhraseSetResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*}/phraseSets" - }; - option (google.api.method_signature) = "parent"; - } - - // Update a phrase set. - rpc UpdatePhraseSet(UpdatePhraseSetRequest) returns (PhraseSet) { - option (google.api.http) = { - patch: "/v1/{phrase_set.name=projects/*/locations/*/phraseSets/*}" - body: "phrase_set" - }; - option (google.api.method_signature) = "phrase_set,update_mask"; - } - - // Delete a phrase set. - rpc DeletePhraseSet(DeletePhraseSetRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1/{name=projects/*/locations/*/phraseSets/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Create a custom class. - rpc CreateCustomClass(CreateCustomClassRequest) returns (CustomClass) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*}/customClasses" - body: "*" - }; - option (google.api.method_signature) = "parent,custom_class,custom_class_id"; - } - - // Get a custom class. - rpc GetCustomClass(GetCustomClassRequest) returns (CustomClass) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/customClasses/*}" - }; - option (google.api.method_signature) = "name"; - } - - // List custom classes. - rpc ListCustomClasses(ListCustomClassesRequest) returns (ListCustomClassesResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*}/customClasses" - }; - option (google.api.method_signature) = "parent"; - } - - // Update a custom class. - rpc UpdateCustomClass(UpdateCustomClassRequest) returns (CustomClass) { - option (google.api.http) = { - patch: "/v1/{custom_class.name=projects/*/locations/*/customClasses/*}" - body: "custom_class" - }; - option (google.api.method_signature) = "custom_class,update_mask"; - } - - // Delete a custom class. - rpc DeleteCustomClass(DeleteCustomClassRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1/{name=projects/*/locations/*/customClasses/*}" - }; - option (google.api.method_signature) = "name"; - } -} - -// Message sent by the client for the `CreatePhraseSet` method. -message CreatePhraseSetRequest { - // Required. The parent resource where this phrase set will be created. Format: - // - // `projects/{project}/locations/{location}/phraseSets` - // - // Speech-to-Text supports three locations: `global`, `us` (US North America), - // and `eu` (Europe). If you are calling the `speech.googleapis.com` - // endpoint, use the `global` location. To specify a region, use a - // [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - // with matching `us` or `eu` location value. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "speech.googleapis.com/PhraseSet" - } - ]; - - // Required. The ID to use for the phrase set, which will become the final - // component of the phrase set's resource name. - // - // This value should restrict to letters, numbers, and hyphens, with the first - // character a letter, the last a letter or a number, and be 4-63 characters. - string phrase_set_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The phrase set to create. - PhraseSet phrase_set = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Message sent by the client for the `UpdatePhraseSet` method. -message UpdatePhraseSetRequest { - // Required. The phrase set to update. - // - // The phrase set's `name` field is used to identify the set to be - // updated. Format: - // - // `projects/{project}/locations/{location}/phraseSets/{phrase_set}` - // - // Speech-to-Text supports three locations: `global`, `us` (US North America), - // and `eu` (Europe). If you are calling the `speech.googleapis.com` - // endpoint, use the `global` location. To specify a region, use a - // [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - // with matching `us` or `eu` location value. - PhraseSet phrase_set = 1 [(google.api.field_behavior) = REQUIRED]; - - // The list of fields to be updated. - google.protobuf.FieldMask update_mask = 2; -} - -// Message sent by the client for the `GetPhraseSet` method. -message GetPhraseSetRequest { - // Required. The name of the phrase set to retrieve. Format: - // - // `projects/{project}/locations/{location}/phraseSets/{phrase_set}` - // - // Speech-to-Text supports three locations: `global`, `us` (US North America), - // and `eu` (Europe). If you are calling the `speech.googleapis.com` - // endpoint, use the `global` location. To specify a region, use a - // [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - // with matching `us` or `eu` location value. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "speech.googleapis.com/PhraseSet" - } - ]; -} - -// Message sent by the client for the `ListPhraseSet` method. -message ListPhraseSetRequest { - // Required. The parent, which owns this collection of phrase set. Format: - // - // `projects/{project}/locations/{location}` - // - // Speech-to-Text supports three locations: `global`, `us` (US North America), - // and `eu` (Europe). If you are calling the `speech.googleapis.com` - // endpoint, use the `global` location. To specify a region, use a - // [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - // with matching `us` or `eu` location value. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "speech.googleapis.com/PhraseSet" - } - ]; - - // 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. - int32 page_size = 2; - - // 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. - string page_token = 3; -} - -// Message returned to the client by the `ListPhraseSet` method. -message ListPhraseSetResponse { - // The phrase set. - repeated PhraseSet phrase_sets = 1; - - // A token, which can be sent as `page_token` to retrieve the next page. - // If this field is omitted, there are no subsequent pages. - string next_page_token = 2; -} - -// Message sent by the client for the `DeletePhraseSet` method. -message DeletePhraseSetRequest { - // Required. The name of the phrase set to delete. Format: - // - // `projects/{project}/locations/{location}/phraseSets/{phrase_set}` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "speech.googleapis.com/PhraseSet" - } - ]; -} - -// Message sent by the client for the `CreateCustomClass` method. -message CreateCustomClassRequest { - // Required. The parent resource where this custom class will be created. Format: - // - // `projects/{project}/locations/{location}/customClasses` - // - // Speech-to-Text supports three locations: `global`, `us` (US North America), - // and `eu` (Europe). If you are calling the `speech.googleapis.com` - // endpoint, use the `global` location. To specify a region, use a - // [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - // with matching `us` or `eu` location value. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "speech.googleapis.com/CustomClass" - } - ]; - - // Required. The ID to use for the custom class, which will become the final - // component of the custom class' resource name. - // - // This value should restrict to letters, numbers, and hyphens, with the first - // character a letter, the last a letter or a number, and be 4-63 characters. - string custom_class_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The custom class to create. - CustomClass custom_class = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Message sent by the client for the `UpdateCustomClass` method. -message UpdateCustomClassRequest { - // Required. The custom class to update. - // - // The custom class's `name` field is used to identify the custom class to be - // updated. Format: - // - // `projects/{project}/locations/{location}/customClasses/{custom_class}` - // - // Speech-to-Text supports three locations: `global`, `us` (US North America), - // and `eu` (Europe). If you are calling the `speech.googleapis.com` - // endpoint, use the `global` location. To specify a region, use a - // [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - // with matching `us` or `eu` location value. - CustomClass custom_class = 1 [(google.api.field_behavior) = REQUIRED]; - - // The list of fields to be updated. - google.protobuf.FieldMask update_mask = 2; -} - -// Message sent by the client for the `GetCustomClass` method. -message GetCustomClassRequest { - // Required. The name of the custom class to retrieve. Format: - // - // `projects/{project}/locations/{location}/customClasses/{custom_class}` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "speech.googleapis.com/CustomClass" - } - ]; -} - -// Message sent by the client for the `ListCustomClasses` method. -message ListCustomClassesRequest { - // Required. The parent, which owns this collection of custom classes. Format: - // - // `projects/{project}/locations/{location}/customClasses` - // - // Speech-to-Text supports three locations: `global`, `us` (US North America), - // and `eu` (Europe). If you are calling the `speech.googleapis.com` - // endpoint, use the `global` location. To specify a region, use a - // [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - // with matching `us` or `eu` location value. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "speech.googleapis.com/CustomClass" - } - ]; - - // 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. - int32 page_size = 2; - - // 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. - string page_token = 3; -} - -// Message returned to the client by the `ListCustomClasses` method. -message ListCustomClassesResponse { - // The custom classes. - repeated CustomClass custom_classes = 1; - - // A token, which can be sent as `page_token` to retrieve the next page. - // If this field is omitted, there are no subsequent pages. - string next_page_token = 2; -} - -// Message sent by the client for the `DeleteCustomClass` method. -message DeleteCustomClassRequest { - // Required. The name of the custom class to delete. Format: - // - // `projects/{project}/locations/{location}/customClasses/{custom_class}` - // - // Speech-to-Text supports three locations: `global`, `us` (US North America), - // and `eu` (Europe). If you are calling the `speech.googleapis.com` - // endpoint, use the `global` location. To specify a region, use a - // [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - // with matching `us` or `eu` location value. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "speech.googleapis.com/CustomClass" - } - ]; -} diff --git a/owl-bot-staging/v1/protos/google/cloud/speech/v1/resource.proto b/owl-bot-staging/v1/protos/google/cloud/speech/v1/resource.proto deleted file mode 100644 index 0ae5caa9..00000000 --- a/owl-bot-staging/v1/protos/google/cloud/speech/v1/resource.proto +++ /dev/null @@ -1,138 +0,0 @@ -// Copyright 2022 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 -// -// http://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. - -syntax = "proto3"; - -package google.cloud.speech.v1; - -import "google/api/resource.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/speech/v1;speech"; -option java_multiple_files = true; -option java_outer_classname = "SpeechResourceProto"; -option java_package = "com.google.cloud.speech.v1"; -option objc_class_prefix = "GCS"; - -// A set of words or phrases that represents a common concept likely to appear -// in your audio, for example a list of passenger ship names. CustomClass items -// can be substituted into placeholders that you set in PhraseSet phrases. -message CustomClass { - option (google.api.resource) = { - type: "speech.googleapis.com/CustomClass" - pattern: "projects/{project}/locations/{location}/customClasses/{custom_class}" - }; - - // An item of the class. - message ClassItem { - // The class item's value. - string value = 1; - } - - // The resource name of the custom class. - string name = 1; - - // If this custom class is a resource, the custom_class_id is the resource id - // of the CustomClass. Case sensitive. - string custom_class_id = 2; - - // A collection of class items. - repeated ClassItem items = 3; -} - -// Provides "hints" to the speech recognizer to favor specific words and phrases -// in the results. -message PhraseSet { - option (google.api.resource) = { - type: "speech.googleapis.com/PhraseSet" - pattern: "projects/{project}/locations/{location}/phraseSets/{phrase_set}" - }; - - // A phrases containing words and phrase "hints" so that - // the speech recognition is more likely to recognize them. This can be used - // to improve the accuracy for specific words and phrases, for example, if - // specific commands are typically spoken by the user. This can also be used - // to add additional words to the vocabulary of the recognizer. See - // [usage limits](https://cloud.google.com/speech-to-text/quotas#content). - // - // List items can also include pre-built or custom classes containing groups - // of words that represent common concepts that occur in natural language. For - // example, rather than providing a phrase hint for every month of the - // year (e.g. "i was born in january", "i was born in febuary", ...), use the - // pre-built `$MONTH` class improves the likelihood of correctly transcribing - // audio that includes months (e.g. "i was born in $month"). - // To refer to pre-built classes, use the class' symbol prepended with `$` - // e.g. `$MONTH`. To refer to custom classes that were defined inline in the - // request, set the class's `custom_class_id` to a string unique to all class - // resources and inline classes. Then use the class' id wrapped in $`{...}` - // e.g. "${my-months}". To refer to custom classes resources, use the class' - // id wrapped in `${}` (e.g. `${my-months}`). - // - // Speech-to-Text supports three locations: `global`, `us` (US North America), - // and `eu` (Europe). If you are calling the `speech.googleapis.com` - // endpoint, use the `global` location. To specify a region, use a - // [regional endpoint](/speech-to-text/docs/endpoints) with matching `us` or - // `eu` location value. - message Phrase { - // The phrase itself. - string value = 1; - - // Hint Boost. Overrides the boost set at the phrase set level. - // Positive value will increase the probability that a specific phrase will - // be recognized over other similar sounding phrases. The higher the boost, - // the higher the chance of false positive recognition as well. Negative - // boost will simply be ignored. Though `boost` can accept a wide range of - // positive values, most use cases are best served - // with values between 0 and 20. We recommend using a binary search approach - // to finding the optimal value for your use case. Speech recognition - // will skip PhraseSets with a boost value of 0. - float boost = 2; - } - - // The resource name of the phrase set. - string name = 1; - - // A list of word and phrases. - repeated Phrase phrases = 2; - - // Hint Boost. Positive value will increase the probability that a specific - // phrase will be recognized over other similar sounding phrases. The higher - // the boost, the higher the chance of false positive recognition as well. - // Negative boost values would correspond to anti-biasing. Anti-biasing is not - // enabled, so negative boost will simply be ignored. Though `boost` can - // accept a wide range of positive values, most use cases are best served with - // values between 0 (exclusive) and 20. We recommend using a binary search - // approach to finding the optimal value for your use case. Speech recognition - // will skip PhraseSets with a boost value of 0. - float boost = 4; -} - -// Speech adaptation configuration. -message SpeechAdaptation { - // A collection of phrase sets. To specify the hints inline, leave the - // phrase set's `name` blank and fill in the rest of its fields. Any - // phrase set can use any custom class. - repeated PhraseSet phrase_sets = 1; - - // A collection of phrase set resource names to use. - repeated string phrase_set_references = 2 [(google.api.resource_reference) = { - type: "speech.googleapis.com/PhraseSet" - }]; - - // A collection of custom classes. To specify the classes inline, leave the - // class' `name` blank and fill in the rest of its fields, giving it a unique - // `custom_class_id`. Refer to the inline defined class in phrase hints by its - // `custom_class_id`. - repeated CustomClass custom_classes = 3; -} diff --git a/owl-bot-staging/v1/samples/generated/v1/adaptation.create_custom_class.js b/owl-bot-staging/v1/samples/generated/v1/adaptation.create_custom_class.js deleted file mode 100644 index ebc4d9be..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/adaptation.create_custom_class.js +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2022 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. ** - - - -'use strict'; - -function main(parent, customClassId, customClass) { - // [START speech_v1_generated_Adaptation_CreateCustomClass_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent resource where this custom class will be created. Format: - * `projects/{project}/locations/{location}/customClasses` - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * regional endpoint (https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - */ - // const parent = 'abc123' - /** - * Required. The ID to use for the custom class, which will become the final - * component of the custom class' resource name. - * This value should restrict to letters, numbers, and hyphens, with the first - * character a letter, the last a letter or a number, and be 4-63 characters. - */ - // const customClassId = 'abc123' - /** - * Required. The custom class to create. - */ - // const customClass = {} - - // Imports the Speech library - const {AdaptationClient} = require('@google-cloud/speech').v1; - - // Instantiates a client - const speechClient = new AdaptationClient(); - - async function callCreateCustomClass() { - // Construct request - const request = { - parent, - customClassId, - customClass, - }; - - // Run request - const response = await speechClient.createCustomClass(request); - console.log(response); - } - - callCreateCustomClass(); - // [END speech_v1_generated_Adaptation_CreateCustomClass_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/adaptation.create_phrase_set.js b/owl-bot-staging/v1/samples/generated/v1/adaptation.create_phrase_set.js deleted file mode 100644 index 7aedc67a..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/adaptation.create_phrase_set.js +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2022 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. ** - - - -'use strict'; - -function main(parent, phraseSetId, phraseSet) { - // [START speech_v1_generated_Adaptation_CreatePhraseSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent resource where this phrase set will be created. Format: - * `projects/{project}/locations/{location}/phraseSets` - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * regional endpoint (https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - */ - // const parent = 'abc123' - /** - * Required. The ID to use for the phrase set, which will become the final - * component of the phrase set's resource name. - * This value should restrict to letters, numbers, and hyphens, with the first - * character a letter, the last a letter or a number, and be 4-63 characters. - */ - // const phraseSetId = 'abc123' - /** - * Required. The phrase set to create. - */ - // const phraseSet = {} - - // Imports the Speech library - const {AdaptationClient} = require('@google-cloud/speech').v1; - - // Instantiates a client - const speechClient = new AdaptationClient(); - - async function callCreatePhraseSet() { - // Construct request - const request = { - parent, - phraseSetId, - phraseSet, - }; - - // Run request - const response = await speechClient.createPhraseSet(request); - console.log(response); - } - - callCreatePhraseSet(); - // [END speech_v1_generated_Adaptation_CreatePhraseSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/adaptation.delete_custom_class.js b/owl-bot-staging/v1/samples/generated/v1/adaptation.delete_custom_class.js deleted file mode 100644 index 09105820..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/adaptation.delete_custom_class.js +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2022 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. ** - - - -'use strict'; - -function main(name) { - // [START speech_v1_generated_Adaptation_DeleteCustomClass_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The name of the custom class to delete. Format: - * `projects/{project}/locations/{location}/customClasses/{custom_class}` - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * regional endpoint (https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - */ - // const name = 'abc123' - - // Imports the Speech library - const {AdaptationClient} = require('@google-cloud/speech').v1; - - // Instantiates a client - const speechClient = new AdaptationClient(); - - async function callDeleteCustomClass() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await speechClient.deleteCustomClass(request); - console.log(response); - } - - callDeleteCustomClass(); - // [END speech_v1_generated_Adaptation_DeleteCustomClass_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/adaptation.delete_phrase_set.js b/owl-bot-staging/v1/samples/generated/v1/adaptation.delete_phrase_set.js deleted file mode 100644 index 18e7f7ff..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/adaptation.delete_phrase_set.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2022 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. ** - - - -'use strict'; - -function main(name) { - // [START speech_v1_generated_Adaptation_DeletePhraseSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The name of the phrase set to delete. Format: - * `projects/{project}/locations/{location}/phraseSets/{phrase_set}` - */ - // const name = 'abc123' - - // Imports the Speech library - const {AdaptationClient} = require('@google-cloud/speech').v1; - - // Instantiates a client - const speechClient = new AdaptationClient(); - - async function callDeletePhraseSet() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await speechClient.deletePhraseSet(request); - console.log(response); - } - - callDeletePhraseSet(); - // [END speech_v1_generated_Adaptation_DeletePhraseSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/adaptation.get_custom_class.js b/owl-bot-staging/v1/samples/generated/v1/adaptation.get_custom_class.js deleted file mode 100644 index 40cffe02..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/adaptation.get_custom_class.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2022 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. ** - - - -'use strict'; - -function main(name) { - // [START speech_v1_generated_Adaptation_GetCustomClass_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The name of the custom class to retrieve. Format: - * `projects/{project}/locations/{location}/customClasses/{custom_class}` - */ - // const name = 'abc123' - - // Imports the Speech library - const {AdaptationClient} = require('@google-cloud/speech').v1; - - // Instantiates a client - const speechClient = new AdaptationClient(); - - async function callGetCustomClass() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await speechClient.getCustomClass(request); - console.log(response); - } - - callGetCustomClass(); - // [END speech_v1_generated_Adaptation_GetCustomClass_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/adaptation.get_phrase_set.js b/owl-bot-staging/v1/samples/generated/v1/adaptation.get_phrase_set.js deleted file mode 100644 index 65ccaa4b..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/adaptation.get_phrase_set.js +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2022 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. ** - - - -'use strict'; - -function main(name) { - // [START speech_v1_generated_Adaptation_GetPhraseSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The name of the phrase set to retrieve. Format: - * `projects/{project}/locations/{location}/phraseSets/{phrase_set}` - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * regional endpoint (https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - */ - // const name = 'abc123' - - // Imports the Speech library - const {AdaptationClient} = require('@google-cloud/speech').v1; - - // Instantiates a client - const speechClient = new AdaptationClient(); - - async function callGetPhraseSet() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await speechClient.getPhraseSet(request); - console.log(response); - } - - callGetPhraseSet(); - // [END speech_v1_generated_Adaptation_GetPhraseSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/adaptation.list_custom_classes.js b/owl-bot-staging/v1/samples/generated/v1/adaptation.list_custom_classes.js deleted file mode 100644 index bb2692b8..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/adaptation.list_custom_classes.js +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2022 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. ** - - - -'use strict'; - -function main(parent) { - // [START speech_v1_generated_Adaptation_ListCustomClasses_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent, which owns this collection of custom classes. Format: - * `projects/{project}/locations/{location}/customClasses` - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * regional endpoint (https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - */ - // const parent = 'abc123' - /** - * 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. - */ - // const pageSize = 1234 - /** - * 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. - */ - // const pageToken = 'abc123' - - // Imports the Speech library - const {AdaptationClient} = require('@google-cloud/speech').v1; - - // Instantiates a client - const speechClient = new AdaptationClient(); - - async function callListCustomClasses() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await speechClient.listCustomClassesAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListCustomClasses(); - // [END speech_v1_generated_Adaptation_ListCustomClasses_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/adaptation.list_phrase_set.js b/owl-bot-staging/v1/samples/generated/v1/adaptation.list_phrase_set.js deleted file mode 100644 index 14f715d8..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/adaptation.list_phrase_set.js +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2022 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. ** - - - -'use strict'; - -function main(parent) { - // [START speech_v1_generated_Adaptation_ListPhraseSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent, which owns this collection of phrase set. Format: - * `projects/{project}/locations/{location}` - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * regional endpoint (https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - */ - // const parent = 'abc123' - /** - * 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. - */ - // const pageSize = 1234 - /** - * 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. - */ - // const pageToken = 'abc123' - - // Imports the Speech library - const {AdaptationClient} = require('@google-cloud/speech').v1; - - // Instantiates a client - const speechClient = new AdaptationClient(); - - async function callListPhraseSet() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await speechClient.listPhraseSetAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListPhraseSet(); - // [END speech_v1_generated_Adaptation_ListPhraseSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/adaptation.update_custom_class.js b/owl-bot-staging/v1/samples/generated/v1/adaptation.update_custom_class.js deleted file mode 100644 index a5b6946e..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/adaptation.update_custom_class.js +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2022 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. ** - - - -'use strict'; - -function main(customClass) { - // [START speech_v1_generated_Adaptation_UpdateCustomClass_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The custom class to update. - * The custom class's `name` field is used to identify the custom class to be - * updated. Format: - * `projects/{project}/locations/{location}/customClasses/{custom_class}` - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * regional endpoint (https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - */ - // const customClass = {} - /** - * The list of fields to be updated. - */ - // const updateMask = {} - - // Imports the Speech library - const {AdaptationClient} = require('@google-cloud/speech').v1; - - // Instantiates a client - const speechClient = new AdaptationClient(); - - async function callUpdateCustomClass() { - // Construct request - const request = { - customClass, - }; - - // Run request - const response = await speechClient.updateCustomClass(request); - console.log(response); - } - - callUpdateCustomClass(); - // [END speech_v1_generated_Adaptation_UpdateCustomClass_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/adaptation.update_phrase_set.js b/owl-bot-staging/v1/samples/generated/v1/adaptation.update_phrase_set.js deleted file mode 100644 index 076453a9..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/adaptation.update_phrase_set.js +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2022 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. ** - - - -'use strict'; - -function main(phraseSet) { - // [START speech_v1_generated_Adaptation_UpdatePhraseSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The phrase set to update. - * The phrase set's `name` field is used to identify the set to be - * updated. Format: - * `projects/{project}/locations/{location}/phraseSets/{phrase_set}` - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * regional endpoint (https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - */ - // const phraseSet = {} - /** - * The list of fields to be updated. - */ - // const updateMask = {} - - // Imports the Speech library - const {AdaptationClient} = require('@google-cloud/speech').v1; - - // Instantiates a client - const speechClient = new AdaptationClient(); - - async function callUpdatePhraseSet() { - // Construct request - const request = { - phraseSet, - }; - - // Run request - const response = await speechClient.updatePhraseSet(request); - console.log(response); - } - - callUpdatePhraseSet(); - // [END speech_v1_generated_Adaptation_UpdatePhraseSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.speech.v1.json b/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.speech.v1.json deleted file mode 100644 index 11747e69..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.speech.v1.json +++ /dev/null @@ -1,591 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-speech", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.speech.v1", - "version": "v1" - } - ] - }, - "snippets": [ - { - "regionTag": "speech_v1_generated_Adaptation_CreatePhraseSet_async", - "title": "Adaptation createPhraseSet Sample", - "origin": "API_DEFINITION", - "description": " 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.", - "canonical": true, - "file": "adaptation.create_phrase_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 72, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreatePhraseSet", - "fullName": "google.cloud.speech.v1.Adaptation.CreatePhraseSet", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "phrase_set_id", - "type": "TYPE_STRING" - }, - { - "name": "phrase_set", - "type": ".google.cloud.speech.v1.PhraseSet" - } - ], - "resultType": ".google.cloud.speech.v1.PhraseSet", - "client": { - "shortName": "AdaptationClient", - "fullName": "google.cloud.speech.v1.AdaptationClient" - }, - "method": { - "shortName": "CreatePhraseSet", - "fullName": "google.cloud.speech.v1.Adaptation.CreatePhraseSet", - "service": { - "shortName": "Adaptation", - "fullName": "google.cloud.speech.v1.Adaptation" - } - } - } - }, - { - "regionTag": "speech_v1_generated_Adaptation_GetPhraseSet_async", - "title": "Adaptation getPhraseSet Sample", - "origin": "API_DEFINITION", - "description": " Get a phrase set.", - "canonical": true, - "file": "adaptation.get_phrase_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetPhraseSet", - "fullName": "google.cloud.speech.v1.Adaptation.GetPhraseSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.speech.v1.PhraseSet", - "client": { - "shortName": "AdaptationClient", - "fullName": "google.cloud.speech.v1.AdaptationClient" - }, - "method": { - "shortName": "GetPhraseSet", - "fullName": "google.cloud.speech.v1.Adaptation.GetPhraseSet", - "service": { - "shortName": "Adaptation", - "fullName": "google.cloud.speech.v1.Adaptation" - } - } - } - }, - { - "regionTag": "speech_v1_generated_Adaptation_ListPhraseSet_async", - "title": "Adaptation listPhraseSet Sample", - "origin": "API_DEFINITION", - "description": " List phrase sets.", - "canonical": true, - "file": "adaptation.list_phrase_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 75, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListPhraseSet", - "fullName": "google.cloud.speech.v1.Adaptation.ListPhraseSet", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.speech.v1.ListPhraseSetResponse", - "client": { - "shortName": "AdaptationClient", - "fullName": "google.cloud.speech.v1.AdaptationClient" - }, - "method": { - "shortName": "ListPhraseSet", - "fullName": "google.cloud.speech.v1.Adaptation.ListPhraseSet", - "service": { - "shortName": "Adaptation", - "fullName": "google.cloud.speech.v1.Adaptation" - } - } - } - }, - { - "regionTag": "speech_v1_generated_Adaptation_UpdatePhraseSet_async", - "title": "Adaptation updatePhraseSet Sample", - "origin": "API_DEFINITION", - "description": " Update a phrase set.", - "canonical": true, - "file": "adaptation.update_phrase_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdatePhraseSet", - "fullName": "google.cloud.speech.v1.Adaptation.UpdatePhraseSet", - "async": true, - "parameters": [ - { - "name": "phrase_set", - "type": ".google.cloud.speech.v1.PhraseSet" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.speech.v1.PhraseSet", - "client": { - "shortName": "AdaptationClient", - "fullName": "google.cloud.speech.v1.AdaptationClient" - }, - "method": { - "shortName": "UpdatePhraseSet", - "fullName": "google.cloud.speech.v1.Adaptation.UpdatePhraseSet", - "service": { - "shortName": "Adaptation", - "fullName": "google.cloud.speech.v1.Adaptation" - } - } - } - }, - { - "regionTag": "speech_v1_generated_Adaptation_DeletePhraseSet_async", - "title": "Adaptation deletePhraseSet Sample", - "origin": "API_DEFINITION", - "description": " Delete a phrase set.", - "canonical": true, - "file": "adaptation.delete_phrase_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeletePhraseSet", - "fullName": "google.cloud.speech.v1.Adaptation.DeletePhraseSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "AdaptationClient", - "fullName": "google.cloud.speech.v1.AdaptationClient" - }, - "method": { - "shortName": "DeletePhraseSet", - "fullName": "google.cloud.speech.v1.Adaptation.DeletePhraseSet", - "service": { - "shortName": "Adaptation", - "fullName": "google.cloud.speech.v1.Adaptation" - } - } - } - }, - { - "regionTag": "speech_v1_generated_Adaptation_CreateCustomClass_async", - "title": "Adaptation createCustomClass Sample", - "origin": "API_DEFINITION", - "description": " Create a custom class.", - "canonical": true, - "file": "adaptation.create_custom_class.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 72, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateCustomClass", - "fullName": "google.cloud.speech.v1.Adaptation.CreateCustomClass", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "custom_class_id", - "type": "TYPE_STRING" - }, - { - "name": "custom_class", - "type": ".google.cloud.speech.v1.CustomClass" - } - ], - "resultType": ".google.cloud.speech.v1.CustomClass", - "client": { - "shortName": "AdaptationClient", - "fullName": "google.cloud.speech.v1.AdaptationClient" - }, - "method": { - "shortName": "CreateCustomClass", - "fullName": "google.cloud.speech.v1.Adaptation.CreateCustomClass", - "service": { - "shortName": "Adaptation", - "fullName": "google.cloud.speech.v1.Adaptation" - } - } - } - }, - { - "regionTag": "speech_v1_generated_Adaptation_GetCustomClass_async", - "title": "Adaptation getCustomClass Sample", - "origin": "API_DEFINITION", - "description": " Get a custom class.", - "canonical": true, - "file": "adaptation.get_custom_class.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetCustomClass", - "fullName": "google.cloud.speech.v1.Adaptation.GetCustomClass", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.speech.v1.CustomClass", - "client": { - "shortName": "AdaptationClient", - "fullName": "google.cloud.speech.v1.AdaptationClient" - }, - "method": { - "shortName": "GetCustomClass", - "fullName": "google.cloud.speech.v1.Adaptation.GetCustomClass", - "service": { - "shortName": "Adaptation", - "fullName": "google.cloud.speech.v1.Adaptation" - } - } - } - }, - { - "regionTag": "speech_v1_generated_Adaptation_ListCustomClasses_async", - "title": "Adaptation listCustomClasses Sample", - "origin": "API_DEFINITION", - "description": " List custom classes.", - "canonical": true, - "file": "adaptation.list_custom_classes.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 75, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListCustomClasses", - "fullName": "google.cloud.speech.v1.Adaptation.ListCustomClasses", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.speech.v1.ListCustomClassesResponse", - "client": { - "shortName": "AdaptationClient", - "fullName": "google.cloud.speech.v1.AdaptationClient" - }, - "method": { - "shortName": "ListCustomClasses", - "fullName": "google.cloud.speech.v1.Adaptation.ListCustomClasses", - "service": { - "shortName": "Adaptation", - "fullName": "google.cloud.speech.v1.Adaptation" - } - } - } - }, - { - "regionTag": "speech_v1_generated_Adaptation_UpdateCustomClass_async", - "title": "Adaptation updateCustomClass Sample", - "origin": "API_DEFINITION", - "description": " Update a custom class.", - "canonical": true, - "file": "adaptation.update_custom_class.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateCustomClass", - "fullName": "google.cloud.speech.v1.Adaptation.UpdateCustomClass", - "async": true, - "parameters": [ - { - "name": "custom_class", - "type": ".google.cloud.speech.v1.CustomClass" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.speech.v1.CustomClass", - "client": { - "shortName": "AdaptationClient", - "fullName": "google.cloud.speech.v1.AdaptationClient" - }, - "method": { - "shortName": "UpdateCustomClass", - "fullName": "google.cloud.speech.v1.Adaptation.UpdateCustomClass", - "service": { - "shortName": "Adaptation", - "fullName": "google.cloud.speech.v1.Adaptation" - } - } - } - }, - { - "regionTag": "speech_v1_generated_Adaptation_DeleteCustomClass_async", - "title": "Adaptation deleteCustomClass Sample", - "origin": "API_DEFINITION", - "description": " Delete a custom class.", - "canonical": true, - "file": "adaptation.delete_custom_class.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteCustomClass", - "fullName": "google.cloud.speech.v1.Adaptation.DeleteCustomClass", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "AdaptationClient", - "fullName": "google.cloud.speech.v1.AdaptationClient" - }, - "method": { - "shortName": "DeleteCustomClass", - "fullName": "google.cloud.speech.v1.Adaptation.DeleteCustomClass", - "service": { - "shortName": "Adaptation", - "fullName": "google.cloud.speech.v1.Adaptation" - } - } - } - }, - { - "regionTag": "speech_v1_generated_Speech_Recognize_async", - "title": "Adaptation recognize Sample", - "origin": "API_DEFINITION", - "description": " Performs synchronous speech recognition: receive results after all audio has been sent and processed.", - "canonical": true, - "file": "speech.recognize.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "Recognize", - "fullName": "google.cloud.speech.v1.Speech.Recognize", - "async": true, - "parameters": [ - { - "name": "config", - "type": ".google.cloud.speech.v1.RecognitionConfig" - }, - { - "name": "audio", - "type": ".google.cloud.speech.v1.RecognitionAudio" - } - ], - "resultType": ".google.cloud.speech.v1.RecognizeResponse", - "client": { - "shortName": "SpeechClient", - "fullName": "google.cloud.speech.v1.SpeechClient" - }, - "method": { - "shortName": "Recognize", - "fullName": "google.cloud.speech.v1.Speech.Recognize", - "service": { - "shortName": "Speech", - "fullName": "google.cloud.speech.v1.Speech" - } - } - } - }, - { - "regionTag": "speech_v1_generated_Speech_LongRunningRecognize_async", - "title": "Adaptation longRunningRecognize Sample", - "origin": "API_DEFINITION", - "description": " Performs asynchronous speech recognition: receive results via the google.longrunning.Operations interface. Returns either an `Operation.error` or an `Operation.response` which contains a `LongRunningRecognizeResponse` message. For more information on asynchronous speech recognition, see the [how-to](https://cloud.google.com/speech-to-text/docs/async-recognize).", - "canonical": true, - "file": "speech.long_running_recognize.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 64, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "LongRunningRecognize", - "fullName": "google.cloud.speech.v1.Speech.LongRunningRecognize", - "async": true, - "parameters": [ - { - "name": "config", - "type": ".google.cloud.speech.v1.RecognitionConfig" - }, - { - "name": "audio", - "type": ".google.cloud.speech.v1.RecognitionAudio" - }, - { - "name": "output_config", - "type": ".google.cloud.speech.v1.TranscriptOutputConfig" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "SpeechClient", - "fullName": "google.cloud.speech.v1.SpeechClient" - }, - "method": { - "shortName": "LongRunningRecognize", - "fullName": "google.cloud.speech.v1.Speech.LongRunningRecognize", - "service": { - "shortName": "Speech", - "fullName": "google.cloud.speech.v1.Speech" - } - } - } - }, - { - "regionTag": "speech_v1_generated_Speech_StreamingRecognize_async", - "title": "Adaptation streamingRecognize Sample", - "origin": "API_DEFINITION", - "description": " Performs bidirectional streaming speech recognition: receive results while sending audio. This method is only available via the gRPC API (not REST).", - "canonical": true, - "file": "speech.streaming_recognize.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 69, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "StreamingRecognize", - "fullName": "google.cloud.speech.v1.Speech.StreamingRecognize", - "async": true, - "parameters": [ - { - "name": "streaming_config", - "type": ".google.cloud.speech.v1.StreamingRecognitionConfig" - }, - { - "name": "audio_content", - "type": "TYPE_BYTES" - } - ], - "resultType": ".google.cloud.speech.v1.StreamingRecognizeResponse", - "client": { - "shortName": "SpeechClient", - "fullName": "google.cloud.speech.v1.SpeechClient" - }, - "method": { - "shortName": "StreamingRecognize", - "fullName": "google.cloud.speech.v1.Speech.StreamingRecognize", - "service": { - "shortName": "Speech", - "fullName": "google.cloud.speech.v1.Speech" - } - } - } - } - ] -} diff --git a/owl-bot-staging/v1/samples/generated/v1/speech.long_running_recognize.js b/owl-bot-staging/v1/samples/generated/v1/speech.long_running_recognize.js deleted file mode 100644 index 0400a955..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/speech.long_running_recognize.js +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright 2022 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. ** - - - -'use strict'; - -function main(config, audio) { - // [START speech_v1_generated_Speech_LongRunningRecognize_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Provides information to the recognizer that specifies how to - * process the request. - */ - // const config = {} - /** - * Required. The audio data to be recognized. - */ - // const audio = {} - /** - * Optional. Specifies an optional destination for the recognition results. - */ - // const outputConfig = {} - - // Imports the Speech library - const {SpeechClient} = require('@google-cloud/speech').v1; - - // Instantiates a client - const speechClient = new SpeechClient(); - - async function callLongRunningRecognize() { - // Construct request - const request = { - config, - audio, - }; - - // Run request - const [operation] = await speechClient.longRunningRecognize(request); - const [response] = await operation.promise(); - console.log(response); - } - - callLongRunningRecognize(); - // [END speech_v1_generated_Speech_LongRunningRecognize_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/speech.recognize.js b/owl-bot-staging/v1/samples/generated/v1/speech.recognize.js deleted file mode 100644 index 4d3d67cd..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/speech.recognize.js +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2022 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. ** - - - -'use strict'; - -function main(config, audio) { - // [START speech_v1_generated_Speech_Recognize_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Provides information to the recognizer that specifies how to - * process the request. - */ - // const config = {} - /** - * Required. The audio data to be recognized. - */ - // const audio = {} - - // Imports the Speech library - const {SpeechClient} = require('@google-cloud/speech').v1; - - // Instantiates a client - const speechClient = new SpeechClient(); - - async function callRecognize() { - // Construct request - const request = { - config, - audio, - }; - - // Run request - const response = await speechClient.recognize(request); - console.log(response); - } - - callRecognize(); - // [END speech_v1_generated_Speech_Recognize_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/speech.streaming_recognize.js b/owl-bot-staging/v1/samples/generated/v1/speech.streaming_recognize.js deleted file mode 100644 index 39205be9..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/speech.streaming_recognize.js +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2022 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. ** - - - -'use strict'; - -function main() { - // [START speech_v1_generated_Speech_StreamingRecognize_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Provides information to the recognizer that specifies how to process the - * request. The first `StreamingRecognizeRequest` message must contain a - * `streaming_config` message. - */ - // const streamingConfig = {} - /** - * The audio data to be recognized. Sequential chunks of audio data are sent - * in sequential `StreamingRecognizeRequest` messages. The first - * `StreamingRecognizeRequest` message must not contain `audio_content` data - * and all subsequent `StreamingRecognizeRequest` messages must contain - * `audio_content` data. The audio bytes must be encoded as specified in - * `RecognitionConfig`. Note: as with all bytes fields, proto buffers use a - * pure binary representation (not base64). See - * content limits (https://cloud.google.com/speech-to-text/quotas#content). - */ - // const audioContent = 'Buffer.from('string')' - - // Imports the Speech library - const {SpeechClient} = require('@google-cloud/speech').v1; - - // Instantiates a client - const speechClient = new SpeechClient(); - - async function callStreamingRecognize() { - // Construct request - const request = { - }; - - // Run request - const stream = await speechClient.streamingRecognize(); - stream.on('data', (response) => { console.log(response) }); - stream.on('error', (err) => { throw(err) }); - stream.on('end', () => { /* API call completed */ }); - stream.write(request); - stream.end(); - } - - callStreamingRecognize(); - // [END speech_v1_generated_Speech_StreamingRecognize_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/src/index.ts b/owl-bot-staging/v1/src/index.ts deleted file mode 100644 index 5ea8dd11..00000000 --- a/owl-bot-staging/v1/src/index.ts +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2022 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. ** - -import * as v1 from './v1'; -const AdaptationClient = v1.AdaptationClient; -type AdaptationClient = v1.AdaptationClient; -const SpeechClient = v1.SpeechClient; -type SpeechClient = v1.SpeechClient; -export {v1, AdaptationClient, SpeechClient}; -export default {v1, AdaptationClient, SpeechClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/v1/src/v1/adaptation_client.ts b/owl-bot-staging/v1/src/v1/adaptation_client.ts deleted file mode 100644 index f7f3f0aa..00000000 --- a/owl-bot-staging/v1/src/v1/adaptation_client.ts +++ /dev/null @@ -1,1578 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1/adaptation_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './adaptation_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Service that implements Google Cloud Speech Adaptation API. - * @class - * @memberof v1 - */ -export class AdaptationClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - adaptationStub?: Promise<{[name: string]: Function}>; - - /** - * 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/main/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 | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new AdaptationClient({fallback: 'rest'}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof AdaptationClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // 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.v1.Adaptation', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = this._gaxModule.warn; - } - - /** - * 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.v1.Adaptation. - this.adaptationStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.speech.v1.Adaptation') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.speech.v1.Adaptation, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // 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: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.page[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor, - this._opts.fallback - ); - - 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' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * 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: - * - * `projects/{project}/locations/{location}/phraseSets` - * - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - * @param {string} request.phraseSetId - * Required. The ID to use for the phrase set, which will become the final - * component of the phrase set's resource name. - * - * This value should restrict to letters, numbers, and hyphens, with the first - * character a letter, the last a letter or a number, and be 4-63 characters. - * @param {google.cloud.speech.v1.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.v1.PhraseSet}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/adaptation.create_phrase_set.js - * region_tag:speech_v1_generated_Adaptation_CreatePhraseSet_async - */ - createPhraseSet( - request?: protos.google.cloud.speech.v1.ICreatePhraseSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.speech.v1.IPhraseSet, - protos.google.cloud.speech.v1.ICreatePhraseSetRequest|undefined, {}|undefined - ]>; - createPhraseSet( - request: protos.google.cloud.speech.v1.ICreatePhraseSetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.speech.v1.IPhraseSet, - protos.google.cloud.speech.v1.ICreatePhraseSetRequest|null|undefined, - {}|null|undefined>): void; - createPhraseSet( - request: protos.google.cloud.speech.v1.ICreatePhraseSetRequest, - callback: Callback< - protos.google.cloud.speech.v1.IPhraseSet, - protos.google.cloud.speech.v1.ICreatePhraseSetRequest|null|undefined, - {}|null|undefined>): void; - createPhraseSet( - request?: protos.google.cloud.speech.v1.ICreatePhraseSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.speech.v1.IPhraseSet, - protos.google.cloud.speech.v1.ICreatePhraseSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.speech.v1.IPhraseSet, - protos.google.cloud.speech.v1.ICreatePhraseSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.speech.v1.IPhraseSet, - protos.google.cloud.speech.v1.ICreatePhraseSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.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: - * - * `projects/{project}/locations/{location}/phraseSets/{phrase_set}` - * - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - * @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.v1.PhraseSet}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/adaptation.get_phrase_set.js - * region_tag:speech_v1_generated_Adaptation_GetPhraseSet_async - */ - getPhraseSet( - request?: protos.google.cloud.speech.v1.IGetPhraseSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.speech.v1.IPhraseSet, - protos.google.cloud.speech.v1.IGetPhraseSetRequest|undefined, {}|undefined - ]>; - getPhraseSet( - request: protos.google.cloud.speech.v1.IGetPhraseSetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.speech.v1.IPhraseSet, - protos.google.cloud.speech.v1.IGetPhraseSetRequest|null|undefined, - {}|null|undefined>): void; - getPhraseSet( - request: protos.google.cloud.speech.v1.IGetPhraseSetRequest, - callback: Callback< - protos.google.cloud.speech.v1.IPhraseSet, - protos.google.cloud.speech.v1.IGetPhraseSetRequest|null|undefined, - {}|null|undefined>): void; - getPhraseSet( - request?: protos.google.cloud.speech.v1.IGetPhraseSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.speech.v1.IPhraseSet, - protos.google.cloud.speech.v1.IGetPhraseSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.speech.v1.IPhraseSet, - protos.google.cloud.speech.v1.IGetPhraseSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.speech.v1.IPhraseSet, - protos.google.cloud.speech.v1.IGetPhraseSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.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.v1.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: - * - * `projects/{project}/locations/{location}/phraseSets/{phrase_set}` - * - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - * @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.v1.PhraseSet}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/adaptation.update_phrase_set.js - * region_tag:speech_v1_generated_Adaptation_UpdatePhraseSet_async - */ - updatePhraseSet( - request?: protos.google.cloud.speech.v1.IUpdatePhraseSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.speech.v1.IPhraseSet, - protos.google.cloud.speech.v1.IUpdatePhraseSetRequest|undefined, {}|undefined - ]>; - updatePhraseSet( - request: protos.google.cloud.speech.v1.IUpdatePhraseSetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.speech.v1.IPhraseSet, - protos.google.cloud.speech.v1.IUpdatePhraseSetRequest|null|undefined, - {}|null|undefined>): void; - updatePhraseSet( - request: protos.google.cloud.speech.v1.IUpdatePhraseSetRequest, - callback: Callback< - protos.google.cloud.speech.v1.IPhraseSet, - protos.google.cloud.speech.v1.IUpdatePhraseSetRequest|null|undefined, - {}|null|undefined>): void; - updatePhraseSet( - request?: protos.google.cloud.speech.v1.IUpdatePhraseSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.speech.v1.IPhraseSet, - protos.google.cloud.speech.v1.IUpdatePhraseSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.speech.v1.IPhraseSet, - protos.google.cloud.speech.v1.IUpdatePhraseSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.speech.v1.IPhraseSet, - protos.google.cloud.speech.v1.IUpdatePhraseSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.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: - * - * `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 include:samples/generated/v1/adaptation.delete_phrase_set.js - * region_tag:speech_v1_generated_Adaptation_DeletePhraseSet_async - */ - deletePhraseSet( - request?: protos.google.cloud.speech.v1.IDeletePhraseSetRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.speech.v1.IDeletePhraseSetRequest|undefined, {}|undefined - ]>; - deletePhraseSet( - request: protos.google.cloud.speech.v1.IDeletePhraseSetRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.speech.v1.IDeletePhraseSetRequest|null|undefined, - {}|null|undefined>): void; - deletePhraseSet( - request: protos.google.cloud.speech.v1.IDeletePhraseSetRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.speech.v1.IDeletePhraseSetRequest|null|undefined, - {}|null|undefined>): void; - deletePhraseSet( - request?: protos.google.cloud.speech.v1.IDeletePhraseSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.speech.v1.IDeletePhraseSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.speech.v1.IDeletePhraseSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.speech.v1.IDeletePhraseSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.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: - * - * `projects/{project}/locations/{location}/customClasses` - * - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - * @param {string} request.customClassId - * Required. The ID to use for the custom class, which will become the final - * component of the custom class' resource name. - * - * This value should restrict to letters, numbers, and hyphens, with the first - * character a letter, the last a letter or a number, and be 4-63 characters. - * @param {google.cloud.speech.v1.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.v1.CustomClass}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/adaptation.create_custom_class.js - * region_tag:speech_v1_generated_Adaptation_CreateCustomClass_async - */ - createCustomClass( - request?: protos.google.cloud.speech.v1.ICreateCustomClassRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.speech.v1.ICustomClass, - protos.google.cloud.speech.v1.ICreateCustomClassRequest|undefined, {}|undefined - ]>; - createCustomClass( - request: protos.google.cloud.speech.v1.ICreateCustomClassRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.speech.v1.ICustomClass, - protos.google.cloud.speech.v1.ICreateCustomClassRequest|null|undefined, - {}|null|undefined>): void; - createCustomClass( - request: protos.google.cloud.speech.v1.ICreateCustomClassRequest, - callback: Callback< - protos.google.cloud.speech.v1.ICustomClass, - protos.google.cloud.speech.v1.ICreateCustomClassRequest|null|undefined, - {}|null|undefined>): void; - createCustomClass( - request?: protos.google.cloud.speech.v1.ICreateCustomClassRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.speech.v1.ICustomClass, - protos.google.cloud.speech.v1.ICreateCustomClassRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.speech.v1.ICustomClass, - protos.google.cloud.speech.v1.ICreateCustomClassRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.speech.v1.ICustomClass, - protos.google.cloud.speech.v1.ICreateCustomClassRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.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: - * - * `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.v1.CustomClass}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/adaptation.get_custom_class.js - * region_tag:speech_v1_generated_Adaptation_GetCustomClass_async - */ - getCustomClass( - request?: protos.google.cloud.speech.v1.IGetCustomClassRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.speech.v1.ICustomClass, - protos.google.cloud.speech.v1.IGetCustomClassRequest|undefined, {}|undefined - ]>; - getCustomClass( - request: protos.google.cloud.speech.v1.IGetCustomClassRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.speech.v1.ICustomClass, - protos.google.cloud.speech.v1.IGetCustomClassRequest|null|undefined, - {}|null|undefined>): void; - getCustomClass( - request: protos.google.cloud.speech.v1.IGetCustomClassRequest, - callback: Callback< - protos.google.cloud.speech.v1.ICustomClass, - protos.google.cloud.speech.v1.IGetCustomClassRequest|null|undefined, - {}|null|undefined>): void; - getCustomClass( - request?: protos.google.cloud.speech.v1.IGetCustomClassRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.speech.v1.ICustomClass, - protos.google.cloud.speech.v1.IGetCustomClassRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.speech.v1.ICustomClass, - protos.google.cloud.speech.v1.IGetCustomClassRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.speech.v1.ICustomClass, - protos.google.cloud.speech.v1.IGetCustomClassRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.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.v1.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: - * - * `projects/{project}/locations/{location}/customClasses/{custom_class}` - * - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - * @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.v1.CustomClass}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/adaptation.update_custom_class.js - * region_tag:speech_v1_generated_Adaptation_UpdateCustomClass_async - */ - updateCustomClass( - request?: protos.google.cloud.speech.v1.IUpdateCustomClassRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.speech.v1.ICustomClass, - protos.google.cloud.speech.v1.IUpdateCustomClassRequest|undefined, {}|undefined - ]>; - updateCustomClass( - request: protos.google.cloud.speech.v1.IUpdateCustomClassRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.speech.v1.ICustomClass, - protos.google.cloud.speech.v1.IUpdateCustomClassRequest|null|undefined, - {}|null|undefined>): void; - updateCustomClass( - request: protos.google.cloud.speech.v1.IUpdateCustomClassRequest, - callback: Callback< - protos.google.cloud.speech.v1.ICustomClass, - protos.google.cloud.speech.v1.IUpdateCustomClassRequest|null|undefined, - {}|null|undefined>): void; - updateCustomClass( - request?: protos.google.cloud.speech.v1.IUpdateCustomClassRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.speech.v1.ICustomClass, - protos.google.cloud.speech.v1.IUpdateCustomClassRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.speech.v1.ICustomClass, - protos.google.cloud.speech.v1.IUpdateCustomClassRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.speech.v1.ICustomClass, - protos.google.cloud.speech.v1.IUpdateCustomClassRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.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: - * - * `projects/{project}/locations/{location}/customClasses/{custom_class}` - * - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - * @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 include:samples/generated/v1/adaptation.delete_custom_class.js - * region_tag:speech_v1_generated_Adaptation_DeleteCustomClass_async - */ - deleteCustomClass( - request?: protos.google.cloud.speech.v1.IDeleteCustomClassRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.speech.v1.IDeleteCustomClassRequest|undefined, {}|undefined - ]>; - deleteCustomClass( - request: protos.google.cloud.speech.v1.IDeleteCustomClassRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.speech.v1.IDeleteCustomClassRequest|null|undefined, - {}|null|undefined>): void; - deleteCustomClass( - request: protos.google.cloud.speech.v1.IDeleteCustomClassRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.speech.v1.IDeleteCustomClassRequest|null|undefined, - {}|null|undefined>): void; - deleteCustomClass( - request?: protos.google.cloud.speech.v1.IDeleteCustomClassRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.speech.v1.IDeleteCustomClassRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.speech.v1.IDeleteCustomClassRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.speech.v1.IDeleteCustomClassRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.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}` - * - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - * @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.v1.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?: protos.google.cloud.speech.v1.IListPhraseSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.speech.v1.IPhraseSet[], - protos.google.cloud.speech.v1.IListPhraseSetRequest|null, - protos.google.cloud.speech.v1.IListPhraseSetResponse - ]>; - listPhraseSet( - request: protos.google.cloud.speech.v1.IListPhraseSetRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.speech.v1.IListPhraseSetRequest, - protos.google.cloud.speech.v1.IListPhraseSetResponse|null|undefined, - protos.google.cloud.speech.v1.IPhraseSet>): void; - listPhraseSet( - request: protos.google.cloud.speech.v1.IListPhraseSetRequest, - callback: PaginationCallback< - protos.google.cloud.speech.v1.IListPhraseSetRequest, - protos.google.cloud.speech.v1.IListPhraseSetResponse|null|undefined, - protos.google.cloud.speech.v1.IPhraseSet>): void; - listPhraseSet( - request?: protos.google.cloud.speech.v1.IListPhraseSetRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.speech.v1.IListPhraseSetRequest, - protos.google.cloud.speech.v1.IListPhraseSetResponse|null|undefined, - protos.google.cloud.speech.v1.IPhraseSet>, - callback?: PaginationCallback< - protos.google.cloud.speech.v1.IListPhraseSetRequest, - protos.google.cloud.speech.v1.IListPhraseSetResponse|null|undefined, - protos.google.cloud.speech.v1.IPhraseSet>): - Promise<[ - protos.google.cloud.speech.v1.IPhraseSet[], - protos.google.cloud.speech.v1.IListPhraseSetRequest|null, - protos.google.cloud.speech.v1.IListPhraseSetResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.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}` - * - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - * @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.v1.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?: protos.google.cloud.speech.v1.IListPhraseSetRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listPhraseSet']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listPhraseSet.createStream( - this.innerApiCalls.listPhraseSet as GaxCall, - 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}` - * - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - * @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.v1.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 include:samples/generated/v1/adaptation.list_phrase_set.js - * region_tag:speech_v1_generated_Adaptation_ListPhraseSet_async - */ - listPhraseSetAsync( - request?: protos.google.cloud.speech.v1.IListPhraseSetRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listPhraseSet']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listPhraseSet.asyncIterate( - this.innerApiCalls['listPhraseSet'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * 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: - * - * `projects/{project}/locations/{location}/customClasses` - * - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - * @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.v1.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?: protos.google.cloud.speech.v1.IListCustomClassesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.speech.v1.ICustomClass[], - protos.google.cloud.speech.v1.IListCustomClassesRequest|null, - protos.google.cloud.speech.v1.IListCustomClassesResponse - ]>; - listCustomClasses( - request: protos.google.cloud.speech.v1.IListCustomClassesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.speech.v1.IListCustomClassesRequest, - protos.google.cloud.speech.v1.IListCustomClassesResponse|null|undefined, - protos.google.cloud.speech.v1.ICustomClass>): void; - listCustomClasses( - request: protos.google.cloud.speech.v1.IListCustomClassesRequest, - callback: PaginationCallback< - protos.google.cloud.speech.v1.IListCustomClassesRequest, - protos.google.cloud.speech.v1.IListCustomClassesResponse|null|undefined, - protos.google.cloud.speech.v1.ICustomClass>): void; - listCustomClasses( - request?: protos.google.cloud.speech.v1.IListCustomClassesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.speech.v1.IListCustomClassesRequest, - protos.google.cloud.speech.v1.IListCustomClassesResponse|null|undefined, - protos.google.cloud.speech.v1.ICustomClass>, - callback?: PaginationCallback< - protos.google.cloud.speech.v1.IListCustomClassesRequest, - protos.google.cloud.speech.v1.IListCustomClassesResponse|null|undefined, - protos.google.cloud.speech.v1.ICustomClass>): - Promise<[ - protos.google.cloud.speech.v1.ICustomClass[], - protos.google.cloud.speech.v1.IListCustomClassesRequest|null, - protos.google.cloud.speech.v1.IListCustomClassesResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.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: - * - * `projects/{project}/locations/{location}/customClasses` - * - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - * @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.v1.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?: protos.google.cloud.speech.v1.IListCustomClassesRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listCustomClasses']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listCustomClasses.createStream( - this.innerApiCalls.listCustomClasses as GaxCall, - 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: - * - * `projects/{project}/locations/{location}/customClasses` - * - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - * @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.v1.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 include:samples/generated/v1/adaptation.list_custom_classes.js - * region_tag:speech_v1_generated_Adaptation_ListCustomClasses_async - */ - listCustomClassesAsync( - request?: protos.google.cloud.speech.v1.IListCustomClassesRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listCustomClasses']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listCustomClasses.asyncIterate( - this.innerApiCalls['listCustomClasses'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- 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:string,location:string,customClass:string) { - 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: string) { - 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: string) { - 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: string) { - 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:string,location:string) { - 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: string) { - 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: string) { - 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:string,location:string,phraseSet:string) { - 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: string) { - 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: string) { - 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: string) { - 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:string) { - 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: string) { - 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(): Promise { - if (this.adaptationStub && !this._terminated) { - return this.adaptationStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1/src/v1/adaptation_client_config.json b/owl-bot-staging/v1/src/v1/adaptation_client_config.json deleted file mode 100644 index 029e9b88..00000000 --- a/owl-bot-staging/v1/src/v1/adaptation_client_config.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "interfaces": { - "google.cloud.speech.v1.Adaptation": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "CreatePhraseSet": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetPhraseSet": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListPhraseSet": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdatePhraseSet": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeletePhraseSet": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CreateCustomClass": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetCustomClass": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListCustomClasses": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateCustomClass": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteCustomClass": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1/src/v1/adaptation_proto_list.json b/owl-bot-staging/v1/src/v1/adaptation_proto_list.json deleted file mode 100644 index 46afac3f..00000000 --- a/owl-bot-staging/v1/src/v1/adaptation_proto_list.json +++ /dev/null @@ -1,5 +0,0 @@ -[ - "../../protos/google/cloud/speech/v1/cloud_speech.proto", - "../../protos/google/cloud/speech/v1/cloud_speech_adaptation.proto", - "../../protos/google/cloud/speech/v1/resource.proto" -] diff --git a/owl-bot-staging/v1/src/v1/gapic_metadata.json b/owl-bot-staging/v1/src/v1/gapic_metadata.json deleted file mode 100644 index 96f60b3c..00000000 --- a/owl-bot-staging/v1/src/v1/gapic_metadata.json +++ /dev/null @@ -1,170 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.speech.v1", - "libraryPackage": "@google-cloud/speech", - "services": { - "Adaptation": { - "clients": { - "grpc": { - "libraryClient": "AdaptationClient", - "rpcs": { - "CreatePhraseSet": { - "methods": [ - "createPhraseSet" - ] - }, - "GetPhraseSet": { - "methods": [ - "getPhraseSet" - ] - }, - "UpdatePhraseSet": { - "methods": [ - "updatePhraseSet" - ] - }, - "DeletePhraseSet": { - "methods": [ - "deletePhraseSet" - ] - }, - "CreateCustomClass": { - "methods": [ - "createCustomClass" - ] - }, - "GetCustomClass": { - "methods": [ - "getCustomClass" - ] - }, - "UpdateCustomClass": { - "methods": [ - "updateCustomClass" - ] - }, - "DeleteCustomClass": { - "methods": [ - "deleteCustomClass" - ] - }, - "ListPhraseSet": { - "methods": [ - "listPhraseSet", - "listPhraseSetStream", - "listPhraseSetAsync" - ] - }, - "ListCustomClasses": { - "methods": [ - "listCustomClasses", - "listCustomClassesStream", - "listCustomClassesAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "AdaptationClient", - "rpcs": { - "CreatePhraseSet": { - "methods": [ - "createPhraseSet" - ] - }, - "GetPhraseSet": { - "methods": [ - "getPhraseSet" - ] - }, - "UpdatePhraseSet": { - "methods": [ - "updatePhraseSet" - ] - }, - "DeletePhraseSet": { - "methods": [ - "deletePhraseSet" - ] - }, - "CreateCustomClass": { - "methods": [ - "createCustomClass" - ] - }, - "GetCustomClass": { - "methods": [ - "getCustomClass" - ] - }, - "UpdateCustomClass": { - "methods": [ - "updateCustomClass" - ] - }, - "DeleteCustomClass": { - "methods": [ - "deleteCustomClass" - ] - }, - "ListPhraseSet": { - "methods": [ - "listPhraseSet", - "listPhraseSetStream", - "listPhraseSetAsync" - ] - }, - "ListCustomClasses": { - "methods": [ - "listCustomClasses", - "listCustomClassesStream", - "listCustomClassesAsync" - ] - } - } - } - } - }, - "Speech": { - "clients": { - "grpc": { - "libraryClient": "SpeechClient", - "rpcs": { - "Recognize": { - "methods": [ - "recognize" - ] - }, - "StreamingRecognize": { - "methods": [ - "streamingRecognize" - ] - }, - "LongRunningRecognize": { - "methods": [ - "longRunningRecognize" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "SpeechClient", - "rpcs": { - "Recognize": { - "methods": [ - "recognize" - ] - }, - "LongRunningRecognize": { - "methods": [ - "longRunningRecognize" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/v1/src/v1/index.ts b/owl-bot-staging/v1/src/v1/index.ts deleted file mode 100644 index 5b4cfbf4..00000000 --- a/owl-bot-staging/v1/src/v1/index.ts +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2022 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. ** - -export {AdaptationClient} from './adaptation_client'; -export {SpeechClient} from './speech_client'; diff --git a/owl-bot-staging/v1/src/v1/speech_client.ts b/owl-bot-staging/v1/src/v1/speech_client.ts deleted file mode 100644 index b79549d7..00000000 --- a/owl-bot-staging/v1/src/v1/speech_client.ts +++ /dev/null @@ -1,649 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation} from 'google-gax'; -import {PassThrough} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1/speech_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './speech_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Service that implements Google Cloud Speech API. - * @class - * @memberof v1 - */ -export class SpeechClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - speechStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of SpeechClient. - * - * @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/main/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 | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new SpeechClient({fallback: 'rest'}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof SpeechClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // 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}' - ), - phraseSetPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/phraseSets/{phrase_set}' - ), - }; - - // Some of the methods on this service provide streaming responses. - // Provide descriptors for these. - this.descriptors.stream = { - streamingRecognize: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.BIDI_STREAMING, opts.fallback === 'rest') - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/operations/{name=**}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1/operations',}]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const longRunningRecognizeResponse = protoFilesRoot.lookup( - '.google.cloud.speech.v1.LongRunningRecognizeResponse') as gax.protobuf.Type; - const longRunningRecognizeMetadata = protoFilesRoot.lookup( - '.google.cloud.speech.v1.LongRunningRecognizeMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - longRunningRecognize: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - longRunningRecognizeResponse.decode.bind(longRunningRecognizeResponse), - longRunningRecognizeMetadata.decode.bind(longRunningRecognizeMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.speech.v1.Speech', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = this._gaxModule.warn; - } - - /** - * 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.speechStub) { - return this.speechStub; - } - - // Put together the "service stub" for - // google.cloud.speech.v1.Speech. - this.speechStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.speech.v1.Speech') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.speech.v1.Speech, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const speechStubMethods = - ['recognize', 'longRunningRecognize', 'streamingRecognize']; - for (const methodName of speechStubMethods) { - const callPromise = this.speechStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - if (methodName in this.descriptors.stream) { - const stream = new PassThrough(); - setImmediate(() => { - stream.emit('error', new this._gaxModule.GoogleError('The client has already been closed.')); - }); - return stream; - } - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.stream[methodName] || - this.descriptors.longrunning[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor, - this._opts.fallback - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.speechStub; - } - - /** - * 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' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Performs synchronous speech recognition: receive results after all audio - * has been sent and processed. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.speech.v1.RecognitionConfig} request.config - * Required. Provides information to the recognizer that specifies how to - * process the request. - * @param {google.cloud.speech.v1.RecognitionAudio} request.audio - * Required. The audio data to be recognized. - * @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 [RecognizeResponse]{@link google.cloud.speech.v1.RecognizeResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/speech.recognize.js - * region_tag:speech_v1_generated_Speech_Recognize_async - */ - recognize( - request?: protos.google.cloud.speech.v1.IRecognizeRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.speech.v1.IRecognizeResponse, - protos.google.cloud.speech.v1.IRecognizeRequest|undefined, {}|undefined - ]>; - recognize( - request: protos.google.cloud.speech.v1.IRecognizeRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.speech.v1.IRecognizeResponse, - protos.google.cloud.speech.v1.IRecognizeRequest|null|undefined, - {}|null|undefined>): void; - recognize( - request: protos.google.cloud.speech.v1.IRecognizeRequest, - callback: Callback< - protos.google.cloud.speech.v1.IRecognizeResponse, - protos.google.cloud.speech.v1.IRecognizeRequest|null|undefined, - {}|null|undefined>): void; - recognize( - request?: protos.google.cloud.speech.v1.IRecognizeRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.speech.v1.IRecognizeResponse, - protos.google.cloud.speech.v1.IRecognizeRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.speech.v1.IRecognizeResponse, - protos.google.cloud.speech.v1.IRecognizeRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.speech.v1.IRecognizeResponse, - protos.google.cloud.speech.v1.IRecognizeRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - this.initialize(); - return this.innerApiCalls.recognize(request, options, callback); - } - -/** - * Performs bidirectional streaming speech recognition: receive results while - * sending audio. This method is only available via the gRPC API (not REST). - * - * @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 is both readable and writable. It accepts objects - * representing [StreamingRecognizeRequest]{@link google.cloud.speech.v1.StreamingRecognizeRequest} for write() method, and - * will emit objects representing [StreamingRecognizeResponse]{@link google.cloud.speech.v1.StreamingRecognizeResponse} on 'data' event asynchronously. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#bi-directional-streaming) - * for more details and examples. - * @example include:samples/generated/v1/speech.streaming_recognize.js - * region_tag:speech_v1_generated_Speech_StreamingRecognize_async - */ - streamingRecognize( - options?: CallOptions): - gax.CancellableStream { - this.initialize(); - return this.innerApiCalls.streamingRecognize(null, options); - } - -/** - * Performs asynchronous speech recognition: receive results via the - * google.longrunning.Operations interface. Returns either an - * `Operation.error` or an `Operation.response` which contains - * a `LongRunningRecognizeResponse` message. - * For more information on asynchronous speech recognition, see the - * [how-to](https://cloud.google.com/speech-to-text/docs/async-recognize). - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.speech.v1.RecognitionConfig} request.config - * Required. Provides information to the recognizer that specifies how to - * process the request. - * @param {google.cloud.speech.v1.RecognitionAudio} request.audio - * Required. The audio data to be recognized. - * @param {google.cloud.speech.v1.TranscriptOutputConfig} [request.outputConfig] - * Optional. Specifies an optional destination for the recognition results. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1/speech.long_running_recognize.js - * region_tag:speech_v1_generated_Speech_LongRunningRecognize_async - */ - longRunningRecognize( - request?: protos.google.cloud.speech.v1.ILongRunningRecognizeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - longRunningRecognize( - request: protos.google.cloud.speech.v1.ILongRunningRecognizeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - longRunningRecognize( - request: protos.google.cloud.speech.v1.ILongRunningRecognizeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - longRunningRecognize( - request?: protos.google.cloud.speech.v1.ILongRunningRecognizeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - this.initialize(); - return this.innerApiCalls.longRunningRecognize(request, options, callback); - } -/** - * Check the status of the long running operation returned by `longRunningRecognize()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1/speech.long_running_recognize.js - * region_tag:speech_v1_generated_Speech_LongRunningRecognize_async - */ - async checkLongRunningRecognizeProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.longRunningRecognize, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - // -------------------- - // -- 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:string,location:string,customClass:string) { - 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: string) { - 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: string) { - 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: string) { - return this.pathTemplates.customClassPathTemplate.match(customClassName).custom_class; - } - - /** - * 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:string,location:string,phraseSet:string) { - 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: string) { - 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: string) { - 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: string) { - return this.pathTemplates.phraseSetPathTemplate.match(phraseSetName).phrase_set; - } - - /** - * 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(): Promise { - if (this.speechStub && !this._terminated) { - return this.speechStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1/src/v1/speech_client_config.json b/owl-bot-staging/v1/src/v1/speech_client_config.json deleted file mode 100644 index 35b04f64..00000000 --- a/owl-bot-staging/v1/src/v1/speech_client_config.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "interfaces": { - "google.cloud.speech.v1.Speech": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "Recognize": { - "timeout_millis": 5000000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "LongRunningRecognize": { - "timeout_millis": 5000000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "StreamingRecognize": { - "timeout_millis": 5000000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1/src/v1/speech_proto_list.json b/owl-bot-staging/v1/src/v1/speech_proto_list.json deleted file mode 100644 index 46afac3f..00000000 --- a/owl-bot-staging/v1/src/v1/speech_proto_list.json +++ /dev/null @@ -1,5 +0,0 @@ -[ - "../../protos/google/cloud/speech/v1/cloud_speech.proto", - "../../protos/google/cloud/speech/v1/cloud_speech_adaptation.proto", - "../../protos/google/cloud/speech/v1/resource.proto" -] diff --git a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 36731b35..00000000 --- a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2022 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. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const speech = require('@google-cloud/speech'); - -function main() { - const adaptationClient = new speech.AdaptationClient(); - const speechClient = new speech.SpeechClient(); -} - -main(); diff --git a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 1c746cf8..00000000 --- a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2022 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. ** - -import {AdaptationClient, SpeechClient} from '@google-cloud/speech'; - -// check that the client class type name can be used -function doStuffWithAdaptationClient(client: AdaptationClient) { - client.close(); -} -function doStuffWithSpeechClient(client: SpeechClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const adaptationClient = new AdaptationClient(); - doStuffWithAdaptationClient(adaptationClient); - // check that the client instance can be created - const speechClient = new SpeechClient(); - doStuffWithSpeechClient(speechClient); -} - -main(); diff --git a/owl-bot-staging/v1/system-test/install.ts b/owl-bot-staging/v1/system-test/install.ts deleted file mode 100644 index 557a5755..00000000 --- a/owl-bot-staging/v1/system-test/install.ts +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2022 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. ** - -import {packNTest} from 'pack-n-play'; -import {readFileSync} from 'fs'; -import {describe, it} from 'mocha'; - -describe('📦 pack-n-play test', () => { - - it('TypeScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'TypeScript user can use the type definitions', - ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() - } - }; - await packNTest(options); - }); - - it('JavaScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'JavaScript user can use the library', - ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() - } - }; - await packNTest(options); - }); - -}); diff --git a/owl-bot-staging/v1/test/gapic_adaptation_v1.ts b/owl-bot-staging/v1/test/gapic_adaptation_v1.ts deleted file mode 100644 index 45fdade1..00000000 --- a/owl-bot-staging/v1/test/gapic_adaptation_v1.ts +++ /dev/null @@ -1,1722 +0,0 @@ -// Copyright 2022 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. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; -import * as adaptationModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1.AdaptationClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = adaptationModule.v1.AdaptationClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = adaptationModule.v1.AdaptationClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = adaptationModule.v1.AdaptationClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new adaptationModule.v1.AdaptationClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new adaptationModule.v1.AdaptationClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.adaptationStub, undefined); - await client.initialize(); - assert(client.adaptationStub); - }); - - it('has close method for the initialized client', done => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.adaptationStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.adaptationStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - }); - - describe('createPhraseSet', () => { - it('invokes createPhraseSet without error', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.CreatePhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('CreatePhraseSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1.PhraseSet() - ); - client.innerApiCalls.createPhraseSet = stubSimpleCall(expectedResponse); - const [response] = await client.createPhraseSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createPhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createPhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createPhraseSet without error using callback', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.CreatePhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('CreatePhraseSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1.PhraseSet() - ); - client.innerApiCalls.createPhraseSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createPhraseSet( - request, - (err?: Error|null, result?: protos.google.cloud.speech.v1.IPhraseSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createPhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createPhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createPhraseSet with error', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.CreatePhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('CreatePhraseSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createPhraseSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createPhraseSet(request), expectedError); - const actualRequest = (client.innerApiCalls.createPhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createPhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createPhraseSet with closed client', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.CreatePhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('CreatePhraseSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createPhraseSet(request), expectedError); - }); - }); - - describe('getPhraseSet', () => { - it('invokes getPhraseSet without error', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.GetPhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('GetPhraseSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1.PhraseSet() - ); - client.innerApiCalls.getPhraseSet = stubSimpleCall(expectedResponse); - const [response] = await client.getPhraseSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getPhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getPhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getPhraseSet without error using callback', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.GetPhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('GetPhraseSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1.PhraseSet() - ); - client.innerApiCalls.getPhraseSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getPhraseSet( - request, - (err?: Error|null, result?: protos.google.cloud.speech.v1.IPhraseSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getPhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getPhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getPhraseSet with error', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.GetPhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('GetPhraseSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getPhraseSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getPhraseSet(request), expectedError); - const actualRequest = (client.innerApiCalls.getPhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getPhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getPhraseSet with closed client', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.GetPhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('GetPhraseSetRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getPhraseSet(request), expectedError); - }); - }); - - describe('updatePhraseSet', () => { - it('invokes updatePhraseSet without error', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.UpdatePhraseSetRequest() - ); - request.phraseSet ??= {}; - const defaultValue1 = - getTypeDefaultValue('UpdatePhraseSetRequest', ['phraseSet', 'name']); - request.phraseSet.name = defaultValue1; - const expectedHeaderRequestParams = `phrase_set.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1.PhraseSet() - ); - client.innerApiCalls.updatePhraseSet = stubSimpleCall(expectedResponse); - const [response] = await client.updatePhraseSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updatePhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updatePhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updatePhraseSet without error using callback', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.UpdatePhraseSetRequest() - ); - request.phraseSet ??= {}; - const defaultValue1 = - getTypeDefaultValue('UpdatePhraseSetRequest', ['phraseSet', 'name']); - request.phraseSet.name = defaultValue1; - const expectedHeaderRequestParams = `phrase_set.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1.PhraseSet() - ); - client.innerApiCalls.updatePhraseSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updatePhraseSet( - request, - (err?: Error|null, result?: protos.google.cloud.speech.v1.IPhraseSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updatePhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updatePhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updatePhraseSet with error', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.UpdatePhraseSetRequest() - ); - request.phraseSet ??= {}; - const defaultValue1 = - getTypeDefaultValue('UpdatePhraseSetRequest', ['phraseSet', 'name']); - request.phraseSet.name = defaultValue1; - const expectedHeaderRequestParams = `phrase_set.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updatePhraseSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updatePhraseSet(request), expectedError); - const actualRequest = (client.innerApiCalls.updatePhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updatePhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updatePhraseSet with closed client', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.UpdatePhraseSetRequest() - ); - request.phraseSet ??= {}; - const defaultValue1 = - getTypeDefaultValue('UpdatePhraseSetRequest', ['phraseSet', 'name']); - request.phraseSet.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updatePhraseSet(request), expectedError); - }); - }); - - describe('deletePhraseSet', () => { - it('invokes deletePhraseSet without error', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.DeletePhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('DeletePhraseSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deletePhraseSet = stubSimpleCall(expectedResponse); - const [response] = await client.deletePhraseSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deletePhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deletePhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deletePhraseSet without error using callback', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.DeletePhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('DeletePhraseSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deletePhraseSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deletePhraseSet( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deletePhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deletePhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deletePhraseSet with error', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.DeletePhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('DeletePhraseSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deletePhraseSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deletePhraseSet(request), expectedError); - const actualRequest = (client.innerApiCalls.deletePhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deletePhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deletePhraseSet with closed client', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.DeletePhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('DeletePhraseSetRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deletePhraseSet(request), expectedError); - }); - }); - - describe('createCustomClass', () => { - it('invokes createCustomClass without error', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.CreateCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('CreateCustomClassRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1.CustomClass() - ); - client.innerApiCalls.createCustomClass = stubSimpleCall(expectedResponse); - const [response] = await client.createCustomClass(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createCustomClass without error using callback', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.CreateCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('CreateCustomClassRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1.CustomClass() - ); - client.innerApiCalls.createCustomClass = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createCustomClass( - request, - (err?: Error|null, result?: protos.google.cloud.speech.v1.ICustomClass|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createCustomClass with error', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.CreateCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('CreateCustomClassRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createCustomClass = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createCustomClass(request), expectedError); - const actualRequest = (client.innerApiCalls.createCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createCustomClass with closed client', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.CreateCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('CreateCustomClassRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createCustomClass(request), expectedError); - }); - }); - - describe('getCustomClass', () => { - it('invokes getCustomClass without error', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.GetCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('GetCustomClassRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1.CustomClass() - ); - client.innerApiCalls.getCustomClass = stubSimpleCall(expectedResponse); - const [response] = await client.getCustomClass(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getCustomClass without error using callback', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.GetCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('GetCustomClassRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1.CustomClass() - ); - client.innerApiCalls.getCustomClass = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getCustomClass( - request, - (err?: Error|null, result?: protos.google.cloud.speech.v1.ICustomClass|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getCustomClass with error', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.GetCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('GetCustomClassRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getCustomClass = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getCustomClass(request), expectedError); - const actualRequest = (client.innerApiCalls.getCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getCustomClass with closed client', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.GetCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('GetCustomClassRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getCustomClass(request), expectedError); - }); - }); - - describe('updateCustomClass', () => { - it('invokes updateCustomClass without error', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.UpdateCustomClassRequest() - ); - request.customClass ??= {}; - const defaultValue1 = - getTypeDefaultValue('UpdateCustomClassRequest', ['customClass', 'name']); - request.customClass.name = defaultValue1; - const expectedHeaderRequestParams = `custom_class.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1.CustomClass() - ); - client.innerApiCalls.updateCustomClass = stubSimpleCall(expectedResponse); - const [response] = await client.updateCustomClass(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateCustomClass without error using callback', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.UpdateCustomClassRequest() - ); - request.customClass ??= {}; - const defaultValue1 = - getTypeDefaultValue('UpdateCustomClassRequest', ['customClass', 'name']); - request.customClass.name = defaultValue1; - const expectedHeaderRequestParams = `custom_class.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1.CustomClass() - ); - client.innerApiCalls.updateCustomClass = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateCustomClass( - request, - (err?: Error|null, result?: protos.google.cloud.speech.v1.ICustomClass|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateCustomClass with error', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.UpdateCustomClassRequest() - ); - request.customClass ??= {}; - const defaultValue1 = - getTypeDefaultValue('UpdateCustomClassRequest', ['customClass', 'name']); - request.customClass.name = defaultValue1; - const expectedHeaderRequestParams = `custom_class.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateCustomClass = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateCustomClass(request), expectedError); - const actualRequest = (client.innerApiCalls.updateCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateCustomClass with closed client', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.UpdateCustomClassRequest() - ); - request.customClass ??= {}; - const defaultValue1 = - getTypeDefaultValue('UpdateCustomClassRequest', ['customClass', 'name']); - request.customClass.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateCustomClass(request), expectedError); - }); - }); - - describe('deleteCustomClass', () => { - it('invokes deleteCustomClass without error', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.DeleteCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('DeleteCustomClassRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteCustomClass = stubSimpleCall(expectedResponse); - const [response] = await client.deleteCustomClass(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteCustomClass without error using callback', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.DeleteCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('DeleteCustomClassRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteCustomClass = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteCustomClass( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteCustomClass with error', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.DeleteCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('DeleteCustomClassRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteCustomClass = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteCustomClass(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteCustomClass with closed client', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.DeleteCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('DeleteCustomClassRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteCustomClass(request), expectedError); - }); - }); - - describe('listPhraseSet', () => { - it('invokes listPhraseSet without error', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.ListPhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListPhraseSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.speech.v1.PhraseSet()), - generateSampleMessage(new protos.google.cloud.speech.v1.PhraseSet()), - generateSampleMessage(new protos.google.cloud.speech.v1.PhraseSet()), - ]; - client.innerApiCalls.listPhraseSet = stubSimpleCall(expectedResponse); - const [response] = await client.listPhraseSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listPhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listPhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listPhraseSet without error using callback', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.ListPhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListPhraseSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.speech.v1.PhraseSet()), - generateSampleMessage(new protos.google.cloud.speech.v1.PhraseSet()), - generateSampleMessage(new protos.google.cloud.speech.v1.PhraseSet()), - ]; - client.innerApiCalls.listPhraseSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listPhraseSet( - request, - (err?: Error|null, result?: protos.google.cloud.speech.v1.IPhraseSet[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listPhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listPhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listPhraseSet with error', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.ListPhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListPhraseSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listPhraseSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listPhraseSet(request), expectedError); - const actualRequest = (client.innerApiCalls.listPhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listPhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listPhraseSetStream without error', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.ListPhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListPhraseSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.speech.v1.PhraseSet()), - generateSampleMessage(new protos.google.cloud.speech.v1.PhraseSet()), - generateSampleMessage(new protos.google.cloud.speech.v1.PhraseSet()), - ]; - client.descriptors.page.listPhraseSet.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listPhraseSetStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.speech.v1.PhraseSet[] = []; - stream.on('data', (response: protos.google.cloud.speech.v1.PhraseSet) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listPhraseSet.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listPhraseSet, request)); - assert( - (client.descriptors.page.listPhraseSet.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listPhraseSetStream with error', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.ListPhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListPhraseSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listPhraseSet.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listPhraseSetStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.speech.v1.PhraseSet[] = []; - stream.on('data', (response: protos.google.cloud.speech.v1.PhraseSet) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listPhraseSet.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listPhraseSet, request)); - assert( - (client.descriptors.page.listPhraseSet.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listPhraseSet without error', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.ListPhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListPhraseSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.speech.v1.PhraseSet()), - generateSampleMessage(new protos.google.cloud.speech.v1.PhraseSet()), - generateSampleMessage(new protos.google.cloud.speech.v1.PhraseSet()), - ]; - client.descriptors.page.listPhraseSet.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.speech.v1.IPhraseSet[] = []; - const iterable = client.listPhraseSetAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listPhraseSet.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listPhraseSet.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listPhraseSet with error', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.ListPhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListPhraseSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listPhraseSet.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listPhraseSetAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.speech.v1.IPhraseSet[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listPhraseSet.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listPhraseSet.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listCustomClasses', () => { - it('invokes listCustomClasses without error', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.ListCustomClassesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListCustomClassesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.speech.v1.CustomClass()), - generateSampleMessage(new protos.google.cloud.speech.v1.CustomClass()), - generateSampleMessage(new protos.google.cloud.speech.v1.CustomClass()), - ]; - client.innerApiCalls.listCustomClasses = stubSimpleCall(expectedResponse); - const [response] = await client.listCustomClasses(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listCustomClasses as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCustomClasses as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listCustomClasses without error using callback', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.ListCustomClassesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListCustomClassesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.speech.v1.CustomClass()), - generateSampleMessage(new protos.google.cloud.speech.v1.CustomClass()), - generateSampleMessage(new protos.google.cloud.speech.v1.CustomClass()), - ]; - client.innerApiCalls.listCustomClasses = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listCustomClasses( - request, - (err?: Error|null, result?: protos.google.cloud.speech.v1.ICustomClass[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listCustomClasses as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCustomClasses as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listCustomClasses with error', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.ListCustomClassesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListCustomClassesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listCustomClasses = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listCustomClasses(request), expectedError); - const actualRequest = (client.innerApiCalls.listCustomClasses as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCustomClasses as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listCustomClassesStream without error', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.ListCustomClassesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListCustomClassesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.speech.v1.CustomClass()), - generateSampleMessage(new protos.google.cloud.speech.v1.CustomClass()), - generateSampleMessage(new protos.google.cloud.speech.v1.CustomClass()), - ]; - client.descriptors.page.listCustomClasses.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listCustomClassesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.speech.v1.CustomClass[] = []; - stream.on('data', (response: protos.google.cloud.speech.v1.CustomClass) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listCustomClasses.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listCustomClasses, request)); - assert( - (client.descriptors.page.listCustomClasses.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listCustomClassesStream with error', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.ListCustomClassesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListCustomClassesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listCustomClasses.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listCustomClassesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.speech.v1.CustomClass[] = []; - stream.on('data', (response: protos.google.cloud.speech.v1.CustomClass) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listCustomClasses.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listCustomClasses, request)); - assert( - (client.descriptors.page.listCustomClasses.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listCustomClasses without error', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.ListCustomClassesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListCustomClassesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.speech.v1.CustomClass()), - generateSampleMessage(new protos.google.cloud.speech.v1.CustomClass()), - generateSampleMessage(new protos.google.cloud.speech.v1.CustomClass()), - ]; - client.descriptors.page.listCustomClasses.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.speech.v1.ICustomClass[] = []; - const iterable = client.listCustomClassesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listCustomClasses.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listCustomClasses.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listCustomClasses with error', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.ListCustomClassesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListCustomClassesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listCustomClasses.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listCustomClassesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.speech.v1.ICustomClass[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listCustomClasses.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listCustomClasses.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('Path templates', () => { - - describe('customClass', () => { - const fakePath = "/rendered/path/customClass"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - custom_class: "customClassValue", - }; - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.customClassPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.customClassPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('customClassPath', () => { - const result = client.customClassPath("projectValue", "locationValue", "customClassValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.customClassPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCustomClassName', () => { - const result = client.matchProjectFromCustomClassName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.customClassPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCustomClassName', () => { - const result = client.matchLocationFromCustomClassName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.customClassPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCustomClassFromCustomClassName', () => { - const result = client.matchCustomClassFromCustomClassName(fakePath); - assert.strictEqual(result, "customClassValue"); - assert((client.pathTemplates.customClassPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('location', () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('phraseSet', () => { - const fakePath = "/rendered/path/phraseSet"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - phrase_set: "phraseSetValue", - }; - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.phraseSetPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.phraseSetPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('phraseSetPath', () => { - const result = client.phraseSetPath("projectValue", "locationValue", "phraseSetValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.phraseSetPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromPhraseSetName', () => { - const result = client.matchProjectFromPhraseSetName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.phraseSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromPhraseSetName', () => { - const result = client.matchLocationFromPhraseSetName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.phraseSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchPhraseSetFromPhraseSetName', () => { - const result = client.matchPhraseSetFromPhraseSetName(fakePath); - assert.strictEqual(result, "phraseSetValue"); - assert((client.pathTemplates.phraseSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('project', () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v1/test/gapic_speech_v1.ts b/owl-bot-staging/v1/test/gapic_speech_v1.ts deleted file mode 100644 index c7d0b9fb..00000000 --- a/owl-bot-staging/v1/test/gapic_speech_v1.ts +++ /dev/null @@ -1,525 +0,0 @@ -// Copyright 2022 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. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; -import * as speechModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubBidiStreamingCall(response?: ResponseType, error?: Error) { - const transformStub = error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - return sinon.stub().returns(mockStream); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -describe('v1.SpeechClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = speechModule.v1.SpeechClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = speechModule.v1.SpeechClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = speechModule.v1.SpeechClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new speechModule.v1.SpeechClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new speechModule.v1.SpeechClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new speechModule.v1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.speechStub, undefined); - await client.initialize(); - assert(client.speechStub); - }); - - it('has close method for the initialized client', done => { - const client = new speechModule.v1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.speechStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new speechModule.v1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.speechStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new speechModule.v1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new speechModule.v1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - }); - - describe('recognize', () => { - it('invokes recognize without error', async () => { - const client = new speechModule.v1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.RecognizeRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1.RecognizeResponse() - ); - client.innerApiCalls.recognize = stubSimpleCall(expectedResponse); - const [response] = await client.recognize(request); - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes recognize without error using callback', async () => { - const client = new speechModule.v1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.RecognizeRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1.RecognizeResponse() - ); - client.innerApiCalls.recognize = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.recognize( - request, - (err?: Error|null, result?: protos.google.cloud.speech.v1.IRecognizeResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes recognize with error', async () => { - const client = new speechModule.v1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.RecognizeRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.recognize = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.recognize(request), expectedError); - }); - - it('invokes recognize with closed client', async () => { - const client = new speechModule.v1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.RecognizeRequest() - ); - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.recognize(request), expectedError); - }); - }); - - describe('longRunningRecognize', () => { - it('invokes longRunningRecognize without error', async () => { - const client = new speechModule.v1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.LongRunningRecognizeRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.longRunningRecognize = stubLongRunningCall(expectedResponse); - const [operation] = await client.longRunningRecognize(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes longRunningRecognize without error using callback', async () => { - const client = new speechModule.v1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.LongRunningRecognizeRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.longRunningRecognize = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.longRunningRecognize( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes longRunningRecognize with call error', async () => { - const client = new speechModule.v1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.LongRunningRecognizeRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.longRunningRecognize = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.longRunningRecognize(request), expectedError); - }); - - it('invokes longRunningRecognize with LRO error', async () => { - const client = new speechModule.v1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.LongRunningRecognizeRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.longRunningRecognize = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.longRunningRecognize(request); - await assert.rejects(operation.promise(), expectedError); - }); - - it('invokes checkLongRunningRecognizeProgress without error', async () => { - const client = new speechModule.v1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkLongRunningRecognizeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkLongRunningRecognizeProgress with error', async () => { - const client = new speechModule.v1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkLongRunningRecognizeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('streamingRecognize', () => { - it('invokes streamingRecognize without error', async () => { - const client = new speechModule.v1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.StreamingRecognizeRequest() - ); - - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1.StreamingRecognizeResponse() - ); - client.innerApiCalls.streamingRecognize = stubBidiStreamingCall(expectedResponse); - const stream = client.streamingRecognize(); - const promise = new Promise((resolve, reject) => { - stream.on('data', (response: protos.google.cloud.speech.v1.StreamingRecognizeResponse) => { - resolve(response); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - stream.write(request); - stream.end(); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.streamingRecognize as SinonStub) - .getCall(0).calledWith(null)); - assert.deepStrictEqual(((stream as unknown as PassThrough) - ._transform as SinonStub).getCall(0).args[0], request); - }); - - it('invokes streamingRecognize with error', async () => { - const client = new speechModule.v1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.StreamingRecognizeRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.streamingRecognize = stubBidiStreamingCall(undefined, expectedError); - const stream = client.streamingRecognize(); - const promise = new Promise((resolve, reject) => { - stream.on('data', (response: protos.google.cloud.speech.v1.StreamingRecognizeResponse) => { - resolve(response); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - stream.write(request); - stream.end(); - }); - await assert.rejects(promise, expectedError); - assert((client.innerApiCalls.streamingRecognize as SinonStub) - .getCall(0).calledWith(null)); - assert.deepStrictEqual(((stream as unknown as PassThrough) - ._transform as SinonStub).getCall(0).args[0], request); - }); - }); - - describe('Path templates', () => { - - describe('customClass', () => { - const fakePath = "/rendered/path/customClass"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - custom_class: "customClassValue", - }; - const client = new speechModule.v1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.customClassPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.customClassPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('customClassPath', () => { - const result = client.customClassPath("projectValue", "locationValue", "customClassValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.customClassPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCustomClassName', () => { - const result = client.matchProjectFromCustomClassName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.customClassPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCustomClassName', () => { - const result = client.matchLocationFromCustomClassName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.customClassPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCustomClassFromCustomClassName', () => { - const result = client.matchCustomClassFromCustomClassName(fakePath); - assert.strictEqual(result, "customClassValue"); - assert((client.pathTemplates.customClassPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('phraseSet', () => { - const fakePath = "/rendered/path/phraseSet"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - phrase_set: "phraseSetValue", - }; - const client = new speechModule.v1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.phraseSetPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.phraseSetPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('phraseSetPath', () => { - const result = client.phraseSetPath("projectValue", "locationValue", "phraseSetValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.phraseSetPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromPhraseSetName', () => { - const result = client.matchProjectFromPhraseSetName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.phraseSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromPhraseSetName', () => { - const result = client.matchLocationFromPhraseSetName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.phraseSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchPhraseSetFromPhraseSetName', () => { - const result = client.matchPhraseSetFromPhraseSetName(fakePath); - assert.strictEqual(result, "phraseSetValue"); - assert((client.pathTemplates.phraseSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v1/tsconfig.json b/owl-bot-staging/v1/tsconfig.json deleted file mode 100644 index c78f1c88..00000000 --- a/owl-bot-staging/v1/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "resolveJsonModule": true, - "lib": [ - "es2018", - "dom" - ] - }, - "include": [ - "src/*.ts", - "src/**/*.ts", - "test/*.ts", - "test/**/*.ts", - "system-test/*.ts" - ] -} diff --git a/owl-bot-staging/v1/webpack.config.js b/owl-bot-staging/v1/webpack.config.js deleted file mode 100644 index 50273cca..00000000 --- a/owl-bot-staging/v1/webpack.config.js +++ /dev/null @@ -1,64 +0,0 @@ -// 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. - -const path = require('path'); - -module.exports = { - entry: './src/index.ts', - output: { - library: 'Adaptation', - filename: './adaptation.js', - }, - node: { - child_process: 'empty', - fs: 'empty', - crypto: 'empty', - }, - resolve: { - alias: { - '../../../package.json': path.resolve(__dirname, 'package.json'), - }, - extensions: ['.js', '.json', '.ts'], - }, - module: { - rules: [ - { - test: /\.tsx?$/, - use: 'ts-loader', - exclude: /node_modules/ - }, - { - test: /node_modules[\\/]@grpc[\\/]grpc-js/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]grpc/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]retry-request/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]https?-proxy-agent/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]gtoken/, - use: 'null-loader' - }, - ], - }, - mode: 'production', -}; diff --git a/owl-bot-staging/v1p1beta1/.eslintignore b/owl-bot-staging/v1p1beta1/.eslintignore deleted file mode 100644 index cfc348ec..00000000 --- a/owl-bot-staging/v1p1beta1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/v1p1beta1/.eslintrc.json b/owl-bot-staging/v1p1beta1/.eslintrc.json deleted file mode 100644 index 78215349..00000000 --- a/owl-bot-staging/v1p1beta1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/v1p1beta1/.gitignore b/owl-bot-staging/v1p1beta1/.gitignore deleted file mode 100644 index 5d32b237..00000000 --- a/owl-bot-staging/v1p1beta1/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -**/*.log -**/node_modules -.coverage -coverage -.nyc_output -docs/ -out/ -build/ -system-test/secrets.js -system-test/*key.json -*.lock -.DS_Store -package-lock.json -__pycache__ diff --git a/owl-bot-staging/v1p1beta1/.jsdoc.js b/owl-bot-staging/v1p1beta1/.jsdoc.js deleted file mode 100644 index d2a7104e..00000000 --- a/owl-bot-staging/v1p1beta1/.jsdoc.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2022 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. ** - -'use strict'; - -module.exports = { - opts: { - readme: './README.md', - package: './package.json', - template: './node_modules/jsdoc-fresh', - recurse: true, - verbose: true, - destination: './docs/' - }, - plugins: [ - 'plugins/markdown', - 'jsdoc-region-tag' - ], - source: { - excludePattern: '(^|\\/|\\\\)[._]', - include: [ - 'build/src', - 'protos' - ], - includePattern: '\\.js$' - }, - templates: { - copyright: 'Copyright 2022 Google LLC', - includeDate: false, - sourceFiles: false, - systemName: '@google-cloud/speech', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/v1p1beta1/.mocharc.js b/owl-bot-staging/v1p1beta1/.mocharc.js deleted file mode 100644 index 481c522b..00000000 --- a/owl-bot-staging/v1p1beta1/.mocharc.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2022 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. ** - -const config = { - "enable-source-maps": true, - "throw-deprecation": true, - "timeout": 10000 -} -if (process.env.MOCHA_THROW_DEPRECATION === 'false') { - delete config['throw-deprecation']; -} -if (process.env.MOCHA_REPORTER) { - config.reporter = process.env.MOCHA_REPORTER; -} -if (process.env.MOCHA_REPORTER_OUTPUT) { - config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; -} -module.exports = config diff --git a/owl-bot-staging/v1p1beta1/.prettierrc.js b/owl-bot-staging/v1p1beta1/.prettierrc.js deleted file mode 100644 index 494e1478..00000000 --- a/owl-bot-staging/v1p1beta1/.prettierrc.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2022 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. ** - - -module.exports = { - ...require('gts/.prettierrc.json') -} diff --git a/owl-bot-staging/v1p1beta1/README.md b/owl-bot-staging/v1p1beta1/README.md deleted file mode 100644 index 45c3b2af..00000000 --- a/owl-bot-staging/v1p1beta1/README.md +++ /dev/null @@ -1 +0,0 @@ -Speech: Nodejs Client diff --git a/owl-bot-staging/v1p1beta1/linkinator.config.json b/owl-bot-staging/v1p1beta1/linkinator.config.json deleted file mode 100644 index befd23c8..00000000 --- a/owl-bot-staging/v1p1beta1/linkinator.config.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "recurse": true, - "skip": [ - "https://codecov.io/gh/googleapis/", - "www.googleapis.com", - "img.shields.io", - "https://console.cloud.google.com/cloudshell", - "https://support.google.com" - ], - "silent": true, - "concurrency": 5, - "retry": true, - "retryErrors": true, - "retryErrorsCount": 5, - "retryErrorsJitter": 3000 -} diff --git a/owl-bot-staging/v1p1beta1/package.json b/owl-bot-staging/v1p1beta1/package.json deleted file mode 100644 index 53356248..00000000 --- a/owl-bot-staging/v1p1beta1/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@google-cloud/speech", - "version": "0.1.0", - "description": "Speech client for Node.js", - "repository": "googleapis/nodejs-speech", - "license": "Apache-2.0", - "author": "Google LLC", - "main": "build/src/index.js", - "files": [ - "build/src", - "build/protos" - ], - "keywords": [ - "google apis client", - "google api client", - "google apis", - "google api", - "google", - "google cloud platform", - "google cloud", - "cloud", - "google speech", - "speech", - "adaptation", - "speech" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "predocs-test": "npm run docs", - "docs-test": "linkinator docs", - "fix": "gts fix", - "lint": "gts check", - "prepare": "npm run compile-protos && npm run compile", - "system-test": "c8 mocha build/system-test", - "test": "c8 mocha build/test" - }, - "dependencies": { - "google-gax": "^3.5.1" - }, - "devDependencies": { - "@types/mocha": "^9.1.1", - "@types/node": "^16.11.59", - "@types/sinon": "^10.0.13", - "c8": "^7.12.0", - "gts": "^3.1.1", - "jsdoc": "^3.6.11", - "jsdoc-fresh": "^2.0.1", - "jsdoc-region-tag": "^2.0.1", - "linkinator": "^4.0.3", - "mocha": "^10.0.0", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^14.0.0", - "ts-loader": "^8.4.0", - "typescript": "^4.8.3", - "webpack": "^4.46.0", - "webpack-cli": "^4.10.0" - }, - "engines": { - "node": ">=v12" - } -} diff --git a/owl-bot-staging/v1p1beta1/protos/google/cloud/speech/v1p1beta1/cloud_speech.proto b/owl-bot-staging/v1p1beta1/protos/google/cloud/speech/v1p1beta1/cloud_speech.proto deleted file mode 100644 index 9bf36fcc..00000000 --- a/owl-bot-staging/v1p1beta1/protos/google/cloud/speech/v1p1beta1/cloud_speech.proto +++ /dev/null @@ -1,929 +0,0 @@ -// Copyright 2022 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 -// -// http://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. - -syntax = "proto3"; - -package google.cloud.speech.v1p1beta1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/cloud/speech/v1p1beta1/resource.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/timestamp.proto"; -import "google/protobuf/wrappers.proto"; -import "google/rpc/status.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/speech/v1p1beta1;speech"; -option java_multiple_files = true; -option java_outer_classname = "SpeechProto"; -option java_package = "com.google.cloud.speech.v1p1beta1"; -option objc_class_prefix = "GCS"; - -// Service that implements Google Cloud Speech API. -service Speech { - option (google.api.default_host) = "speech.googleapis.com"; - option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; - - // Performs synchronous speech recognition: receive results after all audio - // has been sent and processed. - rpc Recognize(RecognizeRequest) returns (RecognizeResponse) { - option (google.api.http) = { - post: "/v1p1beta1/speech:recognize" - body: "*" - }; - option (google.api.method_signature) = "config,audio"; - } - - // Performs asynchronous speech recognition: receive results via the - // google.longrunning.Operations interface. Returns either an - // `Operation.error` or an `Operation.response` which contains - // a `LongRunningRecognizeResponse` message. - // For more information on asynchronous speech recognition, see the - // [how-to](https://cloud.google.com/speech-to-text/docs/async-recognize). - rpc LongRunningRecognize(LongRunningRecognizeRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1p1beta1/speech:longrunningrecognize" - body: "*" - }; - option (google.api.method_signature) = "config,audio"; - option (google.longrunning.operation_info) = { - response_type: "LongRunningRecognizeResponse" - metadata_type: "LongRunningRecognizeMetadata" - }; - } - - // Performs bidirectional streaming speech recognition: receive results while - // sending audio. This method is only available via the gRPC API (not REST). - rpc StreamingRecognize(stream StreamingRecognizeRequest) returns (stream StreamingRecognizeResponse) { - } -} - -// The top-level message sent by the client for the `Recognize` method. -message RecognizeRequest { - // Required. Provides information to the recognizer that specifies how to - // process the request. - RecognitionConfig config = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. The audio data to be recognized. - RecognitionAudio audio = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// The top-level message sent by the client for the `LongRunningRecognize` -// method. -message LongRunningRecognizeRequest { - // Required. Provides information to the recognizer that specifies how to - // process the request. - RecognitionConfig config = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. The audio data to be recognized. - RecognitionAudio audio = 2 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Specifies an optional destination for the recognition results. - TranscriptOutputConfig output_config = 4 [(google.api.field_behavior) = OPTIONAL]; -} - -// Specifies an optional destination for the recognition results. -message TranscriptOutputConfig { - oneof output_type { - // Specifies a Cloud Storage URI for the recognition results. Must be - // specified in the format: `gs://bucket_name/object_name`, and the bucket - // must already exist. - string gcs_uri = 1; - } -} - -// The top-level message sent by the client for the `StreamingRecognize` method. -// Multiple `StreamingRecognizeRequest` messages are sent. The first message -// must contain a `streaming_config` message and must not contain -// `audio_content`. All subsequent messages must contain `audio_content` and -// must not contain a `streaming_config` message. -message StreamingRecognizeRequest { - // The streaming request, which is either a streaming config or audio content. - oneof streaming_request { - // Provides information to the recognizer that specifies how to process the - // request. The first `StreamingRecognizeRequest` message must contain a - // `streaming_config` message. - StreamingRecognitionConfig streaming_config = 1; - - // The audio data to be recognized. Sequential chunks of audio data are sent - // in sequential `StreamingRecognizeRequest` messages. The first - // `StreamingRecognizeRequest` message must not contain `audio_content` data - // and all subsequent `StreamingRecognizeRequest` messages must contain - // `audio_content` data. The audio bytes must be encoded as specified in - // `RecognitionConfig`. Note: as with all bytes fields, proto buffers use a - // pure binary representation (not base64). See - // [content limits](https://cloud.google.com/speech-to-text/quotas#content). - bytes audio_content = 2; - } -} - -// Provides information to the recognizer that specifies how to process the -// request. -message StreamingRecognitionConfig { - // Required. Provides information to the recognizer that specifies how to - // process the request. - RecognitionConfig config = 1 [(google.api.field_behavior) = REQUIRED]; - - // If `false` or omitted, the recognizer will perform continuous - // recognition (continuing to wait for and process audio even if the user - // pauses speaking) until the client closes the input stream (gRPC API) or - // until the maximum time limit has been reached. May return multiple - // `StreamingRecognitionResult`s with the `is_final` flag set to `true`. - // - // If `true`, the recognizer will detect a single spoken utterance. When it - // detects that the user has paused or stopped speaking, it will return an - // `END_OF_SINGLE_UTTERANCE` event and cease recognition. It will return no - // more than one `StreamingRecognitionResult` with the `is_final` flag set to - // `true`. - // - // The `single_utterance` field can only be used with specified models, - // otherwise an error is thrown. The `model` field in [`RecognitionConfig`][] - // must be set to: - // - // * `command_and_search` - // * `phone_call` AND additional field `useEnhanced`=`true` - // * The `model` field is left undefined. In this case the API auto-selects - // a model based on any other parameters that you set in - // `RecognitionConfig`. - bool single_utterance = 2; - - // If `true`, interim results (tentative hypotheses) may be - // returned as they become available (these interim results are indicated with - // the `is_final=false` flag). - // If `false` or omitted, only `is_final=true` result(s) are returned. - bool interim_results = 3; -} - -// Provides information to the recognizer that specifies how to process the -// request. -message RecognitionConfig { - // The encoding of the audio data sent in the request. - // - // All encodings support only 1 channel (mono) audio, unless the - // `audio_channel_count` and `enable_separate_recognition_per_channel` fields - // are set. - // - // For best results, the audio source should be captured and transmitted using - // a lossless encoding (`FLAC` or `LINEAR16`). The accuracy of the speech - // recognition can be reduced if lossy codecs are used to capture or transmit - // audio, particularly if background noise is present. Lossy codecs include - // `MULAW`, `AMR`, `AMR_WB`, `OGG_OPUS`, `SPEEX_WITH_HEADER_BYTE`, `MP3`, - // and `WEBM_OPUS`. - // - // The `FLAC` and `WAV` audio file formats include a header that describes the - // included audio content. You can request recognition for `WAV` files that - // contain either `LINEAR16` or `MULAW` encoded audio. - // If you send `FLAC` or `WAV` audio file format in - // your request, you do not need to specify an `AudioEncoding`; the audio - // encoding format is determined from the file header. If you specify - // an `AudioEncoding` when you send send `FLAC` or `WAV` audio, the - // encoding configuration must match the encoding described in the audio - // header; otherwise the request returns an - // [google.rpc.Code.INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT] error code. - enum AudioEncoding { - // Not specified. - ENCODING_UNSPECIFIED = 0; - - // Uncompressed 16-bit signed little-endian samples (Linear PCM). - LINEAR16 = 1; - - // `FLAC` (Free Lossless Audio - // Codec) is the recommended encoding because it is - // lossless--therefore recognition is not compromised--and - // requires only about half the bandwidth of `LINEAR16`. `FLAC` stream - // encoding supports 16-bit and 24-bit samples, however, not all fields in - // `STREAMINFO` are supported. - FLAC = 2; - - // 8-bit samples that compand 14-bit audio samples using G.711 PCMU/mu-law. - MULAW = 3; - - // Adaptive Multi-Rate Narrowband codec. `sample_rate_hertz` must be 8000. - AMR = 4; - - // Adaptive Multi-Rate Wideband codec. `sample_rate_hertz` must be 16000. - AMR_WB = 5; - - // Opus encoded audio frames in Ogg container - // ([OggOpus](https://wiki.xiph.org/OggOpus)). - // `sample_rate_hertz` must be one of 8000, 12000, 16000, 24000, or 48000. - OGG_OPUS = 6; - - // Although the use of lossy encodings is not recommended, if a very low - // bitrate encoding is required, `OGG_OPUS` is highly preferred over - // Speex encoding. The [Speex](https://speex.org/) encoding supported by - // Cloud Speech API has a header byte in each block, as in MIME type - // `audio/x-speex-with-header-byte`. - // It is a variant of the RTP Speex encoding defined in - // [RFC 5574](https://tools.ietf.org/html/rfc5574). - // The stream is a sequence of blocks, one block per RTP packet. Each block - // starts with a byte containing the length of the block, in bytes, followed - // by one or more frames of Speex data, padded to an integral number of - // bytes (octets) as specified in RFC 5574. In other words, each RTP header - // is replaced with a single byte containing the block length. Only Speex - // wideband is supported. `sample_rate_hertz` must be 16000. - SPEEX_WITH_HEADER_BYTE = 7; - - // MP3 audio. MP3 encoding is a Beta feature and only available in - // v1p1beta1. Support all standard MP3 bitrates (which range from 32-320 - // kbps). When using this encoding, `sample_rate_hertz` has to match the - // sample rate of the file being used. - MP3 = 8; - - // Opus encoded audio frames in WebM container - // ([OggOpus](https://wiki.xiph.org/OggOpus)). `sample_rate_hertz` must be - // one of 8000, 12000, 16000, 24000, or 48000. - WEBM_OPUS = 9; - } - - // Encoding of audio data sent in all `RecognitionAudio` messages. - // This field is optional for `FLAC` and `WAV` audio files and required - // for all other audio formats. For details, see [AudioEncoding][google.cloud.speech.v1p1beta1.RecognitionConfig.AudioEncoding]. - AudioEncoding encoding = 1; - - // Sample rate in Hertz of the audio data sent in all - // `RecognitionAudio` messages. Valid values are: 8000-48000. - // 16000 is optimal. For best results, set the sampling rate of the audio - // source to 16000 Hz. If that's not possible, use the native sample rate of - // the audio source (instead of re-sampling). - // This field is optional for FLAC and WAV audio files, but is - // required for all other audio formats. For details, see [AudioEncoding][google.cloud.speech.v1p1beta1.RecognitionConfig.AudioEncoding]. - int32 sample_rate_hertz = 2; - - // The number of channels in the input audio data. - // ONLY set this for MULTI-CHANNEL recognition. - // Valid values for LINEAR16 and FLAC are `1`-`8`. - // Valid values for OGG_OPUS are '1'-'254'. - // Valid value for MULAW, AMR, AMR_WB and SPEEX_WITH_HEADER_BYTE is only `1`. - // If `0` or omitted, defaults to one channel (mono). - // Note: We only recognize the first channel by default. - // To perform independent recognition on each channel set - // `enable_separate_recognition_per_channel` to 'true'. - int32 audio_channel_count = 7; - - // This needs to be set to `true` explicitly and `audio_channel_count` > 1 - // to get each channel recognized separately. The recognition result will - // contain a `channel_tag` field to state which channel that result belongs - // to. If this is not true, we will only recognize the first channel. The - // request is billed cumulatively for all channels recognized: - // `audio_channel_count` multiplied by the length of the audio. - bool enable_separate_recognition_per_channel = 12; - - // Required. The language of the supplied audio as a - // [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag. - // Example: "en-US". - // See [Language - // Support](https://cloud.google.com/speech-to-text/docs/languages) for a list - // of the currently supported language codes. - string language_code = 3 [(google.api.field_behavior) = REQUIRED]; - - // A list of up to 3 additional - // [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tags, - // listing possible alternative languages of the supplied audio. - // See [Language - // Support](https://cloud.google.com/speech-to-text/docs/languages) for a list - // of the currently supported language codes. If alternative languages are - // listed, recognition result will contain recognition in the most likely - // language detected including the main language_code. The recognition result - // will include the language tag of the language detected in the audio. Note: - // This feature is only supported for Voice Command and Voice Search use cases - // and performance may vary for other use cases (e.g., phone call - // transcription). - repeated string alternative_language_codes = 18; - - // Maximum number of recognition hypotheses to be returned. - // Specifically, the maximum number of `SpeechRecognitionAlternative` messages - // within each `SpeechRecognitionResult`. - // The server may return fewer than `max_alternatives`. - // Valid values are `0`-`30`. A value of `0` or `1` will return a maximum of - // one. If omitted, will return a maximum of one. - int32 max_alternatives = 4; - - // If set to `true`, the server will attempt to filter out - // profanities, replacing all but the initial character in each filtered word - // with asterisks, e.g. "f***". If set to `false` or omitted, profanities - // won't be filtered out. - bool profanity_filter = 5; - - // Speech adaptation configuration improves the accuracy of speech - // recognition. For more information, see the [speech - // adaptation](https://cloud.google.com/speech-to-text/docs/adaptation) - // documentation. - // When speech adaptation is set it supersedes the `speech_contexts` field. - SpeechAdaptation adaptation = 20; - - // Use transcription normalization to automatically replace parts of the - // transcript with phrases of your choosing. For StreamingRecognize, this - // normalization only applies to stable partial transcripts (stability > 0.8) - // and final transcripts. - TranscriptNormalization transcript_normalization = 24; - - // Array of [SpeechContext][google.cloud.speech.v1p1beta1.SpeechContext]. - // A means to provide context to assist the speech recognition. For more - // information, see - // [speech - // adaptation](https://cloud.google.com/speech-to-text/docs/adaptation). - repeated SpeechContext speech_contexts = 6; - - // If `true`, the top result includes a list of words and - // the start and end time offsets (timestamps) for those words. If - // `false`, no word-level time offset information is returned. The default is - // `false`. - bool enable_word_time_offsets = 8; - - // If `true`, the top result includes a list of words and the - // confidence for those words. If `false`, no word-level confidence - // information is returned. The default is `false`. - bool enable_word_confidence = 15; - - // If 'true', adds punctuation to recognition result hypotheses. - // This feature is only available in select languages. Setting this for - // requests in other languages has no effect at all. - // The default 'false' value does not add punctuation to result hypotheses. - bool enable_automatic_punctuation = 11; - - // The spoken punctuation behavior for the call - // If not set, uses default behavior based on model of choice - // e.g. command_and_search will enable spoken punctuation by default - // If 'true', replaces spoken punctuation with the corresponding symbols in - // the request. For example, "how are you question mark" becomes "how are - // you?". See https://cloud.google.com/speech-to-text/docs/spoken-punctuation - // for support. If 'false', spoken punctuation is not replaced. - google.protobuf.BoolValue enable_spoken_punctuation = 22; - - // The spoken emoji behavior for the call - // If not set, uses default behavior based on model of choice - // If 'true', adds spoken emoji formatting for the request. This will replace - // spoken emojis with the corresponding Unicode symbols in the final - // transcript. If 'false', spoken emojis are not replaced. - google.protobuf.BoolValue enable_spoken_emojis = 23; - - // If 'true', enables speaker detection for each recognized word in - // the top alternative of the recognition result using a speaker_tag provided - // in the WordInfo. - // Note: Use diarization_config instead. - bool enable_speaker_diarization = 16 [deprecated = true]; - - // If set, specifies the estimated number of speakers in the conversation. - // Defaults to '2'. Ignored unless enable_speaker_diarization is set to true. - // Note: Use diarization_config instead. - int32 diarization_speaker_count = 17 [deprecated = true]; - - // Config to enable speaker diarization and set additional - // parameters to make diarization better suited for your application. - // Note: When this is enabled, we send all the words from the beginning of the - // audio for the top alternative in every consecutive STREAMING responses. - // This is done in order to improve our speaker tags as our models learn to - // identify the speakers in the conversation over time. - // For non-streaming requests, the diarization results will be provided only - // in the top alternative of the FINAL SpeechRecognitionResult. - SpeakerDiarizationConfig diarization_config = 19; - - // Metadata regarding this request. - RecognitionMetadata metadata = 9; - - // Which model to select for the given request. Select the model - // best suited to your domain to get best results. If a model is not - // explicitly specified, then we auto-select a model based on the parameters - // in the RecognitionConfig. - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - //
ModelDescription
latest_longBest for long form content like media or conversation.
latest_shortBest for short form content like commands or single shot directed - // speech.
command_and_searchBest for short queries such as voice commands or voice search.
phone_callBest for audio that originated from a phone call (typically - // recorded at an 8khz sampling rate).
videoBest for audio that originated from video or includes multiple - // speakers. Ideally the audio is recorded at a 16khz or greater - // sampling rate. This is a premium model that costs more than the - // standard rate.
defaultBest for audio that is not one of the specific audio models. - // For example, long-form audio. Ideally the audio is high-fidelity, - // recorded at a 16khz or greater sampling rate.
medical_conversationBest for audio that originated from a conversation between a - // medical provider and patient.
medical_dictationBest for audio that originated from dictation notes by a medical - // provider.
- string model = 13; - - // Set to true to use an enhanced model for speech recognition. - // If `use_enhanced` is set to true and the `model` field is not set, then - // an appropriate enhanced model is chosen if an enhanced model exists for - // the audio. - // - // If `use_enhanced` is true and an enhanced version of the specified model - // does not exist, then the speech is recognized using the standard version - // of the specified model. - bool use_enhanced = 14; -} - -// Config to enable speaker diarization. -message SpeakerDiarizationConfig { - // If 'true', enables speaker detection for each recognized word in - // the top alternative of the recognition result using a speaker_tag provided - // in the WordInfo. - bool enable_speaker_diarization = 1; - - // Minimum number of speakers in the conversation. This range gives you more - // flexibility by allowing the system to automatically determine the correct - // number of speakers. If not set, the default value is 2. - int32 min_speaker_count = 2; - - // Maximum number of speakers in the conversation. This range gives you more - // flexibility by allowing the system to automatically determine the correct - // number of speakers. If not set, the default value is 6. - int32 max_speaker_count = 3; - - // Output only. Unused. - int32 speaker_tag = 5 [ - deprecated = true, - (google.api.field_behavior) = OUTPUT_ONLY - ]; -} - -// Description of audio data to be recognized. -message RecognitionMetadata { - option deprecated = true; - - // Use case categories that the audio recognition request can be described - // by. - enum InteractionType { - // Use case is either unknown or is something other than one of the other - // values below. - INTERACTION_TYPE_UNSPECIFIED = 0; - - // Multiple people in a conversation or discussion. For example in a - // meeting with two or more people actively participating. Typically - // all the primary people speaking would be in the same room (if not, - // see PHONE_CALL) - DISCUSSION = 1; - - // One or more persons lecturing or presenting to others, mostly - // uninterrupted. - PRESENTATION = 2; - - // A phone-call or video-conference in which two or more people, who are - // not in the same room, are actively participating. - PHONE_CALL = 3; - - // A recorded message intended for another person to listen to. - VOICEMAIL = 4; - - // Professionally produced audio (eg. TV Show, Podcast). - PROFESSIONALLY_PRODUCED = 5; - - // Transcribe spoken questions and queries into text. - VOICE_SEARCH = 6; - - // Transcribe voice commands, such as for controlling a device. - VOICE_COMMAND = 7; - - // Transcribe speech to text to create a written document, such as a - // text-message, email or report. - DICTATION = 8; - } - - // Enumerates the types of capture settings describing an audio file. - enum MicrophoneDistance { - // Audio type is not known. - MICROPHONE_DISTANCE_UNSPECIFIED = 0; - - // The audio was captured from a closely placed microphone. Eg. phone, - // dictaphone, or handheld microphone. Generally if there speaker is within - // 1 meter of the microphone. - NEARFIELD = 1; - - // The speaker if within 3 meters of the microphone. - MIDFIELD = 2; - - // The speaker is more than 3 meters away from the microphone. - FARFIELD = 3; - } - - // The original media the speech was recorded on. - enum OriginalMediaType { - // Unknown original media type. - ORIGINAL_MEDIA_TYPE_UNSPECIFIED = 0; - - // The speech data is an audio recording. - AUDIO = 1; - - // The speech data originally recorded on a video. - VIDEO = 2; - } - - // The type of device the speech was recorded with. - enum RecordingDeviceType { - // The recording device is unknown. - RECORDING_DEVICE_TYPE_UNSPECIFIED = 0; - - // Speech was recorded on a smartphone. - SMARTPHONE = 1; - - // Speech was recorded using a personal computer or tablet. - PC = 2; - - // Speech was recorded over a phone line. - PHONE_LINE = 3; - - // Speech was recorded in a vehicle. - VEHICLE = 4; - - // Speech was recorded outdoors. - OTHER_OUTDOOR_DEVICE = 5; - - // Speech was recorded indoors. - OTHER_INDOOR_DEVICE = 6; - } - - // The use case most closely describing the audio content to be recognized. - InteractionType interaction_type = 1; - - // The industry vertical to which this speech recognition request most - // closely applies. This is most indicative of the topics contained - // in the audio. Use the 6-digit NAICS code to identify the industry - // vertical - see https://www.naics.com/search/. - uint32 industry_naics_code_of_audio = 3; - - // The audio type that most closely describes the audio being recognized. - MicrophoneDistance microphone_distance = 4; - - // The original media the speech was recorded on. - OriginalMediaType original_media_type = 5; - - // The type of device the speech was recorded with. - RecordingDeviceType recording_device_type = 6; - - // The device used to make the recording. Examples 'Nexus 5X' or - // 'Polycom SoundStation IP 6000' or 'POTS' or 'VoIP' or - // 'Cardioid Microphone'. - string recording_device_name = 7; - - // Mime type of the original audio file. For example `audio/m4a`, - // `audio/x-alaw-basic`, `audio/mp3`, `audio/3gpp`. - // A list of possible audio mime types is maintained at - // http://www.iana.org/assignments/media-types/media-types.xhtml#audio - string original_mime_type = 8; - - // Obfuscated (privacy-protected) ID of the user, to identify number of - // unique users using the service. - int64 obfuscated_id = 9 [deprecated = true]; - - // Description of the content. Eg. "Recordings of federal supreme court - // hearings from 2012". - string audio_topic = 10; -} - -// Provides "hints" to the speech recognizer to favor specific words and phrases -// in the results. -message SpeechContext { - // A list of strings containing words and phrases "hints" so that - // the speech recognition is more likely to recognize them. This can be used - // to improve the accuracy for specific words and phrases, for example, if - // specific commands are typically spoken by the user. This can also be used - // to add additional words to the vocabulary of the recognizer. See - // [usage limits](https://cloud.google.com/speech-to-text/quotas#content). - // - // List items can also be set to classes for groups of words that represent - // common concepts that occur in natural language. For example, rather than - // providing phrase hints for every month of the year, using the $MONTH class - // improves the likelihood of correctly transcribing audio that includes - // months. - repeated string phrases = 1; - - // Hint Boost. Positive value will increase the probability that a specific - // phrase will be recognized over other similar sounding phrases. The higher - // the boost, the higher the chance of false positive recognition as well. - // Negative boost values would correspond to anti-biasing. Anti-biasing is not - // enabled, so negative boost will simply be ignored. Though `boost` can - // accept a wide range of positive values, most use cases are best served with - // values between 0 and 20. We recommend using a binary search approach to - // finding the optimal value for your use case. - float boost = 4; -} - -// Contains audio data in the encoding specified in the `RecognitionConfig`. -// Either `content` or `uri` must be supplied. Supplying both or neither -// returns [google.rpc.Code.INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT]. See -// [content limits](https://cloud.google.com/speech-to-text/quotas#content). -message RecognitionAudio { - // The audio source, which is either inline content or a Google Cloud - // Storage uri. - oneof audio_source { - // The audio data bytes encoded as specified in - // `RecognitionConfig`. Note: as with all bytes fields, proto buffers use a - // pure binary representation, whereas JSON representations use base64. - bytes content = 1; - - // URI that points to a file that contains audio data bytes as specified in - // `RecognitionConfig`. The file must not be compressed (for example, gzip). - // Currently, only Google Cloud Storage URIs are - // supported, which must be specified in the following format: - // `gs://bucket_name/object_name` (other URI formats return - // [google.rpc.Code.INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT]). For more information, see - // [Request URIs](https://cloud.google.com/storage/docs/reference-uris). - string uri = 2; - } -} - -// The only message returned to the client by the `Recognize` method. It -// contains the result as zero or more sequential `SpeechRecognitionResult` -// messages. -message RecognizeResponse { - // Sequential list of transcription results corresponding to - // sequential portions of audio. - repeated SpeechRecognitionResult results = 2; - - // When available, billed audio seconds for the corresponding request. - google.protobuf.Duration total_billed_time = 3; -} - -// The only message returned to the client by the `LongRunningRecognize` method. -// It contains the result as zero or more sequential `SpeechRecognitionResult` -// messages. It is included in the `result.response` field of the `Operation` -// returned by the `GetOperation` call of the `google::longrunning::Operations` -// service. -message LongRunningRecognizeResponse { - // Sequential list of transcription results corresponding to - // sequential portions of audio. - repeated SpeechRecognitionResult results = 2; - - // When available, billed audio seconds for the corresponding request. - google.protobuf.Duration total_billed_time = 3; - - // Original output config if present in the request. - TranscriptOutputConfig output_config = 6; - - // If the transcript output fails this field contains the relevant error. - google.rpc.Status output_error = 7; -} - -// Describes the progress of a long-running `LongRunningRecognize` call. It is -// included in the `metadata` field of the `Operation` returned by the -// `GetOperation` call of the `google::longrunning::Operations` service. -message LongRunningRecognizeMetadata { - // Approximate percentage of audio processed thus far. Guaranteed to be 100 - // when the audio is fully processed and the results are available. - int32 progress_percent = 1; - - // Time when the request was received. - google.protobuf.Timestamp start_time = 2; - - // Time of the most recent processing update. - google.protobuf.Timestamp last_update_time = 3; - - // Output only. The URI of the audio file being transcribed. Empty if the audio was sent - // as byte content. - string uri = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. A copy of the TranscriptOutputConfig if it was set in the request. - TranscriptOutputConfig output_config = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// `StreamingRecognizeResponse` is the only message returned to the client by -// `StreamingRecognize`. A series of zero or more `StreamingRecognizeResponse` -// messages are streamed back to the client. If there is no recognizable -// audio, and `single_utterance` is set to false, then no messages are streamed -// back to the client. -// -// Here's an example of a series of `StreamingRecognizeResponse`s that might be -// returned while processing audio: -// -// 1. results { alternatives { transcript: "tube" } stability: 0.01 } -// -// 2. results { alternatives { transcript: "to be a" } stability: 0.01 } -// -// 3. results { alternatives { transcript: "to be" } stability: 0.9 } -// results { alternatives { transcript: " or not to be" } stability: 0.01 } -// -// 4. results { alternatives { transcript: "to be or not to be" -// confidence: 0.92 } -// alternatives { transcript: "to bee or not to bee" } -// is_final: true } -// -// 5. results { alternatives { transcript: " that's" } stability: 0.01 } -// -// 6. results { alternatives { transcript: " that is" } stability: 0.9 } -// results { alternatives { transcript: " the question" } stability: 0.01 } -// -// 7. results { alternatives { transcript: " that is the question" -// confidence: 0.98 } -// alternatives { transcript: " that was the question" } -// is_final: true } -// -// Notes: -// -// - Only two of the above responses #4 and #7 contain final results; they are -// indicated by `is_final: true`. Concatenating these together generates the -// full transcript: "to be or not to be that is the question". -// -// - The others contain interim `results`. #3 and #6 contain two interim -// `results`: the first portion has a high stability and is less likely to -// change; the second portion has a low stability and is very likely to -// change. A UI designer might choose to show only high stability `results`. -// -// - The specific `stability` and `confidence` values shown above are only for -// illustrative purposes. Actual values may vary. -// -// - In each response, only one of these fields will be set: -// `error`, -// `speech_event_type`, or -// one or more (repeated) `results`. -message StreamingRecognizeResponse { - // Indicates the type of speech event. - enum SpeechEventType { - // No speech event specified. - SPEECH_EVENT_UNSPECIFIED = 0; - - // This event indicates that the server has detected the end of the user's - // speech utterance and expects no additional speech. Therefore, the server - // will not process additional audio (although it may subsequently return - // additional results). The client should stop sending additional audio - // data, half-close the gRPC connection, and wait for any additional results - // until the server closes the gRPC connection. This event is only sent if - // `single_utterance` was set to `true`, and is not used otherwise. - END_OF_SINGLE_UTTERANCE = 1; - } - - // If set, returns a [google.rpc.Status][google.rpc.Status] message that - // specifies the error for the operation. - google.rpc.Status error = 1; - - // This repeated list contains zero or more results that - // correspond to consecutive portions of the audio currently being processed. - // It contains zero or one `is_final=true` result (the newly settled portion), - // followed by zero or more `is_final=false` results (the interim results). - repeated StreamingRecognitionResult results = 2; - - // Indicates the type of speech event. - SpeechEventType speech_event_type = 4; - - // When available, billed audio seconds for the stream. - // Set only if this is the last response in the stream. - google.protobuf.Duration total_billed_time = 5; -} - -// A streaming speech recognition result corresponding to a portion of the audio -// that is currently being processed. -message StreamingRecognitionResult { - // May contain one or more recognition hypotheses (up to the - // maximum specified in `max_alternatives`). - // These alternatives are ordered in terms of accuracy, with the top (first) - // alternative being the most probable, as ranked by the recognizer. - repeated SpeechRecognitionAlternative alternatives = 1; - - // If `false`, this `StreamingRecognitionResult` represents an - // interim result that may change. If `true`, this is the final time the - // speech service will return this particular `StreamingRecognitionResult`, - // the recognizer will not return any further hypotheses for this portion of - // the transcript and corresponding audio. - bool is_final = 2; - - // An estimate of the likelihood that the recognizer will not - // change its guess about this interim result. Values range from 0.0 - // (completely unstable) to 1.0 (completely stable). - // This field is only provided for interim results (`is_final=false`). - // The default of 0.0 is a sentinel value indicating `stability` was not set. - float stability = 3; - - // Time offset of the end of this result relative to the - // beginning of the audio. - google.protobuf.Duration result_end_time = 4; - - // For multi-channel audio, this is the channel number corresponding to the - // recognized result for the audio from that channel. - // For audio_channel_count = N, its output values can range from '1' to 'N'. - int32 channel_tag = 5; - - // Output only. The [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag - // of the language in this result. This language code was detected to have - // the most likelihood of being spoken in the audio. - string language_code = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// A speech recognition result corresponding to a portion of the audio. -message SpeechRecognitionResult { - // May contain one or more recognition hypotheses (up to the - // maximum specified in `max_alternatives`). - // These alternatives are ordered in terms of accuracy, with the top (first) - // alternative being the most probable, as ranked by the recognizer. - repeated SpeechRecognitionAlternative alternatives = 1; - - // For multi-channel audio, this is the channel number corresponding to the - // recognized result for the audio from that channel. - // For audio_channel_count = N, its output values can range from '1' to 'N'. - int32 channel_tag = 2; - - // Time offset of the end of this result relative to the - // beginning of the audio. - google.protobuf.Duration result_end_time = 4; - - // Output only. The [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag - // of the language in this result. This language code was detected to have - // the most likelihood of being spoken in the audio. - string language_code = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// Alternative hypotheses (a.k.a. n-best list). -message SpeechRecognitionAlternative { - // Transcript text representing the words that the user spoke. - // In languages that use spaces to separate words, the transcript might have a - // leading space if it isn't the first result. You can concatenate each result - // to obtain the full transcript without using a separator. - string transcript = 1; - - // The confidence estimate between 0.0 and 1.0. A higher number - // indicates an estimated greater likelihood that the recognized words are - // correct. This field is set only for the top alternative of a non-streaming - // result or, of a streaming result where `is_final=true`. - // This field is not guaranteed to be accurate and users should not rely on it - // to be always provided. - // The default of 0.0 is a sentinel value indicating `confidence` was not set. - float confidence = 2; - - // A list of word-specific information for each recognized word. - // Note: When `enable_speaker_diarization` is true, you will see all the words - // from the beginning of the audio. - repeated WordInfo words = 3; -} - -// Word-specific information for recognized words. -message WordInfo { - // Time offset relative to the beginning of the audio, - // and corresponding to the start of the spoken word. - // This field is only set if `enable_word_time_offsets=true` and only - // in the top hypothesis. - // This is an experimental feature and the accuracy of the time offset can - // vary. - google.protobuf.Duration start_time = 1; - - // Time offset relative to the beginning of the audio, - // and corresponding to the end of the spoken word. - // This field is only set if `enable_word_time_offsets=true` and only - // in the top hypothesis. - // This is an experimental feature and the accuracy of the time offset can - // vary. - google.protobuf.Duration end_time = 2; - - // The word corresponding to this set of information. - string word = 3; - - // The confidence estimate between 0.0 and 1.0. A higher number - // indicates an estimated greater likelihood that the recognized words are - // correct. This field is set only for the top alternative of a non-streaming - // result or, of a streaming result where `is_final=true`. - // This field is not guaranteed to be accurate and users should not rely on it - // to be always provided. - // The default of 0.0 is a sentinel value indicating `confidence` was not set. - float confidence = 4; - - // Output only. A distinct integer value is assigned for every speaker within - // the audio. This field specifies which one of those speakers was detected to - // have spoken this word. Value ranges from '1' to diarization_speaker_count. - // speaker_tag is set if enable_speaker_diarization = 'true' and only in the - // top alternative. - int32 speaker_tag = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; -} diff --git a/owl-bot-staging/v1p1beta1/protos/google/cloud/speech/v1p1beta1/cloud_speech_adaptation.proto b/owl-bot-staging/v1p1beta1/protos/google/cloud/speech/v1p1beta1/cloud_speech_adaptation.proto deleted file mode 100644 index 45ca97f2..00000000 --- a/owl-bot-staging/v1p1beta1/protos/google/cloud/speech/v1p1beta1/cloud_speech_adaptation.proto +++ /dev/null @@ -1,370 +0,0 @@ -// Copyright 2022 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 -// -// http://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. - -syntax = "proto3"; - -package google.cloud.speech.v1p1beta1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/speech/v1p1beta1/resource.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/speech/v1p1beta1;speech"; -option java_multiple_files = true; -option java_outer_classname = "SpeechAdaptationProto"; -option java_package = "com.google.cloud.speech.v1p1beta1"; -option objc_class_prefix = "GCS"; - -// Service that implements Google Cloud Speech Adaptation API. -service Adaptation { - option (google.api.default_host) = "speech.googleapis.com"; - option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; - - // 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. - rpc CreatePhraseSet(CreatePhraseSetRequest) returns (PhraseSet) { - option (google.api.http) = { - post: "/v1p1beta1/{parent=projects/*/locations/*}/phraseSets" - body: "*" - }; - option (google.api.method_signature) = "parent,phrase_set,phrase_set_id"; - } - - // Get a phrase set. - rpc GetPhraseSet(GetPhraseSetRequest) returns (PhraseSet) { - option (google.api.http) = { - get: "/v1p1beta1/{name=projects/*/locations/*/phraseSets/*}" - }; - option (google.api.method_signature) = "name"; - } - - // List phrase sets. - rpc ListPhraseSet(ListPhraseSetRequest) returns (ListPhraseSetResponse) { - option (google.api.http) = { - get: "/v1p1beta1/{parent=projects/*/locations/*}/phraseSets" - }; - option (google.api.method_signature) = "parent"; - } - - // Update a phrase set. - rpc UpdatePhraseSet(UpdatePhraseSetRequest) returns (PhraseSet) { - option (google.api.http) = { - patch: "/v1p1beta1/{phrase_set.name=projects/*/locations/*/phraseSets/*}" - body: "phrase_set" - }; - option (google.api.method_signature) = "phrase_set,update_mask"; - } - - // Delete a phrase set. - rpc DeletePhraseSet(DeletePhraseSetRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1p1beta1/{name=projects/*/locations/*/phraseSets/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Create a custom class. - rpc CreateCustomClass(CreateCustomClassRequest) returns (CustomClass) { - option (google.api.http) = { - post: "/v1p1beta1/{parent=projects/*/locations/*}/customClasses" - body: "*" - }; - option (google.api.method_signature) = "parent,custom_class,custom_class_id"; - } - - // Get a custom class. - rpc GetCustomClass(GetCustomClassRequest) returns (CustomClass) { - option (google.api.http) = { - get: "/v1p1beta1/{name=projects/*/locations/*/customClasses/*}" - }; - option (google.api.method_signature) = "name"; - } - - // List custom classes. - rpc ListCustomClasses(ListCustomClassesRequest) returns (ListCustomClassesResponse) { - option (google.api.http) = { - get: "/v1p1beta1/{parent=projects/*/locations/*}/customClasses" - }; - option (google.api.method_signature) = "parent"; - } - - // Update a custom class. - rpc UpdateCustomClass(UpdateCustomClassRequest) returns (CustomClass) { - option (google.api.http) = { - patch: "/v1p1beta1/{custom_class.name=projects/*/locations/*/customClasses/*}" - body: "custom_class" - }; - option (google.api.method_signature) = "custom_class,update_mask"; - } - - // Delete a custom class. - rpc DeleteCustomClass(DeleteCustomClassRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1p1beta1/{name=projects/*/locations/*/customClasses/*}" - }; - option (google.api.method_signature) = "name"; - } -} - -// Message sent by the client for the `CreatePhraseSet` method. -message CreatePhraseSetRequest { - // Required. The parent resource where this phrase set will be created. Format: - // - // `projects/{project}/locations/{location}/phraseSets` - // - // Speech-to-Text supports three locations: `global`, `us` (US North America), - // and `eu` (Europe). If you are calling the `speech.googleapis.com` - // endpoint, use the `global` location. To specify a region, use a - // [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - // with matching `us` or `eu` location value. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "speech.googleapis.com/PhraseSet" - } - ]; - - // Required. The ID to use for the phrase set, which will become the final - // component of the phrase set's resource name. - // - // This value should restrict to letters, numbers, and hyphens, with the first - // character a letter, the last a letter or a number, and be 4-63 characters. - string phrase_set_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The phrase set to create. - PhraseSet phrase_set = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Message sent by the client for the `UpdatePhraseSet` method. -message UpdatePhraseSetRequest { - // Required. The phrase set to update. - // - // The phrase set's `name` field is used to identify the set to be - // updated. Format: - // - // `projects/{project}/locations/{location}/phraseSets/{phrase_set}` - // - // Speech-to-Text supports three locations: `global`, `us` (US North America), - // and `eu` (Europe). If you are calling the `speech.googleapis.com` - // endpoint, use the `global` location. To specify a region, use a - // [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - // with matching `us` or `eu` location value. - PhraseSet phrase_set = 1 [(google.api.field_behavior) = REQUIRED]; - - // The list of fields to be updated. - google.protobuf.FieldMask update_mask = 2; -} - -// Message sent by the client for the `GetPhraseSet` method. -message GetPhraseSetRequest { - // Required. The name of the phrase set to retrieve. Format: - // - // `projects/{project}/locations/{location}/phraseSets/{phrase_set}` - // - // Speech-to-Text supports three locations: `global`, `us` (US North America), - // and `eu` (Europe). If you are calling the `speech.googleapis.com` - // endpoint, use the `global` location. To specify a region, use a - // [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - // with matching `us` or `eu` location value. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "speech.googleapis.com/PhraseSet" - } - ]; -} - -// Message sent by the client for the `ListPhraseSet` method. -message ListPhraseSetRequest { - // Required. The parent, which owns this collection of phrase set. Format: - // - // `projects/{project}/locations/{location}` - // - // Speech-to-Text supports three locations: `global`, `us` (US North America), - // and `eu` (Europe). If you are calling the `speech.googleapis.com` - // endpoint, use the `global` location. To specify a region, use a - // [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - // with matching `us` or `eu` location value. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "speech.googleapis.com/PhraseSet" - } - ]; - - // 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. - int32 page_size = 2; - - // 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. - string page_token = 3; -} - -// Message returned to the client by the `ListPhraseSet` method. -message ListPhraseSetResponse { - // The phrase set. - repeated PhraseSet phrase_sets = 1; - - // A token, which can be sent as `page_token` to retrieve the next page. - // If this field is omitted, there are no subsequent pages. - string next_page_token = 2; -} - -// Message sent by the client for the `DeletePhraseSet` method. -message DeletePhraseSetRequest { - // Required. The name of the phrase set to delete. Format: - // - // `projects/{project}/locations/{location}/phraseSets/{phrase_set}` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "speech.googleapis.com/PhraseSet" - } - ]; -} - -// Message sent by the client for the `CreateCustomClass` method. -message CreateCustomClassRequest { - // Required. The parent resource where this custom class will be created. Format: - // - // `projects/{project}/locations/{location}/customClasses` - // - // Speech-to-Text supports three locations: `global`, `us` (US North America), - // and `eu` (Europe). If you are calling the `speech.googleapis.com` - // endpoint, use the `global` location. To specify a region, use a - // [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - // with matching `us` or `eu` location value. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "speech.googleapis.com/CustomClass" - } - ]; - - // Required. The ID to use for the custom class, which will become the final - // component of the custom class' resource name. - // - // This value should restrict to letters, numbers, and hyphens, with the first - // character a letter, the last a letter or a number, and be 4-63 characters. - string custom_class_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The custom class to create. - CustomClass custom_class = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Message sent by the client for the `UpdateCustomClass` method. -message UpdateCustomClassRequest { - // Required. The custom class to update. - // - // The custom class's `name` field is used to identify the custom class to be - // updated. Format: - // - // `projects/{project}/locations/{location}/customClasses/{custom_class}` - // - // Speech-to-Text supports three locations: `global`, `us` (US North America), - // and `eu` (Europe). If you are calling the `speech.googleapis.com` - // endpoint, use the `global` location. To specify a region, use a - // [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - // with matching `us` or `eu` location value. - CustomClass custom_class = 1 [(google.api.field_behavior) = REQUIRED]; - - // The list of fields to be updated. - google.protobuf.FieldMask update_mask = 2; -} - -// Message sent by the client for the `GetCustomClass` method. -message GetCustomClassRequest { - // Required. The name of the custom class to retrieve. Format: - // - // `projects/{project}/locations/{location}/customClasses/{custom_class}` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "speech.googleapis.com/CustomClass" - } - ]; -} - -// Message sent by the client for the `ListCustomClasses` method. -message ListCustomClassesRequest { - // Required. The parent, which owns this collection of custom classes. Format: - // - // `projects/{project}/locations/{location}/customClasses` - // - // Speech-to-Text supports three locations: `global`, `us` (US North America), - // and `eu` (Europe). If you are calling the `speech.googleapis.com` - // endpoint, use the `global` location. To specify a region, use a - // [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - // with matching `us` or `eu` location value. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "speech.googleapis.com/CustomClass" - } - ]; - - // 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. - int32 page_size = 2; - - // 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. - string page_token = 3; -} - -// Message returned to the client by the `ListCustomClasses` method. -message ListCustomClassesResponse { - // The custom classes. - repeated CustomClass custom_classes = 1; - - // A token, which can be sent as `page_token` to retrieve the next page. - // If this field is omitted, there are no subsequent pages. - string next_page_token = 2; -} - -// Message sent by the client for the `DeleteCustomClass` method. -message DeleteCustomClassRequest { - // Required. The name of the custom class to delete. Format: - // - // `projects/{project}/locations/{location}/customClasses/{custom_class}` - // - // Speech-to-Text supports three locations: `global`, `us` (US North America), - // and `eu` (Europe). If you are calling the `speech.googleapis.com` - // endpoint, use the `global` location. To specify a region, use a - // [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - // with matching `us` or `eu` location value. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "speech.googleapis.com/CustomClass" - } - ]; -} diff --git a/owl-bot-staging/v1p1beta1/protos/google/cloud/speech/v1p1beta1/resource.proto b/owl-bot-staging/v1p1beta1/protos/google/cloud/speech/v1p1beta1/resource.proto deleted file mode 100644 index 0323b19e..00000000 --- a/owl-bot-staging/v1p1beta1/protos/google/cloud/speech/v1p1beta1/resource.proto +++ /dev/null @@ -1,162 +0,0 @@ -// Copyright 2022 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 -// -// http://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. - -syntax = "proto3"; - -package google.cloud.speech.v1p1beta1; - -import "google/api/resource.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/speech/v1p1beta1;speech"; -option java_multiple_files = true; -option java_outer_classname = "SpeechResourceProto"; -option java_package = "com.google.cloud.speech.v1p1beta1"; -option objc_class_prefix = "GCS"; - -// A set of words or phrases that represents a common concept likely to appear -// in your audio, for example a list of passenger ship names. CustomClass items -// can be substituted into placeholders that you set in PhraseSet phrases. -message CustomClass { - option (google.api.resource) = { - type: "speech.googleapis.com/CustomClass" - pattern: "projects/{project}/locations/{location}/customClasses/{custom_class}" - }; - - // An item of the class. - message ClassItem { - // The class item's value. - string value = 1; - } - - // The resource name of the custom class. - string name = 1; - - // If this custom class is a resource, the custom_class_id is the resource id - // of the CustomClass. Case sensitive. - string custom_class_id = 2; - - // A collection of class items. - repeated ClassItem items = 3; -} - -// Provides "hints" to the speech recognizer to favor specific words and phrases -// in the results. -message PhraseSet { - option (google.api.resource) = { - type: "speech.googleapis.com/PhraseSet" - pattern: "projects/{project}/locations/{location}/phraseSets/{phrase_set}" - }; - - // A phrases containing words and phrase "hints" so that - // the speech recognition is more likely to recognize them. This can be used - // to improve the accuracy for specific words and phrases, for example, if - // specific commands are typically spoken by the user. This can also be used - // to add additional words to the vocabulary of the recognizer. See - // [usage limits](https://cloud.google.com/speech-to-text/quotas#content). - // - // List items can also include pre-built or custom classes containing groups - // of words that represent common concepts that occur in natural language. For - // example, rather than providing a phrase hint for every month of the - // year (e.g. "i was born in january", "i was born in febuary", ...), use the - // pre-built `$MONTH` class improves the likelihood of correctly transcribing - // audio that includes months (e.g. "i was born in $month"). - // To refer to pre-built classes, use the class' symbol prepended with `$` - // e.g. `$MONTH`. To refer to custom classes that were defined inline in the - // request, set the class's `custom_class_id` to a string unique to all class - // resources and inline classes. Then use the class' id wrapped in $`{...}` - // e.g. "${my-months}". To refer to custom classes resources, use the class' - // id wrapped in `${}` (e.g. `${my-months}`). - // - // Speech-to-Text supports three locations: `global`, `us` (US North America), - // and `eu` (Europe). If you are calling the `speech.googleapis.com` - // endpoint, use the `global` location. To specify a region, use a - // [regional endpoint](/speech-to-text/docs/endpoints) with matching `us` or - // `eu` location value. - message Phrase { - // The phrase itself. - string value = 1; - - // Hint Boost. Overrides the boost set at the phrase set level. - // Positive value will increase the probability that a specific phrase will - // be recognized over other similar sounding phrases. The higher the boost, - // the higher the chance of false positive recognition as well. Negative - // boost will simply be ignored. Though `boost` can accept a wide range of - // positive values, most use cases are best served - // with values between 0 and 20. We recommend using a binary search approach - // to finding the optimal value for your use case. Speech recognition - // will skip PhraseSets with a boost value of 0. - float boost = 2; - } - - // The resource name of the phrase set. - string name = 1; - - // A list of word and phrases. - repeated Phrase phrases = 2; - - // Hint Boost. Positive value will increase the probability that a specific - // phrase will be recognized over other similar sounding phrases. The higher - // the boost, the higher the chance of false positive recognition as well. - // Negative boost values would correspond to anti-biasing. Anti-biasing is not - // enabled, so negative boost will simply be ignored. Though `boost` can - // accept a wide range of positive values, most use cases are best served with - // values between 0 (exclusive) and 20. We recommend using a binary search - // approach to finding the optimal value for your use case. Speech recognition - // will skip PhraseSets with a boost value of 0. - float boost = 4; -} - -// Speech adaptation configuration. -message SpeechAdaptation { - // A collection of phrase sets. To specify the hints inline, leave the - // phrase set's `name` blank and fill in the rest of its fields. Any - // phrase set can use any custom class. - repeated PhraseSet phrase_sets = 1; - - // A collection of phrase set resource names to use. - repeated string phrase_set_references = 2 [(google.api.resource_reference) = { - type: "speech.googleapis.com/PhraseSet" - }]; - - // A collection of custom classes. To specify the classes inline, leave the - // class' `name` blank and fill in the rest of its fields, giving it a unique - // `custom_class_id`. Refer to the inline defined class in phrase hints by its - // `custom_class_id`. - repeated CustomClass custom_classes = 3; -} - -// Transcription normalization configuration. Use transcription normalization -// to automatically replace parts of the transcript with phrases of your -// choosing. For StreamingRecognize, this normalization only applies to stable -// partial transcripts (stability > 0.8) and final transcripts. -message TranscriptNormalization { - // A single replacement configuration. - message Entry { - // What to replace. Max length is 100 characters. - string search = 1; - - // What to replace with. Max length is 100 characters. - string replace = 2; - - // Whether the search is case sensitive. - bool case_sensitive = 3; - } - - // A list of replacement entries. We will perform replacement with one entry - // at a time. For example, the second entry in ["cat" => "dog", "mountain cat" - // => "mountain dog"] will never be applied because we will always process the - // first entry before it. At most 100 entries. - repeated Entry entries = 1; -} diff --git a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.create_custom_class.js b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.create_custom_class.js deleted file mode 100644 index 0429b977..00000000 --- a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.create_custom_class.js +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2022 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. ** - - - -'use strict'; - -function main(parent, customClassId, customClass) { - // [START speech_v1p1beta1_generated_Adaptation_CreateCustomClass_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent resource where this custom class will be created. Format: - * `projects/{project}/locations/{location}/customClasses` - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * regional endpoint (https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - */ - // const parent = 'abc123' - /** - * Required. The ID to use for the custom class, which will become the final - * component of the custom class' resource name. - * This value should restrict to letters, numbers, and hyphens, with the first - * character a letter, the last a letter or a number, and be 4-63 characters. - */ - // const customClassId = 'abc123' - /** - * Required. The custom class to create. - */ - // const customClass = {} - - // Imports the Speech library - const {AdaptationClient} = require('@google-cloud/speech').v1p1beta1; - - // Instantiates a client - const speechClient = new AdaptationClient(); - - async function callCreateCustomClass() { - // Construct request - const request = { - parent, - customClassId, - customClass, - }; - - // Run request - const response = await speechClient.createCustomClass(request); - console.log(response); - } - - callCreateCustomClass(); - // [END speech_v1p1beta1_generated_Adaptation_CreateCustomClass_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.create_phrase_set.js b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.create_phrase_set.js deleted file mode 100644 index 4025a95d..00000000 --- a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.create_phrase_set.js +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2022 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. ** - - - -'use strict'; - -function main(parent, phraseSetId, phraseSet) { - // [START speech_v1p1beta1_generated_Adaptation_CreatePhraseSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent resource where this phrase set will be created. Format: - * `projects/{project}/locations/{location}/phraseSets` - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * regional endpoint (https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - */ - // const parent = 'abc123' - /** - * Required. The ID to use for the phrase set, which will become the final - * component of the phrase set's resource name. - * This value should restrict to letters, numbers, and hyphens, with the first - * character a letter, the last a letter or a number, and be 4-63 characters. - */ - // const phraseSetId = 'abc123' - /** - * Required. The phrase set to create. - */ - // const phraseSet = {} - - // Imports the Speech library - const {AdaptationClient} = require('@google-cloud/speech').v1p1beta1; - - // Instantiates a client - const speechClient = new AdaptationClient(); - - async function callCreatePhraseSet() { - // Construct request - const request = { - parent, - phraseSetId, - phraseSet, - }; - - // Run request - const response = await speechClient.createPhraseSet(request); - console.log(response); - } - - callCreatePhraseSet(); - // [END speech_v1p1beta1_generated_Adaptation_CreatePhraseSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.delete_custom_class.js b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.delete_custom_class.js deleted file mode 100644 index 47693ff1..00000000 --- a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.delete_custom_class.js +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2022 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. ** - - - -'use strict'; - -function main(name) { - // [START speech_v1p1beta1_generated_Adaptation_DeleteCustomClass_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The name of the custom class to delete. Format: - * `projects/{project}/locations/{location}/customClasses/{custom_class}` - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * regional endpoint (https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - */ - // const name = 'abc123' - - // Imports the Speech library - const {AdaptationClient} = require('@google-cloud/speech').v1p1beta1; - - // Instantiates a client - const speechClient = new AdaptationClient(); - - async function callDeleteCustomClass() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await speechClient.deleteCustomClass(request); - console.log(response); - } - - callDeleteCustomClass(); - // [END speech_v1p1beta1_generated_Adaptation_DeleteCustomClass_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.delete_phrase_set.js b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.delete_phrase_set.js deleted file mode 100644 index 76aed0d0..00000000 --- a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.delete_phrase_set.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2022 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. ** - - - -'use strict'; - -function main(name) { - // [START speech_v1p1beta1_generated_Adaptation_DeletePhraseSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The name of the phrase set to delete. Format: - * `projects/{project}/locations/{location}/phraseSets/{phrase_set}` - */ - // const name = 'abc123' - - // Imports the Speech library - const {AdaptationClient} = require('@google-cloud/speech').v1p1beta1; - - // Instantiates a client - const speechClient = new AdaptationClient(); - - async function callDeletePhraseSet() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await speechClient.deletePhraseSet(request); - console.log(response); - } - - callDeletePhraseSet(); - // [END speech_v1p1beta1_generated_Adaptation_DeletePhraseSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.get_custom_class.js b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.get_custom_class.js deleted file mode 100644 index 2e4208b9..00000000 --- a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.get_custom_class.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2022 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. ** - - - -'use strict'; - -function main(name) { - // [START speech_v1p1beta1_generated_Adaptation_GetCustomClass_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The name of the custom class to retrieve. Format: - * `projects/{project}/locations/{location}/customClasses/{custom_class}` - */ - // const name = 'abc123' - - // Imports the Speech library - const {AdaptationClient} = require('@google-cloud/speech').v1p1beta1; - - // Instantiates a client - const speechClient = new AdaptationClient(); - - async function callGetCustomClass() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await speechClient.getCustomClass(request); - console.log(response); - } - - callGetCustomClass(); - // [END speech_v1p1beta1_generated_Adaptation_GetCustomClass_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.get_phrase_set.js b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.get_phrase_set.js deleted file mode 100644 index b94463a1..00000000 --- a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.get_phrase_set.js +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2022 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. ** - - - -'use strict'; - -function main(name) { - // [START speech_v1p1beta1_generated_Adaptation_GetPhraseSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The name of the phrase set to retrieve. Format: - * `projects/{project}/locations/{location}/phraseSets/{phrase_set}` - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * regional endpoint (https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - */ - // const name = 'abc123' - - // Imports the Speech library - const {AdaptationClient} = require('@google-cloud/speech').v1p1beta1; - - // Instantiates a client - const speechClient = new AdaptationClient(); - - async function callGetPhraseSet() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await speechClient.getPhraseSet(request); - console.log(response); - } - - callGetPhraseSet(); - // [END speech_v1p1beta1_generated_Adaptation_GetPhraseSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.list_custom_classes.js b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.list_custom_classes.js deleted file mode 100644 index 8a935c16..00000000 --- a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.list_custom_classes.js +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2022 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. ** - - - -'use strict'; - -function main(parent) { - // [START speech_v1p1beta1_generated_Adaptation_ListCustomClasses_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent, which owns this collection of custom classes. Format: - * `projects/{project}/locations/{location}/customClasses` - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * regional endpoint (https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - */ - // const parent = 'abc123' - /** - * 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. - */ - // const pageSize = 1234 - /** - * 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. - */ - // const pageToken = 'abc123' - - // Imports the Speech library - const {AdaptationClient} = require('@google-cloud/speech').v1p1beta1; - - // Instantiates a client - const speechClient = new AdaptationClient(); - - async function callListCustomClasses() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await speechClient.listCustomClassesAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListCustomClasses(); - // [END speech_v1p1beta1_generated_Adaptation_ListCustomClasses_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.list_phrase_set.js b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.list_phrase_set.js deleted file mode 100644 index 0912eb8f..00000000 --- a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.list_phrase_set.js +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2022 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. ** - - - -'use strict'; - -function main(parent) { - // [START speech_v1p1beta1_generated_Adaptation_ListPhraseSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent, which owns this collection of phrase set. Format: - * `projects/{project}/locations/{location}` - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * regional endpoint (https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - */ - // const parent = 'abc123' - /** - * 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. - */ - // const pageSize = 1234 - /** - * 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. - */ - // const pageToken = 'abc123' - - // Imports the Speech library - const {AdaptationClient} = require('@google-cloud/speech').v1p1beta1; - - // Instantiates a client - const speechClient = new AdaptationClient(); - - async function callListPhraseSet() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await speechClient.listPhraseSetAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListPhraseSet(); - // [END speech_v1p1beta1_generated_Adaptation_ListPhraseSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.update_custom_class.js b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.update_custom_class.js deleted file mode 100644 index 7676ed2a..00000000 --- a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.update_custom_class.js +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2022 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. ** - - - -'use strict'; - -function main(customClass) { - // [START speech_v1p1beta1_generated_Adaptation_UpdateCustomClass_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The custom class to update. - * The custom class's `name` field is used to identify the custom class to be - * updated. Format: - * `projects/{project}/locations/{location}/customClasses/{custom_class}` - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * regional endpoint (https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - */ - // const customClass = {} - /** - * The list of fields to be updated. - */ - // const updateMask = {} - - // Imports the Speech library - const {AdaptationClient} = require('@google-cloud/speech').v1p1beta1; - - // Instantiates a client - const speechClient = new AdaptationClient(); - - async function callUpdateCustomClass() { - // Construct request - const request = { - customClass, - }; - - // Run request - const response = await speechClient.updateCustomClass(request); - console.log(response); - } - - callUpdateCustomClass(); - // [END speech_v1p1beta1_generated_Adaptation_UpdateCustomClass_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.update_phrase_set.js b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.update_phrase_set.js deleted file mode 100644 index 8a8b15a3..00000000 --- a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/adaptation.update_phrase_set.js +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2022 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. ** - - - -'use strict'; - -function main(phraseSet) { - // [START speech_v1p1beta1_generated_Adaptation_UpdatePhraseSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The phrase set to update. - * The phrase set's `name` field is used to identify the set to be - * updated. Format: - * `projects/{project}/locations/{location}/phraseSets/{phrase_set}` - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * regional endpoint (https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - */ - // const phraseSet = {} - /** - * The list of fields to be updated. - */ - // const updateMask = {} - - // Imports the Speech library - const {AdaptationClient} = require('@google-cloud/speech').v1p1beta1; - - // Instantiates a client - const speechClient = new AdaptationClient(); - - async function callUpdatePhraseSet() { - // Construct request - const request = { - phraseSet, - }; - - // Run request - const response = await speechClient.updatePhraseSet(request); - console.log(response); - } - - callUpdatePhraseSet(); - // [END speech_v1p1beta1_generated_Adaptation_UpdatePhraseSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/snippet_metadata.google.cloud.speech.v1p1beta1.json b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/snippet_metadata.google.cloud.speech.v1p1beta1.json deleted file mode 100644 index 5e3b27e4..00000000 --- a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/snippet_metadata.google.cloud.speech.v1p1beta1.json +++ /dev/null @@ -1,591 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-speech", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.speech.v1p1beta1", - "version": "v1p1beta1" - } - ] - }, - "snippets": [ - { - "regionTag": "speech_v1p1beta1_generated_Adaptation_CreatePhraseSet_async", - "title": "Adaptation createPhraseSet Sample", - "origin": "API_DEFINITION", - "description": " 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.", - "canonical": true, - "file": "adaptation.create_phrase_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 72, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreatePhraseSet", - "fullName": "google.cloud.speech.v1p1beta1.Adaptation.CreatePhraseSet", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "phrase_set_id", - "type": "TYPE_STRING" - }, - { - "name": "phrase_set", - "type": ".google.cloud.speech.v1p1beta1.PhraseSet" - } - ], - "resultType": ".google.cloud.speech.v1p1beta1.PhraseSet", - "client": { - "shortName": "AdaptationClient", - "fullName": "google.cloud.speech.v1p1beta1.AdaptationClient" - }, - "method": { - "shortName": "CreatePhraseSet", - "fullName": "google.cloud.speech.v1p1beta1.Adaptation.CreatePhraseSet", - "service": { - "shortName": "Adaptation", - "fullName": "google.cloud.speech.v1p1beta1.Adaptation" - } - } - } - }, - { - "regionTag": "speech_v1p1beta1_generated_Adaptation_GetPhraseSet_async", - "title": "Adaptation getPhraseSet Sample", - "origin": "API_DEFINITION", - "description": " Get a phrase set.", - "canonical": true, - "file": "adaptation.get_phrase_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetPhraseSet", - "fullName": "google.cloud.speech.v1p1beta1.Adaptation.GetPhraseSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.speech.v1p1beta1.PhraseSet", - "client": { - "shortName": "AdaptationClient", - "fullName": "google.cloud.speech.v1p1beta1.AdaptationClient" - }, - "method": { - "shortName": "GetPhraseSet", - "fullName": "google.cloud.speech.v1p1beta1.Adaptation.GetPhraseSet", - "service": { - "shortName": "Adaptation", - "fullName": "google.cloud.speech.v1p1beta1.Adaptation" - } - } - } - }, - { - "regionTag": "speech_v1p1beta1_generated_Adaptation_ListPhraseSet_async", - "title": "Adaptation listPhraseSet Sample", - "origin": "API_DEFINITION", - "description": " List phrase sets.", - "canonical": true, - "file": "adaptation.list_phrase_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 75, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListPhraseSet", - "fullName": "google.cloud.speech.v1p1beta1.Adaptation.ListPhraseSet", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.speech.v1p1beta1.ListPhraseSetResponse", - "client": { - "shortName": "AdaptationClient", - "fullName": "google.cloud.speech.v1p1beta1.AdaptationClient" - }, - "method": { - "shortName": "ListPhraseSet", - "fullName": "google.cloud.speech.v1p1beta1.Adaptation.ListPhraseSet", - "service": { - "shortName": "Adaptation", - "fullName": "google.cloud.speech.v1p1beta1.Adaptation" - } - } - } - }, - { - "regionTag": "speech_v1p1beta1_generated_Adaptation_UpdatePhraseSet_async", - "title": "Adaptation updatePhraseSet Sample", - "origin": "API_DEFINITION", - "description": " Update a phrase set.", - "canonical": true, - "file": "adaptation.update_phrase_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdatePhraseSet", - "fullName": "google.cloud.speech.v1p1beta1.Adaptation.UpdatePhraseSet", - "async": true, - "parameters": [ - { - "name": "phrase_set", - "type": ".google.cloud.speech.v1p1beta1.PhraseSet" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.speech.v1p1beta1.PhraseSet", - "client": { - "shortName": "AdaptationClient", - "fullName": "google.cloud.speech.v1p1beta1.AdaptationClient" - }, - "method": { - "shortName": "UpdatePhraseSet", - "fullName": "google.cloud.speech.v1p1beta1.Adaptation.UpdatePhraseSet", - "service": { - "shortName": "Adaptation", - "fullName": "google.cloud.speech.v1p1beta1.Adaptation" - } - } - } - }, - { - "regionTag": "speech_v1p1beta1_generated_Adaptation_DeletePhraseSet_async", - "title": "Adaptation deletePhraseSet Sample", - "origin": "API_DEFINITION", - "description": " Delete a phrase set.", - "canonical": true, - "file": "adaptation.delete_phrase_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeletePhraseSet", - "fullName": "google.cloud.speech.v1p1beta1.Adaptation.DeletePhraseSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "AdaptationClient", - "fullName": "google.cloud.speech.v1p1beta1.AdaptationClient" - }, - "method": { - "shortName": "DeletePhraseSet", - "fullName": "google.cloud.speech.v1p1beta1.Adaptation.DeletePhraseSet", - "service": { - "shortName": "Adaptation", - "fullName": "google.cloud.speech.v1p1beta1.Adaptation" - } - } - } - }, - { - "regionTag": "speech_v1p1beta1_generated_Adaptation_CreateCustomClass_async", - "title": "Adaptation createCustomClass Sample", - "origin": "API_DEFINITION", - "description": " Create a custom class.", - "canonical": true, - "file": "adaptation.create_custom_class.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 72, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateCustomClass", - "fullName": "google.cloud.speech.v1p1beta1.Adaptation.CreateCustomClass", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "custom_class_id", - "type": "TYPE_STRING" - }, - { - "name": "custom_class", - "type": ".google.cloud.speech.v1p1beta1.CustomClass" - } - ], - "resultType": ".google.cloud.speech.v1p1beta1.CustomClass", - "client": { - "shortName": "AdaptationClient", - "fullName": "google.cloud.speech.v1p1beta1.AdaptationClient" - }, - "method": { - "shortName": "CreateCustomClass", - "fullName": "google.cloud.speech.v1p1beta1.Adaptation.CreateCustomClass", - "service": { - "shortName": "Adaptation", - "fullName": "google.cloud.speech.v1p1beta1.Adaptation" - } - } - } - }, - { - "regionTag": "speech_v1p1beta1_generated_Adaptation_GetCustomClass_async", - "title": "Adaptation getCustomClass Sample", - "origin": "API_DEFINITION", - "description": " Get a custom class.", - "canonical": true, - "file": "adaptation.get_custom_class.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetCustomClass", - "fullName": "google.cloud.speech.v1p1beta1.Adaptation.GetCustomClass", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.speech.v1p1beta1.CustomClass", - "client": { - "shortName": "AdaptationClient", - "fullName": "google.cloud.speech.v1p1beta1.AdaptationClient" - }, - "method": { - "shortName": "GetCustomClass", - "fullName": "google.cloud.speech.v1p1beta1.Adaptation.GetCustomClass", - "service": { - "shortName": "Adaptation", - "fullName": "google.cloud.speech.v1p1beta1.Adaptation" - } - } - } - }, - { - "regionTag": "speech_v1p1beta1_generated_Adaptation_ListCustomClasses_async", - "title": "Adaptation listCustomClasses Sample", - "origin": "API_DEFINITION", - "description": " List custom classes.", - "canonical": true, - "file": "adaptation.list_custom_classes.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 75, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListCustomClasses", - "fullName": "google.cloud.speech.v1p1beta1.Adaptation.ListCustomClasses", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.speech.v1p1beta1.ListCustomClassesResponse", - "client": { - "shortName": "AdaptationClient", - "fullName": "google.cloud.speech.v1p1beta1.AdaptationClient" - }, - "method": { - "shortName": "ListCustomClasses", - "fullName": "google.cloud.speech.v1p1beta1.Adaptation.ListCustomClasses", - "service": { - "shortName": "Adaptation", - "fullName": "google.cloud.speech.v1p1beta1.Adaptation" - } - } - } - }, - { - "regionTag": "speech_v1p1beta1_generated_Adaptation_UpdateCustomClass_async", - "title": "Adaptation updateCustomClass Sample", - "origin": "API_DEFINITION", - "description": " Update a custom class.", - "canonical": true, - "file": "adaptation.update_custom_class.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateCustomClass", - "fullName": "google.cloud.speech.v1p1beta1.Adaptation.UpdateCustomClass", - "async": true, - "parameters": [ - { - "name": "custom_class", - "type": ".google.cloud.speech.v1p1beta1.CustomClass" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.speech.v1p1beta1.CustomClass", - "client": { - "shortName": "AdaptationClient", - "fullName": "google.cloud.speech.v1p1beta1.AdaptationClient" - }, - "method": { - "shortName": "UpdateCustomClass", - "fullName": "google.cloud.speech.v1p1beta1.Adaptation.UpdateCustomClass", - "service": { - "shortName": "Adaptation", - "fullName": "google.cloud.speech.v1p1beta1.Adaptation" - } - } - } - }, - { - "regionTag": "speech_v1p1beta1_generated_Adaptation_DeleteCustomClass_async", - "title": "Adaptation deleteCustomClass Sample", - "origin": "API_DEFINITION", - "description": " Delete a custom class.", - "canonical": true, - "file": "adaptation.delete_custom_class.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteCustomClass", - "fullName": "google.cloud.speech.v1p1beta1.Adaptation.DeleteCustomClass", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "AdaptationClient", - "fullName": "google.cloud.speech.v1p1beta1.AdaptationClient" - }, - "method": { - "shortName": "DeleteCustomClass", - "fullName": "google.cloud.speech.v1p1beta1.Adaptation.DeleteCustomClass", - "service": { - "shortName": "Adaptation", - "fullName": "google.cloud.speech.v1p1beta1.Adaptation" - } - } - } - }, - { - "regionTag": "speech_v1p1beta1_generated_Speech_Recognize_async", - "title": "Adaptation recognize Sample", - "origin": "API_DEFINITION", - "description": " Performs synchronous speech recognition: receive results after all audio has been sent and processed.", - "canonical": true, - "file": "speech.recognize.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "Recognize", - "fullName": "google.cloud.speech.v1p1beta1.Speech.Recognize", - "async": true, - "parameters": [ - { - "name": "config", - "type": ".google.cloud.speech.v1p1beta1.RecognitionConfig" - }, - { - "name": "audio", - "type": ".google.cloud.speech.v1p1beta1.RecognitionAudio" - } - ], - "resultType": ".google.cloud.speech.v1p1beta1.RecognizeResponse", - "client": { - "shortName": "SpeechClient", - "fullName": "google.cloud.speech.v1p1beta1.SpeechClient" - }, - "method": { - "shortName": "Recognize", - "fullName": "google.cloud.speech.v1p1beta1.Speech.Recognize", - "service": { - "shortName": "Speech", - "fullName": "google.cloud.speech.v1p1beta1.Speech" - } - } - } - }, - { - "regionTag": "speech_v1p1beta1_generated_Speech_LongRunningRecognize_async", - "title": "Adaptation longRunningRecognize Sample", - "origin": "API_DEFINITION", - "description": " Performs asynchronous speech recognition: receive results via the google.longrunning.Operations interface. Returns either an `Operation.error` or an `Operation.response` which contains a `LongRunningRecognizeResponse` message. For more information on asynchronous speech recognition, see the [how-to](https://cloud.google.com/speech-to-text/docs/async-recognize).", - "canonical": true, - "file": "speech.long_running_recognize.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 64, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "LongRunningRecognize", - "fullName": "google.cloud.speech.v1p1beta1.Speech.LongRunningRecognize", - "async": true, - "parameters": [ - { - "name": "config", - "type": ".google.cloud.speech.v1p1beta1.RecognitionConfig" - }, - { - "name": "audio", - "type": ".google.cloud.speech.v1p1beta1.RecognitionAudio" - }, - { - "name": "output_config", - "type": ".google.cloud.speech.v1p1beta1.TranscriptOutputConfig" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "SpeechClient", - "fullName": "google.cloud.speech.v1p1beta1.SpeechClient" - }, - "method": { - "shortName": "LongRunningRecognize", - "fullName": "google.cloud.speech.v1p1beta1.Speech.LongRunningRecognize", - "service": { - "shortName": "Speech", - "fullName": "google.cloud.speech.v1p1beta1.Speech" - } - } - } - }, - { - "regionTag": "speech_v1p1beta1_generated_Speech_StreamingRecognize_async", - "title": "Adaptation streamingRecognize Sample", - "origin": "API_DEFINITION", - "description": " Performs bidirectional streaming speech recognition: receive results while sending audio. This method is only available via the gRPC API (not REST).", - "canonical": true, - "file": "speech.streaming_recognize.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 69, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "StreamingRecognize", - "fullName": "google.cloud.speech.v1p1beta1.Speech.StreamingRecognize", - "async": true, - "parameters": [ - { - "name": "streaming_config", - "type": ".google.cloud.speech.v1p1beta1.StreamingRecognitionConfig" - }, - { - "name": "audio_content", - "type": "TYPE_BYTES" - } - ], - "resultType": ".google.cloud.speech.v1p1beta1.StreamingRecognizeResponse", - "client": { - "shortName": "SpeechClient", - "fullName": "google.cloud.speech.v1p1beta1.SpeechClient" - }, - "method": { - "shortName": "StreamingRecognize", - "fullName": "google.cloud.speech.v1p1beta1.Speech.StreamingRecognize", - "service": { - "shortName": "Speech", - "fullName": "google.cloud.speech.v1p1beta1.Speech" - } - } - } - } - ] -} diff --git a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/speech.long_running_recognize.js b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/speech.long_running_recognize.js deleted file mode 100644 index 5521bfb8..00000000 --- a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/speech.long_running_recognize.js +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright 2022 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. ** - - - -'use strict'; - -function main(config, audio) { - // [START speech_v1p1beta1_generated_Speech_LongRunningRecognize_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Provides information to the recognizer that specifies how to - * process the request. - */ - // const config = {} - /** - * Required. The audio data to be recognized. - */ - // const audio = {} - /** - * Optional. Specifies an optional destination for the recognition results. - */ - // const outputConfig = {} - - // Imports the Speech library - const {SpeechClient} = require('@google-cloud/speech').v1p1beta1; - - // Instantiates a client - const speechClient = new SpeechClient(); - - async function callLongRunningRecognize() { - // Construct request - const request = { - config, - audio, - }; - - // Run request - const [operation] = await speechClient.longRunningRecognize(request); - const [response] = await operation.promise(); - console.log(response); - } - - callLongRunningRecognize(); - // [END speech_v1p1beta1_generated_Speech_LongRunningRecognize_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/speech.recognize.js b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/speech.recognize.js deleted file mode 100644 index 8d1ba6b1..00000000 --- a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/speech.recognize.js +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2022 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. ** - - - -'use strict'; - -function main(config, audio) { - // [START speech_v1p1beta1_generated_Speech_Recognize_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Provides information to the recognizer that specifies how to - * process the request. - */ - // const config = {} - /** - * Required. The audio data to be recognized. - */ - // const audio = {} - - // Imports the Speech library - const {SpeechClient} = require('@google-cloud/speech').v1p1beta1; - - // Instantiates a client - const speechClient = new SpeechClient(); - - async function callRecognize() { - // Construct request - const request = { - config, - audio, - }; - - // Run request - const response = await speechClient.recognize(request); - console.log(response); - } - - callRecognize(); - // [END speech_v1p1beta1_generated_Speech_Recognize_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/speech.streaming_recognize.js b/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/speech.streaming_recognize.js deleted file mode 100644 index 5cd87845..00000000 --- a/owl-bot-staging/v1p1beta1/samples/generated/v1p1beta1/speech.streaming_recognize.js +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2022 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. ** - - - -'use strict'; - -function main() { - // [START speech_v1p1beta1_generated_Speech_StreamingRecognize_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Provides information to the recognizer that specifies how to process the - * request. The first `StreamingRecognizeRequest` message must contain a - * `streaming_config` message. - */ - // const streamingConfig = {} - /** - * The audio data to be recognized. Sequential chunks of audio data are sent - * in sequential `StreamingRecognizeRequest` messages. The first - * `StreamingRecognizeRequest` message must not contain `audio_content` data - * and all subsequent `StreamingRecognizeRequest` messages must contain - * `audio_content` data. The audio bytes must be encoded as specified in - * `RecognitionConfig`. Note: as with all bytes fields, proto buffers use a - * pure binary representation (not base64). See - * content limits (https://cloud.google.com/speech-to-text/quotas#content). - */ - // const audioContent = 'Buffer.from('string')' - - // Imports the Speech library - const {SpeechClient} = require('@google-cloud/speech').v1p1beta1; - - // Instantiates a client - const speechClient = new SpeechClient(); - - async function callStreamingRecognize() { - // Construct request - const request = { - }; - - // Run request - const stream = await speechClient.streamingRecognize(); - stream.on('data', (response) => { console.log(response) }); - stream.on('error', (err) => { throw(err) }); - stream.on('end', () => { /* API call completed */ }); - stream.write(request); - stream.end(); - } - - callStreamingRecognize(); - // [END speech_v1p1beta1_generated_Speech_StreamingRecognize_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1p1beta1/src/index.ts b/owl-bot-staging/v1p1beta1/src/index.ts deleted file mode 100644 index 86112770..00000000 --- a/owl-bot-staging/v1p1beta1/src/index.ts +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2022 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. ** - -import * as v1p1beta1 from './v1p1beta1'; -const AdaptationClient = v1p1beta1.AdaptationClient; -type AdaptationClient = v1p1beta1.AdaptationClient; -const SpeechClient = v1p1beta1.SpeechClient; -type SpeechClient = v1p1beta1.SpeechClient; -export {v1p1beta1, AdaptationClient, SpeechClient}; -export default {v1p1beta1, AdaptationClient, SpeechClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/v1p1beta1/src/v1p1beta1/adaptation_client.ts b/owl-bot-staging/v1p1beta1/src/v1p1beta1/adaptation_client.ts deleted file mode 100644 index 7dbdeafb..00000000 --- a/owl-bot-staging/v1p1beta1/src/v1p1beta1/adaptation_client.ts +++ /dev/null @@ -1,1578 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import 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. - */ -import * as gapicConfig from './adaptation_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Service that implements Google Cloud Speech Adaptation API. - * @class - * @memberof v1p1beta1 - */ -export class AdaptationClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - adaptationStub?: Promise<{[name: string]: Function}>; - - /** - * 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/main/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 | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new AdaptationClient({fallback: 'rest'}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof AdaptationClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // 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 as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = this._gaxModule.warn; - } - - /** - * 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 as protobuf.Root).lookupService('google.cloud.speech.v1p1beta1.Adaptation') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.speech.v1p1beta1.Adaptation, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // 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: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.page[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor, - this._opts.fallback - ); - - 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' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * 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: - * - * `projects/{project}/locations/{location}/phraseSets` - * - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - * @param {string} request.phraseSetId - * Required. The ID to use for the phrase set, which will become the final - * component of the phrase set's resource name. - * - * This value should restrict to letters, numbers, and hyphens, with the first - * character a letter, the last a letter or a number, and be 4-63 characters. - * @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 include:samples/generated/v1p1beta1/adaptation.create_phrase_set.js - * region_tag:speech_v1p1beta1_generated_Adaptation_CreatePhraseSet_async - */ - createPhraseSet( - request?: protos.google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.speech.v1p1beta1.IPhraseSet, - protos.google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest|undefined, {}|undefined - ]>; - createPhraseSet( - request: protos.google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.speech.v1p1beta1.IPhraseSet, - protos.google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest|null|undefined, - {}|null|undefined>): void; - createPhraseSet( - request: protos.google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest, - callback: Callback< - protos.google.cloud.speech.v1p1beta1.IPhraseSet, - protos.google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest|null|undefined, - {}|null|undefined>): void; - createPhraseSet( - request?: protos.google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.speech.v1p1beta1.IPhraseSet, - protos.google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.speech.v1p1beta1.IPhraseSet, - protos.google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.speech.v1p1beta1.IPhraseSet, - protos.google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.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: - * - * `projects/{project}/locations/{location}/phraseSets/{phrase_set}` - * - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - * @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 include:samples/generated/v1p1beta1/adaptation.get_phrase_set.js - * region_tag:speech_v1p1beta1_generated_Adaptation_GetPhraseSet_async - */ - getPhraseSet( - request?: protos.google.cloud.speech.v1p1beta1.IGetPhraseSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.speech.v1p1beta1.IPhraseSet, - protos.google.cloud.speech.v1p1beta1.IGetPhraseSetRequest|undefined, {}|undefined - ]>; - getPhraseSet( - request: protos.google.cloud.speech.v1p1beta1.IGetPhraseSetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.speech.v1p1beta1.IPhraseSet, - protos.google.cloud.speech.v1p1beta1.IGetPhraseSetRequest|null|undefined, - {}|null|undefined>): void; - getPhraseSet( - request: protos.google.cloud.speech.v1p1beta1.IGetPhraseSetRequest, - callback: Callback< - protos.google.cloud.speech.v1p1beta1.IPhraseSet, - protos.google.cloud.speech.v1p1beta1.IGetPhraseSetRequest|null|undefined, - {}|null|undefined>): void; - getPhraseSet( - request?: protos.google.cloud.speech.v1p1beta1.IGetPhraseSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.speech.v1p1beta1.IPhraseSet, - protos.google.cloud.speech.v1p1beta1.IGetPhraseSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.speech.v1p1beta1.IPhraseSet, - protos.google.cloud.speech.v1p1beta1.IGetPhraseSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.speech.v1p1beta1.IPhraseSet, - protos.google.cloud.speech.v1p1beta1.IGetPhraseSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.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: - * - * `projects/{project}/locations/{location}/phraseSets/{phrase_set}` - * - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - * @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 include:samples/generated/v1p1beta1/adaptation.update_phrase_set.js - * region_tag:speech_v1p1beta1_generated_Adaptation_UpdatePhraseSet_async - */ - updatePhraseSet( - request?: protos.google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.speech.v1p1beta1.IPhraseSet, - protos.google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest|undefined, {}|undefined - ]>; - updatePhraseSet( - request: protos.google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.speech.v1p1beta1.IPhraseSet, - protos.google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest|null|undefined, - {}|null|undefined>): void; - updatePhraseSet( - request: protos.google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest, - callback: Callback< - protos.google.cloud.speech.v1p1beta1.IPhraseSet, - protos.google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest|null|undefined, - {}|null|undefined>): void; - updatePhraseSet( - request?: protos.google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.speech.v1p1beta1.IPhraseSet, - protos.google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.speech.v1p1beta1.IPhraseSet, - protos.google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.speech.v1p1beta1.IPhraseSet, - protos.google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.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: - * - * `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 include:samples/generated/v1p1beta1/adaptation.delete_phrase_set.js - * region_tag:speech_v1p1beta1_generated_Adaptation_DeletePhraseSet_async - */ - deletePhraseSet( - request?: protos.google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest|undefined, {}|undefined - ]>; - deletePhraseSet( - request: protos.google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest|null|undefined, - {}|null|undefined>): void; - deletePhraseSet( - request: protos.google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest|null|undefined, - {}|null|undefined>): void; - deletePhraseSet( - request?: protos.google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.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: - * - * `projects/{project}/locations/{location}/customClasses` - * - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - * @param {string} request.customClassId - * Required. The ID to use for the custom class, which will become the final - * component of the custom class' resource name. - * - * This value should restrict to letters, numbers, and hyphens, with the first - * character a letter, the last a letter or a number, and be 4-63 characters. - * @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 include:samples/generated/v1p1beta1/adaptation.create_custom_class.js - * region_tag:speech_v1p1beta1_generated_Adaptation_CreateCustomClass_async - */ - createCustomClass( - request?: protos.google.cloud.speech.v1p1beta1.ICreateCustomClassRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.speech.v1p1beta1.ICustomClass, - protos.google.cloud.speech.v1p1beta1.ICreateCustomClassRequest|undefined, {}|undefined - ]>; - createCustomClass( - request: protos.google.cloud.speech.v1p1beta1.ICreateCustomClassRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.speech.v1p1beta1.ICustomClass, - protos.google.cloud.speech.v1p1beta1.ICreateCustomClassRequest|null|undefined, - {}|null|undefined>): void; - createCustomClass( - request: protos.google.cloud.speech.v1p1beta1.ICreateCustomClassRequest, - callback: Callback< - protos.google.cloud.speech.v1p1beta1.ICustomClass, - protos.google.cloud.speech.v1p1beta1.ICreateCustomClassRequest|null|undefined, - {}|null|undefined>): void; - createCustomClass( - request?: protos.google.cloud.speech.v1p1beta1.ICreateCustomClassRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.speech.v1p1beta1.ICustomClass, - protos.google.cloud.speech.v1p1beta1.ICreateCustomClassRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.speech.v1p1beta1.ICustomClass, - protos.google.cloud.speech.v1p1beta1.ICreateCustomClassRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.speech.v1p1beta1.ICustomClass, - protos.google.cloud.speech.v1p1beta1.ICreateCustomClassRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.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: - * - * `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 include:samples/generated/v1p1beta1/adaptation.get_custom_class.js - * region_tag:speech_v1p1beta1_generated_Adaptation_GetCustomClass_async - */ - getCustomClass( - request?: protos.google.cloud.speech.v1p1beta1.IGetCustomClassRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.speech.v1p1beta1.ICustomClass, - protos.google.cloud.speech.v1p1beta1.IGetCustomClassRequest|undefined, {}|undefined - ]>; - getCustomClass( - request: protos.google.cloud.speech.v1p1beta1.IGetCustomClassRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.speech.v1p1beta1.ICustomClass, - protos.google.cloud.speech.v1p1beta1.IGetCustomClassRequest|null|undefined, - {}|null|undefined>): void; - getCustomClass( - request: protos.google.cloud.speech.v1p1beta1.IGetCustomClassRequest, - callback: Callback< - protos.google.cloud.speech.v1p1beta1.ICustomClass, - protos.google.cloud.speech.v1p1beta1.IGetCustomClassRequest|null|undefined, - {}|null|undefined>): void; - getCustomClass( - request?: protos.google.cloud.speech.v1p1beta1.IGetCustomClassRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.speech.v1p1beta1.ICustomClass, - protos.google.cloud.speech.v1p1beta1.IGetCustomClassRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.speech.v1p1beta1.ICustomClass, - protos.google.cloud.speech.v1p1beta1.IGetCustomClassRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.speech.v1p1beta1.ICustomClass, - protos.google.cloud.speech.v1p1beta1.IGetCustomClassRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.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: - * - * `projects/{project}/locations/{location}/customClasses/{custom_class}` - * - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - * @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 include:samples/generated/v1p1beta1/adaptation.update_custom_class.js - * region_tag:speech_v1p1beta1_generated_Adaptation_UpdateCustomClass_async - */ - updateCustomClass( - request?: protos.google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.speech.v1p1beta1.ICustomClass, - protos.google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest|undefined, {}|undefined - ]>; - updateCustomClass( - request: protos.google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.speech.v1p1beta1.ICustomClass, - protos.google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest|null|undefined, - {}|null|undefined>): void; - updateCustomClass( - request: protos.google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest, - callback: Callback< - protos.google.cloud.speech.v1p1beta1.ICustomClass, - protos.google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest|null|undefined, - {}|null|undefined>): void; - updateCustomClass( - request?: protos.google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.speech.v1p1beta1.ICustomClass, - protos.google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.speech.v1p1beta1.ICustomClass, - protos.google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.speech.v1p1beta1.ICustomClass, - protos.google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.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: - * - * `projects/{project}/locations/{location}/customClasses/{custom_class}` - * - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - * @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 include:samples/generated/v1p1beta1/adaptation.delete_custom_class.js - * region_tag:speech_v1p1beta1_generated_Adaptation_DeleteCustomClass_async - */ - deleteCustomClass( - request?: protos.google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest|undefined, {}|undefined - ]>; - deleteCustomClass( - request: protos.google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest|null|undefined, - {}|null|undefined>): void; - deleteCustomClass( - request: protos.google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest|null|undefined, - {}|null|undefined>): void; - deleteCustomClass( - request?: protos.google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.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}` - * - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - * @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?: protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.speech.v1p1beta1.IPhraseSet[], - protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest|null, - protos.google.cloud.speech.v1p1beta1.IListPhraseSetResponse - ]>; - listPhraseSet( - request: protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest, - protos.google.cloud.speech.v1p1beta1.IListPhraseSetResponse|null|undefined, - protos.google.cloud.speech.v1p1beta1.IPhraseSet>): void; - listPhraseSet( - request: protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest, - callback: PaginationCallback< - protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest, - protos.google.cloud.speech.v1p1beta1.IListPhraseSetResponse|null|undefined, - protos.google.cloud.speech.v1p1beta1.IPhraseSet>): void; - listPhraseSet( - request?: protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest, - protos.google.cloud.speech.v1p1beta1.IListPhraseSetResponse|null|undefined, - protos.google.cloud.speech.v1p1beta1.IPhraseSet>, - callback?: PaginationCallback< - protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest, - protos.google.cloud.speech.v1p1beta1.IListPhraseSetResponse|null|undefined, - protos.google.cloud.speech.v1p1beta1.IPhraseSet>): - Promise<[ - protos.google.cloud.speech.v1p1beta1.IPhraseSet[], - protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest|null, - protos.google.cloud.speech.v1p1beta1.IListPhraseSetResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.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}` - * - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - * @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?: protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listPhraseSet']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listPhraseSet.createStream( - this.innerApiCalls.listPhraseSet as GaxCall, - 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}` - * - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - * @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 include:samples/generated/v1p1beta1/adaptation.list_phrase_set.js - * region_tag:speech_v1p1beta1_generated_Adaptation_ListPhraseSet_async - */ - listPhraseSetAsync( - request?: protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listPhraseSet']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listPhraseSet.asyncIterate( - this.innerApiCalls['listPhraseSet'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * 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: - * - * `projects/{project}/locations/{location}/customClasses` - * - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - * @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?: protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.speech.v1p1beta1.ICustomClass[], - protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest|null, - protos.google.cloud.speech.v1p1beta1.IListCustomClassesResponse - ]>; - listCustomClasses( - request: protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest, - protos.google.cloud.speech.v1p1beta1.IListCustomClassesResponse|null|undefined, - protos.google.cloud.speech.v1p1beta1.ICustomClass>): void; - listCustomClasses( - request: protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest, - callback: PaginationCallback< - protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest, - protos.google.cloud.speech.v1p1beta1.IListCustomClassesResponse|null|undefined, - protos.google.cloud.speech.v1p1beta1.ICustomClass>): void; - listCustomClasses( - request?: protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest, - protos.google.cloud.speech.v1p1beta1.IListCustomClassesResponse|null|undefined, - protos.google.cloud.speech.v1p1beta1.ICustomClass>, - callback?: PaginationCallback< - protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest, - protos.google.cloud.speech.v1p1beta1.IListCustomClassesResponse|null|undefined, - protos.google.cloud.speech.v1p1beta1.ICustomClass>): - Promise<[ - protos.google.cloud.speech.v1p1beta1.ICustomClass[], - protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest|null, - protos.google.cloud.speech.v1p1beta1.IListCustomClassesResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.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: - * - * `projects/{project}/locations/{location}/customClasses` - * - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - * @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?: protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listCustomClasses']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listCustomClasses.createStream( - this.innerApiCalls.listCustomClasses as GaxCall, - 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: - * - * `projects/{project}/locations/{location}/customClasses` - * - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - * @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 include:samples/generated/v1p1beta1/adaptation.list_custom_classes.js - * region_tag:speech_v1p1beta1_generated_Adaptation_ListCustomClasses_async - */ - listCustomClassesAsync( - request?: protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listCustomClasses']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listCustomClasses.asyncIterate( - this.innerApiCalls['listCustomClasses'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- 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:string,location:string,customClass:string) { - 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: string) { - 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: string) { - 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: string) { - 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:string,location:string) { - 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: string) { - 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: string) { - 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:string,location:string,phraseSet:string) { - 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: string) { - 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: string) { - 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: string) { - 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:string) { - 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: string) { - 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(): Promise { - if (this.adaptationStub && !this._terminated) { - return this.adaptationStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1p1beta1/src/v1p1beta1/adaptation_client_config.json b/owl-bot-staging/v1p1beta1/src/v1p1beta1/adaptation_client_config.json deleted file mode 100644 index 9de68447..00000000 --- a/owl-bot-staging/v1p1beta1/src/v1p1beta1/adaptation_client_config.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "interfaces": { - "google.cloud.speech.v1p1beta1.Adaptation": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "CreatePhraseSet": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetPhraseSet": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListPhraseSet": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdatePhraseSet": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeletePhraseSet": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CreateCustomClass": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetCustomClass": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListCustomClasses": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateCustomClass": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteCustomClass": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1p1beta1/src/v1p1beta1/adaptation_proto_list.json b/owl-bot-staging/v1p1beta1/src/v1p1beta1/adaptation_proto_list.json deleted file mode 100644 index d05ded22..00000000 --- a/owl-bot-staging/v1p1beta1/src/v1p1beta1/adaptation_proto_list.json +++ /dev/null @@ -1,5 +0,0 @@ -[ - "../../protos/google/cloud/speech/v1p1beta1/cloud_speech.proto", - "../../protos/google/cloud/speech/v1p1beta1/cloud_speech_adaptation.proto", - "../../protos/google/cloud/speech/v1p1beta1/resource.proto" -] diff --git a/owl-bot-staging/v1p1beta1/src/v1p1beta1/gapic_metadata.json b/owl-bot-staging/v1p1beta1/src/v1p1beta1/gapic_metadata.json deleted file mode 100644 index deb25a92..00000000 --- a/owl-bot-staging/v1p1beta1/src/v1p1beta1/gapic_metadata.json +++ /dev/null @@ -1,170 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.speech.v1p1beta1", - "libraryPackage": "@google-cloud/speech", - "services": { - "Adaptation": { - "clients": { - "grpc": { - "libraryClient": "AdaptationClient", - "rpcs": { - "CreatePhraseSet": { - "methods": [ - "createPhraseSet" - ] - }, - "GetPhraseSet": { - "methods": [ - "getPhraseSet" - ] - }, - "UpdatePhraseSet": { - "methods": [ - "updatePhraseSet" - ] - }, - "DeletePhraseSet": { - "methods": [ - "deletePhraseSet" - ] - }, - "CreateCustomClass": { - "methods": [ - "createCustomClass" - ] - }, - "GetCustomClass": { - "methods": [ - "getCustomClass" - ] - }, - "UpdateCustomClass": { - "methods": [ - "updateCustomClass" - ] - }, - "DeleteCustomClass": { - "methods": [ - "deleteCustomClass" - ] - }, - "ListPhraseSet": { - "methods": [ - "listPhraseSet", - "listPhraseSetStream", - "listPhraseSetAsync" - ] - }, - "ListCustomClasses": { - "methods": [ - "listCustomClasses", - "listCustomClassesStream", - "listCustomClassesAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "AdaptationClient", - "rpcs": { - "CreatePhraseSet": { - "methods": [ - "createPhraseSet" - ] - }, - "GetPhraseSet": { - "methods": [ - "getPhraseSet" - ] - }, - "UpdatePhraseSet": { - "methods": [ - "updatePhraseSet" - ] - }, - "DeletePhraseSet": { - "methods": [ - "deletePhraseSet" - ] - }, - "CreateCustomClass": { - "methods": [ - "createCustomClass" - ] - }, - "GetCustomClass": { - "methods": [ - "getCustomClass" - ] - }, - "UpdateCustomClass": { - "methods": [ - "updateCustomClass" - ] - }, - "DeleteCustomClass": { - "methods": [ - "deleteCustomClass" - ] - }, - "ListPhraseSet": { - "methods": [ - "listPhraseSet", - "listPhraseSetStream", - "listPhraseSetAsync" - ] - }, - "ListCustomClasses": { - "methods": [ - "listCustomClasses", - "listCustomClassesStream", - "listCustomClassesAsync" - ] - } - } - } - } - }, - "Speech": { - "clients": { - "grpc": { - "libraryClient": "SpeechClient", - "rpcs": { - "Recognize": { - "methods": [ - "recognize" - ] - }, - "StreamingRecognize": { - "methods": [ - "streamingRecognize" - ] - }, - "LongRunningRecognize": { - "methods": [ - "longRunningRecognize" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "SpeechClient", - "rpcs": { - "Recognize": { - "methods": [ - "recognize" - ] - }, - "LongRunningRecognize": { - "methods": [ - "longRunningRecognize" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/v1p1beta1/src/v1p1beta1/index.ts b/owl-bot-staging/v1p1beta1/src/v1p1beta1/index.ts deleted file mode 100644 index 5b4cfbf4..00000000 --- a/owl-bot-staging/v1p1beta1/src/v1p1beta1/index.ts +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2022 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. ** - -export {AdaptationClient} from './adaptation_client'; -export {SpeechClient} from './speech_client'; diff --git a/owl-bot-staging/v1p1beta1/src/v1p1beta1/speech_client.ts b/owl-bot-staging/v1p1beta1/src/v1p1beta1/speech_client.ts deleted file mode 100644 index 4eac2179..00000000 --- a/owl-bot-staging/v1p1beta1/src/v1p1beta1/speech_client.ts +++ /dev/null @@ -1,649 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation} from 'google-gax'; -import {PassThrough} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1p1beta1/speech_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './speech_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Service that implements Google Cloud Speech API. - * @class - * @memberof v1p1beta1 - */ -export class SpeechClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - speechStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of SpeechClient. - * - * @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/main/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 | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new SpeechClient({fallback: 'rest'}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof SpeechClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // 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}' - ), - phraseSetPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/phraseSets/{phrase_set}' - ), - }; - - // Some of the methods on this service provide streaming responses. - // Provide descriptors for these. - this.descriptors.stream = { - streamingRecognize: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.BIDI_STREAMING, opts.fallback === 'rest') - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v1p1beta1/operations/{name=**}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1p1beta1/operations',}]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const longRunningRecognizeResponse = protoFilesRoot.lookup( - '.google.cloud.speech.v1p1beta1.LongRunningRecognizeResponse') as gax.protobuf.Type; - const longRunningRecognizeMetadata = protoFilesRoot.lookup( - '.google.cloud.speech.v1p1beta1.LongRunningRecognizeMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - longRunningRecognize: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - longRunningRecognizeResponse.decode.bind(longRunningRecognizeResponse), - longRunningRecognizeMetadata.decode.bind(longRunningRecognizeMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.speech.v1p1beta1.Speech', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = this._gaxModule.warn; - } - - /** - * 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.speechStub) { - return this.speechStub; - } - - // Put together the "service stub" for - // google.cloud.speech.v1p1beta1.Speech. - this.speechStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.speech.v1p1beta1.Speech') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.speech.v1p1beta1.Speech, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const speechStubMethods = - ['recognize', 'longRunningRecognize', 'streamingRecognize']; - for (const methodName of speechStubMethods) { - const callPromise = this.speechStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - if (methodName in this.descriptors.stream) { - const stream = new PassThrough(); - setImmediate(() => { - stream.emit('error', new this._gaxModule.GoogleError('The client has already been closed.')); - }); - return stream; - } - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.stream[methodName] || - this.descriptors.longrunning[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor, - this._opts.fallback - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.speechStub; - } - - /** - * 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' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Performs synchronous speech recognition: receive results after all audio - * has been sent and processed. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.speech.v1p1beta1.RecognitionConfig} request.config - * Required. Provides information to the recognizer that specifies how to - * process the request. - * @param {google.cloud.speech.v1p1beta1.RecognitionAudio} request.audio - * Required. The audio data to be recognized. - * @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 [RecognizeResponse]{@link google.cloud.speech.v1p1beta1.RecognizeResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1p1beta1/speech.recognize.js - * region_tag:speech_v1p1beta1_generated_Speech_Recognize_async - */ - recognize( - request?: protos.google.cloud.speech.v1p1beta1.IRecognizeRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.speech.v1p1beta1.IRecognizeResponse, - protos.google.cloud.speech.v1p1beta1.IRecognizeRequest|undefined, {}|undefined - ]>; - recognize( - request: protos.google.cloud.speech.v1p1beta1.IRecognizeRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.speech.v1p1beta1.IRecognizeResponse, - protos.google.cloud.speech.v1p1beta1.IRecognizeRequest|null|undefined, - {}|null|undefined>): void; - recognize( - request: protos.google.cloud.speech.v1p1beta1.IRecognizeRequest, - callback: Callback< - protos.google.cloud.speech.v1p1beta1.IRecognizeResponse, - protos.google.cloud.speech.v1p1beta1.IRecognizeRequest|null|undefined, - {}|null|undefined>): void; - recognize( - request?: protos.google.cloud.speech.v1p1beta1.IRecognizeRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.speech.v1p1beta1.IRecognizeResponse, - protos.google.cloud.speech.v1p1beta1.IRecognizeRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.speech.v1p1beta1.IRecognizeResponse, - protos.google.cloud.speech.v1p1beta1.IRecognizeRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.speech.v1p1beta1.IRecognizeResponse, - protos.google.cloud.speech.v1p1beta1.IRecognizeRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - this.initialize(); - return this.innerApiCalls.recognize(request, options, callback); - } - -/** - * Performs bidirectional streaming speech recognition: receive results while - * sending audio. This method is only available via the gRPC API (not REST). - * - * @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 is both readable and writable. It accepts objects - * representing [StreamingRecognizeRequest]{@link google.cloud.speech.v1p1beta1.StreamingRecognizeRequest} for write() method, and - * will emit objects representing [StreamingRecognizeResponse]{@link google.cloud.speech.v1p1beta1.StreamingRecognizeResponse} on 'data' event asynchronously. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#bi-directional-streaming) - * for more details and examples. - * @example include:samples/generated/v1p1beta1/speech.streaming_recognize.js - * region_tag:speech_v1p1beta1_generated_Speech_StreamingRecognize_async - */ - streamingRecognize( - options?: CallOptions): - gax.CancellableStream { - this.initialize(); - return this.innerApiCalls.streamingRecognize(null, options); - } - -/** - * Performs asynchronous speech recognition: receive results via the - * google.longrunning.Operations interface. Returns either an - * `Operation.error` or an `Operation.response` which contains - * a `LongRunningRecognizeResponse` message. - * For more information on asynchronous speech recognition, see the - * [how-to](https://cloud.google.com/speech-to-text/docs/async-recognize). - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.speech.v1p1beta1.RecognitionConfig} request.config - * Required. Provides information to the recognizer that specifies how to - * process the request. - * @param {google.cloud.speech.v1p1beta1.RecognitionAudio} request.audio - * Required. The audio data to be recognized. - * @param {google.cloud.speech.v1p1beta1.TranscriptOutputConfig} [request.outputConfig] - * Optional. Specifies an optional destination for the recognition results. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1p1beta1/speech.long_running_recognize.js - * region_tag:speech_v1p1beta1_generated_Speech_LongRunningRecognize_async - */ - longRunningRecognize( - request?: protos.google.cloud.speech.v1p1beta1.ILongRunningRecognizeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - longRunningRecognize( - request: protos.google.cloud.speech.v1p1beta1.ILongRunningRecognizeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - longRunningRecognize( - request: protos.google.cloud.speech.v1p1beta1.ILongRunningRecognizeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - longRunningRecognize( - request?: protos.google.cloud.speech.v1p1beta1.ILongRunningRecognizeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - this.initialize(); - return this.innerApiCalls.longRunningRecognize(request, options, callback); - } -/** - * Check the status of the long running operation returned by `longRunningRecognize()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1p1beta1/speech.long_running_recognize.js - * region_tag:speech_v1p1beta1_generated_Speech_LongRunningRecognize_async - */ - async checkLongRunningRecognizeProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.longRunningRecognize, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - // -------------------- - // -- 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:string,location:string,customClass:string) { - 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: string) { - 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: string) { - 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: string) { - return this.pathTemplates.customClassPathTemplate.match(customClassName).custom_class; - } - - /** - * 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:string,location:string,phraseSet:string) { - 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: string) { - 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: string) { - 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: string) { - return this.pathTemplates.phraseSetPathTemplate.match(phraseSetName).phrase_set; - } - - /** - * 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(): Promise { - if (this.speechStub && !this._terminated) { - return this.speechStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1p1beta1/src/v1p1beta1/speech_client_config.json b/owl-bot-staging/v1p1beta1/src/v1p1beta1/speech_client_config.json deleted file mode 100644 index c5e1b104..00000000 --- a/owl-bot-staging/v1p1beta1/src/v1p1beta1/speech_client_config.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "interfaces": { - "google.cloud.speech.v1p1beta1.Speech": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "Recognize": { - "timeout_millis": 5000000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "LongRunningRecognize": { - "timeout_millis": 5000000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "StreamingRecognize": { - "timeout_millis": 5000000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1p1beta1/src/v1p1beta1/speech_proto_list.json b/owl-bot-staging/v1p1beta1/src/v1p1beta1/speech_proto_list.json deleted file mode 100644 index d05ded22..00000000 --- a/owl-bot-staging/v1p1beta1/src/v1p1beta1/speech_proto_list.json +++ /dev/null @@ -1,5 +0,0 @@ -[ - "../../protos/google/cloud/speech/v1p1beta1/cloud_speech.proto", - "../../protos/google/cloud/speech/v1p1beta1/cloud_speech_adaptation.proto", - "../../protos/google/cloud/speech/v1p1beta1/resource.proto" -] diff --git a/owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 36731b35..00000000 --- a/owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2022 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. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const speech = require('@google-cloud/speech'); - -function main() { - const adaptationClient = new speech.AdaptationClient(); - const speechClient = new speech.SpeechClient(); -} - -main(); diff --git a/owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 1c746cf8..00000000 --- a/owl-bot-staging/v1p1beta1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2022 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. ** - -import {AdaptationClient, SpeechClient} from '@google-cloud/speech'; - -// check that the client class type name can be used -function doStuffWithAdaptationClient(client: AdaptationClient) { - client.close(); -} -function doStuffWithSpeechClient(client: SpeechClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const adaptationClient = new AdaptationClient(); - doStuffWithAdaptationClient(adaptationClient); - // check that the client instance can be created - const speechClient = new SpeechClient(); - doStuffWithSpeechClient(speechClient); -} - -main(); diff --git a/owl-bot-staging/v1p1beta1/system-test/install.ts b/owl-bot-staging/v1p1beta1/system-test/install.ts deleted file mode 100644 index 557a5755..00000000 --- a/owl-bot-staging/v1p1beta1/system-test/install.ts +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2022 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. ** - -import {packNTest} from 'pack-n-play'; -import {readFileSync} from 'fs'; -import {describe, it} from 'mocha'; - -describe('📦 pack-n-play test', () => { - - it('TypeScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'TypeScript user can use the type definitions', - ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() - } - }; - await packNTest(options); - }); - - it('JavaScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'JavaScript user can use the library', - ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() - } - }; - await packNTest(options); - }); - -}); diff --git a/owl-bot-staging/v1p1beta1/test/gapic_adaptation_v1p1beta1.ts b/owl-bot-staging/v1p1beta1/test/gapic_adaptation_v1p1beta1.ts deleted file mode 100644 index 634f2f6b..00000000 --- a/owl-bot-staging/v1p1beta1/test/gapic_adaptation_v1p1beta1.ts +++ /dev/null @@ -1,1722 +0,0 @@ -// Copyright 2022 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. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; -import * as adaptationModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1p1beta1.AdaptationClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = adaptationModule.v1p1beta1.AdaptationClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = adaptationModule.v1p1beta1.AdaptationClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = adaptationModule.v1p1beta1.AdaptationClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.adaptationStub, undefined); - await client.initialize(); - assert(client.adaptationStub); - }); - - it('has close method for the initialized client', done => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.adaptationStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.adaptationStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - }); - - describe('createPhraseSet', () => { - it('invokes createPhraseSet without error', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.CreatePhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('CreatePhraseSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.PhraseSet() - ); - client.innerApiCalls.createPhraseSet = stubSimpleCall(expectedResponse); - const [response] = await client.createPhraseSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createPhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createPhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createPhraseSet without error using callback', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.CreatePhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('CreatePhraseSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.PhraseSet() - ); - client.innerApiCalls.createPhraseSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createPhraseSet( - request, - (err?: Error|null, result?: protos.google.cloud.speech.v1p1beta1.IPhraseSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createPhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createPhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createPhraseSet with error', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.CreatePhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('CreatePhraseSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createPhraseSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createPhraseSet(request), expectedError); - const actualRequest = (client.innerApiCalls.createPhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createPhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createPhraseSet with closed client', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.CreatePhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('CreatePhraseSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createPhraseSet(request), expectedError); - }); - }); - - describe('getPhraseSet', () => { - it('invokes getPhraseSet without error', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.GetPhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('GetPhraseSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.PhraseSet() - ); - client.innerApiCalls.getPhraseSet = stubSimpleCall(expectedResponse); - const [response] = await client.getPhraseSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getPhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getPhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getPhraseSet without error using callback', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.GetPhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('GetPhraseSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.PhraseSet() - ); - client.innerApiCalls.getPhraseSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getPhraseSet( - request, - (err?: Error|null, result?: protos.google.cloud.speech.v1p1beta1.IPhraseSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getPhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getPhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getPhraseSet with error', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.GetPhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('GetPhraseSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getPhraseSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getPhraseSet(request), expectedError); - const actualRequest = (client.innerApiCalls.getPhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getPhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getPhraseSet with closed client', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.GetPhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('GetPhraseSetRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getPhraseSet(request), expectedError); - }); - }); - - describe('updatePhraseSet', () => { - it('invokes updatePhraseSet without error', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest() - ); - request.phraseSet ??= {}; - const defaultValue1 = - getTypeDefaultValue('UpdatePhraseSetRequest', ['phraseSet', 'name']); - request.phraseSet.name = defaultValue1; - const expectedHeaderRequestParams = `phrase_set.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.PhraseSet() - ); - client.innerApiCalls.updatePhraseSet = stubSimpleCall(expectedResponse); - const [response] = await client.updatePhraseSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updatePhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updatePhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updatePhraseSet without error using callback', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest() - ); - request.phraseSet ??= {}; - const defaultValue1 = - getTypeDefaultValue('UpdatePhraseSetRequest', ['phraseSet', 'name']); - request.phraseSet.name = defaultValue1; - const expectedHeaderRequestParams = `phrase_set.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.PhraseSet() - ); - client.innerApiCalls.updatePhraseSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updatePhraseSet( - request, - (err?: Error|null, result?: protos.google.cloud.speech.v1p1beta1.IPhraseSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updatePhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updatePhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updatePhraseSet with error', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest() - ); - request.phraseSet ??= {}; - const defaultValue1 = - getTypeDefaultValue('UpdatePhraseSetRequest', ['phraseSet', 'name']); - request.phraseSet.name = defaultValue1; - const expectedHeaderRequestParams = `phrase_set.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updatePhraseSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updatePhraseSet(request), expectedError); - const actualRequest = (client.innerApiCalls.updatePhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updatePhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updatePhraseSet with closed client', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest() - ); - request.phraseSet ??= {}; - const defaultValue1 = - getTypeDefaultValue('UpdatePhraseSetRequest', ['phraseSet', 'name']); - request.phraseSet.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updatePhraseSet(request), expectedError); - }); - }); - - describe('deletePhraseSet', () => { - it('invokes deletePhraseSet without error', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.DeletePhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('DeletePhraseSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deletePhraseSet = stubSimpleCall(expectedResponse); - const [response] = await client.deletePhraseSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deletePhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deletePhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deletePhraseSet without error using callback', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.DeletePhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('DeletePhraseSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deletePhraseSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deletePhraseSet( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deletePhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deletePhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deletePhraseSet with error', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.DeletePhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('DeletePhraseSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deletePhraseSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deletePhraseSet(request), expectedError); - const actualRequest = (client.innerApiCalls.deletePhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deletePhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deletePhraseSet with closed client', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.DeletePhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('DeletePhraseSetRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deletePhraseSet(request), expectedError); - }); - }); - - describe('createCustomClass', () => { - it('invokes createCustomClass without error', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.CreateCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('CreateCustomClassRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.CustomClass() - ); - client.innerApiCalls.createCustomClass = stubSimpleCall(expectedResponse); - const [response] = await client.createCustomClass(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createCustomClass without error using callback', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.CreateCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('CreateCustomClassRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.CustomClass() - ); - client.innerApiCalls.createCustomClass = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createCustomClass( - request, - (err?: Error|null, result?: protos.google.cloud.speech.v1p1beta1.ICustomClass|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createCustomClass with error', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.CreateCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('CreateCustomClassRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createCustomClass = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createCustomClass(request), expectedError); - const actualRequest = (client.innerApiCalls.createCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createCustomClass with closed client', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.CreateCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('CreateCustomClassRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createCustomClass(request), expectedError); - }); - }); - - describe('getCustomClass', () => { - it('invokes getCustomClass without error', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.GetCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('GetCustomClassRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.CustomClass() - ); - client.innerApiCalls.getCustomClass = stubSimpleCall(expectedResponse); - const [response] = await client.getCustomClass(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getCustomClass without error using callback', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.GetCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('GetCustomClassRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.CustomClass() - ); - client.innerApiCalls.getCustomClass = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getCustomClass( - request, - (err?: Error|null, result?: protos.google.cloud.speech.v1p1beta1.ICustomClass|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getCustomClass with error', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.GetCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('GetCustomClassRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getCustomClass = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getCustomClass(request), expectedError); - const actualRequest = (client.innerApiCalls.getCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getCustomClass with closed client', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.GetCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('GetCustomClassRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getCustomClass(request), expectedError); - }); - }); - - describe('updateCustomClass', () => { - it('invokes updateCustomClass without error', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.UpdateCustomClassRequest() - ); - request.customClass ??= {}; - const defaultValue1 = - getTypeDefaultValue('UpdateCustomClassRequest', ['customClass', 'name']); - request.customClass.name = defaultValue1; - const expectedHeaderRequestParams = `custom_class.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.CustomClass() - ); - client.innerApiCalls.updateCustomClass = stubSimpleCall(expectedResponse); - const [response] = await client.updateCustomClass(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateCustomClass without error using callback', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.UpdateCustomClassRequest() - ); - request.customClass ??= {}; - const defaultValue1 = - getTypeDefaultValue('UpdateCustomClassRequest', ['customClass', 'name']); - request.customClass.name = defaultValue1; - const expectedHeaderRequestParams = `custom_class.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.CustomClass() - ); - client.innerApiCalls.updateCustomClass = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateCustomClass( - request, - (err?: Error|null, result?: protos.google.cloud.speech.v1p1beta1.ICustomClass|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateCustomClass with error', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.UpdateCustomClassRequest() - ); - request.customClass ??= {}; - const defaultValue1 = - getTypeDefaultValue('UpdateCustomClassRequest', ['customClass', 'name']); - request.customClass.name = defaultValue1; - const expectedHeaderRequestParams = `custom_class.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateCustomClass = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateCustomClass(request), expectedError); - const actualRequest = (client.innerApiCalls.updateCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateCustomClass with closed client', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.UpdateCustomClassRequest() - ); - request.customClass ??= {}; - const defaultValue1 = - getTypeDefaultValue('UpdateCustomClassRequest', ['customClass', 'name']); - request.customClass.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateCustomClass(request), expectedError); - }); - }); - - describe('deleteCustomClass', () => { - it('invokes deleteCustomClass without error', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.DeleteCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('DeleteCustomClassRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteCustomClass = stubSimpleCall(expectedResponse); - const [response] = await client.deleteCustomClass(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteCustomClass without error using callback', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.DeleteCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('DeleteCustomClassRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteCustomClass = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteCustomClass( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteCustomClass with error', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.DeleteCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('DeleteCustomClassRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteCustomClass = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteCustomClass(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteCustomClass with closed client', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.DeleteCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('DeleteCustomClassRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteCustomClass(request), expectedError); - }); - }); - - describe('listPhraseSet', () => { - it('invokes listPhraseSet without error', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.ListPhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListPhraseSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.PhraseSet()), - generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.PhraseSet()), - generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.PhraseSet()), - ]; - client.innerApiCalls.listPhraseSet = stubSimpleCall(expectedResponse); - const [response] = await client.listPhraseSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listPhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listPhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listPhraseSet without error using callback', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.ListPhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListPhraseSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.PhraseSet()), - generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.PhraseSet()), - generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.PhraseSet()), - ]; - client.innerApiCalls.listPhraseSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listPhraseSet( - request, - (err?: Error|null, result?: protos.google.cloud.speech.v1p1beta1.IPhraseSet[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listPhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listPhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listPhraseSet with error', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.ListPhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListPhraseSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listPhraseSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listPhraseSet(request), expectedError); - const actualRequest = (client.innerApiCalls.listPhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listPhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listPhraseSetStream without error', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.ListPhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListPhraseSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.PhraseSet()), - generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.PhraseSet()), - generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.PhraseSet()), - ]; - client.descriptors.page.listPhraseSet.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listPhraseSetStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.speech.v1p1beta1.PhraseSet[] = []; - stream.on('data', (response: protos.google.cloud.speech.v1p1beta1.PhraseSet) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listPhraseSet.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listPhraseSet, request)); - assert( - (client.descriptors.page.listPhraseSet.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listPhraseSetStream with error', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.ListPhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListPhraseSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listPhraseSet.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listPhraseSetStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.speech.v1p1beta1.PhraseSet[] = []; - stream.on('data', (response: protos.google.cloud.speech.v1p1beta1.PhraseSet) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listPhraseSet.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listPhraseSet, request)); - assert( - (client.descriptors.page.listPhraseSet.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listPhraseSet without error', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.ListPhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListPhraseSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.PhraseSet()), - generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.PhraseSet()), - generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.PhraseSet()), - ]; - client.descriptors.page.listPhraseSet.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.speech.v1p1beta1.IPhraseSet[] = []; - const iterable = client.listPhraseSetAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listPhraseSet.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listPhraseSet.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listPhraseSet with error', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.ListPhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListPhraseSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listPhraseSet.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listPhraseSetAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.speech.v1p1beta1.IPhraseSet[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listPhraseSet.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listPhraseSet.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listCustomClasses', () => { - it('invokes listCustomClasses without error', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.ListCustomClassesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListCustomClassesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.CustomClass()), - generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.CustomClass()), - generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.CustomClass()), - ]; - client.innerApiCalls.listCustomClasses = stubSimpleCall(expectedResponse); - const [response] = await client.listCustomClasses(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listCustomClasses as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCustomClasses as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listCustomClasses without error using callback', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.ListCustomClassesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListCustomClassesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.CustomClass()), - generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.CustomClass()), - generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.CustomClass()), - ]; - client.innerApiCalls.listCustomClasses = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listCustomClasses( - request, - (err?: Error|null, result?: protos.google.cloud.speech.v1p1beta1.ICustomClass[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listCustomClasses as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCustomClasses as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listCustomClasses with error', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.ListCustomClassesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListCustomClassesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listCustomClasses = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listCustomClasses(request), expectedError); - const actualRequest = (client.innerApiCalls.listCustomClasses as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCustomClasses as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listCustomClassesStream without error', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.ListCustomClassesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListCustomClassesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.CustomClass()), - generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.CustomClass()), - generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.CustomClass()), - ]; - client.descriptors.page.listCustomClasses.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listCustomClassesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.speech.v1p1beta1.CustomClass[] = []; - stream.on('data', (response: protos.google.cloud.speech.v1p1beta1.CustomClass) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listCustomClasses.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listCustomClasses, request)); - assert( - (client.descriptors.page.listCustomClasses.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listCustomClassesStream with error', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.ListCustomClassesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListCustomClassesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listCustomClasses.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listCustomClassesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.speech.v1p1beta1.CustomClass[] = []; - stream.on('data', (response: protos.google.cloud.speech.v1p1beta1.CustomClass) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listCustomClasses.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listCustomClasses, request)); - assert( - (client.descriptors.page.listCustomClasses.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listCustomClasses without error', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.ListCustomClassesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListCustomClassesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.CustomClass()), - generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.CustomClass()), - generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.CustomClass()), - ]; - client.descriptors.page.listCustomClasses.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.speech.v1p1beta1.ICustomClass[] = []; - const iterable = client.listCustomClassesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listCustomClasses.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listCustomClasses.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listCustomClasses with error', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.ListCustomClassesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('ListCustomClassesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listCustomClasses.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listCustomClassesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.speech.v1p1beta1.ICustomClass[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listCustomClasses.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listCustomClasses.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('Path templates', () => { - - describe('customClass', () => { - const fakePath = "/rendered/path/customClass"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - custom_class: "customClassValue", - }; - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.customClassPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.customClassPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('customClassPath', () => { - const result = client.customClassPath("projectValue", "locationValue", "customClassValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.customClassPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCustomClassName', () => { - const result = client.matchProjectFromCustomClassName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.customClassPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCustomClassName', () => { - const result = client.matchLocationFromCustomClassName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.customClassPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCustomClassFromCustomClassName', () => { - const result = client.matchCustomClassFromCustomClassName(fakePath); - assert.strictEqual(result, "customClassValue"); - assert((client.pathTemplates.customClassPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('location', () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('phraseSet', () => { - const fakePath = "/rendered/path/phraseSet"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - phrase_set: "phraseSetValue", - }; - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.phraseSetPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.phraseSetPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('phraseSetPath', () => { - const result = client.phraseSetPath("projectValue", "locationValue", "phraseSetValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.phraseSetPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromPhraseSetName', () => { - const result = client.matchProjectFromPhraseSetName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.phraseSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromPhraseSetName', () => { - const result = client.matchLocationFromPhraseSetName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.phraseSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchPhraseSetFromPhraseSetName', () => { - const result = client.matchPhraseSetFromPhraseSetName(fakePath); - assert.strictEqual(result, "phraseSetValue"); - assert((client.pathTemplates.phraseSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('project', () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v1p1beta1/test/gapic_speech_v1p1beta1.ts b/owl-bot-staging/v1p1beta1/test/gapic_speech_v1p1beta1.ts deleted file mode 100644 index 0149c0af..00000000 --- a/owl-bot-staging/v1p1beta1/test/gapic_speech_v1p1beta1.ts +++ /dev/null @@ -1,525 +0,0 @@ -// Copyright 2022 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. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; -import * as speechModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubBidiStreamingCall(response?: ResponseType, error?: Error) { - const transformStub = error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - return sinon.stub().returns(mockStream); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -describe('v1p1beta1.SpeechClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = speechModule.v1p1beta1.SpeechClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = speechModule.v1p1beta1.SpeechClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = speechModule.v1p1beta1.SpeechClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new speechModule.v1p1beta1.SpeechClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new speechModule.v1p1beta1.SpeechClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new speechModule.v1p1beta1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.speechStub, undefined); - await client.initialize(); - assert(client.speechStub); - }); - - it('has close method for the initialized client', done => { - const client = new speechModule.v1p1beta1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.speechStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new speechModule.v1p1beta1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.speechStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new speechModule.v1p1beta1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new speechModule.v1p1beta1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - }); - - describe('recognize', () => { - it('invokes recognize without error', async () => { - const client = new speechModule.v1p1beta1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.RecognizeRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.RecognizeResponse() - ); - client.innerApiCalls.recognize = stubSimpleCall(expectedResponse); - const [response] = await client.recognize(request); - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes recognize without error using callback', async () => { - const client = new speechModule.v1p1beta1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.RecognizeRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.RecognizeResponse() - ); - client.innerApiCalls.recognize = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.recognize( - request, - (err?: Error|null, result?: protos.google.cloud.speech.v1p1beta1.IRecognizeResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes recognize with error', async () => { - const client = new speechModule.v1p1beta1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.RecognizeRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.recognize = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.recognize(request), expectedError); - }); - - it('invokes recognize with closed client', async () => { - const client = new speechModule.v1p1beta1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.RecognizeRequest() - ); - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.recognize(request), expectedError); - }); - }); - - describe('longRunningRecognize', () => { - it('invokes longRunningRecognize without error', async () => { - const client = new speechModule.v1p1beta1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.LongRunningRecognizeRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.longRunningRecognize = stubLongRunningCall(expectedResponse); - const [operation] = await client.longRunningRecognize(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes longRunningRecognize without error using callback', async () => { - const client = new speechModule.v1p1beta1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.LongRunningRecognizeRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.longRunningRecognize = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.longRunningRecognize( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes longRunningRecognize with call error', async () => { - const client = new speechModule.v1p1beta1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.LongRunningRecognizeRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.longRunningRecognize = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.longRunningRecognize(request), expectedError); - }); - - it('invokes longRunningRecognize with LRO error', async () => { - const client = new speechModule.v1p1beta1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.LongRunningRecognizeRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.longRunningRecognize = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.longRunningRecognize(request); - await assert.rejects(operation.promise(), expectedError); - }); - - it('invokes checkLongRunningRecognizeProgress without error', async () => { - const client = new speechModule.v1p1beta1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkLongRunningRecognizeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkLongRunningRecognizeProgress with error', async () => { - const client = new speechModule.v1p1beta1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkLongRunningRecognizeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('streamingRecognize', () => { - it('invokes streamingRecognize without error', async () => { - const client = new speechModule.v1p1beta1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.StreamingRecognizeRequest() - ); - - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.StreamingRecognizeResponse() - ); - client.innerApiCalls.streamingRecognize = stubBidiStreamingCall(expectedResponse); - const stream = client.streamingRecognize(); - const promise = new Promise((resolve, reject) => { - stream.on('data', (response: protos.google.cloud.speech.v1p1beta1.StreamingRecognizeResponse) => { - resolve(response); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - stream.write(request); - stream.end(); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.streamingRecognize as SinonStub) - .getCall(0).calledWith(null)); - assert.deepStrictEqual(((stream as unknown as PassThrough) - ._transform as SinonStub).getCall(0).args[0], request); - }); - - it('invokes streamingRecognize with error', async () => { - const client = new speechModule.v1p1beta1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.StreamingRecognizeRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.streamingRecognize = stubBidiStreamingCall(undefined, expectedError); - const stream = client.streamingRecognize(); - const promise = new Promise((resolve, reject) => { - stream.on('data', (response: protos.google.cloud.speech.v1p1beta1.StreamingRecognizeResponse) => { - resolve(response); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - stream.write(request); - stream.end(); - }); - await assert.rejects(promise, expectedError); - assert((client.innerApiCalls.streamingRecognize as SinonStub) - .getCall(0).calledWith(null)); - assert.deepStrictEqual(((stream as unknown as PassThrough) - ._transform as SinonStub).getCall(0).args[0], request); - }); - }); - - describe('Path templates', () => { - - describe('customClass', () => { - const fakePath = "/rendered/path/customClass"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - custom_class: "customClassValue", - }; - const client = new speechModule.v1p1beta1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.customClassPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.customClassPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('customClassPath', () => { - const result = client.customClassPath("projectValue", "locationValue", "customClassValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.customClassPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCustomClassName', () => { - const result = client.matchProjectFromCustomClassName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.customClassPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCustomClassName', () => { - const result = client.matchLocationFromCustomClassName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.customClassPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCustomClassFromCustomClassName', () => { - const result = client.matchCustomClassFromCustomClassName(fakePath); - assert.strictEqual(result, "customClassValue"); - assert((client.pathTemplates.customClassPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('phraseSet', () => { - const fakePath = "/rendered/path/phraseSet"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - phrase_set: "phraseSetValue", - }; - const client = new speechModule.v1p1beta1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.phraseSetPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.phraseSetPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('phraseSetPath', () => { - const result = client.phraseSetPath("projectValue", "locationValue", "phraseSetValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.phraseSetPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromPhraseSetName', () => { - const result = client.matchProjectFromPhraseSetName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.phraseSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromPhraseSetName', () => { - const result = client.matchLocationFromPhraseSetName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.phraseSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchPhraseSetFromPhraseSetName', () => { - const result = client.matchPhraseSetFromPhraseSetName(fakePath); - assert.strictEqual(result, "phraseSetValue"); - assert((client.pathTemplates.phraseSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v1p1beta1/tsconfig.json b/owl-bot-staging/v1p1beta1/tsconfig.json deleted file mode 100644 index c78f1c88..00000000 --- a/owl-bot-staging/v1p1beta1/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "resolveJsonModule": true, - "lib": [ - "es2018", - "dom" - ] - }, - "include": [ - "src/*.ts", - "src/**/*.ts", - "test/*.ts", - "test/**/*.ts", - "system-test/*.ts" - ] -} diff --git a/owl-bot-staging/v1p1beta1/webpack.config.js b/owl-bot-staging/v1p1beta1/webpack.config.js deleted file mode 100644 index 50273cca..00000000 --- a/owl-bot-staging/v1p1beta1/webpack.config.js +++ /dev/null @@ -1,64 +0,0 @@ -// 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. - -const path = require('path'); - -module.exports = { - entry: './src/index.ts', - output: { - library: 'Adaptation', - filename: './adaptation.js', - }, - node: { - child_process: 'empty', - fs: 'empty', - crypto: 'empty', - }, - resolve: { - alias: { - '../../../package.json': path.resolve(__dirname, 'package.json'), - }, - extensions: ['.js', '.json', '.ts'], - }, - module: { - rules: [ - { - test: /\.tsx?$/, - use: 'ts-loader', - exclude: /node_modules/ - }, - { - test: /node_modules[\\/]@grpc[\\/]grpc-js/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]grpc/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]retry-request/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]https?-proxy-agent/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]gtoken/, - use: 'null-loader' - }, - ], - }, - mode: 'production', -}; diff --git a/src/v1/adaptation_client.ts b/src/v1/adaptation_client.ts index f4e12fc6..33eec017 100644 --- a/src/v1/adaptation_client.ts +++ b/src/v1/adaptation_client.ts @@ -446,7 +446,7 @@ export class AdaptationClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createPhraseSet(request, options, callback); @@ -537,7 +537,7 @@ export class AdaptationClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getPhraseSet(request, options, callback); @@ -635,7 +635,7 @@ export class AdaptationClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - 'phrase_set.name': request.phraseSet!.name || '', + 'phrase_set.name': request.phraseSet!.name ?? '', }); this.initialize(); return this.innerApiCalls.updatePhraseSet(request, options, callback); @@ -722,7 +722,7 @@ export class AdaptationClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deletePhraseSet(request, options, callback); @@ -829,7 +829,7 @@ export class AdaptationClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createCustomClass(request, options, callback); @@ -916,7 +916,7 @@ export class AdaptationClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getCustomClass(request, options, callback); @@ -1020,7 +1020,7 @@ export class AdaptationClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - 'custom_class.name': request.customClass!.name || '', + 'custom_class.name': request.customClass!.name ?? '', }); this.initialize(); return this.innerApiCalls.updateCustomClass(request, options, callback); @@ -1119,7 +1119,7 @@ export class AdaptationClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteCustomClass(request, options, callback); @@ -1227,7 +1227,7 @@ export class AdaptationClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listPhraseSet(request, options, callback); @@ -1280,7 +1280,7 @@ export class AdaptationClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listPhraseSet']; const callSettings = defaultCallSettings.merge(options); @@ -1342,7 +1342,7 @@ export class AdaptationClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listPhraseSet']; const callSettings = defaultCallSettings.merge(options); @@ -1461,7 +1461,7 @@ export class AdaptationClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listCustomClasses(request, options, callback); @@ -1514,7 +1514,7 @@ export class AdaptationClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listCustomClasses']; const callSettings = defaultCallSettings.merge(options); @@ -1576,7 +1576,7 @@ export class AdaptationClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listCustomClasses']; const callSettings = defaultCallSettings.merge(options); diff --git a/src/v1p1beta1/adaptation_client.ts b/src/v1p1beta1/adaptation_client.ts index 3350fafd..80f1ff00 100644 --- a/src/v1p1beta1/adaptation_client.ts +++ b/src/v1p1beta1/adaptation_client.ts @@ -452,7 +452,7 @@ export class AdaptationClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createPhraseSet(request, options, callback); @@ -551,7 +551,7 @@ export class AdaptationClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getPhraseSet(request, options, callback); @@ -655,7 +655,7 @@ export class AdaptationClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - 'phrase_set.name': request.phraseSet!.name || '', + 'phrase_set.name': request.phraseSet!.name ?? '', }); this.initialize(); return this.innerApiCalls.updatePhraseSet(request, options, callback); @@ -748,7 +748,7 @@ export class AdaptationClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deletePhraseSet(request, options, callback); @@ -861,7 +861,7 @@ export class AdaptationClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createCustomClass(request, options, callback); @@ -954,7 +954,7 @@ export class AdaptationClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getCustomClass(request, options, callback); @@ -1064,7 +1064,7 @@ export class AdaptationClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - 'custom_class.name': request.customClass!.name || '', + 'custom_class.name': request.customClass!.name ?? '', }); this.initialize(); return this.innerApiCalls.updateCustomClass(request, options, callback); @@ -1169,7 +1169,7 @@ export class AdaptationClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteCustomClass(request, options, callback); @@ -1283,7 +1283,7 @@ export class AdaptationClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listPhraseSet(request, options, callback); @@ -1336,7 +1336,7 @@ export class AdaptationClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listPhraseSet']; const callSettings = defaultCallSettings.merge(options); @@ -1398,7 +1398,7 @@ export class AdaptationClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listPhraseSet']; const callSettings = defaultCallSettings.merge(options); @@ -1517,7 +1517,7 @@ export class AdaptationClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listCustomClasses(request, options, callback); @@ -1570,7 +1570,7 @@ export class AdaptationClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listCustomClasses']; const callSettings = defaultCallSettings.merge(options); @@ -1632,7 +1632,7 @@ export class AdaptationClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listCustomClasses']; const callSettings = defaultCallSettings.merge(options); diff --git a/test/gapic_adaptation_v1.ts b/test/gapic_adaptation_v1.ts index 277eb4df..62d7debc 100644 --- a/test/gapic_adaptation_v1.ts +++ b/test/gapic_adaptation_v1.ts @@ -27,6 +27,21 @@ import {PassThrough} from 'stream'; import {protobuf} from 'google-gax'; +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + function generateSampleMessage(instance: T) { const filledObject = ( instance.constructor as typeof protobuf.Message @@ -220,26 +235,25 @@ describe('v1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1.CreatePhraseSetRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreatePhraseSetRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.speech.v1.PhraseSet() ); client.innerApiCalls.createPhraseSet = stubSimpleCall(expectedResponse); const [response] = await client.createPhraseSet(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createPhraseSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createPhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createPhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createPhraseSet without error using callback', async () => { @@ -251,15 +265,11 @@ describe('v1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1.CreatePhraseSetRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreatePhraseSetRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.speech.v1.PhraseSet() ); @@ -282,11 +292,14 @@ describe('v1.AdaptationClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createPhraseSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createPhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createPhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createPhraseSet with error', async () => { @@ -298,26 +311,25 @@ describe('v1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1.CreatePhraseSetRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreatePhraseSetRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createPhraseSet = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.createPhraseSet(request), expectedError); - assert( - (client.innerApiCalls.createPhraseSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createPhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createPhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createPhraseSet with closed client', async () => { @@ -329,7 +341,10 @@ describe('v1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1.CreatePhraseSetRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue('CreatePhraseSetRequest', [ + 'parent', + ]); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.createPhraseSet(request), expectedError); @@ -346,26 +361,25 @@ describe('v1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1.GetPhraseSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetPhraseSetRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.speech.v1.PhraseSet() ); client.innerApiCalls.getPhraseSet = stubSimpleCall(expectedResponse); const [response] = await client.getPhraseSet(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getPhraseSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getPhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getPhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getPhraseSet without error using callback', async () => { @@ -377,15 +391,11 @@ describe('v1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1.GetPhraseSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetPhraseSetRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.speech.v1.PhraseSet() ); @@ -408,11 +418,14 @@ describe('v1.AdaptationClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getPhraseSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getPhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getPhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getPhraseSet with error', async () => { @@ -424,26 +437,25 @@ describe('v1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1.GetPhraseSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetPhraseSetRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getPhraseSet = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getPhraseSet(request), expectedError); - assert( - (client.innerApiCalls.getPhraseSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getPhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getPhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getPhraseSet with closed client', async () => { @@ -455,7 +467,10 @@ describe('v1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1.GetPhraseSetRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetPhraseSetRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getPhraseSet(request), expectedError); @@ -472,27 +487,27 @@ describe('v1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1.UpdatePhraseSetRequest() ); - request.phraseSet = {}; - request.phraseSet.name = ''; - const expectedHeaderRequestParams = 'phrase_set.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.phraseSet ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdatePhraseSetRequest', [ + 'phraseSet', + 'name', + ]); + request.phraseSet.name = defaultValue1; + const expectedHeaderRequestParams = `phrase_set.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.speech.v1.PhraseSet() ); client.innerApiCalls.updatePhraseSet = stubSimpleCall(expectedResponse); const [response] = await client.updatePhraseSet(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updatePhraseSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updatePhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updatePhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updatePhraseSet without error using callback', async () => { @@ -504,16 +519,13 @@ describe('v1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1.UpdatePhraseSetRequest() ); - request.phraseSet = {}; - request.phraseSet.name = ''; - const expectedHeaderRequestParams = 'phrase_set.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.phraseSet ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdatePhraseSetRequest', [ + 'phraseSet', + 'name', + ]); + request.phraseSet.name = defaultValue1; + const expectedHeaderRequestParams = `phrase_set.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.speech.v1.PhraseSet() ); @@ -536,11 +548,14 @@ describe('v1.AdaptationClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updatePhraseSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updatePhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updatePhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updatePhraseSet with error', async () => { @@ -552,27 +567,27 @@ describe('v1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1.UpdatePhraseSetRequest() ); - request.phraseSet = {}; - request.phraseSet.name = ''; - const expectedHeaderRequestParams = 'phrase_set.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.phraseSet ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdatePhraseSetRequest', [ + 'phraseSet', + 'name', + ]); + request.phraseSet.name = defaultValue1; + const expectedHeaderRequestParams = `phrase_set.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updatePhraseSet = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.updatePhraseSet(request), expectedError); - assert( - (client.innerApiCalls.updatePhraseSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updatePhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updatePhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updatePhraseSet with closed client', async () => { @@ -584,8 +599,12 @@ describe('v1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1.UpdatePhraseSetRequest() ); - request.phraseSet = {}; - request.phraseSet.name = ''; + request.phraseSet ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdatePhraseSetRequest', [ + 'phraseSet', + 'name', + ]); + request.phraseSet.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.updatePhraseSet(request), expectedError); @@ -602,26 +621,25 @@ describe('v1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1.DeletePhraseSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeletePhraseSetRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); client.innerApiCalls.deletePhraseSet = stubSimpleCall(expectedResponse); const [response] = await client.deletePhraseSet(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deletePhraseSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deletePhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deletePhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deletePhraseSet without error using callback', async () => { @@ -633,15 +651,11 @@ describe('v1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1.DeletePhraseSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeletePhraseSetRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -664,11 +678,14 @@ describe('v1.AdaptationClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deletePhraseSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deletePhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deletePhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deletePhraseSet with error', async () => { @@ -680,26 +697,25 @@ describe('v1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1.DeletePhraseSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeletePhraseSetRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deletePhraseSet = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.deletePhraseSet(request), expectedError); - assert( - (client.innerApiCalls.deletePhraseSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deletePhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deletePhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deletePhraseSet with closed client', async () => { @@ -711,7 +727,10 @@ describe('v1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1.DeletePhraseSetRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('DeletePhraseSetRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.deletePhraseSet(request), expectedError); @@ -728,26 +747,25 @@ describe('v1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1.CreateCustomClassRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateCustomClassRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.speech.v1.CustomClass() ); client.innerApiCalls.createCustomClass = stubSimpleCall(expectedResponse); const [response] = await client.createCustomClass(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createCustomClass as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createCustomClass without error using callback', async () => { @@ -759,15 +777,11 @@ describe('v1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1.CreateCustomClassRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateCustomClassRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.speech.v1.CustomClass() ); @@ -790,11 +804,14 @@ describe('v1.AdaptationClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createCustomClass as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createCustomClass with error', async () => { @@ -806,26 +823,25 @@ describe('v1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1.CreateCustomClassRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateCustomClassRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createCustomClass = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.createCustomClass(request), expectedError); - assert( - (client.innerApiCalls.createCustomClass as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createCustomClass with closed client', async () => { @@ -837,7 +853,10 @@ describe('v1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1.CreateCustomClassRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue('CreateCustomClassRequest', [ + 'parent', + ]); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.createCustomClass(request), expectedError); @@ -854,26 +873,25 @@ describe('v1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1.GetCustomClassRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetCustomClassRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.speech.v1.CustomClass() ); client.innerApiCalls.getCustomClass = stubSimpleCall(expectedResponse); const [response] = await client.getCustomClass(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getCustomClass as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getCustomClass without error using callback', async () => { @@ -885,15 +903,11 @@ describe('v1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1.GetCustomClassRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetCustomClassRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.speech.v1.CustomClass() ); @@ -916,11 +930,14 @@ describe('v1.AdaptationClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getCustomClass as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getCustomClass with error', async () => { @@ -932,26 +949,25 @@ describe('v1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1.GetCustomClassRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetCustomClassRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getCustomClass = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getCustomClass(request), expectedError); - assert( - (client.innerApiCalls.getCustomClass as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getCustomClass with closed client', async () => { @@ -963,7 +979,10 @@ describe('v1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1.GetCustomClassRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetCustomClassRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getCustomClass(request), expectedError); @@ -980,27 +999,27 @@ describe('v1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1.UpdateCustomClassRequest() ); - request.customClass = {}; - request.customClass.name = ''; - const expectedHeaderRequestParams = 'custom_class.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.customClass ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateCustomClassRequest', [ + 'customClass', + 'name', + ]); + request.customClass.name = defaultValue1; + const expectedHeaderRequestParams = `custom_class.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.speech.v1.CustomClass() ); client.innerApiCalls.updateCustomClass = stubSimpleCall(expectedResponse); const [response] = await client.updateCustomClass(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateCustomClass as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateCustomClass without error using callback', async () => { @@ -1012,16 +1031,13 @@ describe('v1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1.UpdateCustomClassRequest() ); - request.customClass = {}; - request.customClass.name = ''; - const expectedHeaderRequestParams = 'custom_class.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.customClass ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateCustomClassRequest', [ + 'customClass', + 'name', + ]); + request.customClass.name = defaultValue1; + const expectedHeaderRequestParams = `custom_class.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.speech.v1.CustomClass() ); @@ -1044,11 +1060,14 @@ describe('v1.AdaptationClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateCustomClass as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updateCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateCustomClass with error', async () => { @@ -1060,27 +1079,27 @@ describe('v1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1.UpdateCustomClassRequest() ); - request.customClass = {}; - request.customClass.name = ''; - const expectedHeaderRequestParams = 'custom_class.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.customClass ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateCustomClassRequest', [ + 'customClass', + 'name', + ]); + request.customClass.name = defaultValue1; + const expectedHeaderRequestParams = `custom_class.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateCustomClass = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.updateCustomClass(request), expectedError); - assert( - (client.innerApiCalls.updateCustomClass as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateCustomClass with closed client', async () => { @@ -1092,8 +1111,12 @@ describe('v1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1.UpdateCustomClassRequest() ); - request.customClass = {}; - request.customClass.name = ''; + request.customClass ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateCustomClassRequest', [ + 'customClass', + 'name', + ]); + request.customClass.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.updateCustomClass(request), expectedError); @@ -1110,26 +1133,25 @@ describe('v1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1.DeleteCustomClassRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteCustomClassRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); client.innerApiCalls.deleteCustomClass = stubSimpleCall(expectedResponse); const [response] = await client.deleteCustomClass(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteCustomClass as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteCustomClass without error using callback', async () => { @@ -1141,15 +1163,11 @@ describe('v1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1.DeleteCustomClassRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteCustomClassRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1172,11 +1190,14 @@ describe('v1.AdaptationClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteCustomClass as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteCustomClass with error', async () => { @@ -1188,26 +1209,25 @@ describe('v1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1.DeleteCustomClassRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteCustomClassRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteCustomClass = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.deleteCustomClass(request), expectedError); - assert( - (client.innerApiCalls.deleteCustomClass as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteCustomClass with closed client', async () => { @@ -1219,7 +1239,10 @@ describe('v1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1.DeleteCustomClassRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('DeleteCustomClassRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.deleteCustomClass(request), expectedError); @@ -1236,15 +1259,11 @@ describe('v1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1.ListPhraseSetRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListPhraseSetRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.speech.v1.PhraseSet()), generateSampleMessage(new protos.google.cloud.speech.v1.PhraseSet()), @@ -1253,11 +1272,14 @@ describe('v1.AdaptationClient', () => { client.innerApiCalls.listPhraseSet = stubSimpleCall(expectedResponse); const [response] = await client.listPhraseSet(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listPhraseSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listPhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listPhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listPhraseSet without error using callback', async () => { @@ -1269,15 +1291,11 @@ describe('v1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1.ListPhraseSetRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListPhraseSetRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.speech.v1.PhraseSet()), generateSampleMessage(new protos.google.cloud.speech.v1.PhraseSet()), @@ -1302,11 +1320,14 @@ describe('v1.AdaptationClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listPhraseSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listPhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listPhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listPhraseSet with error', async () => { @@ -1318,26 +1339,25 @@ describe('v1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1.ListPhraseSetRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListPhraseSetRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listPhraseSet = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listPhraseSet(request), expectedError); - assert( - (client.innerApiCalls.listPhraseSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listPhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listPhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listPhraseSetStream without error', async () => { @@ -1349,8 +1369,11 @@ describe('v1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1.ListPhraseSetRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListPhraseSetRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.speech.v1.PhraseSet()), generateSampleMessage(new protos.google.cloud.speech.v1.PhraseSet()), @@ -1381,11 +1404,12 @@ describe('v1.AdaptationClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listPhraseSet, request) ); - assert.strictEqual( - ( - client.descriptors.page.listPhraseSet.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listPhraseSet.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1398,8 +1422,11 @@ describe('v1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1.ListPhraseSetRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListPhraseSetRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listPhraseSet.createStream = stubPageStreamingCall(undefined, expectedError); @@ -1425,11 +1452,12 @@ describe('v1.AdaptationClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listPhraseSet, request) ); - assert.strictEqual( - ( - client.descriptors.page.listPhraseSet.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listPhraseSet.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1442,8 +1470,11 @@ describe('v1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1.ListPhraseSetRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListPhraseSetRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.speech.v1.PhraseSet()), generateSampleMessage(new protos.google.cloud.speech.v1.PhraseSet()), @@ -1463,11 +1494,12 @@ describe('v1.AdaptationClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listPhraseSet.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listPhraseSet.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1480,8 +1512,11 @@ describe('v1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1.ListPhraseSetRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListPhraseSetRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listPhraseSet.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -1498,11 +1533,12 @@ describe('v1.AdaptationClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listPhraseSet.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listPhraseSet.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -1517,15 +1553,11 @@ describe('v1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1.ListCustomClassesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListCustomClassesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.speech.v1.CustomClass()), generateSampleMessage(new protos.google.cloud.speech.v1.CustomClass()), @@ -1534,11 +1566,14 @@ describe('v1.AdaptationClient', () => { client.innerApiCalls.listCustomClasses = stubSimpleCall(expectedResponse); const [response] = await client.listCustomClasses(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listCustomClasses as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listCustomClasses as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCustomClasses as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listCustomClasses without error using callback', async () => { @@ -1550,15 +1585,11 @@ describe('v1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1.ListCustomClassesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListCustomClassesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.speech.v1.CustomClass()), generateSampleMessage(new protos.google.cloud.speech.v1.CustomClass()), @@ -1583,11 +1614,14 @@ describe('v1.AdaptationClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listCustomClasses as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listCustomClasses as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCustomClasses as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listCustomClasses with error', async () => { @@ -1599,26 +1633,25 @@ describe('v1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1.ListCustomClassesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListCustomClassesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listCustomClasses = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listCustomClasses(request), expectedError); - assert( - (client.innerApiCalls.listCustomClasses as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listCustomClasses as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCustomClasses as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listCustomClassesStream without error', async () => { @@ -1630,8 +1663,11 @@ describe('v1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1.ListCustomClassesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListCustomClassesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.speech.v1.CustomClass()), generateSampleMessage(new protos.google.cloud.speech.v1.CustomClass()), @@ -1662,11 +1698,12 @@ describe('v1.AdaptationClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listCustomClasses, request) ); - assert.strictEqual( - ( - client.descriptors.page.listCustomClasses.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listCustomClasses.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1679,8 +1716,11 @@ describe('v1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1.ListCustomClassesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListCustomClassesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listCustomClasses.createStream = stubPageStreamingCall(undefined, expectedError); @@ -1706,11 +1746,12 @@ describe('v1.AdaptationClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listCustomClasses, request) ); - assert.strictEqual( - ( - client.descriptors.page.listCustomClasses.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listCustomClasses.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1723,8 +1764,11 @@ describe('v1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1.ListCustomClassesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListCustomClassesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.speech.v1.CustomClass()), generateSampleMessage(new protos.google.cloud.speech.v1.CustomClass()), @@ -1744,11 +1788,12 @@ describe('v1.AdaptationClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listCustomClasses.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listCustomClasses.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1761,8 +1806,11 @@ describe('v1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1.ListCustomClassesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListCustomClassesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listCustomClasses.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -1779,11 +1827,12 @@ describe('v1.AdaptationClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listCustomClasses.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listCustomClasses.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); diff --git a/test/gapic_adaptation_v1p1beta1.ts b/test/gapic_adaptation_v1p1beta1.ts index b36b2370..54b4c86f 100644 --- a/test/gapic_adaptation_v1p1beta1.ts +++ b/test/gapic_adaptation_v1p1beta1.ts @@ -27,6 +27,21 @@ import {PassThrough} from 'stream'; import {protobuf} from 'google-gax'; +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + function generateSampleMessage(instance: T) { const filledObject = ( instance.constructor as typeof protobuf.Message @@ -222,26 +237,25 @@ describe('v1p1beta1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.CreatePhraseSetRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreatePhraseSetRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.PhraseSet() ); client.innerApiCalls.createPhraseSet = stubSimpleCall(expectedResponse); const [response] = await client.createPhraseSet(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createPhraseSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createPhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createPhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createPhraseSet without error using callback', async () => { @@ -253,15 +267,11 @@ describe('v1p1beta1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.CreatePhraseSetRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreatePhraseSetRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.PhraseSet() ); @@ -284,11 +294,14 @@ describe('v1p1beta1.AdaptationClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createPhraseSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createPhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createPhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createPhraseSet with error', async () => { @@ -300,26 +313,25 @@ describe('v1p1beta1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.CreatePhraseSetRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreatePhraseSetRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createPhraseSet = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.createPhraseSet(request), expectedError); - assert( - (client.innerApiCalls.createPhraseSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createPhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createPhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createPhraseSet with closed client', async () => { @@ -331,7 +343,10 @@ describe('v1p1beta1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.CreatePhraseSetRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue('CreatePhraseSetRequest', [ + 'parent', + ]); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.createPhraseSet(request), expectedError); @@ -348,26 +363,25 @@ describe('v1p1beta1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.GetPhraseSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetPhraseSetRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.PhraseSet() ); client.innerApiCalls.getPhraseSet = stubSimpleCall(expectedResponse); const [response] = await client.getPhraseSet(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getPhraseSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getPhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getPhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getPhraseSet without error using callback', async () => { @@ -379,15 +393,11 @@ describe('v1p1beta1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.GetPhraseSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetPhraseSetRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.PhraseSet() ); @@ -410,11 +420,14 @@ describe('v1p1beta1.AdaptationClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getPhraseSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getPhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getPhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getPhraseSet with error', async () => { @@ -426,26 +439,25 @@ describe('v1p1beta1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.GetPhraseSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetPhraseSetRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getPhraseSet = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getPhraseSet(request), expectedError); - assert( - (client.innerApiCalls.getPhraseSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getPhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getPhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getPhraseSet with closed client', async () => { @@ -457,7 +469,10 @@ describe('v1p1beta1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.GetPhraseSetRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetPhraseSetRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getPhraseSet(request), expectedError); @@ -474,27 +489,27 @@ describe('v1p1beta1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest() ); - request.phraseSet = {}; - request.phraseSet.name = ''; - const expectedHeaderRequestParams = 'phrase_set.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.phraseSet ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdatePhraseSetRequest', [ + 'phraseSet', + 'name', + ]); + request.phraseSet.name = defaultValue1; + const expectedHeaderRequestParams = `phrase_set.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.PhraseSet() ); client.innerApiCalls.updatePhraseSet = stubSimpleCall(expectedResponse); const [response] = await client.updatePhraseSet(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updatePhraseSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updatePhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updatePhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updatePhraseSet without error using callback', async () => { @@ -506,16 +521,13 @@ describe('v1p1beta1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest() ); - request.phraseSet = {}; - request.phraseSet.name = ''; - const expectedHeaderRequestParams = 'phrase_set.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.phraseSet ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdatePhraseSetRequest', [ + 'phraseSet', + 'name', + ]); + request.phraseSet.name = defaultValue1; + const expectedHeaderRequestParams = `phrase_set.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.PhraseSet() ); @@ -538,11 +550,14 @@ describe('v1p1beta1.AdaptationClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updatePhraseSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updatePhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updatePhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updatePhraseSet with error', async () => { @@ -554,27 +569,27 @@ describe('v1p1beta1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest() ); - request.phraseSet = {}; - request.phraseSet.name = ''; - const expectedHeaderRequestParams = 'phrase_set.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.phraseSet ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdatePhraseSetRequest', [ + 'phraseSet', + 'name', + ]); + request.phraseSet.name = defaultValue1; + const expectedHeaderRequestParams = `phrase_set.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updatePhraseSet = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.updatePhraseSet(request), expectedError); - assert( - (client.innerApiCalls.updatePhraseSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updatePhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updatePhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updatePhraseSet with closed client', async () => { @@ -586,8 +601,12 @@ describe('v1p1beta1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest() ); - request.phraseSet = {}; - request.phraseSet.name = ''; + request.phraseSet ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdatePhraseSetRequest', [ + 'phraseSet', + 'name', + ]); + request.phraseSet.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.updatePhraseSet(request), expectedError); @@ -604,26 +623,25 @@ describe('v1p1beta1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.DeletePhraseSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeletePhraseSetRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); client.innerApiCalls.deletePhraseSet = stubSimpleCall(expectedResponse); const [response] = await client.deletePhraseSet(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deletePhraseSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deletePhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deletePhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deletePhraseSet without error using callback', async () => { @@ -635,15 +653,11 @@ describe('v1p1beta1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.DeletePhraseSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeletePhraseSetRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -666,11 +680,14 @@ describe('v1p1beta1.AdaptationClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deletePhraseSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deletePhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deletePhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deletePhraseSet with error', async () => { @@ -682,26 +699,25 @@ describe('v1p1beta1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.DeletePhraseSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeletePhraseSetRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deletePhraseSet = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.deletePhraseSet(request), expectedError); - assert( - (client.innerApiCalls.deletePhraseSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deletePhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deletePhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deletePhraseSet with closed client', async () => { @@ -713,7 +729,10 @@ describe('v1p1beta1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.DeletePhraseSetRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('DeletePhraseSetRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.deletePhraseSet(request), expectedError); @@ -730,26 +749,25 @@ describe('v1p1beta1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.CreateCustomClassRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateCustomClassRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.CustomClass() ); client.innerApiCalls.createCustomClass = stubSimpleCall(expectedResponse); const [response] = await client.createCustomClass(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createCustomClass as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createCustomClass without error using callback', async () => { @@ -761,15 +779,11 @@ describe('v1p1beta1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.CreateCustomClassRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateCustomClassRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.CustomClass() ); @@ -792,11 +806,14 @@ describe('v1p1beta1.AdaptationClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createCustomClass as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createCustomClass with error', async () => { @@ -808,26 +825,25 @@ describe('v1p1beta1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.CreateCustomClassRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateCustomClassRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createCustomClass = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.createCustomClass(request), expectedError); - assert( - (client.innerApiCalls.createCustomClass as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createCustomClass with closed client', async () => { @@ -839,7 +855,10 @@ describe('v1p1beta1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.CreateCustomClassRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue('CreateCustomClassRequest', [ + 'parent', + ]); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.createCustomClass(request), expectedError); @@ -856,26 +875,25 @@ describe('v1p1beta1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.GetCustomClassRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetCustomClassRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.CustomClass() ); client.innerApiCalls.getCustomClass = stubSimpleCall(expectedResponse); const [response] = await client.getCustomClass(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getCustomClass as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getCustomClass without error using callback', async () => { @@ -887,15 +905,11 @@ describe('v1p1beta1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.GetCustomClassRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetCustomClassRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.CustomClass() ); @@ -918,11 +932,14 @@ describe('v1p1beta1.AdaptationClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getCustomClass as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getCustomClass with error', async () => { @@ -934,26 +951,25 @@ describe('v1p1beta1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.GetCustomClassRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetCustomClassRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getCustomClass = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getCustomClass(request), expectedError); - assert( - (client.innerApiCalls.getCustomClass as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getCustomClass with closed client', async () => { @@ -965,7 +981,10 @@ describe('v1p1beta1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.GetCustomClassRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetCustomClassRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getCustomClass(request), expectedError); @@ -982,27 +1001,27 @@ describe('v1p1beta1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.UpdateCustomClassRequest() ); - request.customClass = {}; - request.customClass.name = ''; - const expectedHeaderRequestParams = 'custom_class.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.customClass ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateCustomClassRequest', [ + 'customClass', + 'name', + ]); + request.customClass.name = defaultValue1; + const expectedHeaderRequestParams = `custom_class.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.CustomClass() ); client.innerApiCalls.updateCustomClass = stubSimpleCall(expectedResponse); const [response] = await client.updateCustomClass(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateCustomClass as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateCustomClass without error using callback', async () => { @@ -1014,16 +1033,13 @@ describe('v1p1beta1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.UpdateCustomClassRequest() ); - request.customClass = {}; - request.customClass.name = ''; - const expectedHeaderRequestParams = 'custom_class.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.customClass ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateCustomClassRequest', [ + 'customClass', + 'name', + ]); + request.customClass.name = defaultValue1; + const expectedHeaderRequestParams = `custom_class.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.CustomClass() ); @@ -1046,11 +1062,14 @@ describe('v1p1beta1.AdaptationClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateCustomClass as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updateCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateCustomClass with error', async () => { @@ -1062,27 +1081,27 @@ describe('v1p1beta1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.UpdateCustomClassRequest() ); - request.customClass = {}; - request.customClass.name = ''; - const expectedHeaderRequestParams = 'custom_class.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.customClass ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateCustomClassRequest', [ + 'customClass', + 'name', + ]); + request.customClass.name = defaultValue1; + const expectedHeaderRequestParams = `custom_class.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateCustomClass = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.updateCustomClass(request), expectedError); - assert( - (client.innerApiCalls.updateCustomClass as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateCustomClass with closed client', async () => { @@ -1094,8 +1113,12 @@ describe('v1p1beta1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.UpdateCustomClassRequest() ); - request.customClass = {}; - request.customClass.name = ''; + request.customClass ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateCustomClassRequest', [ + 'customClass', + 'name', + ]); + request.customClass.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.updateCustomClass(request), expectedError); @@ -1112,26 +1135,25 @@ describe('v1p1beta1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.DeleteCustomClassRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteCustomClassRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); client.innerApiCalls.deleteCustomClass = stubSimpleCall(expectedResponse); const [response] = await client.deleteCustomClass(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteCustomClass as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteCustomClass without error using callback', async () => { @@ -1143,15 +1165,11 @@ describe('v1p1beta1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.DeleteCustomClassRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteCustomClassRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1174,11 +1192,14 @@ describe('v1p1beta1.AdaptationClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteCustomClass as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteCustomClass with error', async () => { @@ -1190,26 +1211,25 @@ describe('v1p1beta1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.DeleteCustomClassRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteCustomClassRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteCustomClass = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.deleteCustomClass(request), expectedError); - assert( - (client.innerApiCalls.deleteCustomClass as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteCustomClass with closed client', async () => { @@ -1221,7 +1241,10 @@ describe('v1p1beta1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.DeleteCustomClassRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('DeleteCustomClassRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.deleteCustomClass(request), expectedError); @@ -1238,15 +1261,11 @@ describe('v1p1beta1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.ListPhraseSetRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListPhraseSetRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.PhraseSet() @@ -1261,11 +1280,14 @@ describe('v1p1beta1.AdaptationClient', () => { client.innerApiCalls.listPhraseSet = stubSimpleCall(expectedResponse); const [response] = await client.listPhraseSet(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listPhraseSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listPhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listPhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listPhraseSet without error using callback', async () => { @@ -1277,15 +1299,11 @@ describe('v1p1beta1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.ListPhraseSetRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListPhraseSetRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.PhraseSet() @@ -1316,11 +1334,14 @@ describe('v1p1beta1.AdaptationClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listPhraseSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listPhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listPhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listPhraseSet with error', async () => { @@ -1332,26 +1353,25 @@ describe('v1p1beta1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.ListPhraseSetRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListPhraseSetRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listPhraseSet = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listPhraseSet(request), expectedError); - assert( - (client.innerApiCalls.listPhraseSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listPhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listPhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listPhraseSetStream without error', async () => { @@ -1363,8 +1383,11 @@ describe('v1p1beta1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.ListPhraseSetRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListPhraseSetRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.PhraseSet() @@ -1401,11 +1424,12 @@ describe('v1p1beta1.AdaptationClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listPhraseSet, request) ); - assert.strictEqual( - ( - client.descriptors.page.listPhraseSet.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listPhraseSet.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1418,8 +1442,11 @@ describe('v1p1beta1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.ListPhraseSetRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListPhraseSetRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listPhraseSet.createStream = stubPageStreamingCall(undefined, expectedError); @@ -1445,11 +1472,12 @@ describe('v1p1beta1.AdaptationClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listPhraseSet, request) ); - assert.strictEqual( - ( - client.descriptors.page.listPhraseSet.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listPhraseSet.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1462,8 +1490,11 @@ describe('v1p1beta1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.ListPhraseSetRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListPhraseSetRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.PhraseSet() @@ -1489,11 +1520,12 @@ describe('v1p1beta1.AdaptationClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listPhraseSet.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listPhraseSet.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1506,8 +1538,11 @@ describe('v1p1beta1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.ListPhraseSetRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListPhraseSetRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listPhraseSet.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -1524,11 +1559,12 @@ describe('v1p1beta1.AdaptationClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listPhraseSet.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listPhraseSet.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -1543,15 +1579,11 @@ describe('v1p1beta1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.ListCustomClassesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListCustomClassesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.CustomClass() @@ -1566,11 +1598,14 @@ describe('v1p1beta1.AdaptationClient', () => { client.innerApiCalls.listCustomClasses = stubSimpleCall(expectedResponse); const [response] = await client.listCustomClasses(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listCustomClasses as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listCustomClasses as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCustomClasses as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listCustomClasses without error using callback', async () => { @@ -1582,15 +1617,11 @@ describe('v1p1beta1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.ListCustomClassesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListCustomClassesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.CustomClass() @@ -1621,11 +1652,14 @@ describe('v1p1beta1.AdaptationClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listCustomClasses as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listCustomClasses as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCustomClasses as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listCustomClasses with error', async () => { @@ -1637,26 +1671,25 @@ describe('v1p1beta1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.ListCustomClassesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListCustomClassesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listCustomClasses = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listCustomClasses(request), expectedError); - assert( - (client.innerApiCalls.listCustomClasses as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listCustomClasses as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCustomClasses as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listCustomClassesStream without error', async () => { @@ -1668,8 +1701,11 @@ describe('v1p1beta1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.ListCustomClassesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListCustomClassesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.CustomClass() @@ -1707,11 +1743,12 @@ describe('v1p1beta1.AdaptationClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listCustomClasses, request) ); - assert.strictEqual( - ( - client.descriptors.page.listCustomClasses.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listCustomClasses.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1724,8 +1761,11 @@ describe('v1p1beta1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.ListCustomClassesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListCustomClassesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listCustomClasses.createStream = stubPageStreamingCall(undefined, expectedError); @@ -1752,11 +1792,12 @@ describe('v1p1beta1.AdaptationClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listCustomClasses, request) ); - assert.strictEqual( - ( - client.descriptors.page.listCustomClasses.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listCustomClasses.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1769,8 +1810,11 @@ describe('v1p1beta1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.ListCustomClassesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListCustomClassesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.CustomClass() @@ -1796,11 +1840,12 @@ describe('v1p1beta1.AdaptationClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listCustomClasses.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listCustomClasses.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1813,8 +1858,11 @@ describe('v1p1beta1.AdaptationClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.ListCustomClassesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListCustomClassesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listCustomClasses.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -1832,11 +1880,12 @@ describe('v1p1beta1.AdaptationClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listCustomClasses.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listCustomClasses.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); diff --git a/test/gapic_speech_v1.ts b/test/gapic_speech_v1.ts index e7e18321..5ff11d05 100644 --- a/test/gapic_speech_v1.ts +++ b/test/gapic_speech_v1.ts @@ -27,6 +27,21 @@ import {PassThrough} from 'stream'; import {protobuf, LROperation, operationsProtos} from 'google-gax'; +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + function generateSampleMessage(instance: T) { const filledObject = ( instance.constructor as typeof protobuf.Message @@ -205,18 +220,12 @@ describe('v1.SpeechClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1.RecognizeRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.speech.v1.RecognizeResponse() ); client.innerApiCalls.recognize = stubSimpleCall(expectedResponse); const [response] = await client.recognize(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.recognize as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes recognize without error using callback', async () => { @@ -228,7 +237,6 @@ describe('v1.SpeechClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1.RecognizeRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.speech.v1.RecognizeResponse() ); @@ -251,11 +259,6 @@ describe('v1.SpeechClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.recognize as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); }); it('invokes recognize with error', async () => { @@ -267,15 +270,9 @@ describe('v1.SpeechClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1.RecognizeRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedError = new Error('expected'); client.innerApiCalls.recognize = stubSimpleCall(undefined, expectedError); await assert.rejects(client.recognize(request), expectedError); - assert( - (client.innerApiCalls.recognize as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes recognize with closed client', async () => { @@ -303,7 +300,6 @@ describe('v1.SpeechClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1.LongRunningRecognizeRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -312,11 +308,6 @@ describe('v1.SpeechClient', () => { const [operation] = await client.longRunningRecognize(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.longRunningRecognize as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes longRunningRecognize without error using callback', async () => { @@ -328,7 +319,6 @@ describe('v1.SpeechClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1.LongRunningRecognizeRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -358,11 +348,6 @@ describe('v1.SpeechClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.longRunningRecognize as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); }); it('invokes longRunningRecognize with call error', async () => { @@ -374,18 +359,12 @@ describe('v1.SpeechClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1.LongRunningRecognizeRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedError = new Error('expected'); client.innerApiCalls.longRunningRecognize = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.longRunningRecognize(request), expectedError); - assert( - (client.innerApiCalls.longRunningRecognize as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes longRunningRecognize with LRO error', async () => { @@ -397,7 +376,6 @@ describe('v1.SpeechClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1.LongRunningRecognizeRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedError = new Error('expected'); client.innerApiCalls.longRunningRecognize = stubLongRunningCall( undefined, @@ -406,11 +384,6 @@ describe('v1.SpeechClient', () => { ); const [operation] = await client.longRunningRecognize(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.longRunningRecognize as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes checkLongRunningRecognizeProgress without error', async () => { @@ -465,6 +438,7 @@ describe('v1.SpeechClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1.StreamingRecognizeRequest() ); + const expectedResponse = generateSampleMessage( new protos.google.cloud.speech.v1.StreamingRecognizeResponse() ); diff --git a/test/gapic_speech_v1p1beta1.ts b/test/gapic_speech_v1p1beta1.ts index 2121fdfa..9784590e 100644 --- a/test/gapic_speech_v1p1beta1.ts +++ b/test/gapic_speech_v1p1beta1.ts @@ -27,6 +27,21 @@ import {PassThrough} from 'stream'; import {protobuf, LROperation, operationsProtos} from 'google-gax'; +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + function generateSampleMessage(instance: T) { const filledObject = ( instance.constructor as typeof protobuf.Message @@ -205,18 +220,12 @@ describe('v1p1beta1.SpeechClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.RecognizeRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.RecognizeResponse() ); client.innerApiCalls.recognize = stubSimpleCall(expectedResponse); const [response] = await client.recognize(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.recognize as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes recognize without error using callback', async () => { @@ -228,7 +237,6 @@ describe('v1p1beta1.SpeechClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.RecognizeRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.RecognizeResponse() ); @@ -251,11 +259,6 @@ describe('v1p1beta1.SpeechClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.recognize as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); }); it('invokes recognize with error', async () => { @@ -267,15 +270,9 @@ describe('v1p1beta1.SpeechClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.RecognizeRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedError = new Error('expected'); client.innerApiCalls.recognize = stubSimpleCall(undefined, expectedError); await assert.rejects(client.recognize(request), expectedError); - assert( - (client.innerApiCalls.recognize as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes recognize with closed client', async () => { @@ -303,7 +300,6 @@ describe('v1p1beta1.SpeechClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.LongRunningRecognizeRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -312,11 +308,6 @@ describe('v1p1beta1.SpeechClient', () => { const [operation] = await client.longRunningRecognize(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.longRunningRecognize as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes longRunningRecognize without error using callback', async () => { @@ -328,7 +319,6 @@ describe('v1p1beta1.SpeechClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.LongRunningRecognizeRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -358,11 +348,6 @@ describe('v1p1beta1.SpeechClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.longRunningRecognize as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); }); it('invokes longRunningRecognize with call error', async () => { @@ -374,18 +359,12 @@ describe('v1p1beta1.SpeechClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.LongRunningRecognizeRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedError = new Error('expected'); client.innerApiCalls.longRunningRecognize = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.longRunningRecognize(request), expectedError); - assert( - (client.innerApiCalls.longRunningRecognize as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes longRunningRecognize with LRO error', async () => { @@ -397,7 +376,6 @@ describe('v1p1beta1.SpeechClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.LongRunningRecognizeRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedError = new Error('expected'); client.innerApiCalls.longRunningRecognize = stubLongRunningCall( undefined, @@ -406,11 +384,6 @@ describe('v1p1beta1.SpeechClient', () => { ); const [operation] = await client.longRunningRecognize(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.longRunningRecognize as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes checkLongRunningRecognizeProgress without error', async () => { @@ -465,6 +438,7 @@ describe('v1p1beta1.SpeechClient', () => { const request = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.StreamingRecognizeRequest() ); + const expectedResponse = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.StreamingRecognizeResponse() );