diff --git a/packages/google-cloud-language/linkinator.config.json b/packages/google-cloud-language/linkinator.config.json index 29a223b6db6..0121dfa684f 100644 --- a/packages/google-cloud-language/linkinator.config.json +++ b/packages/google-cloud-language/linkinator.config.json @@ -6,5 +6,5 @@ "img.shields.io" ], "silent": true, - "concurrency": 10 + "concurrency": 5 } diff --git a/packages/google-cloud-language/samples/generated/v1/language_service.analyze_entities.js b/packages/google-cloud-language/samples/generated/v1/language_service.analyze_entities.js new file mode 100644 index 00000000000..d74f55fa4d5 --- /dev/null +++ b/packages/google-cloud-language/samples/generated/v1/language_service.analyze_entities.js @@ -0,0 +1,56 @@ +// 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 +// +// 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. + +'use strict'; + +function main(document) { + // [START language_v1_generated_LanguageService_AnalyzeEntities_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Input document. + */ + // const document = {} + /** + * The encoding type used by the API to calculate offsets. + */ + // const encodingType = {} + + // Imports the Language library + const {LanguageServiceClient} = require('@google-cloud/language').v1; + + // Instantiates a client + const languageClient = new LanguageServiceClient(); + + async function callAnalyzeEntities() { + // Construct request + const request = { + document, + }; + + // Run request + const response = await languageClient.analyzeEntities(request); + console.log(response); + } + + callAnalyzeEntities(); + // [END language_v1_generated_LanguageService_AnalyzeEntities_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-language/samples/generated/v1/language_service.analyze_entity_sentiment.js b/packages/google-cloud-language/samples/generated/v1/language_service.analyze_entity_sentiment.js new file mode 100644 index 00000000000..b78fbfc9d6b --- /dev/null +++ b/packages/google-cloud-language/samples/generated/v1/language_service.analyze_entity_sentiment.js @@ -0,0 +1,56 @@ +// 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 +// +// 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. + +'use strict'; + +function main(document) { + // [START language_v1_generated_LanguageService_AnalyzeEntitySentiment_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Input document. + */ + // const document = {} + /** + * The encoding type used by the API to calculate offsets. + */ + // const encodingType = {} + + // Imports the Language library + const {LanguageServiceClient} = require('@google-cloud/language').v1; + + // Instantiates a client + const languageClient = new LanguageServiceClient(); + + async function callAnalyzeEntitySentiment() { + // Construct request + const request = { + document, + }; + + // Run request + const response = await languageClient.analyzeEntitySentiment(request); + console.log(response); + } + + callAnalyzeEntitySentiment(); + // [END language_v1_generated_LanguageService_AnalyzeEntitySentiment_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-language/samples/generated/v1/language_service.analyze_sentiment.js b/packages/google-cloud-language/samples/generated/v1/language_service.analyze_sentiment.js new file mode 100644 index 00000000000..440cec2398d --- /dev/null +++ b/packages/google-cloud-language/samples/generated/v1/language_service.analyze_sentiment.js @@ -0,0 +1,56 @@ +// 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 +// +// 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. + +'use strict'; + +function main(document) { + // [START language_v1_generated_LanguageService_AnalyzeSentiment_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Input document. + */ + // const document = {} + /** + * The encoding type used by the API to calculate sentence offsets. + */ + // const encodingType = {} + + // Imports the Language library + const {LanguageServiceClient} = require('@google-cloud/language').v1; + + // Instantiates a client + const languageClient = new LanguageServiceClient(); + + async function callAnalyzeSentiment() { + // Construct request + const request = { + document, + }; + + // Run request + const response = await languageClient.analyzeSentiment(request); + console.log(response); + } + + callAnalyzeSentiment(); + // [END language_v1_generated_LanguageService_AnalyzeSentiment_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-language/samples/generated/v1/language_service.analyze_syntax.js b/packages/google-cloud-language/samples/generated/v1/language_service.analyze_syntax.js new file mode 100644 index 00000000000..402a250e40e --- /dev/null +++ b/packages/google-cloud-language/samples/generated/v1/language_service.analyze_syntax.js @@ -0,0 +1,56 @@ +// 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 +// +// 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. + +'use strict'; + +function main(document) { + // [START language_v1_generated_LanguageService_AnalyzeSyntax_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Input document. + */ + // const document = {} + /** + * The encoding type used by the API to calculate offsets. + */ + // const encodingType = {} + + // Imports the Language library + const {LanguageServiceClient} = require('@google-cloud/language').v1; + + // Instantiates a client + const languageClient = new LanguageServiceClient(); + + async function callAnalyzeSyntax() { + // Construct request + const request = { + document, + }; + + // Run request + const response = await languageClient.analyzeSyntax(request); + console.log(response); + } + + callAnalyzeSyntax(); + // [END language_v1_generated_LanguageService_AnalyzeSyntax_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-language/samples/generated/v1/language_service.annotate_text.js b/packages/google-cloud-language/samples/generated/v1/language_service.annotate_text.js new file mode 100644 index 00000000000..9b2be51bfc4 --- /dev/null +++ b/packages/google-cloud-language/samples/generated/v1/language_service.annotate_text.js @@ -0,0 +1,61 @@ +// 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 +// +// 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. + +'use strict'; + +function main(document, features) { + // [START language_v1_generated_LanguageService_AnnotateText_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Input document. + */ + // const document = {} + /** + * The enabled features. + */ + // const features = {} + /** + * The encoding type used by the API to calculate offsets. + */ + // const encodingType = {} + + // Imports the Language library + const {LanguageServiceClient} = require('@google-cloud/language').v1; + + // Instantiates a client + const languageClient = new LanguageServiceClient(); + + async function callAnnotateText() { + // Construct request + const request = { + document, + features, + }; + + // Run request + const response = await languageClient.annotateText(request); + console.log(response); + } + + callAnnotateText(); + // [END language_v1_generated_LanguageService_AnnotateText_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-language/samples/generated/v1/language_service.classify_text.js b/packages/google-cloud-language/samples/generated/v1/language_service.classify_text.js new file mode 100644 index 00000000000..b20fb03a568 --- /dev/null +++ b/packages/google-cloud-language/samples/generated/v1/language_service.classify_text.js @@ -0,0 +1,52 @@ +// 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 +// +// 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. + +'use strict'; + +function main(document) { + // [START language_v1_generated_LanguageService_ClassifyText_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Input document. + */ + // const document = {} + + // Imports the Language library + const {LanguageServiceClient} = require('@google-cloud/language').v1; + + // Instantiates a client + const languageClient = new LanguageServiceClient(); + + async function callClassifyText() { + // Construct request + const request = { + document, + }; + + // Run request + const response = await languageClient.classifyText(request); + console.log(response); + } + + callClassifyText(); + // [END language_v1_generated_LanguageService_ClassifyText_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-language/samples/generated/v1beta2/language_service.analyze_entities.js b/packages/google-cloud-language/samples/generated/v1beta2/language_service.analyze_entities.js new file mode 100644 index 00000000000..358fb868823 --- /dev/null +++ b/packages/google-cloud-language/samples/generated/v1beta2/language_service.analyze_entities.js @@ -0,0 +1,56 @@ +// 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 +// +// 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. + +'use strict'; + +function main(document) { + // [START language_v1beta2_generated_LanguageService_AnalyzeEntities_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Input document. + */ + // const document = {} + /** + * The encoding type used by the API to calculate offsets. + */ + // const encodingType = {} + + // Imports the Language library + const {LanguageServiceClient} = require('@google-cloud/language').v1beta2; + + // Instantiates a client + const languageClient = new LanguageServiceClient(); + + async function callAnalyzeEntities() { + // Construct request + const request = { + document, + }; + + // Run request + const response = await languageClient.analyzeEntities(request); + console.log(response); + } + + callAnalyzeEntities(); + // [END language_v1beta2_generated_LanguageService_AnalyzeEntities_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-language/samples/generated/v1beta2/language_service.analyze_entity_sentiment.js b/packages/google-cloud-language/samples/generated/v1beta2/language_service.analyze_entity_sentiment.js new file mode 100644 index 00000000000..0061d977863 --- /dev/null +++ b/packages/google-cloud-language/samples/generated/v1beta2/language_service.analyze_entity_sentiment.js @@ -0,0 +1,56 @@ +// 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 +// +// 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. + +'use strict'; + +function main(document) { + // [START language_v1beta2_generated_LanguageService_AnalyzeEntitySentiment_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Input document. + */ + // const document = {} + /** + * The encoding type used by the API to calculate offsets. + */ + // const encodingType = {} + + // Imports the Language library + const {LanguageServiceClient} = require('@google-cloud/language').v1beta2; + + // Instantiates a client + const languageClient = new LanguageServiceClient(); + + async function callAnalyzeEntitySentiment() { + // Construct request + const request = { + document, + }; + + // Run request + const response = await languageClient.analyzeEntitySentiment(request); + console.log(response); + } + + callAnalyzeEntitySentiment(); + // [END language_v1beta2_generated_LanguageService_AnalyzeEntitySentiment_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-language/samples/generated/v1beta2/language_service.analyze_sentiment.js b/packages/google-cloud-language/samples/generated/v1beta2/language_service.analyze_sentiment.js new file mode 100644 index 00000000000..b27b7eaccae --- /dev/null +++ b/packages/google-cloud-language/samples/generated/v1beta2/language_service.analyze_sentiment.js @@ -0,0 +1,57 @@ +// 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 +// +// 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. + +'use strict'; + +function main(document) { + // [START language_v1beta2_generated_LanguageService_AnalyzeSentiment_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Input document. + */ + // const document = {} + /** + * The encoding type used by the API to calculate sentence offsets for the + * sentence sentiment. + */ + // const encodingType = {} + + // Imports the Language library + const {LanguageServiceClient} = require('@google-cloud/language').v1beta2; + + // Instantiates a client + const languageClient = new LanguageServiceClient(); + + async function callAnalyzeSentiment() { + // Construct request + const request = { + document, + }; + + // Run request + const response = await languageClient.analyzeSentiment(request); + console.log(response); + } + + callAnalyzeSentiment(); + // [END language_v1beta2_generated_LanguageService_AnalyzeSentiment_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-language/samples/generated/v1beta2/language_service.analyze_syntax.js b/packages/google-cloud-language/samples/generated/v1beta2/language_service.analyze_syntax.js new file mode 100644 index 00000000000..a8a770776ae --- /dev/null +++ b/packages/google-cloud-language/samples/generated/v1beta2/language_service.analyze_syntax.js @@ -0,0 +1,56 @@ +// 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 +// +// 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. + +'use strict'; + +function main(document) { + // [START language_v1beta2_generated_LanguageService_AnalyzeSyntax_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Input document. + */ + // const document = {} + /** + * The encoding type used by the API to calculate offsets. + */ + // const encodingType = {} + + // Imports the Language library + const {LanguageServiceClient} = require('@google-cloud/language').v1beta2; + + // Instantiates a client + const languageClient = new LanguageServiceClient(); + + async function callAnalyzeSyntax() { + // Construct request + const request = { + document, + }; + + // Run request + const response = await languageClient.analyzeSyntax(request); + console.log(response); + } + + callAnalyzeSyntax(); + // [END language_v1beta2_generated_LanguageService_AnalyzeSyntax_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-language/samples/generated/v1beta2/language_service.annotate_text.js b/packages/google-cloud-language/samples/generated/v1beta2/language_service.annotate_text.js new file mode 100644 index 00000000000..61ffb0a1248 --- /dev/null +++ b/packages/google-cloud-language/samples/generated/v1beta2/language_service.annotate_text.js @@ -0,0 +1,61 @@ +// 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 +// +// 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. + +'use strict'; + +function main(document, features) { + // [START language_v1beta2_generated_LanguageService_AnnotateText_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Input document. + */ + // const document = {} + /** + * Required. The enabled features. + */ + // const features = {} + /** + * The encoding type used by the API to calculate offsets. + */ + // const encodingType = {} + + // Imports the Language library + const {LanguageServiceClient} = require('@google-cloud/language').v1beta2; + + // Instantiates a client + const languageClient = new LanguageServiceClient(); + + async function callAnnotateText() { + // Construct request + const request = { + document, + features, + }; + + // Run request + const response = await languageClient.annotateText(request); + console.log(response); + } + + callAnnotateText(); + // [END language_v1beta2_generated_LanguageService_AnnotateText_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-language/samples/generated/v1beta2/language_service.classify_text.js b/packages/google-cloud-language/samples/generated/v1beta2/language_service.classify_text.js new file mode 100644 index 00000000000..e4c448c04a8 --- /dev/null +++ b/packages/google-cloud-language/samples/generated/v1beta2/language_service.classify_text.js @@ -0,0 +1,52 @@ +// 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 +// +// 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. + +'use strict'; + +function main(document) { + // [START language_v1beta2_generated_LanguageService_ClassifyText_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Input document. + */ + // const document = {} + + // Imports the Language library + const {LanguageServiceClient} = require('@google-cloud/language').v1beta2; + + // Instantiates a client + const languageClient = new LanguageServiceClient(); + + async function callClassifyText() { + // Construct request + const request = { + document, + }; + + // Run request + const response = await languageClient.classifyText(request); + console.log(response); + } + + callClassifyText(); + // [END language_v1beta2_generated_LanguageService_ClassifyText_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-language/src/v1/language_service_client.ts b/packages/google-cloud-language/src/v1/language_service_client.ts index aa13ba11105..7e1e65c44b3 100644 --- a/packages/google-cloud-language/src/v1/language_service_client.ts +++ b/packages/google-cloud-language/src/v1/language_service_client.ts @@ -292,6 +292,25 @@ export class LanguageServiceClient { // ------------------- // -- Service calls -- // ------------------- + /** + * Analyzes the sentiment of the provided text. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.language.v1.Document} request.document + * Input document. + * @param {google.cloud.language.v1.EncodingType} request.encodingType + * The encoding type used by the API to calculate sentence offsets. + * @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 [AnalyzeSentimentResponse]{@link google.cloud.language.v1.AnalyzeSentimentResponse}. + * 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/language_service.analyze_sentiment.js + * region_tag:language_v1_generated_LanguageService_AnalyzeSentiment_async + */ analyzeSentiment( request?: protos.google.cloud.language.v1.IAnalyzeSentimentRequest, options?: CallOptions @@ -323,25 +342,6 @@ export class LanguageServiceClient { {} | null | undefined > ): void; - /** - * Analyzes the sentiment of the provided text. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.language.v1.Document} request.document - * Input document. - * @param {google.cloud.language.v1.EncodingType} request.encodingType - * The encoding type used by the API to calculate sentence offsets. - * @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 [AnalyzeSentimentResponse]{@link google.cloud.language.v1.AnalyzeSentimentResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * const [response] = await client.analyzeSentiment(request); - */ analyzeSentiment( request?: protos.google.cloud.language.v1.IAnalyzeSentimentRequest, optionsOrCallback?: @@ -376,9 +376,32 @@ export class LanguageServiceClient { options = optionsOrCallback as CallOptions; } options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; this.initialize(); return this.innerApiCalls.analyzeSentiment(request, options, callback); } + /** + * Finds named entities (currently proper names and common nouns) in the text + * along with entity types, salience, mentions for each entity, and + * other properties. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.language.v1.Document} request.document + * Input document. + * @param {google.cloud.language.v1.EncodingType} request.encodingType + * The encoding type used by the API to calculate offsets. + * @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 [AnalyzeEntitiesResponse]{@link google.cloud.language.v1.AnalyzeEntitiesResponse}. + * 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/language_service.analyze_entities.js + * region_tag:language_v1_generated_LanguageService_AnalyzeEntities_async + */ analyzeEntities( request?: protos.google.cloud.language.v1.IAnalyzeEntitiesRequest, options?: CallOptions @@ -410,27 +433,6 @@ export class LanguageServiceClient { {} | null | undefined > ): void; - /** - * Finds named entities (currently proper names and common nouns) in the text - * along with entity types, salience, mentions for each entity, and - * other properties. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.language.v1.Document} request.document - * Input document. - * @param {google.cloud.language.v1.EncodingType} request.encodingType - * The encoding type used by the API to calculate offsets. - * @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 [AnalyzeEntitiesResponse]{@link google.cloud.language.v1.AnalyzeEntitiesResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * const [response] = await client.analyzeEntities(request); - */ analyzeEntities( request?: protos.google.cloud.language.v1.IAnalyzeEntitiesRequest, optionsOrCallback?: @@ -465,9 +467,31 @@ export class LanguageServiceClient { options = optionsOrCallback as CallOptions; } options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; this.initialize(); return this.innerApiCalls.analyzeEntities(request, options, callback); } + /** + * Finds entities, similar to {@link google.cloud.language.v1.LanguageService.AnalyzeEntities|AnalyzeEntities} in the text and analyzes + * sentiment associated with each entity and its mentions. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.language.v1.Document} request.document + * Input document. + * @param {google.cloud.language.v1.EncodingType} request.encodingType + * The encoding type used by the API to calculate offsets. + * @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 [AnalyzeEntitySentimentResponse]{@link google.cloud.language.v1.AnalyzeEntitySentimentResponse}. + * 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/language_service.analyze_entity_sentiment.js + * region_tag:language_v1_generated_LanguageService_AnalyzeEntitySentiment_async + */ analyzeEntitySentiment( request?: protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest, options?: CallOptions @@ -502,26 +526,6 @@ export class LanguageServiceClient { {} | null | undefined > ): void; - /** - * Finds entities, similar to {@link google.cloud.language.v1.LanguageService.AnalyzeEntities|AnalyzeEntities} in the text and analyzes - * sentiment associated with each entity and its mentions. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.language.v1.Document} request.document - * Input document. - * @param {google.cloud.language.v1.EncodingType} request.encodingType - * The encoding type used by the API to calculate offsets. - * @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 [AnalyzeEntitySentimentResponse]{@link google.cloud.language.v1.AnalyzeEntitySentimentResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * const [response] = await client.analyzeEntitySentiment(request); - */ analyzeEntitySentiment( request?: protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest, optionsOrCallback?: @@ -559,6 +563,8 @@ export class LanguageServiceClient { options = optionsOrCallback as CallOptions; } options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; this.initialize(); return this.innerApiCalls.analyzeEntitySentiment( request, @@ -566,6 +572,27 @@ export class LanguageServiceClient { callback ); } + /** + * Analyzes the syntax of the text and provides sentence boundaries and + * tokenization along with part of speech tags, dependency trees, and other + * properties. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.language.v1.Document} request.document + * Input document. + * @param {google.cloud.language.v1.EncodingType} request.encodingType + * The encoding type used by the API to calculate offsets. + * @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 [AnalyzeSyntaxResponse]{@link google.cloud.language.v1.AnalyzeSyntaxResponse}. + * 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/language_service.analyze_syntax.js + * region_tag:language_v1_generated_LanguageService_AnalyzeSyntax_async + */ analyzeSyntax( request?: protos.google.cloud.language.v1.IAnalyzeSyntaxRequest, options?: CallOptions @@ -593,27 +620,6 @@ export class LanguageServiceClient { {} | null | undefined > ): void; - /** - * Analyzes the syntax of the text and provides sentence boundaries and - * tokenization along with part of speech tags, dependency trees, and other - * properties. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.language.v1.Document} request.document - * Input document. - * @param {google.cloud.language.v1.EncodingType} request.encodingType - * The encoding type used by the API to calculate offsets. - * @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 [AnalyzeSyntaxResponse]{@link google.cloud.language.v1.AnalyzeSyntaxResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * const [response] = await client.analyzeSyntax(request); - */ analyzeSyntax( request?: protos.google.cloud.language.v1.IAnalyzeSyntaxRequest, optionsOrCallback?: @@ -646,9 +652,28 @@ export class LanguageServiceClient { options = optionsOrCallback as CallOptions; } options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; this.initialize(); return this.innerApiCalls.analyzeSyntax(request, options, callback); } + /** + * Classifies a document into categories. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.language.v1.Document} request.document + * Input document. + * @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 [ClassifyTextResponse]{@link google.cloud.language.v1.ClassifyTextResponse}. + * 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/language_service.classify_text.js + * region_tag:language_v1_generated_LanguageService_ClassifyText_async + */ classifyText( request?: protos.google.cloud.language.v1.IClassifyTextRequest, options?: CallOptions @@ -676,23 +701,6 @@ export class LanguageServiceClient { {} | null | undefined > ): void; - /** - * Classifies a document into categories. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.language.v1.Document} request.document - * Input document. - * @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 [ClassifyTextResponse]{@link google.cloud.language.v1.ClassifyTextResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * const [response] = await client.classifyText(request); - */ classifyText( request?: protos.google.cloud.language.v1.IClassifyTextRequest, optionsOrCallback?: @@ -725,9 +733,33 @@ export class LanguageServiceClient { options = optionsOrCallback as CallOptions; } options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; this.initialize(); return this.innerApiCalls.classifyText(request, options, callback); } + /** + * A convenience method that provides all the features that analyzeSentiment, + * analyzeEntities, and analyzeSyntax provide in one call. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.language.v1.Document} request.document + * Input document. + * @param {google.cloud.language.v1.AnnotateTextRequest.Features} request.features + * The enabled features. + * @param {google.cloud.language.v1.EncodingType} request.encodingType + * The encoding type used by the API to calculate offsets. + * @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 [AnnotateTextResponse]{@link google.cloud.language.v1.AnnotateTextResponse}. + * 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/language_service.annotate_text.js + * region_tag:language_v1_generated_LanguageService_AnnotateText_async + */ annotateText( request?: protos.google.cloud.language.v1.IAnnotateTextRequest, options?: CallOptions @@ -755,28 +787,6 @@ export class LanguageServiceClient { {} | null | undefined > ): void; - /** - * A convenience method that provides all the features that analyzeSentiment, - * analyzeEntities, and analyzeSyntax provide in one call. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.language.v1.Document} request.document - * Input document. - * @param {google.cloud.language.v1.AnnotateTextRequest.Features} request.features - * The enabled features. - * @param {google.cloud.language.v1.EncodingType} request.encodingType - * The encoding type used by the API to calculate offsets. - * @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 [AnnotateTextResponse]{@link google.cloud.language.v1.AnnotateTextResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * const [response] = await client.annotateText(request); - */ annotateText( request?: protos.google.cloud.language.v1.IAnnotateTextRequest, optionsOrCallback?: @@ -809,6 +819,8 @@ export class LanguageServiceClient { options = optionsOrCallback as CallOptions; } options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; this.initialize(); return this.innerApiCalls.annotateText(request, options, callback); } diff --git a/packages/google-cloud-language/src/v1beta2/language_service_client.ts b/packages/google-cloud-language/src/v1beta2/language_service_client.ts index 1375ddf5176..b64ddee179d 100644 --- a/packages/google-cloud-language/src/v1beta2/language_service_client.ts +++ b/packages/google-cloud-language/src/v1beta2/language_service_client.ts @@ -292,6 +292,26 @@ export class LanguageServiceClient { // ------------------- // -- Service calls -- // ------------------- + /** + * Analyzes the sentiment of the provided text. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.language.v1beta2.Document} request.document + * Required. Input document. + * @param {google.cloud.language.v1beta2.EncodingType} request.encodingType + * The encoding type used by the API to calculate sentence offsets for the + * sentence sentiment. + * @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 [AnalyzeSentimentResponse]{@link google.cloud.language.v1beta2.AnalyzeSentimentResponse}. + * 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/v1beta2/language_service.analyze_sentiment.js + * region_tag:language_v1beta2_generated_LanguageService_AnalyzeSentiment_async + */ analyzeSentiment( request?: protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest, options?: CallOptions @@ -323,26 +343,6 @@ export class LanguageServiceClient { {} | null | undefined > ): void; - /** - * Analyzes the sentiment of the provided text. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.language.v1beta2.Document} request.document - * Required. Input document. - * @param {google.cloud.language.v1beta2.EncodingType} request.encodingType - * The encoding type used by the API to calculate sentence offsets for the - * sentence sentiment. - * @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 [AnalyzeSentimentResponse]{@link google.cloud.language.v1beta2.AnalyzeSentimentResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * const [response] = await client.analyzeSentiment(request); - */ analyzeSentiment( request?: protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest, optionsOrCallback?: @@ -377,9 +377,32 @@ export class LanguageServiceClient { options = optionsOrCallback as CallOptions; } options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; this.initialize(); return this.innerApiCalls.analyzeSentiment(request, options, callback); } + /** + * Finds named entities (currently proper names and common nouns) in the text + * along with entity types, salience, mentions for each entity, and + * other properties. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.language.v1beta2.Document} request.document + * Required. Input document. + * @param {google.cloud.language.v1beta2.EncodingType} request.encodingType + * The encoding type used by the API to calculate offsets. + * @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 [AnalyzeEntitiesResponse]{@link google.cloud.language.v1beta2.AnalyzeEntitiesResponse}. + * 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/v1beta2/language_service.analyze_entities.js + * region_tag:language_v1beta2_generated_LanguageService_AnalyzeEntities_async + */ analyzeEntities( request?: protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest, options?: CallOptions @@ -411,27 +434,6 @@ export class LanguageServiceClient { {} | null | undefined > ): void; - /** - * Finds named entities (currently proper names and common nouns) in the text - * along with entity types, salience, mentions for each entity, and - * other properties. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.language.v1beta2.Document} request.document - * Required. Input document. - * @param {google.cloud.language.v1beta2.EncodingType} request.encodingType - * The encoding type used by the API to calculate offsets. - * @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 [AnalyzeEntitiesResponse]{@link google.cloud.language.v1beta2.AnalyzeEntitiesResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * const [response] = await client.analyzeEntities(request); - */ analyzeEntities( request?: protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest, optionsOrCallback?: @@ -466,9 +468,31 @@ export class LanguageServiceClient { options = optionsOrCallback as CallOptions; } options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; this.initialize(); return this.innerApiCalls.analyzeEntities(request, options, callback); } + /** + * Finds entities, similar to {@link google.cloud.language.v1beta2.LanguageService.AnalyzeEntities|AnalyzeEntities} in the text and analyzes + * sentiment associated with each entity and its mentions. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.language.v1beta2.Document} request.document + * Required. Input document. + * @param {google.cloud.language.v1beta2.EncodingType} request.encodingType + * The encoding type used by the API to calculate offsets. + * @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 [AnalyzeEntitySentimentResponse]{@link google.cloud.language.v1beta2.AnalyzeEntitySentimentResponse}. + * 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/v1beta2/language_service.analyze_entity_sentiment.js + * region_tag:language_v1beta2_generated_LanguageService_AnalyzeEntitySentiment_async + */ analyzeEntitySentiment( request?: protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest, options?: CallOptions @@ -503,26 +527,6 @@ export class LanguageServiceClient { {} | null | undefined > ): void; - /** - * Finds entities, similar to {@link google.cloud.language.v1beta2.LanguageService.AnalyzeEntities|AnalyzeEntities} in the text and analyzes - * sentiment associated with each entity and its mentions. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.language.v1beta2.Document} request.document - * Required. Input document. - * @param {google.cloud.language.v1beta2.EncodingType} request.encodingType - * The encoding type used by the API to calculate offsets. - * @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 [AnalyzeEntitySentimentResponse]{@link google.cloud.language.v1beta2.AnalyzeEntitySentimentResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * const [response] = await client.analyzeEntitySentiment(request); - */ analyzeEntitySentiment( request?: protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest, optionsOrCallback?: @@ -560,6 +564,8 @@ export class LanguageServiceClient { options = optionsOrCallback as CallOptions; } options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; this.initialize(); return this.innerApiCalls.analyzeEntitySentiment( request, @@ -567,6 +573,27 @@ export class LanguageServiceClient { callback ); } + /** + * Analyzes the syntax of the text and provides sentence boundaries and + * tokenization along with part-of-speech tags, dependency trees, and other + * properties. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.language.v1beta2.Document} request.document + * Required. Input document. + * @param {google.cloud.language.v1beta2.EncodingType} request.encodingType + * The encoding type used by the API to calculate offsets. + * @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 [AnalyzeSyntaxResponse]{@link google.cloud.language.v1beta2.AnalyzeSyntaxResponse}. + * 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/v1beta2/language_service.analyze_syntax.js + * region_tag:language_v1beta2_generated_LanguageService_AnalyzeSyntax_async + */ analyzeSyntax( request?: protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest, options?: CallOptions @@ -598,27 +625,6 @@ export class LanguageServiceClient { {} | null | undefined > ): void; - /** - * Analyzes the syntax of the text and provides sentence boundaries and - * tokenization along with part-of-speech tags, dependency trees, and other - * properties. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.language.v1beta2.Document} request.document - * Required. Input document. - * @param {google.cloud.language.v1beta2.EncodingType} request.encodingType - * The encoding type used by the API to calculate offsets. - * @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 [AnalyzeSyntaxResponse]{@link google.cloud.language.v1beta2.AnalyzeSyntaxResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * const [response] = await client.analyzeSyntax(request); - */ analyzeSyntax( request?: protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest, optionsOrCallback?: @@ -653,9 +659,28 @@ export class LanguageServiceClient { options = optionsOrCallback as CallOptions; } options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; this.initialize(); return this.innerApiCalls.analyzeSyntax(request, options, callback); } + /** + * Classifies a document into categories. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.language.v1beta2.Document} request.document + * Required. Input document. + * @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 [ClassifyTextResponse]{@link google.cloud.language.v1beta2.ClassifyTextResponse}. + * 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/v1beta2/language_service.classify_text.js + * region_tag:language_v1beta2_generated_LanguageService_ClassifyText_async + */ classifyText( request?: protos.google.cloud.language.v1beta2.IClassifyTextRequest, options?: CallOptions @@ -687,23 +712,6 @@ export class LanguageServiceClient { {} | null | undefined > ): void; - /** - * Classifies a document into categories. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.language.v1beta2.Document} request.document - * Required. Input document. - * @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 [ClassifyTextResponse]{@link google.cloud.language.v1beta2.ClassifyTextResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * const [response] = await client.classifyText(request); - */ classifyText( request?: protos.google.cloud.language.v1beta2.IClassifyTextRequest, optionsOrCallback?: @@ -738,9 +746,33 @@ export class LanguageServiceClient { options = optionsOrCallback as CallOptions; } options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; this.initialize(); return this.innerApiCalls.classifyText(request, options, callback); } + /** + * A convenience method that provides all syntax, sentiment, entity, and + * classification features in one call. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.language.v1beta2.Document} request.document + * Required. Input document. + * @param {google.cloud.language.v1beta2.AnnotateTextRequest.Features} request.features + * Required. The enabled features. + * @param {google.cloud.language.v1beta2.EncodingType} request.encodingType + * The encoding type used by the API to calculate offsets. + * @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 [AnnotateTextResponse]{@link google.cloud.language.v1beta2.AnnotateTextResponse}. + * 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/v1beta2/language_service.annotate_text.js + * region_tag:language_v1beta2_generated_LanguageService_AnnotateText_async + */ annotateText( request?: protos.google.cloud.language.v1beta2.IAnnotateTextRequest, options?: CallOptions @@ -772,28 +804,6 @@ export class LanguageServiceClient { {} | null | undefined > ): void; - /** - * A convenience method that provides all syntax, sentiment, entity, and - * classification features in one call. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.language.v1beta2.Document} request.document - * Required. Input document. - * @param {google.cloud.language.v1beta2.AnnotateTextRequest.Features} request.features - * Required. The enabled features. - * @param {google.cloud.language.v1beta2.EncodingType} request.encodingType - * The encoding type used by the API to calculate offsets. - * @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 [AnnotateTextResponse]{@link google.cloud.language.v1beta2.AnnotateTextResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * const [response] = await client.annotateText(request); - */ annotateText( request?: protos.google.cloud.language.v1beta2.IAnnotateTextRequest, optionsOrCallback?: @@ -828,6 +838,8 @@ export class LanguageServiceClient { options = optionsOrCallback as CallOptions; } options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; this.initialize(); return this.innerApiCalls.annotateText(request, options, callback); } diff --git a/packages/google-cloud-language/test/gapic_language_service_v1.ts b/packages/google-cloud-language/test/gapic_language_service_v1.ts index 12b85705fa4..67dc6b26acc 100644 --- a/packages/google-cloud-language/test/gapic_language_service_v1.ts +++ b/packages/google-cloud-language/test/gapic_language_service_v1.ts @@ -142,7 +142,7 @@ describe('v1.LanguageServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.language.v1.AnalyzeSentimentRequest() ); - const expectedOptions = {}; + const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.language.v1.AnalyzeSentimentResponse() ); @@ -165,7 +165,7 @@ describe('v1.LanguageServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.language.v1.AnalyzeSentimentRequest() ); - const expectedOptions = {}; + const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.language.v1.AnalyzeSentimentResponse() ); @@ -204,7 +204,7 @@ describe('v1.LanguageServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.language.v1.AnalyzeSentimentRequest() ); - const expectedOptions = {}; + const expectedOptions = {otherArgs: {headers: {}}}; const expectedError = new Error('expected'); client.innerApiCalls.analyzeSentiment = stubSimpleCall( undefined, @@ -229,7 +229,7 @@ describe('v1.LanguageServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.language.v1.AnalyzeEntitiesRequest() ); - const expectedOptions = {}; + const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.language.v1.AnalyzeEntitiesResponse() ); @@ -252,7 +252,7 @@ describe('v1.LanguageServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.language.v1.AnalyzeEntitiesRequest() ); - const expectedOptions = {}; + const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.language.v1.AnalyzeEntitiesResponse() ); @@ -291,7 +291,7 @@ describe('v1.LanguageServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.language.v1.AnalyzeEntitiesRequest() ); - const expectedOptions = {}; + const expectedOptions = {otherArgs: {headers: {}}}; const expectedError = new Error('expected'); client.innerApiCalls.analyzeEntities = stubSimpleCall( undefined, @@ -316,7 +316,7 @@ describe('v1.LanguageServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.language.v1.AnalyzeEntitySentimentRequest() ); - const expectedOptions = {}; + const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.language.v1.AnalyzeEntitySentimentResponse() ); @@ -340,7 +340,7 @@ describe('v1.LanguageServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.language.v1.AnalyzeEntitySentimentRequest() ); - const expectedOptions = {}; + const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.language.v1.AnalyzeEntitySentimentResponse() ); @@ -379,7 +379,7 @@ describe('v1.LanguageServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.language.v1.AnalyzeEntitySentimentRequest() ); - const expectedOptions = {}; + const expectedOptions = {otherArgs: {headers: {}}}; const expectedError = new Error('expected'); client.innerApiCalls.analyzeEntitySentiment = stubSimpleCall( undefined, @@ -407,7 +407,7 @@ describe('v1.LanguageServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.language.v1.AnalyzeSyntaxRequest() ); - const expectedOptions = {}; + const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.language.v1.AnalyzeSyntaxResponse() ); @@ -430,7 +430,7 @@ describe('v1.LanguageServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.language.v1.AnalyzeSyntaxRequest() ); - const expectedOptions = {}; + const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.language.v1.AnalyzeSyntaxResponse() ); @@ -469,7 +469,7 @@ describe('v1.LanguageServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.language.v1.AnalyzeSyntaxRequest() ); - const expectedOptions = {}; + const expectedOptions = {otherArgs: {headers: {}}}; const expectedError = new Error('expected'); client.innerApiCalls.analyzeSyntax = stubSimpleCall( undefined, @@ -494,7 +494,7 @@ describe('v1.LanguageServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.language.v1.ClassifyTextRequest() ); - const expectedOptions = {}; + const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.language.v1.ClassifyTextResponse() ); @@ -517,7 +517,7 @@ describe('v1.LanguageServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.language.v1.ClassifyTextRequest() ); - const expectedOptions = {}; + const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.language.v1.ClassifyTextResponse() ); @@ -556,7 +556,7 @@ describe('v1.LanguageServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.language.v1.ClassifyTextRequest() ); - const expectedOptions = {}; + const expectedOptions = {otherArgs: {headers: {}}}; const expectedError = new Error('expected'); client.innerApiCalls.classifyText = stubSimpleCall( undefined, @@ -581,7 +581,7 @@ describe('v1.LanguageServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.language.v1.AnnotateTextRequest() ); - const expectedOptions = {}; + const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.language.v1.AnnotateTextResponse() ); @@ -604,7 +604,7 @@ describe('v1.LanguageServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.language.v1.AnnotateTextRequest() ); - const expectedOptions = {}; + const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.language.v1.AnnotateTextResponse() ); @@ -643,7 +643,7 @@ describe('v1.LanguageServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.language.v1.AnnotateTextRequest() ); - const expectedOptions = {}; + const expectedOptions = {otherArgs: {headers: {}}}; const expectedError = new Error('expected'); client.innerApiCalls.annotateText = stubSimpleCall( undefined, diff --git a/packages/google-cloud-language/test/gapic_language_service_v1beta2.ts b/packages/google-cloud-language/test/gapic_language_service_v1beta2.ts index 2453d4e0e46..01594d26a87 100644 --- a/packages/google-cloud-language/test/gapic_language_service_v1beta2.ts +++ b/packages/google-cloud-language/test/gapic_language_service_v1beta2.ts @@ -142,7 +142,7 @@ describe('v1beta2.LanguageServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.language.v1beta2.AnalyzeSentimentRequest() ); - const expectedOptions = {}; + const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.language.v1beta2.AnalyzeSentimentResponse() ); @@ -165,7 +165,7 @@ describe('v1beta2.LanguageServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.language.v1beta2.AnalyzeSentimentRequest() ); - const expectedOptions = {}; + const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.language.v1beta2.AnalyzeSentimentResponse() ); @@ -204,7 +204,7 @@ describe('v1beta2.LanguageServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.language.v1beta2.AnalyzeSentimentRequest() ); - const expectedOptions = {}; + const expectedOptions = {otherArgs: {headers: {}}}; const expectedError = new Error('expected'); client.innerApiCalls.analyzeSentiment = stubSimpleCall( undefined, @@ -229,7 +229,7 @@ describe('v1beta2.LanguageServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.language.v1beta2.AnalyzeEntitiesRequest() ); - const expectedOptions = {}; + const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.language.v1beta2.AnalyzeEntitiesResponse() ); @@ -252,7 +252,7 @@ describe('v1beta2.LanguageServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.language.v1beta2.AnalyzeEntitiesRequest() ); - const expectedOptions = {}; + const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.language.v1beta2.AnalyzeEntitiesResponse() ); @@ -291,7 +291,7 @@ describe('v1beta2.LanguageServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.language.v1beta2.AnalyzeEntitiesRequest() ); - const expectedOptions = {}; + const expectedOptions = {otherArgs: {headers: {}}}; const expectedError = new Error('expected'); client.innerApiCalls.analyzeEntities = stubSimpleCall( undefined, @@ -316,7 +316,7 @@ describe('v1beta2.LanguageServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.language.v1beta2.AnalyzeEntitySentimentRequest() ); - const expectedOptions = {}; + const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.language.v1beta2.AnalyzeEntitySentimentResponse() ); @@ -340,7 +340,7 @@ describe('v1beta2.LanguageServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.language.v1beta2.AnalyzeEntitySentimentRequest() ); - const expectedOptions = {}; + const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.language.v1beta2.AnalyzeEntitySentimentResponse() ); @@ -379,7 +379,7 @@ describe('v1beta2.LanguageServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.language.v1beta2.AnalyzeEntitySentimentRequest() ); - const expectedOptions = {}; + const expectedOptions = {otherArgs: {headers: {}}}; const expectedError = new Error('expected'); client.innerApiCalls.analyzeEntitySentiment = stubSimpleCall( undefined, @@ -407,7 +407,7 @@ describe('v1beta2.LanguageServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.language.v1beta2.AnalyzeSyntaxRequest() ); - const expectedOptions = {}; + const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.language.v1beta2.AnalyzeSyntaxResponse() ); @@ -430,7 +430,7 @@ describe('v1beta2.LanguageServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.language.v1beta2.AnalyzeSyntaxRequest() ); - const expectedOptions = {}; + const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.language.v1beta2.AnalyzeSyntaxResponse() ); @@ -469,7 +469,7 @@ describe('v1beta2.LanguageServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.language.v1beta2.AnalyzeSyntaxRequest() ); - const expectedOptions = {}; + const expectedOptions = {otherArgs: {headers: {}}}; const expectedError = new Error('expected'); client.innerApiCalls.analyzeSyntax = stubSimpleCall( undefined, @@ -494,7 +494,7 @@ describe('v1beta2.LanguageServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.language.v1beta2.ClassifyTextRequest() ); - const expectedOptions = {}; + const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.language.v1beta2.ClassifyTextResponse() ); @@ -517,7 +517,7 @@ describe('v1beta2.LanguageServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.language.v1beta2.ClassifyTextRequest() ); - const expectedOptions = {}; + const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.language.v1beta2.ClassifyTextResponse() ); @@ -556,7 +556,7 @@ describe('v1beta2.LanguageServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.language.v1beta2.ClassifyTextRequest() ); - const expectedOptions = {}; + const expectedOptions = {otherArgs: {headers: {}}}; const expectedError = new Error('expected'); client.innerApiCalls.classifyText = stubSimpleCall( undefined, @@ -581,7 +581,7 @@ describe('v1beta2.LanguageServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.language.v1beta2.AnnotateTextRequest() ); - const expectedOptions = {}; + const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.language.v1beta2.AnnotateTextResponse() ); @@ -604,7 +604,7 @@ describe('v1beta2.LanguageServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.language.v1beta2.AnnotateTextRequest() ); - const expectedOptions = {}; + const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.language.v1beta2.AnnotateTextResponse() ); @@ -643,7 +643,7 @@ describe('v1beta2.LanguageServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.language.v1beta2.AnnotateTextRequest() ); - const expectedOptions = {}; + const expectedOptions = {otherArgs: {headers: {}}}; const expectedError = new Error('expected'); client.innerApiCalls.annotateText = stubSimpleCall( undefined,