From e32cadb8bd6728bc5e2f4952655a0aa746247ac9 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Fri, 24 Jun 2022 10:23:09 +0000 Subject: [PATCH 1/2] feat: support regapic LRO Use gapic-generator-typescript v2.15.1. PiperOrigin-RevId: 456946341 Source-Link: https://github.com/googleapis/googleapis/commit/88fd18d9d3b872b3d06a3d9392879f50b5bf3ce5 Source-Link: https://github.com/googleapis/googleapis-gen/commit/accfa371f667439313335c64042b063c1c53102e Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYWNjZmEzNzFmNjY3NDM5MzEzMzM1YzY0MDQyYjA2M2MxYzUzMTAyZSJ9 --- 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 | 64 + .../cloud/language/v1/language_service.proto | 1122 ++++++++++++++++ .../v1/language_service.analyze_entities.js | 62 + ...nguage_service.analyze_entity_sentiment.js | 62 + .../v1/language_service.analyze_sentiment.js | 62 + .../v1/language_service.analyze_syntax.js | 62 + .../v1/language_service.annotate_text.js | 67 + .../v1/language_service.classify_text.js | 58 + ...pet_metadata.google.cloud.language.v1.json | 279 ++++ owl-bot-staging/v1/src/index.ts | 25 + owl-bot-staging/v1/src/v1/gapic_metadata.json | 83 ++ owl-bot-staging/v1/src/v1/index.ts | 19 + .../v1/src/v1/language_service_client.ts | 708 ++++++++++ .../v1/language_service_client_config.json | 56 + .../src/v1/language_service_proto_list.json | 3 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + owl-bot-staging/v1/system-test/install.ts | 49 + .../v1/test/gapic_language_service_v1.ts | 567 +++++++++ owl-bot-staging/v1/tsconfig.json | 19 + owl-bot-staging/v1/webpack.config.js | 64 + owl-bot-staging/v1beta2/.eslintignore | 7 + owl-bot-staging/v1beta2/.eslintrc.json | 3 + owl-bot-staging/v1beta2/.gitignore | 14 + owl-bot-staging/v1beta2/.jsdoc.js | 55 + owl-bot-staging/v1beta2/.mocharc.js | 33 + owl-bot-staging/v1beta2/.prettierrc.js | 22 + owl-bot-staging/v1beta2/README.md | 1 + .../v1beta2/linkinator.config.json | 16 + owl-bot-staging/v1beta2/package.json | 64 + .../language/v1beta2/language_service.proto | 1134 +++++++++++++++++ .../language_service.analyze_entities.js | 62 + ...nguage_service.analyze_entity_sentiment.js | 62 + .../language_service.analyze_sentiment.js | 63 + .../language_service.analyze_syntax.js | 62 + .../v1beta2/language_service.annotate_text.js | 67 + .../v1beta2/language_service.classify_text.js | 58 + ...etadata.google.cloud.language.v1beta2.json | 279 ++++ owl-bot-staging/v1beta2/src/index.ts | 25 + .../v1beta2/src/v1beta2/gapic_metadata.json | 83 ++ owl-bot-staging/v1beta2/src/v1beta2/index.ts | 19 + .../src/v1beta2/language_service_client.ts | 709 +++++++++++ .../language_service_client_config.json | 56 + .../v1beta2/language_service_proto_list.json | 3 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + .../v1beta2/system-test/install.ts | 49 + .../test/gapic_language_service_v1beta2.ts | 567 +++++++++ owl-bot-staging/v1beta2/tsconfig.json | 19 + owl-bot-staging/v1beta2/webpack.config.js | 64 + 58 files changed, 7296 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/language/v1/language_service.proto create mode 100644 owl-bot-staging/v1/samples/generated/v1/language_service.analyze_entities.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/language_service.analyze_entity_sentiment.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/language_service.analyze_sentiment.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/language_service.analyze_syntax.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/language_service.annotate_text.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/language_service.classify_text.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.language.v1.json create mode 100644 owl-bot-staging/v1/src/index.ts 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/language_service_client.ts create mode 100644 owl-bot-staging/v1/src/v1/language_service_client_config.json create mode 100644 owl-bot-staging/v1/src/v1/language_service_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_language_service_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/v1beta2/.eslintignore create mode 100644 owl-bot-staging/v1beta2/.eslintrc.json create mode 100644 owl-bot-staging/v1beta2/.gitignore create mode 100644 owl-bot-staging/v1beta2/.jsdoc.js create mode 100644 owl-bot-staging/v1beta2/.mocharc.js create mode 100644 owl-bot-staging/v1beta2/.prettierrc.js create mode 100644 owl-bot-staging/v1beta2/README.md create mode 100644 owl-bot-staging/v1beta2/linkinator.config.json create mode 100644 owl-bot-staging/v1beta2/package.json create mode 100644 owl-bot-staging/v1beta2/protos/google/cloud/language/v1beta2/language_service.proto create mode 100644 owl-bot-staging/v1beta2/samples/generated/v1beta2/language_service.analyze_entities.js create mode 100644 owl-bot-staging/v1beta2/samples/generated/v1beta2/language_service.analyze_entity_sentiment.js create mode 100644 owl-bot-staging/v1beta2/samples/generated/v1beta2/language_service.analyze_sentiment.js create mode 100644 owl-bot-staging/v1beta2/samples/generated/v1beta2/language_service.analyze_syntax.js create mode 100644 owl-bot-staging/v1beta2/samples/generated/v1beta2/language_service.annotate_text.js create mode 100644 owl-bot-staging/v1beta2/samples/generated/v1beta2/language_service.classify_text.js create mode 100644 owl-bot-staging/v1beta2/samples/generated/v1beta2/snippet_metadata.google.cloud.language.v1beta2.json create mode 100644 owl-bot-staging/v1beta2/src/index.ts create mode 100644 owl-bot-staging/v1beta2/src/v1beta2/gapic_metadata.json create mode 100644 owl-bot-staging/v1beta2/src/v1beta2/index.ts create mode 100644 owl-bot-staging/v1beta2/src/v1beta2/language_service_client.ts create mode 100644 owl-bot-staging/v1beta2/src/v1beta2/language_service_client_config.json create mode 100644 owl-bot-staging/v1beta2/src/v1beta2/language_service_proto_list.json create mode 100644 owl-bot-staging/v1beta2/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/v1beta2/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/v1beta2/system-test/install.ts create mode 100644 owl-bot-staging/v1beta2/test/gapic_language_service_v1beta2.ts create mode 100644 owl-bot-staging/v1beta2/tsconfig.json create mode 100644 owl-bot-staging/v1beta2/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..79611132 --- /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/language', + 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..7287da54 --- /dev/null +++ b/owl-bot-staging/v1/README.md @@ -0,0 +1 @@ +Language: 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..1b45ee6a --- /dev/null +++ b/owl-bot-staging/v1/package.json @@ -0,0 +1,64 @@ +{ + "name": "@google-cloud/language", + "version": "0.1.0", + "description": "Language client for Node.js", + "repository": "googleapis/nodejs-language", + "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 language", + "language", + "language service" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/", + "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.1.1" + }, + "devDependencies": { + "@types/mocha": "^9.1.0", + "@types/node": "^16.0.0", + "@types/sinon": "^10.0.8", + "c8": "^7.11.0", + "gts": "^3.1.0", + "jsdoc": "^3.6.7", + "jsdoc-fresh": "^1.1.1", + "jsdoc-region-tag": "^1.3.1", + "linkinator": "^3.0.0", + "mocha": "^9.1.4", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^13.0.0", + "ts-loader": "^9.2.6", + "typescript": "^4.5.5", + "webpack": "^5.67.0", + "webpack-cli": "^4.9.1" + }, + "engines": { + "node": ">=v12" + } +} diff --git a/owl-bot-staging/v1/protos/google/cloud/language/v1/language_service.proto b/owl-bot-staging/v1/protos/google/cloud/language/v1/language_service.proto new file mode 100644 index 00000000..304eab07 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/cloud/language/v1/language_service.proto @@ -0,0 +1,1122 @@ +// Copyright 2019 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.language.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/language/v1;language"; +option java_multiple_files = true; +option java_outer_classname = "LanguageServiceProto"; +option java_package = "com.google.cloud.language.v1"; + + +// Provides text analysis operations such as sentiment analysis and entity +// recognition. +service LanguageService { + option (google.api.default_host) = "language.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-language," + "https://www.googleapis.com/auth/cloud-platform"; + // Analyzes the sentiment of the provided text. + rpc AnalyzeSentiment(AnalyzeSentimentRequest) returns (AnalyzeSentimentResponse) { + option (google.api.http) = { + post: "/v1/documents:analyzeSentiment" + body: "*" + }; + option (google.api.method_signature) = "document,encoding_type"; + option (google.api.method_signature) = "document"; + } + + // Finds named entities (currently proper names and common nouns) in the text + // along with entity types, salience, mentions for each entity, and + // other properties. + rpc AnalyzeEntities(AnalyzeEntitiesRequest) returns (AnalyzeEntitiesResponse) { + option (google.api.http) = { + post: "/v1/documents:analyzeEntities" + body: "*" + }; + option (google.api.method_signature) = "document,encoding_type"; + option (google.api.method_signature) = "document"; + } + + // Finds entities, similar to [AnalyzeEntities][google.cloud.language.v1.LanguageService.AnalyzeEntities] in the text and analyzes + // sentiment associated with each entity and its mentions. + rpc AnalyzeEntitySentiment(AnalyzeEntitySentimentRequest) returns (AnalyzeEntitySentimentResponse) { + option (google.api.http) = { + post: "/v1/documents:analyzeEntitySentiment" + body: "*" + }; + option (google.api.method_signature) = "document,encoding_type"; + option (google.api.method_signature) = "document"; + } + + // Analyzes the syntax of the text and provides sentence boundaries and + // tokenization along with part of speech tags, dependency trees, and other + // properties. + rpc AnalyzeSyntax(AnalyzeSyntaxRequest) returns (AnalyzeSyntaxResponse) { + option (google.api.http) = { + post: "/v1/documents:analyzeSyntax" + body: "*" + }; + option (google.api.method_signature) = "document,encoding_type"; + option (google.api.method_signature) = "document"; + } + + // Classifies a document into categories. + rpc ClassifyText(ClassifyTextRequest) returns (ClassifyTextResponse) { + option (google.api.http) = { + post: "/v1/documents:classifyText" + body: "*" + }; + option (google.api.method_signature) = "document"; + } + + // A convenience method that provides all the features that analyzeSentiment, + // analyzeEntities, and analyzeSyntax provide in one call. + rpc AnnotateText(AnnotateTextRequest) returns (AnnotateTextResponse) { + option (google.api.http) = { + post: "/v1/documents:annotateText" + body: "*" + }; + option (google.api.method_signature) = "document,features,encoding_type"; + option (google.api.method_signature) = "document,features"; + } +} + + +// +// Represents the input to API methods. +message Document { + // The document types enum. + enum Type { + // The content type is not specified. + TYPE_UNSPECIFIED = 0; + + // Plain text + PLAIN_TEXT = 1; + + // HTML + HTML = 2; + } + + // Required. If the type is not set or is `TYPE_UNSPECIFIED`, + // returns an `INVALID_ARGUMENT` error. + Type type = 1; + + // The source of the document: a string containing the content or a + // Google Cloud Storage URI. + oneof source { + // The content of the input in string format. + // Cloud audit logging exempt since it is based on user data. + string content = 2; + + // The Google Cloud Storage URI where the file content is located. + // This URI must be of the form: gs://bucket_name/object_name. For more + // details, see https://cloud.google.com/storage/docs/reference-uris. + // NOTE: Cloud Storage object versioning is not supported. + string gcs_content_uri = 3; + } + + // The language of the document (if not specified, the language is + // automatically detected). Both ISO and BCP-47 language codes are + // accepted.
+ // [Language + // Support](https://cloud.google.com/natural-language/docs/languages) lists + // currently supported languages for each API method. If the language (either + // specified by the caller or automatically detected) is not supported by the + // called API method, an `INVALID_ARGUMENT` error is returned. + string language = 4; +} + +// Represents a sentence in the input document. +message Sentence { + // The sentence text. + TextSpan text = 1; + + // For calls to [AnalyzeSentiment][] or if + // [AnnotateTextRequest.Features.extract_document_sentiment][google.cloud.language.v1.AnnotateTextRequest.Features.extract_document_sentiment] is set to + // true, this field will contain the sentiment for the sentence. + Sentiment sentiment = 2; +} + +// Represents a phrase in the text that is a known entity, such as +// a person, an organization, or location. The API associates information, such +// as salience and mentions, with entities. +message Entity { + // The type of the entity. For most entity types, the associated metadata is a + // Wikipedia URL (`wikipedia_url`) and Knowledge Graph MID (`mid`). The table + // below lists the associated fields for entities that have different + // metadata. + enum Type { + // Unknown + UNKNOWN = 0; + + // Person + PERSON = 1; + + // Location + LOCATION = 2; + + // Organization + ORGANIZATION = 3; + + // Event + EVENT = 4; + + // Artwork + WORK_OF_ART = 5; + + // Consumer product + CONSUMER_GOOD = 6; + + // Other types of entities + OTHER = 7; + + // Phone number

+ // The metadata lists the phone number, formatted according to local + // convention, plus whichever additional elements appear in the text: + PHONE_NUMBER = 9; + + // Address

+ // The metadata identifies the street number and locality plus whichever + // additional elements appear in the text: + ADDRESS = 10; + + // Date

+ // The metadata identifies the components of the date: + DATE = 11; + + // Number

+ // The metadata is the number itself. + NUMBER = 12; + + // Price

+ // The metadata identifies the value and currency. + PRICE = 13; + } + + // The representative name for the entity. + string name = 1; + + // The entity type. + Type type = 2; + + // Metadata associated with the entity. + // + // For most entity types, the metadata is a Wikipedia URL (`wikipedia_url`) + // and Knowledge Graph MID (`mid`), if they are available. For the metadata + // associated with other entity types, see the Type table below. + map metadata = 3; + + // The salience score associated with the entity in the [0, 1.0] range. + // + // The salience score for an entity provides information about the + // importance or centrality of that entity to the entire document text. + // Scores closer to 0 are less salient, while scores closer to 1.0 are highly + // salient. + float salience = 4; + + // The mentions of this entity in the input document. The API currently + // supports proper noun mentions. + repeated EntityMention mentions = 5; + + // For calls to [AnalyzeEntitySentiment][] or if + // [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v1.AnnotateTextRequest.Features.extract_entity_sentiment] is set to + // true, this field will contain the aggregate sentiment expressed for this + // entity in the provided document. + Sentiment sentiment = 6; +} + +// Represents the text encoding that the caller uses to process the output. +// Providing an `EncodingType` is recommended because the API provides the +// beginning offsets for various outputs, such as tokens and mentions, and +// languages that natively use different text encodings may access offsets +// differently. +enum EncodingType { + // If `EncodingType` is not specified, encoding-dependent information (such as + // `begin_offset`) will be set at `-1`. + NONE = 0; + + // Encoding-dependent information (such as `begin_offset`) is calculated based + // on the UTF-8 encoding of the input. C++ and Go are examples of languages + // that use this encoding natively. + UTF8 = 1; + + // Encoding-dependent information (such as `begin_offset`) is calculated based + // on the UTF-16 encoding of the input. Java and JavaScript are examples of + // languages that use this encoding natively. + UTF16 = 2; + + // Encoding-dependent information (such as `begin_offset`) is calculated based + // on the UTF-32 encoding of the input. Python is an example of a language + // that uses this encoding natively. + UTF32 = 3; +} + +// Represents the smallest syntactic building block of the text. +message Token { + // The token text. + TextSpan text = 1; + + // Parts of speech tag for this token. + PartOfSpeech part_of_speech = 2; + + // Dependency tree parse for this token. + DependencyEdge dependency_edge = 3; + + // [Lemma](https://en.wikipedia.org/wiki/Lemma_%28morphology%29) of the token. + string lemma = 4; +} + +// Represents the feeling associated with the entire text or entities in +// the text. +message Sentiment { + // A non-negative number in the [0, +inf) range, which represents + // the absolute magnitude of sentiment regardless of score (positive or + // negative). + float magnitude = 2; + + // Sentiment score between -1.0 (negative sentiment) and 1.0 + // (positive sentiment). + float score = 3; +} + +// Represents part of speech information for a token. Parts of speech +// are as defined in +// http://www.lrec-conf.org/proceedings/lrec2012/pdf/274_Paper.pdf +message PartOfSpeech { + // The part of speech tags enum. + enum Tag { + // Unknown + UNKNOWN = 0; + + // Adjective + ADJ = 1; + + // Adposition (preposition and postposition) + ADP = 2; + + // Adverb + ADV = 3; + + // Conjunction + CONJ = 4; + + // Determiner + DET = 5; + + // Noun (common and proper) + NOUN = 6; + + // Cardinal number + NUM = 7; + + // Pronoun + PRON = 8; + + // Particle or other function word + PRT = 9; + + // Punctuation + PUNCT = 10; + + // Verb (all tenses and modes) + VERB = 11; + + // Other: foreign words, typos, abbreviations + X = 12; + + // Affix + AFFIX = 13; + } + + // The characteristic of a verb that expresses time flow during an event. + enum Aspect { + // Aspect is not applicable in the analyzed language or is not predicted. + ASPECT_UNKNOWN = 0; + + // Perfective + PERFECTIVE = 1; + + // Imperfective + IMPERFECTIVE = 2; + + // Progressive + PROGRESSIVE = 3; + } + + // The grammatical function performed by a noun or pronoun in a phrase, + // clause, or sentence. In some languages, other parts of speech, such as + // adjective and determiner, take case inflection in agreement with the noun. + enum Case { + // Case is not applicable in the analyzed language or is not predicted. + CASE_UNKNOWN = 0; + + // Accusative + ACCUSATIVE = 1; + + // Adverbial + ADVERBIAL = 2; + + // Complementive + COMPLEMENTIVE = 3; + + // Dative + DATIVE = 4; + + // Genitive + GENITIVE = 5; + + // Instrumental + INSTRUMENTAL = 6; + + // Locative + LOCATIVE = 7; + + // Nominative + NOMINATIVE = 8; + + // Oblique + OBLIQUE = 9; + + // Partitive + PARTITIVE = 10; + + // Prepositional + PREPOSITIONAL = 11; + + // Reflexive + REFLEXIVE_CASE = 12; + + // Relative + RELATIVE_CASE = 13; + + // Vocative + VOCATIVE = 14; + } + + // Depending on the language, Form can be categorizing different forms of + // verbs, adjectives, adverbs, etc. For example, categorizing inflected + // endings of verbs and adjectives or distinguishing between short and long + // forms of adjectives and participles + enum Form { + // Form is not applicable in the analyzed language or is not predicted. + FORM_UNKNOWN = 0; + + // Adnomial + ADNOMIAL = 1; + + // Auxiliary + AUXILIARY = 2; + + // Complementizer + COMPLEMENTIZER = 3; + + // Final ending + FINAL_ENDING = 4; + + // Gerund + GERUND = 5; + + // Realis + REALIS = 6; + + // Irrealis + IRREALIS = 7; + + // Short form + SHORT = 8; + + // Long form + LONG = 9; + + // Order form + ORDER = 10; + + // Specific form + SPECIFIC = 11; + } + + // Gender classes of nouns reflected in the behaviour of associated words. + enum Gender { + // Gender is not applicable in the analyzed language or is not predicted. + GENDER_UNKNOWN = 0; + + // Feminine + FEMININE = 1; + + // Masculine + MASCULINE = 2; + + // Neuter + NEUTER = 3; + } + + // The grammatical feature of verbs, used for showing modality and attitude. + enum Mood { + // Mood is not applicable in the analyzed language or is not predicted. + MOOD_UNKNOWN = 0; + + // Conditional + CONDITIONAL_MOOD = 1; + + // Imperative + IMPERATIVE = 2; + + // Indicative + INDICATIVE = 3; + + // Interrogative + INTERROGATIVE = 4; + + // Jussive + JUSSIVE = 5; + + // Subjunctive + SUBJUNCTIVE = 6; + } + + // Count distinctions. + enum Number { + // Number is not applicable in the analyzed language or is not predicted. + NUMBER_UNKNOWN = 0; + + // Singular + SINGULAR = 1; + + // Plural + PLURAL = 2; + + // Dual + DUAL = 3; + } + + // The distinction between the speaker, second person, third person, etc. + enum Person { + // Person is not applicable in the analyzed language or is not predicted. + PERSON_UNKNOWN = 0; + + // First + FIRST = 1; + + // Second + SECOND = 2; + + // Third + THIRD = 3; + + // Reflexive + REFLEXIVE_PERSON = 4; + } + + // This category shows if the token is part of a proper name. + enum Proper { + // Proper is not applicable in the analyzed language or is not predicted. + PROPER_UNKNOWN = 0; + + // Proper + PROPER = 1; + + // Not proper + NOT_PROPER = 2; + } + + // Reciprocal features of a pronoun. + enum Reciprocity { + // Reciprocity is not applicable in the analyzed language or is not + // predicted. + RECIPROCITY_UNKNOWN = 0; + + // Reciprocal + RECIPROCAL = 1; + + // Non-reciprocal + NON_RECIPROCAL = 2; + } + + // Time reference. + enum Tense { + // Tense is not applicable in the analyzed language or is not predicted. + TENSE_UNKNOWN = 0; + + // Conditional + CONDITIONAL_TENSE = 1; + + // Future + FUTURE = 2; + + // Past + PAST = 3; + + // Present + PRESENT = 4; + + // Imperfect + IMPERFECT = 5; + + // Pluperfect + PLUPERFECT = 6; + } + + // The relationship between the action that a verb expresses and the + // participants identified by its arguments. + enum Voice { + // Voice is not applicable in the analyzed language or is not predicted. + VOICE_UNKNOWN = 0; + + // Active + ACTIVE = 1; + + // Causative + CAUSATIVE = 2; + + // Passive + PASSIVE = 3; + } + + // The part of speech tag. + Tag tag = 1; + + // The grammatical aspect. + Aspect aspect = 2; + + // The grammatical case. + Case case = 3; + + // The grammatical form. + Form form = 4; + + // The grammatical gender. + Gender gender = 5; + + // The grammatical mood. + Mood mood = 6; + + // The grammatical number. + Number number = 7; + + // The grammatical person. + Person person = 8; + + // The grammatical properness. + Proper proper = 9; + + // The grammatical reciprocity. + Reciprocity reciprocity = 10; + + // The grammatical tense. + Tense tense = 11; + + // The grammatical voice. + Voice voice = 12; +} + +// Represents dependency parse tree information for a token. (For more +// information on dependency labels, see +// http://www.aclweb.org/anthology/P13-2017 +message DependencyEdge { + // The parse label enum for the token. + enum Label { + // Unknown + UNKNOWN = 0; + + // Abbreviation modifier + ABBREV = 1; + + // Adjectival complement + ACOMP = 2; + + // Adverbial clause modifier + ADVCL = 3; + + // Adverbial modifier + ADVMOD = 4; + + // Adjectival modifier of an NP + AMOD = 5; + + // Appositional modifier of an NP + APPOS = 6; + + // Attribute dependent of a copular verb + ATTR = 7; + + // Auxiliary (non-main) verb + AUX = 8; + + // Passive auxiliary + AUXPASS = 9; + + // Coordinating conjunction + CC = 10; + + // Clausal complement of a verb or adjective + CCOMP = 11; + + // Conjunct + CONJ = 12; + + // Clausal subject + CSUBJ = 13; + + // Clausal passive subject + CSUBJPASS = 14; + + // Dependency (unable to determine) + DEP = 15; + + // Determiner + DET = 16; + + // Discourse + DISCOURSE = 17; + + // Direct object + DOBJ = 18; + + // Expletive + EXPL = 19; + + // Goes with (part of a word in a text not well edited) + GOESWITH = 20; + + // Indirect object + IOBJ = 21; + + // Marker (word introducing a subordinate clause) + MARK = 22; + + // Multi-word expression + MWE = 23; + + // Multi-word verbal expression + MWV = 24; + + // Negation modifier + NEG = 25; + + // Noun compound modifier + NN = 26; + + // Noun phrase used as an adverbial modifier + NPADVMOD = 27; + + // Nominal subject + NSUBJ = 28; + + // Passive nominal subject + NSUBJPASS = 29; + + // Numeric modifier of a noun + NUM = 30; + + // Element of compound number + NUMBER = 31; + + // Punctuation mark + P = 32; + + // Parataxis relation + PARATAXIS = 33; + + // Participial modifier + PARTMOD = 34; + + // The complement of a preposition is a clause + PCOMP = 35; + + // Object of a preposition + POBJ = 36; + + // Possession modifier + POSS = 37; + + // Postverbal negative particle + POSTNEG = 38; + + // Predicate complement + PRECOMP = 39; + + // Preconjunt + PRECONJ = 40; + + // Predeterminer + PREDET = 41; + + // Prefix + PREF = 42; + + // Prepositional modifier + PREP = 43; + + // The relationship between a verb and verbal morpheme + PRONL = 44; + + // Particle + PRT = 45; + + // Associative or possessive marker + PS = 46; + + // Quantifier phrase modifier + QUANTMOD = 47; + + // Relative clause modifier + RCMOD = 48; + + // Complementizer in relative clause + RCMODREL = 49; + + // Ellipsis without a preceding predicate + RDROP = 50; + + // Referent + REF = 51; + + // Remnant + REMNANT = 52; + + // Reparandum + REPARANDUM = 53; + + // Root + ROOT = 54; + + // Suffix specifying a unit of number + SNUM = 55; + + // Suffix + SUFF = 56; + + // Temporal modifier + TMOD = 57; + + // Topic marker + TOPIC = 58; + + // Clause headed by an infinite form of the verb that modifies a noun + VMOD = 59; + + // Vocative + VOCATIVE = 60; + + // Open clausal complement + XCOMP = 61; + + // Name suffix + SUFFIX = 62; + + // Name title + TITLE = 63; + + // Adverbial phrase modifier + ADVPHMOD = 64; + + // Causative auxiliary + AUXCAUS = 65; + + // Helper auxiliary + AUXVV = 66; + + // Rentaishi (Prenominal modifier) + DTMOD = 67; + + // Foreign words + FOREIGN = 68; + + // Keyword + KW = 69; + + // List for chains of comparable items + LIST = 70; + + // Nominalized clause + NOMC = 71; + + // Nominalized clausal subject + NOMCSUBJ = 72; + + // Nominalized clausal passive + NOMCSUBJPASS = 73; + + // Compound of numeric modifier + NUMC = 74; + + // Copula + COP = 75; + + // Dislocated relation (for fronted/topicalized elements) + DISLOCATED = 76; + + // Aspect marker + ASP = 77; + + // Genitive modifier + GMOD = 78; + + // Genitive object + GOBJ = 79; + + // Infinitival modifier + INFMOD = 80; + + // Measure + MES = 81; + + // Nominal complement of a noun + NCOMP = 82; + } + + // Represents the head of this token in the dependency tree. + // This is the index of the token which has an arc going to this token. + // The index is the position of the token in the array of tokens returned + // by the API method. If this token is a root token, then the + // `head_token_index` is its own index. + int32 head_token_index = 1; + + // The parse label for the token. + Label label = 2; +} + +// Represents a mention for an entity in the text. Currently, proper noun +// mentions are supported. +message EntityMention { + // The supported types of mentions. + enum Type { + // Unknown + TYPE_UNKNOWN = 0; + + // Proper name + PROPER = 1; + + // Common noun (or noun compound) + COMMON = 2; + } + + // The mention text. + TextSpan text = 1; + + // The type of the entity mention. + Type type = 2; + + // For calls to [AnalyzeEntitySentiment][] or if + // [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v1.AnnotateTextRequest.Features.extract_entity_sentiment] is set to + // true, this field will contain the sentiment expressed for this mention of + // the entity in the provided document. + Sentiment sentiment = 3; +} + +// Represents an output piece of text. +message TextSpan { + // The content of the output text. + string content = 1; + + // The API calculates the beginning offset of the content in the original + // document according to the [EncodingType][google.cloud.language.v1.EncodingType] specified in the API request. + int32 begin_offset = 2; +} + +// Represents a category returned from the text classifier. +message ClassificationCategory { + // The name of the category representing the document, from the [predefined + // taxonomy](https://cloud.google.com/natural-language/docs/categories). + string name = 1; + + // The classifier's confidence of the category. Number represents how certain + // the classifier is that this category represents the given text. + float confidence = 2; +} + +// The sentiment analysis request message. +message AnalyzeSentimentRequest { + // Input document. + Document document = 1 [(google.api.field_behavior) = REQUIRED]; + + // The encoding type used by the API to calculate sentence offsets. + EncodingType encoding_type = 2; +} + +// The sentiment analysis response message. +message AnalyzeSentimentResponse { + // The overall sentiment of the input document. + Sentiment document_sentiment = 1; + + // The language of the text, which will be the same as the language specified + // in the request or, if not specified, the automatically-detected language. + // See [Document.language][google.cloud.language.v1.Document.language] field for more details. + string language = 2; + + // The sentiment for all the sentences in the document. + repeated Sentence sentences = 3; +} + +// The entity-level sentiment analysis request message. +message AnalyzeEntitySentimentRequest { + // Input document. + Document document = 1 [(google.api.field_behavior) = REQUIRED]; + + // The encoding type used by the API to calculate offsets. + EncodingType encoding_type = 2; +} + +// The entity-level sentiment analysis response message. +message AnalyzeEntitySentimentResponse { + // The recognized entities in the input document with associated sentiments. + repeated Entity entities = 1; + + // The language of the text, which will be the same as the language specified + // in the request or, if not specified, the automatically-detected language. + // See [Document.language][google.cloud.language.v1.Document.language] field for more details. + string language = 2; +} + +// The entity analysis request message. +message AnalyzeEntitiesRequest { + // Input document. + Document document = 1 [(google.api.field_behavior) = REQUIRED]; + + // The encoding type used by the API to calculate offsets. + EncodingType encoding_type = 2; +} + +// The entity analysis response message. +message AnalyzeEntitiesResponse { + // The recognized entities in the input document. + repeated Entity entities = 1; + + // The language of the text, which will be the same as the language specified + // in the request or, if not specified, the automatically-detected language. + // See [Document.language][google.cloud.language.v1.Document.language] field for more details. + string language = 2; +} + +// The syntax analysis request message. +message AnalyzeSyntaxRequest { + // Input document. + Document document = 1 [(google.api.field_behavior) = REQUIRED]; + + // The encoding type used by the API to calculate offsets. + EncodingType encoding_type = 2; +} + +// The syntax analysis response message. +message AnalyzeSyntaxResponse { + // Sentences in the input document. + repeated Sentence sentences = 1; + + // Tokens, along with their syntactic information, in the input document. + repeated Token tokens = 2; + + // The language of the text, which will be the same as the language specified + // in the request or, if not specified, the automatically-detected language. + // See [Document.language][google.cloud.language.v1.Document.language] field for more details. + string language = 3; +} + +// The document classification request message. +message ClassifyTextRequest { + // Input document. + Document document = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// The document classification response message. +message ClassifyTextResponse { + // Categories representing the input document. + repeated ClassificationCategory categories = 1; +} + +// The request message for the text annotation API, which can perform multiple +// analysis types (sentiment, entities, and syntax) in one call. +message AnnotateTextRequest { + // All available features for sentiment, syntax, and semantic analysis. + // Setting each one to true will enable that specific analysis for the input. + message Features { + // Extract syntax information. + bool extract_syntax = 1; + + // Extract entities. + bool extract_entities = 2; + + // Extract document-level sentiment. + bool extract_document_sentiment = 3; + + // Extract entities and their associated sentiment. + bool extract_entity_sentiment = 4; + + // Classify the full document into categories. + bool classify_text = 6; + } + + // Input document. + Document document = 1 [(google.api.field_behavior) = REQUIRED]; + + // The enabled features. + Features features = 2 [(google.api.field_behavior) = REQUIRED]; + + // The encoding type used by the API to calculate offsets. + EncodingType encoding_type = 3; +} + +// The text annotations response message. +message AnnotateTextResponse { + // Sentences in the input document. Populated if the user enables + // [AnnotateTextRequest.Features.extract_syntax][google.cloud.language.v1.AnnotateTextRequest.Features.extract_syntax]. + repeated Sentence sentences = 1; + + // Tokens, along with their syntactic information, in the input document. + // Populated if the user enables + // [AnnotateTextRequest.Features.extract_syntax][google.cloud.language.v1.AnnotateTextRequest.Features.extract_syntax]. + repeated Token tokens = 2; + + // Entities, along with their semantic information, in the input document. + // Populated if the user enables + // [AnnotateTextRequest.Features.extract_entities][google.cloud.language.v1.AnnotateTextRequest.Features.extract_entities]. + repeated Entity entities = 3; + + // The overall sentiment for the document. Populated if the user enables + // [AnnotateTextRequest.Features.extract_document_sentiment][google.cloud.language.v1.AnnotateTextRequest.Features.extract_document_sentiment]. + Sentiment document_sentiment = 4; + + // The language of the text, which will be the same as the language specified + // in the request or, if not specified, the automatically-detected language. + // See [Document.language][google.cloud.language.v1.Document.language] field for more details. + string language = 5; + + // Categories identified in the input document. + repeated ClassificationCategory categories = 6; +} diff --git a/owl-bot-staging/v1/samples/generated/v1/language_service.analyze_entities.js b/owl-bot-staging/v1/samples/generated/v1/language_service.analyze_entities.js new file mode 100644 index 00000000..c51b1483 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/language_service.analyze_entities.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(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/owl-bot-staging/v1/samples/generated/v1/language_service.analyze_entity_sentiment.js b/owl-bot-staging/v1/samples/generated/v1/language_service.analyze_entity_sentiment.js new file mode 100644 index 00000000..59d03409 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/language_service.analyze_entity_sentiment.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(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/owl-bot-staging/v1/samples/generated/v1/language_service.analyze_sentiment.js b/owl-bot-staging/v1/samples/generated/v1/language_service.analyze_sentiment.js new file mode 100644 index 00000000..e16a69be --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/language_service.analyze_sentiment.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(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/owl-bot-staging/v1/samples/generated/v1/language_service.analyze_syntax.js b/owl-bot-staging/v1/samples/generated/v1/language_service.analyze_syntax.js new file mode 100644 index 00000000..89bc540e --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/language_service.analyze_syntax.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(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/owl-bot-staging/v1/samples/generated/v1/language_service.annotate_text.js b/owl-bot-staging/v1/samples/generated/v1/language_service.annotate_text.js new file mode 100644 index 00000000..fb978dde --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/language_service.annotate_text.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(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/owl-bot-staging/v1/samples/generated/v1/language_service.classify_text.js b/owl-bot-staging/v1/samples/generated/v1/language_service.classify_text.js new file mode 100644 index 00000000..81a04f8c --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/language_service.classify_text.js @@ -0,0 +1,58 @@ +// 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(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/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.language.v1.json b/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.language.v1.json new file mode 100644 index 00000000..6f66069f --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.language.v1.json @@ -0,0 +1,279 @@ +{ + "clientLibrary": { + "name": "nodejs-language", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.language.v1", + "version": "v1" + } + ] + }, + "snippets": [ + { + "regionTag": "language_v1_generated_LanguageService_AnalyzeSentiment_async", + "title": "LanguageService analyzeSentiment Sample", + "origin": "API_DEFINITION", + "description": " Analyzes the sentiment of the provided text.", + "canonical": true, + "file": "language_service.analyze_sentiment.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AnalyzeSentiment", + "fullName": "google.cloud.language.v1.LanguageService.AnalyzeSentiment", + "async": true, + "parameters": [ + { + "name": "document", + "type": ".google.cloud.language.v1.Document" + }, + { + "name": "encoding_type", + "type": ".google.cloud.language.v1.EncodingType" + } + ], + "resultType": ".google.cloud.language.v1.AnalyzeSentimentResponse", + "client": { + "shortName": "LanguageServiceClient", + "fullName": "google.cloud.language.v1.LanguageServiceClient" + }, + "method": { + "shortName": "AnalyzeSentiment", + "fullName": "google.cloud.language.v1.LanguageService.AnalyzeSentiment", + "service": { + "shortName": "LanguageService", + "fullName": "google.cloud.language.v1.LanguageService" + } + } + } + }, + { + "regionTag": "language_v1_generated_LanguageService_AnalyzeEntities_async", + "title": "LanguageService analyzeEntities Sample", + "origin": "API_DEFINITION", + "description": " Finds named entities (currently proper names and common nouns) in the text along with entity types, salience, mentions for each entity, and other properties.", + "canonical": true, + "file": "language_service.analyze_entities.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AnalyzeEntities", + "fullName": "google.cloud.language.v1.LanguageService.AnalyzeEntities", + "async": true, + "parameters": [ + { + "name": "document", + "type": ".google.cloud.language.v1.Document" + }, + { + "name": "encoding_type", + "type": ".google.cloud.language.v1.EncodingType" + } + ], + "resultType": ".google.cloud.language.v1.AnalyzeEntitiesResponse", + "client": { + "shortName": "LanguageServiceClient", + "fullName": "google.cloud.language.v1.LanguageServiceClient" + }, + "method": { + "shortName": "AnalyzeEntities", + "fullName": "google.cloud.language.v1.LanguageService.AnalyzeEntities", + "service": { + "shortName": "LanguageService", + "fullName": "google.cloud.language.v1.LanguageService" + } + } + } + }, + { + "regionTag": "language_v1_generated_LanguageService_AnalyzeEntitySentiment_async", + "title": "LanguageService analyzeEntitySentiment Sample", + "origin": "API_DEFINITION", + "description": " Finds entities, similar to [AnalyzeEntities][google.cloud.language.v1.LanguageService.AnalyzeEntities] in the text and analyzes sentiment associated with each entity and its mentions.", + "canonical": true, + "file": "language_service.analyze_entity_sentiment.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AnalyzeEntitySentiment", + "fullName": "google.cloud.language.v1.LanguageService.AnalyzeEntitySentiment", + "async": true, + "parameters": [ + { + "name": "document", + "type": ".google.cloud.language.v1.Document" + }, + { + "name": "encoding_type", + "type": ".google.cloud.language.v1.EncodingType" + } + ], + "resultType": ".google.cloud.language.v1.AnalyzeEntitySentimentResponse", + "client": { + "shortName": "LanguageServiceClient", + "fullName": "google.cloud.language.v1.LanguageServiceClient" + }, + "method": { + "shortName": "AnalyzeEntitySentiment", + "fullName": "google.cloud.language.v1.LanguageService.AnalyzeEntitySentiment", + "service": { + "shortName": "LanguageService", + "fullName": "google.cloud.language.v1.LanguageService" + } + } + } + }, + { + "regionTag": "language_v1_generated_LanguageService_AnalyzeSyntax_async", + "title": "LanguageService analyzeSyntax Sample", + "origin": "API_DEFINITION", + "description": " Analyzes the syntax of the text and provides sentence boundaries and tokenization along with part of speech tags, dependency trees, and other properties.", + "canonical": true, + "file": "language_service.analyze_syntax.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AnalyzeSyntax", + "fullName": "google.cloud.language.v1.LanguageService.AnalyzeSyntax", + "async": true, + "parameters": [ + { + "name": "document", + "type": ".google.cloud.language.v1.Document" + }, + { + "name": "encoding_type", + "type": ".google.cloud.language.v1.EncodingType" + } + ], + "resultType": ".google.cloud.language.v1.AnalyzeSyntaxResponse", + "client": { + "shortName": "LanguageServiceClient", + "fullName": "google.cloud.language.v1.LanguageServiceClient" + }, + "method": { + "shortName": "AnalyzeSyntax", + "fullName": "google.cloud.language.v1.LanguageService.AnalyzeSyntax", + "service": { + "shortName": "LanguageService", + "fullName": "google.cloud.language.v1.LanguageService" + } + } + } + }, + { + "regionTag": "language_v1_generated_LanguageService_ClassifyText_async", + "title": "LanguageService classifyText Sample", + "origin": "API_DEFINITION", + "description": " Classifies a document into categories.", + "canonical": true, + "file": "language_service.classify_text.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 50, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ClassifyText", + "fullName": "google.cloud.language.v1.LanguageService.ClassifyText", + "async": true, + "parameters": [ + { + "name": "document", + "type": ".google.cloud.language.v1.Document" + } + ], + "resultType": ".google.cloud.language.v1.ClassifyTextResponse", + "client": { + "shortName": "LanguageServiceClient", + "fullName": "google.cloud.language.v1.LanguageServiceClient" + }, + "method": { + "shortName": "ClassifyText", + "fullName": "google.cloud.language.v1.LanguageService.ClassifyText", + "service": { + "shortName": "LanguageService", + "fullName": "google.cloud.language.v1.LanguageService" + } + } + } + }, + { + "regionTag": "language_v1_generated_LanguageService_AnnotateText_async", + "title": "LanguageService annotateText Sample", + "origin": "API_DEFINITION", + "description": " A convenience method that provides all the features that analyzeSentiment, analyzeEntities, and analyzeSyntax provide in one call.", + "canonical": true, + "file": "language_service.annotate_text.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AnnotateText", + "fullName": "google.cloud.language.v1.LanguageService.AnnotateText", + "async": true, + "parameters": [ + { + "name": "document", + "type": ".google.cloud.language.v1.Document" + }, + { + "name": "features", + "type": ".google.cloud.language.v1.AnnotateTextRequest.Features" + }, + { + "name": "encoding_type", + "type": ".google.cloud.language.v1.EncodingType" + } + ], + "resultType": ".google.cloud.language.v1.AnnotateTextResponse", + "client": { + "shortName": "LanguageServiceClient", + "fullName": "google.cloud.language.v1.LanguageServiceClient" + }, + "method": { + "shortName": "AnnotateText", + "fullName": "google.cloud.language.v1.LanguageService.AnnotateText", + "service": { + "shortName": "LanguageService", + "fullName": "google.cloud.language.v1.LanguageService" + } + } + } + } + ] +} diff --git a/owl-bot-staging/v1/src/index.ts b/owl-bot-staging/v1/src/index.ts new file mode 100644 index 00000000..25e95ead --- /dev/null +++ b/owl-bot-staging/v1/src/index.ts @@ -0,0 +1,25 @@ +// 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 LanguageServiceClient = v1.LanguageServiceClient; +type LanguageServiceClient = v1.LanguageServiceClient; +export {v1, LanguageServiceClient}; +export default {v1, LanguageServiceClient}; +import * as protos from '../protos/protos'; +export {protos} 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..fc97e120 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/gapic_metadata.json @@ -0,0 +1,83 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.language.v1", + "libraryPackage": "@google-cloud/language", + "services": { + "LanguageService": { + "clients": { + "grpc": { + "libraryClient": "LanguageServiceClient", + "rpcs": { + "AnalyzeSentiment": { + "methods": [ + "analyzeSentiment" + ] + }, + "AnalyzeEntities": { + "methods": [ + "analyzeEntities" + ] + }, + "AnalyzeEntitySentiment": { + "methods": [ + "analyzeEntitySentiment" + ] + }, + "AnalyzeSyntax": { + "methods": [ + "analyzeSyntax" + ] + }, + "ClassifyText": { + "methods": [ + "classifyText" + ] + }, + "AnnotateText": { + "methods": [ + "annotateText" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "LanguageServiceClient", + "rpcs": { + "AnalyzeSentiment": { + "methods": [ + "analyzeSentiment" + ] + }, + "AnalyzeEntities": { + "methods": [ + "analyzeEntities" + ] + }, + "AnalyzeEntitySentiment": { + "methods": [ + "analyzeEntitySentiment" + ] + }, + "AnalyzeSyntax": { + "methods": [ + "analyzeSyntax" + ] + }, + "ClassifyText": { + "methods": [ + "classifyText" + ] + }, + "AnnotateText": { + "methods": [ + "annotateText" + ] + } + } + } + } + } + } +} 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..7e077a20 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/index.ts @@ -0,0 +1,19 @@ +// 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 {LanguageServiceClient} from './language_service_client'; diff --git a/owl-bot-staging/v1/src/v1/language_service_client.ts b/owl-bot-staging/v1/src/v1/language_service_client.ts new file mode 100644 index 00000000..032639fd --- /dev/null +++ b/owl-bot-staging/v1/src/v1/language_service_client.ts @@ -0,0 +1,708 @@ +// 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 * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/language_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './language_service_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * Provides text analysis operations such as sentiment analysis and entity + * recognition. + * @class + * @memberof v1 + */ +export class LanguageServiceClient { + 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}; + languageServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of LanguageServiceClient. + * + * @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}. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof LanguageServiceClient; + 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; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth 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); + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.language.v1.LanguageService', 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 = gax.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.languageServiceStub) { + return this.languageServiceStub; + } + + // Put together the "service stub" for + // google.cloud.language.v1.LanguageService. + this.languageServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.language.v1.LanguageService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.language.v1.LanguageService, + 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 languageServiceStubMethods = + ['analyzeSentiment', 'analyzeEntities', 'analyzeEntitySentiment', 'analyzeSyntax', 'classifyText', 'annotateText']; + for (const methodName of languageServiceStubMethods) { + const callPromise = this.languageServiceStub.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 = + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.languageServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'language.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 'language.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-language', + '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 -- + // ------------------- +/** + * 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): + Promise<[ + protos.google.cloud.language.v1.IAnalyzeSentimentResponse, + protos.google.cloud.language.v1.IAnalyzeSentimentRequest|undefined, {}|undefined + ]>; + analyzeSentiment( + request: protos.google.cloud.language.v1.IAnalyzeSentimentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.language.v1.IAnalyzeSentimentResponse, + protos.google.cloud.language.v1.IAnalyzeSentimentRequest|null|undefined, + {}|null|undefined>): void; + analyzeSentiment( + request: protos.google.cloud.language.v1.IAnalyzeSentimentRequest, + callback: Callback< + protos.google.cloud.language.v1.IAnalyzeSentimentResponse, + protos.google.cloud.language.v1.IAnalyzeSentimentRequest|null|undefined, + {}|null|undefined>): void; + analyzeSentiment( + request?: protos.google.cloud.language.v1.IAnalyzeSentimentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.language.v1.IAnalyzeSentimentResponse, + protos.google.cloud.language.v1.IAnalyzeSentimentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.language.v1.IAnalyzeSentimentResponse, + protos.google.cloud.language.v1.IAnalyzeSentimentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.language.v1.IAnalyzeSentimentResponse, + protos.google.cloud.language.v1.IAnalyzeSentimentRequest|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.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): + Promise<[ + protos.google.cloud.language.v1.IAnalyzeEntitiesResponse, + protos.google.cloud.language.v1.IAnalyzeEntitiesRequest|undefined, {}|undefined + ]>; + analyzeEntities( + request: protos.google.cloud.language.v1.IAnalyzeEntitiesRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.language.v1.IAnalyzeEntitiesResponse, + protos.google.cloud.language.v1.IAnalyzeEntitiesRequest|null|undefined, + {}|null|undefined>): void; + analyzeEntities( + request: protos.google.cloud.language.v1.IAnalyzeEntitiesRequest, + callback: Callback< + protos.google.cloud.language.v1.IAnalyzeEntitiesResponse, + protos.google.cloud.language.v1.IAnalyzeEntitiesRequest|null|undefined, + {}|null|undefined>): void; + analyzeEntities( + request?: protos.google.cloud.language.v1.IAnalyzeEntitiesRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.language.v1.IAnalyzeEntitiesResponse, + protos.google.cloud.language.v1.IAnalyzeEntitiesRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.language.v1.IAnalyzeEntitiesResponse, + protos.google.cloud.language.v1.IAnalyzeEntitiesRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.language.v1.IAnalyzeEntitiesResponse, + protos.google.cloud.language.v1.IAnalyzeEntitiesRequest|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.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): + Promise<[ + protos.google.cloud.language.v1.IAnalyzeEntitySentimentResponse, + protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest|undefined, {}|undefined + ]>; + analyzeEntitySentiment( + request: protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.language.v1.IAnalyzeEntitySentimentResponse, + protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest|null|undefined, + {}|null|undefined>): void; + analyzeEntitySentiment( + request: protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest, + callback: Callback< + protos.google.cloud.language.v1.IAnalyzeEntitySentimentResponse, + protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest|null|undefined, + {}|null|undefined>): void; + analyzeEntitySentiment( + request?: protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.language.v1.IAnalyzeEntitySentimentResponse, + protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.language.v1.IAnalyzeEntitySentimentResponse, + protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.language.v1.IAnalyzeEntitySentimentResponse, + protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest|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.analyzeEntitySentiment(request, options, 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): + Promise<[ + protos.google.cloud.language.v1.IAnalyzeSyntaxResponse, + protos.google.cloud.language.v1.IAnalyzeSyntaxRequest|undefined, {}|undefined + ]>; + analyzeSyntax( + request: protos.google.cloud.language.v1.IAnalyzeSyntaxRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.language.v1.IAnalyzeSyntaxResponse, + protos.google.cloud.language.v1.IAnalyzeSyntaxRequest|null|undefined, + {}|null|undefined>): void; + analyzeSyntax( + request: protos.google.cloud.language.v1.IAnalyzeSyntaxRequest, + callback: Callback< + protos.google.cloud.language.v1.IAnalyzeSyntaxResponse, + protos.google.cloud.language.v1.IAnalyzeSyntaxRequest|null|undefined, + {}|null|undefined>): void; + analyzeSyntax( + request?: protos.google.cloud.language.v1.IAnalyzeSyntaxRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.language.v1.IAnalyzeSyntaxResponse, + protos.google.cloud.language.v1.IAnalyzeSyntaxRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.language.v1.IAnalyzeSyntaxResponse, + protos.google.cloud.language.v1.IAnalyzeSyntaxRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.language.v1.IAnalyzeSyntaxResponse, + protos.google.cloud.language.v1.IAnalyzeSyntaxRequest|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.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): + Promise<[ + protos.google.cloud.language.v1.IClassifyTextResponse, + protos.google.cloud.language.v1.IClassifyTextRequest|undefined, {}|undefined + ]>; + classifyText( + request: protos.google.cloud.language.v1.IClassifyTextRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.language.v1.IClassifyTextResponse, + protos.google.cloud.language.v1.IClassifyTextRequest|null|undefined, + {}|null|undefined>): void; + classifyText( + request: protos.google.cloud.language.v1.IClassifyTextRequest, + callback: Callback< + protos.google.cloud.language.v1.IClassifyTextResponse, + protos.google.cloud.language.v1.IClassifyTextRequest|null|undefined, + {}|null|undefined>): void; + classifyText( + request?: protos.google.cloud.language.v1.IClassifyTextRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.language.v1.IClassifyTextResponse, + protos.google.cloud.language.v1.IClassifyTextRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.language.v1.IClassifyTextResponse, + protos.google.cloud.language.v1.IClassifyTextRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.language.v1.IClassifyTextResponse, + protos.google.cloud.language.v1.IClassifyTextRequest|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.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): + Promise<[ + protos.google.cloud.language.v1.IAnnotateTextResponse, + protos.google.cloud.language.v1.IAnnotateTextRequest|undefined, {}|undefined + ]>; + annotateText( + request: protos.google.cloud.language.v1.IAnnotateTextRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.language.v1.IAnnotateTextResponse, + protos.google.cloud.language.v1.IAnnotateTextRequest|null|undefined, + {}|null|undefined>): void; + annotateText( + request: protos.google.cloud.language.v1.IAnnotateTextRequest, + callback: Callback< + protos.google.cloud.language.v1.IAnnotateTextResponse, + protos.google.cloud.language.v1.IAnnotateTextRequest|null|undefined, + {}|null|undefined>): void; + annotateText( + request?: protos.google.cloud.language.v1.IAnnotateTextRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.language.v1.IAnnotateTextResponse, + protos.google.cloud.language.v1.IAnnotateTextRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.language.v1.IAnnotateTextResponse, + protos.google.cloud.language.v1.IAnnotateTextRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.language.v1.IAnnotateTextResponse, + protos.google.cloud.language.v1.IAnnotateTextRequest|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.annotateText(request, options, callback); + } + + + /** + * 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.languageServiceStub && !this._terminated) { + return this.languageServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1/src/v1/language_service_client_config.json b/owl-bot-staging/v1/src/v1/language_service_client_config.json new file mode 100644 index 00000000..4ee37da9 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/language_service_client_config.json @@ -0,0 +1,56 @@ +{ + "interfaces": { + "google.cloud.language.v1.LanguageService": { + "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": { + "AnalyzeSentiment": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "AnalyzeEntities": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "AnalyzeEntitySentiment": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "AnalyzeSyntax": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ClassifyText": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "AnnotateText": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1/src/v1/language_service_proto_list.json b/owl-bot-staging/v1/src/v1/language_service_proto_list.json new file mode 100644 index 00000000..04560528 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/language_service_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/language/v1/language_service.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..d89f290c --- /dev/null +++ b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js @@ -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. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const language = require('@google-cloud/language'); + +function main() { + const languageServiceClient = new language.LanguageServiceClient(); +} + +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..67dcd47c --- /dev/null +++ b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// 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 {LanguageServiceClient} from '@google-cloud/language'; + +// check that the client class type name can be used +function doStuffWithLanguageServiceClient(client: LanguageServiceClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const languageServiceClient = new LanguageServiceClient(); + doStuffWithLanguageServiceClient(languageServiceClient); +} + +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..8ec45222 --- /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_language_service_v1.ts b/owl-bot-staging/v1/test/gapic_language_service_v1.ts new file mode 100644 index 00000000..82493bce --- /dev/null +++ b/owl-bot-staging/v1/test/gapic_language_service_v1.ts @@ -0,0 +1,567 @@ +// 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 languageserviceModule from '../src'; + +import {protobuf} from 'google-gax'; + +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); +} + +describe('v1.LanguageServiceClient', () => { + it('has servicePath', () => { + const servicePath = languageserviceModule.v1.LanguageServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = languageserviceModule.v1.LanguageServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = languageserviceModule.v1.LanguageServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new languageserviceModule.v1.LanguageServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.languageServiceStub, undefined); + await client.initialize(); + assert(client.languageServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.languageServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.languageServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new languageserviceModule.v1.LanguageServiceClient({ + 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 languageserviceModule.v1.LanguageServiceClient({ + 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('analyzeSentiment', () => { + it('invokes analyzeSentiment without error', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeSentimentRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeSentimentResponse()); + client.innerApiCalls.analyzeSentiment = stubSimpleCall(expectedResponse); + const [response] = await client.analyzeSentiment(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.analyzeSentiment as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes analyzeSentiment without error using callback', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeSentimentRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeSentimentResponse()); + client.innerApiCalls.analyzeSentiment = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.analyzeSentiment( + request, + (err?: Error|null, result?: protos.google.cloud.language.v1.IAnalyzeSentimentResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.analyzeSentiment as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes analyzeSentiment with error', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeSentimentRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.analyzeSentiment = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.analyzeSentiment(request), expectedError); + assert((client.innerApiCalls.analyzeSentiment as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes analyzeSentiment with closed client', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeSentimentRequest()); + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.analyzeSentiment(request), expectedError); + }); + }); + + describe('analyzeEntities', () => { + it('invokes analyzeEntities without error', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeEntitiesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeEntitiesResponse()); + client.innerApiCalls.analyzeEntities = stubSimpleCall(expectedResponse); + const [response] = await client.analyzeEntities(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.analyzeEntities as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes analyzeEntities without error using callback', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeEntitiesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeEntitiesResponse()); + client.innerApiCalls.analyzeEntities = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.analyzeEntities( + request, + (err?: Error|null, result?: protos.google.cloud.language.v1.IAnalyzeEntitiesResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.analyzeEntities as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes analyzeEntities with error', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeEntitiesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.analyzeEntities = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.analyzeEntities(request), expectedError); + assert((client.innerApiCalls.analyzeEntities as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes analyzeEntities with closed client', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeEntitiesRequest()); + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.analyzeEntities(request), expectedError); + }); + }); + + describe('analyzeEntitySentiment', () => { + it('invokes analyzeEntitySentiment without error', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeEntitySentimentRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeEntitySentimentResponse()); + client.innerApiCalls.analyzeEntitySentiment = stubSimpleCall(expectedResponse); + const [response] = await client.analyzeEntitySentiment(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.analyzeEntitySentiment as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes analyzeEntitySentiment without error using callback', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeEntitySentimentRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeEntitySentimentResponse()); + client.innerApiCalls.analyzeEntitySentiment = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.analyzeEntitySentiment( + request, + (err?: Error|null, result?: protos.google.cloud.language.v1.IAnalyzeEntitySentimentResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.analyzeEntitySentiment as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes analyzeEntitySentiment with error', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeEntitySentimentRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.analyzeEntitySentiment = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.analyzeEntitySentiment(request), expectedError); + assert((client.innerApiCalls.analyzeEntitySentiment as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes analyzeEntitySentiment with closed client', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeEntitySentimentRequest()); + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.analyzeEntitySentiment(request), expectedError); + }); + }); + + describe('analyzeSyntax', () => { + it('invokes analyzeSyntax without error', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeSyntaxRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeSyntaxResponse()); + client.innerApiCalls.analyzeSyntax = stubSimpleCall(expectedResponse); + const [response] = await client.analyzeSyntax(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.analyzeSyntax as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes analyzeSyntax without error using callback', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeSyntaxRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeSyntaxResponse()); + client.innerApiCalls.analyzeSyntax = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.analyzeSyntax( + request, + (err?: Error|null, result?: protos.google.cloud.language.v1.IAnalyzeSyntaxResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.analyzeSyntax as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes analyzeSyntax with error', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeSyntaxRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.analyzeSyntax = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.analyzeSyntax(request), expectedError); + assert((client.innerApiCalls.analyzeSyntax as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes analyzeSyntax with closed client', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeSyntaxRequest()); + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.analyzeSyntax(request), expectedError); + }); + }); + + describe('classifyText', () => { + it('invokes classifyText without error', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.language.v1.ClassifyTextRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1.ClassifyTextResponse()); + client.innerApiCalls.classifyText = stubSimpleCall(expectedResponse); + const [response] = await client.classifyText(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.classifyText as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes classifyText without error using callback', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.language.v1.ClassifyTextRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1.ClassifyTextResponse()); + client.innerApiCalls.classifyText = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.classifyText( + request, + (err?: Error|null, result?: protos.google.cloud.language.v1.IClassifyTextResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.classifyText as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes classifyText with error', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.language.v1.ClassifyTextRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.classifyText = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.classifyText(request), expectedError); + assert((client.innerApiCalls.classifyText as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes classifyText with closed client', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.language.v1.ClassifyTextRequest()); + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.classifyText(request), expectedError); + }); + }); + + describe('annotateText', () => { + it('invokes annotateText without error', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.language.v1.AnnotateTextRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1.AnnotateTextResponse()); + client.innerApiCalls.annotateText = stubSimpleCall(expectedResponse); + const [response] = await client.annotateText(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.annotateText as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes annotateText without error using callback', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.language.v1.AnnotateTextRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1.AnnotateTextResponse()); + client.innerApiCalls.annotateText = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.annotateText( + request, + (err?: Error|null, result?: protos.google.cloud.language.v1.IAnnotateTextResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.annotateText as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes annotateText with error', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.language.v1.AnnotateTextRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.annotateText = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.annotateText(request), expectedError); + assert((client.innerApiCalls.annotateText as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes annotateText with closed client', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.language.v1.AnnotateTextRequest()); + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.annotateText(request), expectedError); + }); + }); +}); 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..c90df106 --- /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: 'LanguageService', + filename: './language-service.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/v1beta2/.eslintignore b/owl-bot-staging/v1beta2/.eslintignore new file mode 100644 index 00000000..cfc348ec --- /dev/null +++ b/owl-bot-staging/v1beta2/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/v1beta2/.eslintrc.json b/owl-bot-staging/v1beta2/.eslintrc.json new file mode 100644 index 00000000..78215349 --- /dev/null +++ b/owl-bot-staging/v1beta2/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/v1beta2/.gitignore b/owl-bot-staging/v1beta2/.gitignore new file mode 100644 index 00000000..5d32b237 --- /dev/null +++ b/owl-bot-staging/v1beta2/.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/v1beta2/.jsdoc.js b/owl-bot-staging/v1beta2/.jsdoc.js new file mode 100644 index 00000000..79611132 --- /dev/null +++ b/owl-bot-staging/v1beta2/.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/language', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/v1beta2/.mocharc.js b/owl-bot-staging/v1beta2/.mocharc.js new file mode 100644 index 00000000..481c522b --- /dev/null +++ b/owl-bot-staging/v1beta2/.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/v1beta2/.prettierrc.js b/owl-bot-staging/v1beta2/.prettierrc.js new file mode 100644 index 00000000..494e1478 --- /dev/null +++ b/owl-bot-staging/v1beta2/.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/v1beta2/README.md b/owl-bot-staging/v1beta2/README.md new file mode 100644 index 00000000..7287da54 --- /dev/null +++ b/owl-bot-staging/v1beta2/README.md @@ -0,0 +1 @@ +Language: Nodejs Client diff --git a/owl-bot-staging/v1beta2/linkinator.config.json b/owl-bot-staging/v1beta2/linkinator.config.json new file mode 100644 index 00000000..befd23c8 --- /dev/null +++ b/owl-bot-staging/v1beta2/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/v1beta2/package.json b/owl-bot-staging/v1beta2/package.json new file mode 100644 index 00000000..1b45ee6a --- /dev/null +++ b/owl-bot-staging/v1beta2/package.json @@ -0,0 +1,64 @@ +{ + "name": "@google-cloud/language", + "version": "0.1.0", + "description": "Language client for Node.js", + "repository": "googleapis/nodejs-language", + "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 language", + "language", + "language service" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/", + "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.1.1" + }, + "devDependencies": { + "@types/mocha": "^9.1.0", + "@types/node": "^16.0.0", + "@types/sinon": "^10.0.8", + "c8": "^7.11.0", + "gts": "^3.1.0", + "jsdoc": "^3.6.7", + "jsdoc-fresh": "^1.1.1", + "jsdoc-region-tag": "^1.3.1", + "linkinator": "^3.0.0", + "mocha": "^9.1.4", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^13.0.0", + "ts-loader": "^9.2.6", + "typescript": "^4.5.5", + "webpack": "^5.67.0", + "webpack-cli": "^4.9.1" + }, + "engines": { + "node": ">=v12" + } +} diff --git a/owl-bot-staging/v1beta2/protos/google/cloud/language/v1beta2/language_service.proto b/owl-bot-staging/v1beta2/protos/google/cloud/language/v1beta2/language_service.proto new file mode 100644 index 00000000..bd4167a3 --- /dev/null +++ b/owl-bot-staging/v1beta2/protos/google/cloud/language/v1beta2/language_service.proto @@ -0,0 +1,1134 @@ +// Copyright 2019 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.language.v1beta2; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/language/v1beta2;language"; +option java_multiple_files = true; +option java_outer_classname = "LanguageServiceProto"; +option java_package = "com.google.cloud.language.v1beta2"; + +// Provides text analysis operations such as sentiment analysis and entity +// recognition. +service LanguageService { + option (google.api.default_host) = "language.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-language," + "https://www.googleapis.com/auth/cloud-platform"; + + // Analyzes the sentiment of the provided text. + rpc AnalyzeSentiment(AnalyzeSentimentRequest) returns (AnalyzeSentimentResponse) { + option (google.api.http) = { + post: "/v1beta2/documents:analyzeSentiment" + body: "*" + }; + option (google.api.method_signature) = "document,encoding_type"; + option (google.api.method_signature) = "document"; + } + + // Finds named entities (currently proper names and common nouns) in the text + // along with entity types, salience, mentions for each entity, and + // other properties. + rpc AnalyzeEntities(AnalyzeEntitiesRequest) returns (AnalyzeEntitiesResponse) { + option (google.api.http) = { + post: "/v1beta2/documents:analyzeEntities" + body: "*" + }; + option (google.api.method_signature) = "document,encoding_type"; + option (google.api.method_signature) = "document"; + } + + // Finds entities, similar to [AnalyzeEntities][google.cloud.language.v1beta2.LanguageService.AnalyzeEntities] in the text and analyzes + // sentiment associated with each entity and its mentions. + rpc AnalyzeEntitySentiment(AnalyzeEntitySentimentRequest) returns (AnalyzeEntitySentimentResponse) { + option (google.api.http) = { + post: "/v1beta2/documents:analyzeEntitySentiment" + body: "*" + }; + option (google.api.method_signature) = "document,encoding_type"; + option (google.api.method_signature) = "document"; + } + + // Analyzes the syntax of the text and provides sentence boundaries and + // tokenization along with part-of-speech tags, dependency trees, and other + // properties. + rpc AnalyzeSyntax(AnalyzeSyntaxRequest) returns (AnalyzeSyntaxResponse) { + option (google.api.http) = { + post: "/v1beta2/documents:analyzeSyntax" + body: "*" + }; + option (google.api.method_signature) = "document,encoding_type"; + option (google.api.method_signature) = "document"; + } + + // Classifies a document into categories. + rpc ClassifyText(ClassifyTextRequest) returns (ClassifyTextResponse) { + option (google.api.http) = { + post: "/v1beta2/documents:classifyText" + body: "*" + }; + option (google.api.method_signature) = "document"; + } + + // A convenience method that provides all syntax, sentiment, entity, and + // classification features in one call. + rpc AnnotateText(AnnotateTextRequest) returns (AnnotateTextResponse) { + option (google.api.http) = { + post: "/v1beta2/documents:annotateText" + body: "*" + }; + option (google.api.method_signature) = "document,features,encoding_type"; + option (google.api.method_signature) = "document,features"; + } +} + + +// +// Represents the input to API methods. +message Document { + // The document types enum. + enum Type { + // The content type is not specified. + TYPE_UNSPECIFIED = 0; + + // Plain text + PLAIN_TEXT = 1; + + // HTML + HTML = 2; + } + + // Required. If the type is not set or is `TYPE_UNSPECIFIED`, + // returns an `INVALID_ARGUMENT` error. + Type type = 1; + + // The source of the document: a string containing the content or a + // Google Cloud Storage URI. + oneof source { + // The content of the input in string format. + // Cloud audit logging exempt since it is based on user data. + string content = 2; + + // The Google Cloud Storage URI where the file content is located. + // This URI must be of the form: gs://bucket_name/object_name. For more + // details, see https://cloud.google.com/storage/docs/reference-uris. + // NOTE: Cloud Storage object versioning is not supported. + string gcs_content_uri = 3; + } + + // The language of the document (if not specified, the language is + // automatically detected). Both ISO and BCP-47 language codes are + // accepted.
+ // [Language + // Support](https://cloud.google.com/natural-language/docs/languages) lists + // currently supported languages for each API method. If the language (either + // specified by the caller or automatically detected) is not supported by the + // called API method, an `INVALID_ARGUMENT` error is returned. + string language = 4; +} + +// Represents a sentence in the input document. +message Sentence { + // The sentence text. + TextSpan text = 1; + + // For calls to [AnalyzeSentiment][] or if + // [AnnotateTextRequest.Features.extract_document_sentiment][google.cloud.language.v1beta2.AnnotateTextRequest.Features.extract_document_sentiment] is set to + // true, this field will contain the sentiment for the sentence. + Sentiment sentiment = 2; +} + +// Represents a phrase in the text that is a known entity, such as +// a person, an organization, or location. The API associates information, such +// as salience and mentions, with entities. +message Entity { + // The type of the entity. For most entity types, the associated metadata is a + // Wikipedia URL (`wikipedia_url`) and Knowledge Graph MID (`mid`). The table + // below lists the associated fields for entities that have different + // metadata. + enum Type { + // Unknown + UNKNOWN = 0; + + // Person + PERSON = 1; + + // Location + LOCATION = 2; + + // Organization + ORGANIZATION = 3; + + // Event + EVENT = 4; + + // Artwork + WORK_OF_ART = 5; + + // Consumer product + CONSUMER_GOOD = 6; + + // Other types of entities + OTHER = 7; + + // Phone number + // + // The metadata lists the phone number, formatted according to local + // convention, plus whichever additional elements appear in the text: + // + // * `number` - the actual number, broken down into sections as per local + // convention + // * `national_prefix` - country code, if detected + // * `area_code` - region or area code, if detected + // * `extension` - phone extension (to be dialed after connection), if + // detected + PHONE_NUMBER = 9; + + // Address + // + // The metadata identifies the street number and locality plus whichever + // additional elements appear in the text: + // + // * `street_number` - street number + // * `locality` - city or town + // * `street_name` - street/route name, if detected + // * `postal_code` - postal code, if detected + // * `country` - country, if detected< + // * `broad_region` - administrative area, such as the state, if detected + // * `narrow_region` - smaller administrative area, such as county, if + // detected + // * `sublocality` - used in Asian addresses to demark a district within a + // city, if detected + ADDRESS = 10; + + // Date + // + // The metadata identifies the components of the date: + // + // * `year` - four digit year, if detected + // * `month` - two digit month number, if detected + // * `day` - two digit day number, if detected + DATE = 11; + + // Number + // + // The metadata is the number itself. + NUMBER = 12; + + // Price + // + // The metadata identifies the `value` and `currency`. + PRICE = 13; + } + + // The representative name for the entity. + string name = 1; + + // The entity type. + Type type = 2; + + // Metadata associated with the entity. + // + // For most entity types, the metadata is a Wikipedia URL (`wikipedia_url`) + // and Knowledge Graph MID (`mid`), if they are available. For the metadata + // associated with other entity types, see the Type table below. + map metadata = 3; + + // The salience score associated with the entity in the [0, 1.0] range. + // + // The salience score for an entity provides information about the + // importance or centrality of that entity to the entire document text. + // Scores closer to 0 are less salient, while scores closer to 1.0 are highly + // salient. + float salience = 4; + + // The mentions of this entity in the input document. The API currently + // supports proper noun mentions. + repeated EntityMention mentions = 5; + + // For calls to [AnalyzeEntitySentiment][] or if + // [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v1beta2.AnnotateTextRequest.Features.extract_entity_sentiment] is set to + // true, this field will contain the aggregate sentiment expressed for this + // entity in the provided document. + Sentiment sentiment = 6; +} + +// Represents the smallest syntactic building block of the text. +message Token { + // The token text. + TextSpan text = 1; + + // Parts of speech tag for this token. + PartOfSpeech part_of_speech = 2; + + // Dependency tree parse for this token. + DependencyEdge dependency_edge = 3; + + // [Lemma](https://en.wikipedia.org/wiki/Lemma_%28morphology%29) of the token. + string lemma = 4; +} + +// Represents the text encoding that the caller uses to process the output. +// Providing an `EncodingType` is recommended because the API provides the +// beginning offsets for various outputs, such as tokens and mentions, and +// languages that natively use different text encodings may access offsets +// differently. +enum EncodingType { + // If `EncodingType` is not specified, encoding-dependent information (such as + // `begin_offset`) will be set at `-1`. + NONE = 0; + + // Encoding-dependent information (such as `begin_offset`) is calculated based + // on the UTF-8 encoding of the input. C++ and Go are examples of languages + // that use this encoding natively. + UTF8 = 1; + + // Encoding-dependent information (such as `begin_offset`) is calculated based + // on the UTF-16 encoding of the input. Java and JavaScript are examples of + // languages that use this encoding natively. + UTF16 = 2; + + // Encoding-dependent information (such as `begin_offset`) is calculated based + // on the UTF-32 encoding of the input. Python is an example of a language + // that uses this encoding natively. + UTF32 = 3; +} + +// Represents the feeling associated with the entire text or entities in +// the text. +// Next ID: 6 +message Sentiment { + // A non-negative number in the [0, +inf) range, which represents + // the absolute magnitude of sentiment regardless of score (positive or + // negative). + float magnitude = 2; + + // Sentiment score between -1.0 (negative sentiment) and 1.0 + // (positive sentiment). + float score = 3; +} + +// Represents part of speech information for a token. +message PartOfSpeech { + // The part of speech tags enum. + enum Tag { + // Unknown + UNKNOWN = 0; + + // Adjective + ADJ = 1; + + // Adposition (preposition and postposition) + ADP = 2; + + // Adverb + ADV = 3; + + // Conjunction + CONJ = 4; + + // Determiner + DET = 5; + + // Noun (common and proper) + NOUN = 6; + + // Cardinal number + NUM = 7; + + // Pronoun + PRON = 8; + + // Particle or other function word + PRT = 9; + + // Punctuation + PUNCT = 10; + + // Verb (all tenses and modes) + VERB = 11; + + // Other: foreign words, typos, abbreviations + X = 12; + + // Affix + AFFIX = 13; + } + + // The characteristic of a verb that expresses time flow during an event. + enum Aspect { + // Aspect is not applicable in the analyzed language or is not predicted. + ASPECT_UNKNOWN = 0; + + // Perfective + PERFECTIVE = 1; + + // Imperfective + IMPERFECTIVE = 2; + + // Progressive + PROGRESSIVE = 3; + } + + // The grammatical function performed by a noun or pronoun in a phrase, + // clause, or sentence. In some languages, other parts of speech, such as + // adjective and determiner, take case inflection in agreement with the noun. + enum Case { + // Case is not applicable in the analyzed language or is not predicted. + CASE_UNKNOWN = 0; + + // Accusative + ACCUSATIVE = 1; + + // Adverbial + ADVERBIAL = 2; + + // Complementive + COMPLEMENTIVE = 3; + + // Dative + DATIVE = 4; + + // Genitive + GENITIVE = 5; + + // Instrumental + INSTRUMENTAL = 6; + + // Locative + LOCATIVE = 7; + + // Nominative + NOMINATIVE = 8; + + // Oblique + OBLIQUE = 9; + + // Partitive + PARTITIVE = 10; + + // Prepositional + PREPOSITIONAL = 11; + + // Reflexive + REFLEXIVE_CASE = 12; + + // Relative + RELATIVE_CASE = 13; + + // Vocative + VOCATIVE = 14; + } + + // Depending on the language, Form can be categorizing different forms of + // verbs, adjectives, adverbs, etc. For example, categorizing inflected + // endings of verbs and adjectives or distinguishing between short and long + // forms of adjectives and participles + enum Form { + // Form is not applicable in the analyzed language or is not predicted. + FORM_UNKNOWN = 0; + + // Adnomial + ADNOMIAL = 1; + + // Auxiliary + AUXILIARY = 2; + + // Complementizer + COMPLEMENTIZER = 3; + + // Final ending + FINAL_ENDING = 4; + + // Gerund + GERUND = 5; + + // Realis + REALIS = 6; + + // Irrealis + IRREALIS = 7; + + // Short form + SHORT = 8; + + // Long form + LONG = 9; + + // Order form + ORDER = 10; + + // Specific form + SPECIFIC = 11; + } + + // Gender classes of nouns reflected in the behaviour of associated words. + enum Gender { + // Gender is not applicable in the analyzed language or is not predicted. + GENDER_UNKNOWN = 0; + + // Feminine + FEMININE = 1; + + // Masculine + MASCULINE = 2; + + // Neuter + NEUTER = 3; + } + + // The grammatical feature of verbs, used for showing modality and attitude. + enum Mood { + // Mood is not applicable in the analyzed language or is not predicted. + MOOD_UNKNOWN = 0; + + // Conditional + CONDITIONAL_MOOD = 1; + + // Imperative + IMPERATIVE = 2; + + // Indicative + INDICATIVE = 3; + + // Interrogative + INTERROGATIVE = 4; + + // Jussive + JUSSIVE = 5; + + // Subjunctive + SUBJUNCTIVE = 6; + } + + // Count distinctions. + enum Number { + // Number is not applicable in the analyzed language or is not predicted. + NUMBER_UNKNOWN = 0; + + // Singular + SINGULAR = 1; + + // Plural + PLURAL = 2; + + // Dual + DUAL = 3; + } + + // The distinction between the speaker, second person, third person, etc. + enum Person { + // Person is not applicable in the analyzed language or is not predicted. + PERSON_UNKNOWN = 0; + + // First + FIRST = 1; + + // Second + SECOND = 2; + + // Third + THIRD = 3; + + // Reflexive + REFLEXIVE_PERSON = 4; + } + + // This category shows if the token is part of a proper name. + enum Proper { + // Proper is not applicable in the analyzed language or is not predicted. + PROPER_UNKNOWN = 0; + + // Proper + PROPER = 1; + + // Not proper + NOT_PROPER = 2; + } + + // Reciprocal features of a pronoun. + enum Reciprocity { + // Reciprocity is not applicable in the analyzed language or is not + // predicted. + RECIPROCITY_UNKNOWN = 0; + + // Reciprocal + RECIPROCAL = 1; + + // Non-reciprocal + NON_RECIPROCAL = 2; + } + + // Time reference. + enum Tense { + // Tense is not applicable in the analyzed language or is not predicted. + TENSE_UNKNOWN = 0; + + // Conditional + CONDITIONAL_TENSE = 1; + + // Future + FUTURE = 2; + + // Past + PAST = 3; + + // Present + PRESENT = 4; + + // Imperfect + IMPERFECT = 5; + + // Pluperfect + PLUPERFECT = 6; + } + + // The relationship between the action that a verb expresses and the + // participants identified by its arguments. + enum Voice { + // Voice is not applicable in the analyzed language or is not predicted. + VOICE_UNKNOWN = 0; + + // Active + ACTIVE = 1; + + // Causative + CAUSATIVE = 2; + + // Passive + PASSIVE = 3; + } + + // The part of speech tag. + Tag tag = 1; + + // The grammatical aspect. + Aspect aspect = 2; + + // The grammatical case. + Case case = 3; + + // The grammatical form. + Form form = 4; + + // The grammatical gender. + Gender gender = 5; + + // The grammatical mood. + Mood mood = 6; + + // The grammatical number. + Number number = 7; + + // The grammatical person. + Person person = 8; + + // The grammatical properness. + Proper proper = 9; + + // The grammatical reciprocity. + Reciprocity reciprocity = 10; + + // The grammatical tense. + Tense tense = 11; + + // The grammatical voice. + Voice voice = 12; +} + +// Represents dependency parse tree information for a token. +message DependencyEdge { + // The parse label enum for the token. + enum Label { + // Unknown + UNKNOWN = 0; + + // Abbreviation modifier + ABBREV = 1; + + // Adjectival complement + ACOMP = 2; + + // Adverbial clause modifier + ADVCL = 3; + + // Adverbial modifier + ADVMOD = 4; + + // Adjectival modifier of an NP + AMOD = 5; + + // Appositional modifier of an NP + APPOS = 6; + + // Attribute dependent of a copular verb + ATTR = 7; + + // Auxiliary (non-main) verb + AUX = 8; + + // Passive auxiliary + AUXPASS = 9; + + // Coordinating conjunction + CC = 10; + + // Clausal complement of a verb or adjective + CCOMP = 11; + + // Conjunct + CONJ = 12; + + // Clausal subject + CSUBJ = 13; + + // Clausal passive subject + CSUBJPASS = 14; + + // Dependency (unable to determine) + DEP = 15; + + // Determiner + DET = 16; + + // Discourse + DISCOURSE = 17; + + // Direct object + DOBJ = 18; + + // Expletive + EXPL = 19; + + // Goes with (part of a word in a text not well edited) + GOESWITH = 20; + + // Indirect object + IOBJ = 21; + + // Marker (word introducing a subordinate clause) + MARK = 22; + + // Multi-word expression + MWE = 23; + + // Multi-word verbal expression + MWV = 24; + + // Negation modifier + NEG = 25; + + // Noun compound modifier + NN = 26; + + // Noun phrase used as an adverbial modifier + NPADVMOD = 27; + + // Nominal subject + NSUBJ = 28; + + // Passive nominal subject + NSUBJPASS = 29; + + // Numeric modifier of a noun + NUM = 30; + + // Element of compound number + NUMBER = 31; + + // Punctuation mark + P = 32; + + // Parataxis relation + PARATAXIS = 33; + + // Participial modifier + PARTMOD = 34; + + // The complement of a preposition is a clause + PCOMP = 35; + + // Object of a preposition + POBJ = 36; + + // Possession modifier + POSS = 37; + + // Postverbal negative particle + POSTNEG = 38; + + // Predicate complement + PRECOMP = 39; + + // Preconjunt + PRECONJ = 40; + + // Predeterminer + PREDET = 41; + + // Prefix + PREF = 42; + + // Prepositional modifier + PREP = 43; + + // The relationship between a verb and verbal morpheme + PRONL = 44; + + // Particle + PRT = 45; + + // Associative or possessive marker + PS = 46; + + // Quantifier phrase modifier + QUANTMOD = 47; + + // Relative clause modifier + RCMOD = 48; + + // Complementizer in relative clause + RCMODREL = 49; + + // Ellipsis without a preceding predicate + RDROP = 50; + + // Referent + REF = 51; + + // Remnant + REMNANT = 52; + + // Reparandum + REPARANDUM = 53; + + // Root + ROOT = 54; + + // Suffix specifying a unit of number + SNUM = 55; + + // Suffix + SUFF = 56; + + // Temporal modifier + TMOD = 57; + + // Topic marker + TOPIC = 58; + + // Clause headed by an infinite form of the verb that modifies a noun + VMOD = 59; + + // Vocative + VOCATIVE = 60; + + // Open clausal complement + XCOMP = 61; + + // Name suffix + SUFFIX = 62; + + // Name title + TITLE = 63; + + // Adverbial phrase modifier + ADVPHMOD = 64; + + // Causative auxiliary + AUXCAUS = 65; + + // Helper auxiliary + AUXVV = 66; + + // Rentaishi (Prenominal modifier) + DTMOD = 67; + + // Foreign words + FOREIGN = 68; + + // Keyword + KW = 69; + + // List for chains of comparable items + LIST = 70; + + // Nominalized clause + NOMC = 71; + + // Nominalized clausal subject + NOMCSUBJ = 72; + + // Nominalized clausal passive + NOMCSUBJPASS = 73; + + // Compound of numeric modifier + NUMC = 74; + + // Copula + COP = 75; + + // Dislocated relation (for fronted/topicalized elements) + DISLOCATED = 76; + + // Aspect marker + ASP = 77; + + // Genitive modifier + GMOD = 78; + + // Genitive object + GOBJ = 79; + + // Infinitival modifier + INFMOD = 80; + + // Measure + MES = 81; + + // Nominal complement of a noun + NCOMP = 82; + } + + // Represents the head of this token in the dependency tree. + // This is the index of the token which has an arc going to this token. + // The index is the position of the token in the array of tokens returned + // by the API method. If this token is a root token, then the + // `head_token_index` is its own index. + int32 head_token_index = 1; + + // The parse label for the token. + Label label = 2; +} + +// Represents a mention for an entity in the text. Currently, proper noun +// mentions are supported. +message EntityMention { + // The supported types of mentions. + enum Type { + // Unknown + TYPE_UNKNOWN = 0; + + // Proper name + PROPER = 1; + + // Common noun (or noun compound) + COMMON = 2; + } + + // The mention text. + TextSpan text = 1; + + // The type of the entity mention. + Type type = 2; + + // For calls to [AnalyzeEntitySentiment][] or if + // [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v1beta2.AnnotateTextRequest.Features.extract_entity_sentiment] is set to + // true, this field will contain the sentiment expressed for this mention of + // the entity in the provided document. + Sentiment sentiment = 3; +} + +// Represents an output piece of text. +message TextSpan { + // The content of the output text. + string content = 1; + + // The API calculates the beginning offset of the content in the original + // document according to the [EncodingType][google.cloud.language.v1beta2.EncodingType] specified in the API request. + int32 begin_offset = 2; +} + +// Represents a category returned from the text classifier. +message ClassificationCategory { + // The name of the category representing the document, from the [predefined + // taxonomy](https://cloud.google.com/natural-language/docs/categories). + string name = 1; + + // The classifier's confidence of the category. Number represents how certain + // the classifier is that this category represents the given text. + float confidence = 2; +} + +// The sentiment analysis request message. +message AnalyzeSentimentRequest { + // Required. Input document. + Document document = 1 [(google.api.field_behavior) = REQUIRED]; + + // The encoding type used by the API to calculate sentence offsets for the + // sentence sentiment. + EncodingType encoding_type = 2; +} + +// The sentiment analysis response message. +message AnalyzeSentimentResponse { + // The overall sentiment of the input document. + Sentiment document_sentiment = 1; + + // The language of the text, which will be the same as the language specified + // in the request or, if not specified, the automatically-detected language. + // See [Document.language][google.cloud.language.v1beta2.Document.language] field for more details. + string language = 2; + + // The sentiment for all the sentences in the document. + repeated Sentence sentences = 3; +} + +// The entity-level sentiment analysis request message. +message AnalyzeEntitySentimentRequest { + // Required. Input document. + Document document = 1 [(google.api.field_behavior) = REQUIRED]; + + // The encoding type used by the API to calculate offsets. + EncodingType encoding_type = 2; +} + +// The entity-level sentiment analysis response message. +message AnalyzeEntitySentimentResponse { + // The recognized entities in the input document with associated sentiments. + repeated Entity entities = 1; + + // The language of the text, which will be the same as the language specified + // in the request or, if not specified, the automatically-detected language. + // See [Document.language][google.cloud.language.v1beta2.Document.language] field for more details. + string language = 2; +} + +// The entity analysis request message. +message AnalyzeEntitiesRequest { + // Required. Input document. + Document document = 1 [(google.api.field_behavior) = REQUIRED]; + + // The encoding type used by the API to calculate offsets. + EncodingType encoding_type = 2; +} + +// The entity analysis response message. +message AnalyzeEntitiesResponse { + // The recognized entities in the input document. + repeated Entity entities = 1; + + // The language of the text, which will be the same as the language specified + // in the request or, if not specified, the automatically-detected language. + // See [Document.language][google.cloud.language.v1beta2.Document.language] field for more details. + string language = 2; +} + +// The syntax analysis request message. +message AnalyzeSyntaxRequest { + // Required. Input document. + Document document = 1 [(google.api.field_behavior) = REQUIRED]; + + // The encoding type used by the API to calculate offsets. + EncodingType encoding_type = 2; +} + +// The syntax analysis response message. +message AnalyzeSyntaxResponse { + // Sentences in the input document. + repeated Sentence sentences = 1; + + // Tokens, along with their syntactic information, in the input document. + repeated Token tokens = 2; + + // The language of the text, which will be the same as the language specified + // in the request or, if not specified, the automatically-detected language. + // See [Document.language][google.cloud.language.v1beta2.Document.language] field for more details. + string language = 3; +} + +// The document classification request message. +message ClassifyTextRequest { + // Required. Input document. + Document document = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// The document classification response message. +message ClassifyTextResponse { + // Categories representing the input document. + repeated ClassificationCategory categories = 1; +} + +// The request message for the text annotation API, which can perform multiple +// analysis types (sentiment, entities, and syntax) in one call. +message AnnotateTextRequest { + // All available features for sentiment, syntax, and semantic analysis. + // Setting each one to true will enable that specific analysis for the input. + // Next ID: 10 + message Features { + // Extract syntax information. + bool extract_syntax = 1; + + // Extract entities. + bool extract_entities = 2; + + // Extract document-level sentiment. + bool extract_document_sentiment = 3; + + // Extract entities and their associated sentiment. + bool extract_entity_sentiment = 4; + + // Classify the full document into categories. If this is true, + // the API will use the default model which classifies into a + // [predefined + // taxonomy](https://cloud.google.com/natural-language/docs/categories). + bool classify_text = 6; + } + + // Required. Input document. + Document document = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The enabled features. + Features features = 2 [(google.api.field_behavior) = REQUIRED]; + + // The encoding type used by the API to calculate offsets. + EncodingType encoding_type = 3; +} + +// The text annotations response message. +message AnnotateTextResponse { + // Sentences in the input document. Populated if the user enables + // [AnnotateTextRequest.Features.extract_syntax][google.cloud.language.v1beta2.AnnotateTextRequest.Features.extract_syntax]. + repeated Sentence sentences = 1; + + // Tokens, along with their syntactic information, in the input document. + // Populated if the user enables + // [AnnotateTextRequest.Features.extract_syntax][google.cloud.language.v1beta2.AnnotateTextRequest.Features.extract_syntax]. + repeated Token tokens = 2; + + // Entities, along with their semantic information, in the input document. + // Populated if the user enables + // [AnnotateTextRequest.Features.extract_entities][google.cloud.language.v1beta2.AnnotateTextRequest.Features.extract_entities]. + repeated Entity entities = 3; + + // The overall sentiment for the document. Populated if the user enables + // [AnnotateTextRequest.Features.extract_document_sentiment][google.cloud.language.v1beta2.AnnotateTextRequest.Features.extract_document_sentiment]. + Sentiment document_sentiment = 4; + + // The language of the text, which will be the same as the language specified + // in the request or, if not specified, the automatically-detected language. + // See [Document.language][google.cloud.language.v1beta2.Document.language] field for more details. + string language = 5; + + // Categories identified in the input document. + repeated ClassificationCategory categories = 6; +} diff --git a/owl-bot-staging/v1beta2/samples/generated/v1beta2/language_service.analyze_entities.js b/owl-bot-staging/v1beta2/samples/generated/v1beta2/language_service.analyze_entities.js new file mode 100644 index 00000000..61da1c26 --- /dev/null +++ b/owl-bot-staging/v1beta2/samples/generated/v1beta2/language_service.analyze_entities.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(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/owl-bot-staging/v1beta2/samples/generated/v1beta2/language_service.analyze_entity_sentiment.js b/owl-bot-staging/v1beta2/samples/generated/v1beta2/language_service.analyze_entity_sentiment.js new file mode 100644 index 00000000..f7fbf3b4 --- /dev/null +++ b/owl-bot-staging/v1beta2/samples/generated/v1beta2/language_service.analyze_entity_sentiment.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(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/owl-bot-staging/v1beta2/samples/generated/v1beta2/language_service.analyze_sentiment.js b/owl-bot-staging/v1beta2/samples/generated/v1beta2/language_service.analyze_sentiment.js new file mode 100644 index 00000000..8bf110ba --- /dev/null +++ b/owl-bot-staging/v1beta2/samples/generated/v1beta2/language_service.analyze_sentiment.js @@ -0,0 +1,63 @@ +// 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(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/owl-bot-staging/v1beta2/samples/generated/v1beta2/language_service.analyze_syntax.js b/owl-bot-staging/v1beta2/samples/generated/v1beta2/language_service.analyze_syntax.js new file mode 100644 index 00000000..2d928214 --- /dev/null +++ b/owl-bot-staging/v1beta2/samples/generated/v1beta2/language_service.analyze_syntax.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(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/owl-bot-staging/v1beta2/samples/generated/v1beta2/language_service.annotate_text.js b/owl-bot-staging/v1beta2/samples/generated/v1beta2/language_service.annotate_text.js new file mode 100644 index 00000000..b8b0239a --- /dev/null +++ b/owl-bot-staging/v1beta2/samples/generated/v1beta2/language_service.annotate_text.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(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/owl-bot-staging/v1beta2/samples/generated/v1beta2/language_service.classify_text.js b/owl-bot-staging/v1beta2/samples/generated/v1beta2/language_service.classify_text.js new file mode 100644 index 00000000..e7b868ca --- /dev/null +++ b/owl-bot-staging/v1beta2/samples/generated/v1beta2/language_service.classify_text.js @@ -0,0 +1,58 @@ +// 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(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/owl-bot-staging/v1beta2/samples/generated/v1beta2/snippet_metadata.google.cloud.language.v1beta2.json b/owl-bot-staging/v1beta2/samples/generated/v1beta2/snippet_metadata.google.cloud.language.v1beta2.json new file mode 100644 index 00000000..b46b91a8 --- /dev/null +++ b/owl-bot-staging/v1beta2/samples/generated/v1beta2/snippet_metadata.google.cloud.language.v1beta2.json @@ -0,0 +1,279 @@ +{ + "clientLibrary": { + "name": "nodejs-language", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.language.v1beta2", + "version": "v1beta2" + } + ] + }, + "snippets": [ + { + "regionTag": "language_v1beta2_generated_LanguageService_AnalyzeSentiment_async", + "title": "LanguageService analyzeSentiment Sample", + "origin": "API_DEFINITION", + "description": " Analyzes the sentiment of the provided text.", + "canonical": true, + "file": "language_service.analyze_sentiment.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AnalyzeSentiment", + "fullName": "google.cloud.language.v1beta2.LanguageService.AnalyzeSentiment", + "async": true, + "parameters": [ + { + "name": "document", + "type": ".google.cloud.language.v1beta2.Document" + }, + { + "name": "encoding_type", + "type": ".google.cloud.language.v1beta2.EncodingType" + } + ], + "resultType": ".google.cloud.language.v1beta2.AnalyzeSentimentResponse", + "client": { + "shortName": "LanguageServiceClient", + "fullName": "google.cloud.language.v1beta2.LanguageServiceClient" + }, + "method": { + "shortName": "AnalyzeSentiment", + "fullName": "google.cloud.language.v1beta2.LanguageService.AnalyzeSentiment", + "service": { + "shortName": "LanguageService", + "fullName": "google.cloud.language.v1beta2.LanguageService" + } + } + } + }, + { + "regionTag": "language_v1beta2_generated_LanguageService_AnalyzeEntities_async", + "title": "LanguageService analyzeEntities Sample", + "origin": "API_DEFINITION", + "description": " Finds named entities (currently proper names and common nouns) in the text along with entity types, salience, mentions for each entity, and other properties.", + "canonical": true, + "file": "language_service.analyze_entities.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AnalyzeEntities", + "fullName": "google.cloud.language.v1beta2.LanguageService.AnalyzeEntities", + "async": true, + "parameters": [ + { + "name": "document", + "type": ".google.cloud.language.v1beta2.Document" + }, + { + "name": "encoding_type", + "type": ".google.cloud.language.v1beta2.EncodingType" + } + ], + "resultType": ".google.cloud.language.v1beta2.AnalyzeEntitiesResponse", + "client": { + "shortName": "LanguageServiceClient", + "fullName": "google.cloud.language.v1beta2.LanguageServiceClient" + }, + "method": { + "shortName": "AnalyzeEntities", + "fullName": "google.cloud.language.v1beta2.LanguageService.AnalyzeEntities", + "service": { + "shortName": "LanguageService", + "fullName": "google.cloud.language.v1beta2.LanguageService" + } + } + } + }, + { + "regionTag": "language_v1beta2_generated_LanguageService_AnalyzeEntitySentiment_async", + "title": "LanguageService analyzeEntitySentiment Sample", + "origin": "API_DEFINITION", + "description": " Finds entities, similar to [AnalyzeEntities][google.cloud.language.v1beta2.LanguageService.AnalyzeEntities] in the text and analyzes sentiment associated with each entity and its mentions.", + "canonical": true, + "file": "language_service.analyze_entity_sentiment.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AnalyzeEntitySentiment", + "fullName": "google.cloud.language.v1beta2.LanguageService.AnalyzeEntitySentiment", + "async": true, + "parameters": [ + { + "name": "document", + "type": ".google.cloud.language.v1beta2.Document" + }, + { + "name": "encoding_type", + "type": ".google.cloud.language.v1beta2.EncodingType" + } + ], + "resultType": ".google.cloud.language.v1beta2.AnalyzeEntitySentimentResponse", + "client": { + "shortName": "LanguageServiceClient", + "fullName": "google.cloud.language.v1beta2.LanguageServiceClient" + }, + "method": { + "shortName": "AnalyzeEntitySentiment", + "fullName": "google.cloud.language.v1beta2.LanguageService.AnalyzeEntitySentiment", + "service": { + "shortName": "LanguageService", + "fullName": "google.cloud.language.v1beta2.LanguageService" + } + } + } + }, + { + "regionTag": "language_v1beta2_generated_LanguageService_AnalyzeSyntax_async", + "title": "LanguageService analyzeSyntax Sample", + "origin": "API_DEFINITION", + "description": " Analyzes the syntax of the text and provides sentence boundaries and tokenization along with part-of-speech tags, dependency trees, and other properties.", + "canonical": true, + "file": "language_service.analyze_syntax.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AnalyzeSyntax", + "fullName": "google.cloud.language.v1beta2.LanguageService.AnalyzeSyntax", + "async": true, + "parameters": [ + { + "name": "document", + "type": ".google.cloud.language.v1beta2.Document" + }, + { + "name": "encoding_type", + "type": ".google.cloud.language.v1beta2.EncodingType" + } + ], + "resultType": ".google.cloud.language.v1beta2.AnalyzeSyntaxResponse", + "client": { + "shortName": "LanguageServiceClient", + "fullName": "google.cloud.language.v1beta2.LanguageServiceClient" + }, + "method": { + "shortName": "AnalyzeSyntax", + "fullName": "google.cloud.language.v1beta2.LanguageService.AnalyzeSyntax", + "service": { + "shortName": "LanguageService", + "fullName": "google.cloud.language.v1beta2.LanguageService" + } + } + } + }, + { + "regionTag": "language_v1beta2_generated_LanguageService_ClassifyText_async", + "title": "LanguageService classifyText Sample", + "origin": "API_DEFINITION", + "description": " Classifies a document into categories.", + "canonical": true, + "file": "language_service.classify_text.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 50, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ClassifyText", + "fullName": "google.cloud.language.v1beta2.LanguageService.ClassifyText", + "async": true, + "parameters": [ + { + "name": "document", + "type": ".google.cloud.language.v1beta2.Document" + } + ], + "resultType": ".google.cloud.language.v1beta2.ClassifyTextResponse", + "client": { + "shortName": "LanguageServiceClient", + "fullName": "google.cloud.language.v1beta2.LanguageServiceClient" + }, + "method": { + "shortName": "ClassifyText", + "fullName": "google.cloud.language.v1beta2.LanguageService.ClassifyText", + "service": { + "shortName": "LanguageService", + "fullName": "google.cloud.language.v1beta2.LanguageService" + } + } + } + }, + { + "regionTag": "language_v1beta2_generated_LanguageService_AnnotateText_async", + "title": "LanguageService annotateText Sample", + "origin": "API_DEFINITION", + "description": " A convenience method that provides all syntax, sentiment, entity, and classification features in one call.", + "canonical": true, + "file": "language_service.annotate_text.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AnnotateText", + "fullName": "google.cloud.language.v1beta2.LanguageService.AnnotateText", + "async": true, + "parameters": [ + { + "name": "document", + "type": ".google.cloud.language.v1beta2.Document" + }, + { + "name": "features", + "type": ".google.cloud.language.v1beta2.AnnotateTextRequest.Features" + }, + { + "name": "encoding_type", + "type": ".google.cloud.language.v1beta2.EncodingType" + } + ], + "resultType": ".google.cloud.language.v1beta2.AnnotateTextResponse", + "client": { + "shortName": "LanguageServiceClient", + "fullName": "google.cloud.language.v1beta2.LanguageServiceClient" + }, + "method": { + "shortName": "AnnotateText", + "fullName": "google.cloud.language.v1beta2.LanguageService.AnnotateText", + "service": { + "shortName": "LanguageService", + "fullName": "google.cloud.language.v1beta2.LanguageService" + } + } + } + } + ] +} diff --git a/owl-bot-staging/v1beta2/src/index.ts b/owl-bot-staging/v1beta2/src/index.ts new file mode 100644 index 00000000..6905ecd4 --- /dev/null +++ b/owl-bot-staging/v1beta2/src/index.ts @@ -0,0 +1,25 @@ +// 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 v1beta2 from './v1beta2'; +const LanguageServiceClient = v1beta2.LanguageServiceClient; +type LanguageServiceClient = v1beta2.LanguageServiceClient; +export {v1beta2, LanguageServiceClient}; +export default {v1beta2, LanguageServiceClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/v1beta2/src/v1beta2/gapic_metadata.json b/owl-bot-staging/v1beta2/src/v1beta2/gapic_metadata.json new file mode 100644 index 00000000..cc37c24c --- /dev/null +++ b/owl-bot-staging/v1beta2/src/v1beta2/gapic_metadata.json @@ -0,0 +1,83 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.language.v1beta2", + "libraryPackage": "@google-cloud/language", + "services": { + "LanguageService": { + "clients": { + "grpc": { + "libraryClient": "LanguageServiceClient", + "rpcs": { + "AnalyzeSentiment": { + "methods": [ + "analyzeSentiment" + ] + }, + "AnalyzeEntities": { + "methods": [ + "analyzeEntities" + ] + }, + "AnalyzeEntitySentiment": { + "methods": [ + "analyzeEntitySentiment" + ] + }, + "AnalyzeSyntax": { + "methods": [ + "analyzeSyntax" + ] + }, + "ClassifyText": { + "methods": [ + "classifyText" + ] + }, + "AnnotateText": { + "methods": [ + "annotateText" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "LanguageServiceClient", + "rpcs": { + "AnalyzeSentiment": { + "methods": [ + "analyzeSentiment" + ] + }, + "AnalyzeEntities": { + "methods": [ + "analyzeEntities" + ] + }, + "AnalyzeEntitySentiment": { + "methods": [ + "analyzeEntitySentiment" + ] + }, + "AnalyzeSyntax": { + "methods": [ + "analyzeSyntax" + ] + }, + "ClassifyText": { + "methods": [ + "classifyText" + ] + }, + "AnnotateText": { + "methods": [ + "annotateText" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v1beta2/src/v1beta2/index.ts b/owl-bot-staging/v1beta2/src/v1beta2/index.ts new file mode 100644 index 00000000..7e077a20 --- /dev/null +++ b/owl-bot-staging/v1beta2/src/v1beta2/index.ts @@ -0,0 +1,19 @@ +// 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 {LanguageServiceClient} from './language_service_client'; diff --git a/owl-bot-staging/v1beta2/src/v1beta2/language_service_client.ts b/owl-bot-staging/v1beta2/src/v1beta2/language_service_client.ts new file mode 100644 index 00000000..7f72e5ef --- /dev/null +++ b/owl-bot-staging/v1beta2/src/v1beta2/language_service_client.ts @@ -0,0 +1,709 @@ +// 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 * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1beta2/language_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './language_service_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * Provides text analysis operations such as sentiment analysis and entity + * recognition. + * @class + * @memberof v1beta2 + */ +export class LanguageServiceClient { + 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}; + languageServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of LanguageServiceClient. + * + * @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}. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof LanguageServiceClient; + 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; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth 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); + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.language.v1beta2.LanguageService', 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 = gax.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.languageServiceStub) { + return this.languageServiceStub; + } + + // Put together the "service stub" for + // google.cloud.language.v1beta2.LanguageService. + this.languageServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.language.v1beta2.LanguageService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.language.v1beta2.LanguageService, + 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 languageServiceStubMethods = + ['analyzeSentiment', 'analyzeEntities', 'analyzeEntitySentiment', 'analyzeSyntax', 'classifyText', 'annotateText']; + for (const methodName of languageServiceStubMethods) { + const callPromise = this.languageServiceStub.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 = + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.languageServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'language.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 'language.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-language', + '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 -- + // ------------------- +/** + * 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): + Promise<[ + protos.google.cloud.language.v1beta2.IAnalyzeSentimentResponse, + protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest|undefined, {}|undefined + ]>; + analyzeSentiment( + request: protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.language.v1beta2.IAnalyzeSentimentResponse, + protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest|null|undefined, + {}|null|undefined>): void; + analyzeSentiment( + request: protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest, + callback: Callback< + protos.google.cloud.language.v1beta2.IAnalyzeSentimentResponse, + protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest|null|undefined, + {}|null|undefined>): void; + analyzeSentiment( + request?: protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.language.v1beta2.IAnalyzeSentimentResponse, + protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.language.v1beta2.IAnalyzeSentimentResponse, + protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.language.v1beta2.IAnalyzeSentimentResponse, + protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest|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.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): + Promise<[ + protos.google.cloud.language.v1beta2.IAnalyzeEntitiesResponse, + protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest|undefined, {}|undefined + ]>; + analyzeEntities( + request: protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.language.v1beta2.IAnalyzeEntitiesResponse, + protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest|null|undefined, + {}|null|undefined>): void; + analyzeEntities( + request: protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest, + callback: Callback< + protos.google.cloud.language.v1beta2.IAnalyzeEntitiesResponse, + protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest|null|undefined, + {}|null|undefined>): void; + analyzeEntities( + request?: protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.language.v1beta2.IAnalyzeEntitiesResponse, + protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.language.v1beta2.IAnalyzeEntitiesResponse, + protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.language.v1beta2.IAnalyzeEntitiesResponse, + protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest|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.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): + Promise<[ + protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentResponse, + protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest|undefined, {}|undefined + ]>; + analyzeEntitySentiment( + request: protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentResponse, + protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest|null|undefined, + {}|null|undefined>): void; + analyzeEntitySentiment( + request: protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest, + callback: Callback< + protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentResponse, + protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest|null|undefined, + {}|null|undefined>): void; + analyzeEntitySentiment( + request?: protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentResponse, + protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentResponse, + protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentResponse, + protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest|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.analyzeEntitySentiment(request, options, 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): + Promise<[ + protos.google.cloud.language.v1beta2.IAnalyzeSyntaxResponse, + protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest|undefined, {}|undefined + ]>; + analyzeSyntax( + request: protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.language.v1beta2.IAnalyzeSyntaxResponse, + protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest|null|undefined, + {}|null|undefined>): void; + analyzeSyntax( + request: protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest, + callback: Callback< + protos.google.cloud.language.v1beta2.IAnalyzeSyntaxResponse, + protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest|null|undefined, + {}|null|undefined>): void; + analyzeSyntax( + request?: protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.language.v1beta2.IAnalyzeSyntaxResponse, + protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.language.v1beta2.IAnalyzeSyntaxResponse, + protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.language.v1beta2.IAnalyzeSyntaxResponse, + protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest|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.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): + Promise<[ + protos.google.cloud.language.v1beta2.IClassifyTextResponse, + protos.google.cloud.language.v1beta2.IClassifyTextRequest|undefined, {}|undefined + ]>; + classifyText( + request: protos.google.cloud.language.v1beta2.IClassifyTextRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.language.v1beta2.IClassifyTextResponse, + protos.google.cloud.language.v1beta2.IClassifyTextRequest|null|undefined, + {}|null|undefined>): void; + classifyText( + request: protos.google.cloud.language.v1beta2.IClassifyTextRequest, + callback: Callback< + protos.google.cloud.language.v1beta2.IClassifyTextResponse, + protos.google.cloud.language.v1beta2.IClassifyTextRequest|null|undefined, + {}|null|undefined>): void; + classifyText( + request?: protos.google.cloud.language.v1beta2.IClassifyTextRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.language.v1beta2.IClassifyTextResponse, + protos.google.cloud.language.v1beta2.IClassifyTextRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.language.v1beta2.IClassifyTextResponse, + protos.google.cloud.language.v1beta2.IClassifyTextRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.language.v1beta2.IClassifyTextResponse, + protos.google.cloud.language.v1beta2.IClassifyTextRequest|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.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): + Promise<[ + protos.google.cloud.language.v1beta2.IAnnotateTextResponse, + protos.google.cloud.language.v1beta2.IAnnotateTextRequest|undefined, {}|undefined + ]>; + annotateText( + request: protos.google.cloud.language.v1beta2.IAnnotateTextRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.language.v1beta2.IAnnotateTextResponse, + protos.google.cloud.language.v1beta2.IAnnotateTextRequest|null|undefined, + {}|null|undefined>): void; + annotateText( + request: protos.google.cloud.language.v1beta2.IAnnotateTextRequest, + callback: Callback< + protos.google.cloud.language.v1beta2.IAnnotateTextResponse, + protos.google.cloud.language.v1beta2.IAnnotateTextRequest|null|undefined, + {}|null|undefined>): void; + annotateText( + request?: protos.google.cloud.language.v1beta2.IAnnotateTextRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.language.v1beta2.IAnnotateTextResponse, + protos.google.cloud.language.v1beta2.IAnnotateTextRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.language.v1beta2.IAnnotateTextResponse, + protos.google.cloud.language.v1beta2.IAnnotateTextRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.language.v1beta2.IAnnotateTextResponse, + protos.google.cloud.language.v1beta2.IAnnotateTextRequest|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.annotateText(request, options, callback); + } + + + /** + * 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.languageServiceStub && !this._terminated) { + return this.languageServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1beta2/src/v1beta2/language_service_client_config.json b/owl-bot-staging/v1beta2/src/v1beta2/language_service_client_config.json new file mode 100644 index 00000000..a2671a61 --- /dev/null +++ b/owl-bot-staging/v1beta2/src/v1beta2/language_service_client_config.json @@ -0,0 +1,56 @@ +{ + "interfaces": { + "google.cloud.language.v1beta2.LanguageService": { + "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": { + "AnalyzeSentiment": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "AnalyzeEntities": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "AnalyzeEntitySentiment": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "AnalyzeSyntax": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ClassifyText": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "AnnotateText": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1beta2/src/v1beta2/language_service_proto_list.json b/owl-bot-staging/v1beta2/src/v1beta2/language_service_proto_list.json new file mode 100644 index 00000000..d5314f41 --- /dev/null +++ b/owl-bot-staging/v1beta2/src/v1beta2/language_service_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/language/v1beta2/language_service.proto" +] diff --git a/owl-bot-staging/v1beta2/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1beta2/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000..d89f290c --- /dev/null +++ b/owl-bot-staging/v1beta2/system-test/fixtures/sample/src/index.js @@ -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. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const language = require('@google-cloud/language'); + +function main() { + const languageServiceClient = new language.LanguageServiceClient(); +} + +main(); diff --git a/owl-bot-staging/v1beta2/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1beta2/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000..67dcd47c --- /dev/null +++ b/owl-bot-staging/v1beta2/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// 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 {LanguageServiceClient} from '@google-cloud/language'; + +// check that the client class type name can be used +function doStuffWithLanguageServiceClient(client: LanguageServiceClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const languageServiceClient = new LanguageServiceClient(); + doStuffWithLanguageServiceClient(languageServiceClient); +} + +main(); diff --git a/owl-bot-staging/v1beta2/system-test/install.ts b/owl-bot-staging/v1beta2/system-test/install.ts new file mode 100644 index 00000000..8ec45222 --- /dev/null +++ b/owl-bot-staging/v1beta2/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/v1beta2/test/gapic_language_service_v1beta2.ts b/owl-bot-staging/v1beta2/test/gapic_language_service_v1beta2.ts new file mode 100644 index 00000000..9a4cbee5 --- /dev/null +++ b/owl-bot-staging/v1beta2/test/gapic_language_service_v1beta2.ts @@ -0,0 +1,567 @@ +// 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 languageserviceModule from '../src'; + +import {protobuf} from 'google-gax'; + +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); +} + +describe('v1beta2.LanguageServiceClient', () => { + it('has servicePath', () => { + const servicePath = languageserviceModule.v1beta2.LanguageServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = languageserviceModule.v1beta2.LanguageServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = languageserviceModule.v1beta2.LanguageServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.languageServiceStub, undefined); + await client.initialize(); + assert(client.languageServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.languageServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.languageServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + 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 languageserviceModule.v1beta2.LanguageServiceClient({ + 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('analyzeSentiment', () => { + it('invokes analyzeSentiment without error', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeSentimentRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeSentimentResponse()); + client.innerApiCalls.analyzeSentiment = stubSimpleCall(expectedResponse); + const [response] = await client.analyzeSentiment(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.analyzeSentiment as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes analyzeSentiment without error using callback', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeSentimentRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeSentimentResponse()); + client.innerApiCalls.analyzeSentiment = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.analyzeSentiment( + request, + (err?: Error|null, result?: protos.google.cloud.language.v1beta2.IAnalyzeSentimentResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.analyzeSentiment as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes analyzeSentiment with error', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeSentimentRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.analyzeSentiment = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.analyzeSentiment(request), expectedError); + assert((client.innerApiCalls.analyzeSentiment as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes analyzeSentiment with closed client', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeSentimentRequest()); + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.analyzeSentiment(request), expectedError); + }); + }); + + describe('analyzeEntities', () => { + it('invokes analyzeEntities without error', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeEntitiesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeEntitiesResponse()); + client.innerApiCalls.analyzeEntities = stubSimpleCall(expectedResponse); + const [response] = await client.analyzeEntities(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.analyzeEntities as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes analyzeEntities without error using callback', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeEntitiesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeEntitiesResponse()); + client.innerApiCalls.analyzeEntities = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.analyzeEntities( + request, + (err?: Error|null, result?: protos.google.cloud.language.v1beta2.IAnalyzeEntitiesResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.analyzeEntities as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes analyzeEntities with error', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeEntitiesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.analyzeEntities = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.analyzeEntities(request), expectedError); + assert((client.innerApiCalls.analyzeEntities as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes analyzeEntities with closed client', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeEntitiesRequest()); + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.analyzeEntities(request), expectedError); + }); + }); + + describe('analyzeEntitySentiment', () => { + it('invokes analyzeEntitySentiment without error', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeEntitySentimentRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeEntitySentimentResponse()); + client.innerApiCalls.analyzeEntitySentiment = stubSimpleCall(expectedResponse); + const [response] = await client.analyzeEntitySentiment(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.analyzeEntitySentiment as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes analyzeEntitySentiment without error using callback', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeEntitySentimentRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeEntitySentimentResponse()); + client.innerApiCalls.analyzeEntitySentiment = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.analyzeEntitySentiment( + request, + (err?: Error|null, result?: protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.analyzeEntitySentiment as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes analyzeEntitySentiment with error', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeEntitySentimentRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.analyzeEntitySentiment = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.analyzeEntitySentiment(request), expectedError); + assert((client.innerApiCalls.analyzeEntitySentiment as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes analyzeEntitySentiment with closed client', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeEntitySentimentRequest()); + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.analyzeEntitySentiment(request), expectedError); + }); + }); + + describe('analyzeSyntax', () => { + it('invokes analyzeSyntax without error', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeSyntaxRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeSyntaxResponse()); + client.innerApiCalls.analyzeSyntax = stubSimpleCall(expectedResponse); + const [response] = await client.analyzeSyntax(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.analyzeSyntax as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes analyzeSyntax without error using callback', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeSyntaxRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeSyntaxResponse()); + client.innerApiCalls.analyzeSyntax = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.analyzeSyntax( + request, + (err?: Error|null, result?: protos.google.cloud.language.v1beta2.IAnalyzeSyntaxResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.analyzeSyntax as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes analyzeSyntax with error', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeSyntaxRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.analyzeSyntax = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.analyzeSyntax(request), expectedError); + assert((client.innerApiCalls.analyzeSyntax as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes analyzeSyntax with closed client', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeSyntaxRequest()); + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.analyzeSyntax(request), expectedError); + }); + }); + + describe('classifyText', () => { + it('invokes classifyText without error', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.ClassifyTextRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1beta2.ClassifyTextResponse()); + client.innerApiCalls.classifyText = stubSimpleCall(expectedResponse); + const [response] = await client.classifyText(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.classifyText as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes classifyText without error using callback', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.ClassifyTextRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1beta2.ClassifyTextResponse()); + client.innerApiCalls.classifyText = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.classifyText( + request, + (err?: Error|null, result?: protos.google.cloud.language.v1beta2.IClassifyTextResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.classifyText as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes classifyText with error', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.ClassifyTextRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.classifyText = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.classifyText(request), expectedError); + assert((client.innerApiCalls.classifyText as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes classifyText with closed client', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.ClassifyTextRequest()); + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.classifyText(request), expectedError); + }); + }); + + describe('annotateText', () => { + it('invokes annotateText without error', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnnotateTextRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnnotateTextResponse()); + client.innerApiCalls.annotateText = stubSimpleCall(expectedResponse); + const [response] = await client.annotateText(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.annotateText as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes annotateText without error using callback', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnnotateTextRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnnotateTextResponse()); + client.innerApiCalls.annotateText = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.annotateText( + request, + (err?: Error|null, result?: protos.google.cloud.language.v1beta2.IAnnotateTextResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.annotateText as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes annotateText with error', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnnotateTextRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.annotateText = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.annotateText(request), expectedError); + assert((client.innerApiCalls.annotateText as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes annotateText with closed client', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnnotateTextRequest()); + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.annotateText(request), expectedError); + }); + }); +}); diff --git a/owl-bot-staging/v1beta2/tsconfig.json b/owl-bot-staging/v1beta2/tsconfig.json new file mode 100644 index 00000000..c78f1c88 --- /dev/null +++ b/owl-bot-staging/v1beta2/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/v1beta2/webpack.config.js b/owl-bot-staging/v1beta2/webpack.config.js new file mode 100644 index 00000000..c90df106 --- /dev/null +++ b/owl-bot-staging/v1beta2/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: 'LanguageService', + filename: './language-service.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 65dd56ee1d49ae144fcd0302720978a11fe58bc5 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Fri, 24 Jun 2022 10:24:44 +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 | 64 - .../cloud/language/v1/language_service.proto | 1122 ---------------- .../v1/language_service.analyze_entities.js | 62 - ...nguage_service.analyze_entity_sentiment.js | 62 - .../v1/language_service.analyze_sentiment.js | 62 - .../v1/language_service.analyze_syntax.js | 62 - .../v1/language_service.annotate_text.js | 67 - .../v1/language_service.classify_text.js | 58 - ...pet_metadata.google.cloud.language.v1.json | 279 ---- owl-bot-staging/v1/src/index.ts | 25 - owl-bot-staging/v1/src/v1/gapic_metadata.json | 83 -- owl-bot-staging/v1/src/v1/index.ts | 19 - .../v1/src/v1/language_service_client.ts | 708 ---------- .../v1/language_service_client_config.json | 56 - .../src/v1/language_service_proto_list.json | 3 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - owl-bot-staging/v1/system-test/install.ts | 49 - .../v1/test/gapic_language_service_v1.ts | 567 --------- owl-bot-staging/v1/tsconfig.json | 19 - owl-bot-staging/v1/webpack.config.js | 64 - owl-bot-staging/v1beta2/.eslintignore | 7 - owl-bot-staging/v1beta2/.eslintrc.json | 3 - owl-bot-staging/v1beta2/.gitignore | 14 - owl-bot-staging/v1beta2/.jsdoc.js | 55 - owl-bot-staging/v1beta2/.mocharc.js | 33 - owl-bot-staging/v1beta2/.prettierrc.js | 22 - owl-bot-staging/v1beta2/README.md | 1 - .../v1beta2/linkinator.config.json | 16 - owl-bot-staging/v1beta2/package.json | 64 - .../language/v1beta2/language_service.proto | 1134 ----------------- .../language_service.analyze_entities.js | 62 - ...nguage_service.analyze_entity_sentiment.js | 62 - .../language_service.analyze_sentiment.js | 63 - .../language_service.analyze_syntax.js | 62 - .../v1beta2/language_service.annotate_text.js | 67 - .../v1beta2/language_service.classify_text.js | 58 - ...etadata.google.cloud.language.v1beta2.json | 279 ---- owl-bot-staging/v1beta2/src/index.ts | 25 - .../v1beta2/src/v1beta2/gapic_metadata.json | 83 -- owl-bot-staging/v1beta2/src/v1beta2/index.ts | 19 - .../src/v1beta2/language_service_client.ts | 709 ----------- .../language_service_client_config.json | 56 - .../v1beta2/language_service_proto_list.json | 3 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - .../v1beta2/system-test/install.ts | 49 - .../test/gapic_language_service_v1beta2.ts | 567 --------- owl-bot-staging/v1beta2/tsconfig.json | 19 - owl-bot-staging/v1beta2/webpack.config.js | 64 - src/v1/language_service_client.ts | 11 +- src/v1beta2/language_service_client.ts | 11 +- 60 files changed, 10 insertions(+), 7308 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/language/v1/language_service.proto delete mode 100644 owl-bot-staging/v1/samples/generated/v1/language_service.analyze_entities.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/language_service.analyze_entity_sentiment.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/language_service.analyze_sentiment.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/language_service.analyze_syntax.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/language_service.annotate_text.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/language_service.classify_text.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.language.v1.json delete mode 100644 owl-bot-staging/v1/src/index.ts 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/language_service_client.ts delete mode 100644 owl-bot-staging/v1/src/v1/language_service_client_config.json delete mode 100644 owl-bot-staging/v1/src/v1/language_service_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_language_service_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/v1beta2/.eslintignore delete mode 100644 owl-bot-staging/v1beta2/.eslintrc.json delete mode 100644 owl-bot-staging/v1beta2/.gitignore delete mode 100644 owl-bot-staging/v1beta2/.jsdoc.js delete mode 100644 owl-bot-staging/v1beta2/.mocharc.js delete mode 100644 owl-bot-staging/v1beta2/.prettierrc.js delete mode 100644 owl-bot-staging/v1beta2/README.md delete mode 100644 owl-bot-staging/v1beta2/linkinator.config.json delete mode 100644 owl-bot-staging/v1beta2/package.json delete mode 100644 owl-bot-staging/v1beta2/protos/google/cloud/language/v1beta2/language_service.proto delete mode 100644 owl-bot-staging/v1beta2/samples/generated/v1beta2/language_service.analyze_entities.js delete mode 100644 owl-bot-staging/v1beta2/samples/generated/v1beta2/language_service.analyze_entity_sentiment.js delete mode 100644 owl-bot-staging/v1beta2/samples/generated/v1beta2/language_service.analyze_sentiment.js delete mode 100644 owl-bot-staging/v1beta2/samples/generated/v1beta2/language_service.analyze_syntax.js delete mode 100644 owl-bot-staging/v1beta2/samples/generated/v1beta2/language_service.annotate_text.js delete mode 100644 owl-bot-staging/v1beta2/samples/generated/v1beta2/language_service.classify_text.js delete mode 100644 owl-bot-staging/v1beta2/samples/generated/v1beta2/snippet_metadata.google.cloud.language.v1beta2.json delete mode 100644 owl-bot-staging/v1beta2/src/index.ts delete mode 100644 owl-bot-staging/v1beta2/src/v1beta2/gapic_metadata.json delete mode 100644 owl-bot-staging/v1beta2/src/v1beta2/index.ts delete mode 100644 owl-bot-staging/v1beta2/src/v1beta2/language_service_client.ts delete mode 100644 owl-bot-staging/v1beta2/src/v1beta2/language_service_client_config.json delete mode 100644 owl-bot-staging/v1beta2/src/v1beta2/language_service_proto_list.json delete mode 100644 owl-bot-staging/v1beta2/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/v1beta2/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/v1beta2/system-test/install.ts delete mode 100644 owl-bot-staging/v1beta2/test/gapic_language_service_v1beta2.ts delete mode 100644 owl-bot-staging/v1beta2/tsconfig.json delete mode 100644 owl-bot-staging/v1beta2/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 79611132..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/language', - 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 7287da54..00000000 --- a/owl-bot-staging/v1/README.md +++ /dev/null @@ -1 +0,0 @@ -Language: 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 1b45ee6a..00000000 --- a/owl-bot-staging/v1/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "@google-cloud/language", - "version": "0.1.0", - "description": "Language client for Node.js", - "repository": "googleapis/nodejs-language", - "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 language", - "language", - "language service" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/", - "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.1.1" - }, - "devDependencies": { - "@types/mocha": "^9.1.0", - "@types/node": "^16.0.0", - "@types/sinon": "^10.0.8", - "c8": "^7.11.0", - "gts": "^3.1.0", - "jsdoc": "^3.6.7", - "jsdoc-fresh": "^1.1.1", - "jsdoc-region-tag": "^1.3.1", - "linkinator": "^3.0.0", - "mocha": "^9.1.4", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^13.0.0", - "ts-loader": "^9.2.6", - "typescript": "^4.5.5", - "webpack": "^5.67.0", - "webpack-cli": "^4.9.1" - }, - "engines": { - "node": ">=v12" - } -} diff --git a/owl-bot-staging/v1/protos/google/cloud/language/v1/language_service.proto b/owl-bot-staging/v1/protos/google/cloud/language/v1/language_service.proto deleted file mode 100644 index 304eab07..00000000 --- a/owl-bot-staging/v1/protos/google/cloud/language/v1/language_service.proto +++ /dev/null @@ -1,1122 +0,0 @@ -// Copyright 2019 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.language.v1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; - -option go_package = "google.golang.org/genproto/googleapis/cloud/language/v1;language"; -option java_multiple_files = true; -option java_outer_classname = "LanguageServiceProto"; -option java_package = "com.google.cloud.language.v1"; - - -// Provides text analysis operations such as sentiment analysis and entity -// recognition. -service LanguageService { - option (google.api.default_host) = "language.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-language," - "https://www.googleapis.com/auth/cloud-platform"; - // Analyzes the sentiment of the provided text. - rpc AnalyzeSentiment(AnalyzeSentimentRequest) returns (AnalyzeSentimentResponse) { - option (google.api.http) = { - post: "/v1/documents:analyzeSentiment" - body: "*" - }; - option (google.api.method_signature) = "document,encoding_type"; - option (google.api.method_signature) = "document"; - } - - // Finds named entities (currently proper names and common nouns) in the text - // along with entity types, salience, mentions for each entity, and - // other properties. - rpc AnalyzeEntities(AnalyzeEntitiesRequest) returns (AnalyzeEntitiesResponse) { - option (google.api.http) = { - post: "/v1/documents:analyzeEntities" - body: "*" - }; - option (google.api.method_signature) = "document,encoding_type"; - option (google.api.method_signature) = "document"; - } - - // Finds entities, similar to [AnalyzeEntities][google.cloud.language.v1.LanguageService.AnalyzeEntities] in the text and analyzes - // sentiment associated with each entity and its mentions. - rpc AnalyzeEntitySentiment(AnalyzeEntitySentimentRequest) returns (AnalyzeEntitySentimentResponse) { - option (google.api.http) = { - post: "/v1/documents:analyzeEntitySentiment" - body: "*" - }; - option (google.api.method_signature) = "document,encoding_type"; - option (google.api.method_signature) = "document"; - } - - // Analyzes the syntax of the text and provides sentence boundaries and - // tokenization along with part of speech tags, dependency trees, and other - // properties. - rpc AnalyzeSyntax(AnalyzeSyntaxRequest) returns (AnalyzeSyntaxResponse) { - option (google.api.http) = { - post: "/v1/documents:analyzeSyntax" - body: "*" - }; - option (google.api.method_signature) = "document,encoding_type"; - option (google.api.method_signature) = "document"; - } - - // Classifies a document into categories. - rpc ClassifyText(ClassifyTextRequest) returns (ClassifyTextResponse) { - option (google.api.http) = { - post: "/v1/documents:classifyText" - body: "*" - }; - option (google.api.method_signature) = "document"; - } - - // A convenience method that provides all the features that analyzeSentiment, - // analyzeEntities, and analyzeSyntax provide in one call. - rpc AnnotateText(AnnotateTextRequest) returns (AnnotateTextResponse) { - option (google.api.http) = { - post: "/v1/documents:annotateText" - body: "*" - }; - option (google.api.method_signature) = "document,features,encoding_type"; - option (google.api.method_signature) = "document,features"; - } -} - - -// -// Represents the input to API methods. -message Document { - // The document types enum. - enum Type { - // The content type is not specified. - TYPE_UNSPECIFIED = 0; - - // Plain text - PLAIN_TEXT = 1; - - // HTML - HTML = 2; - } - - // Required. If the type is not set or is `TYPE_UNSPECIFIED`, - // returns an `INVALID_ARGUMENT` error. - Type type = 1; - - // The source of the document: a string containing the content or a - // Google Cloud Storage URI. - oneof source { - // The content of the input in string format. - // Cloud audit logging exempt since it is based on user data. - string content = 2; - - // The Google Cloud Storage URI where the file content is located. - // This URI must be of the form: gs://bucket_name/object_name. For more - // details, see https://cloud.google.com/storage/docs/reference-uris. - // NOTE: Cloud Storage object versioning is not supported. - string gcs_content_uri = 3; - } - - // The language of the document (if not specified, the language is - // automatically detected). Both ISO and BCP-47 language codes are - // accepted.
- // [Language - // Support](https://cloud.google.com/natural-language/docs/languages) lists - // currently supported languages for each API method. If the language (either - // specified by the caller or automatically detected) is not supported by the - // called API method, an `INVALID_ARGUMENT` error is returned. - string language = 4; -} - -// Represents a sentence in the input document. -message Sentence { - // The sentence text. - TextSpan text = 1; - - // For calls to [AnalyzeSentiment][] or if - // [AnnotateTextRequest.Features.extract_document_sentiment][google.cloud.language.v1.AnnotateTextRequest.Features.extract_document_sentiment] is set to - // true, this field will contain the sentiment for the sentence. - Sentiment sentiment = 2; -} - -// Represents a phrase in the text that is a known entity, such as -// a person, an organization, or location. The API associates information, such -// as salience and mentions, with entities. -message Entity { - // The type of the entity. For most entity types, the associated metadata is a - // Wikipedia URL (`wikipedia_url`) and Knowledge Graph MID (`mid`). The table - // below lists the associated fields for entities that have different - // metadata. - enum Type { - // Unknown - UNKNOWN = 0; - - // Person - PERSON = 1; - - // Location - LOCATION = 2; - - // Organization - ORGANIZATION = 3; - - // Event - EVENT = 4; - - // Artwork - WORK_OF_ART = 5; - - // Consumer product - CONSUMER_GOOD = 6; - - // Other types of entities - OTHER = 7; - - // Phone number

- // The metadata lists the phone number, formatted according to local - // convention, plus whichever additional elements appear in the text:
    - //
  • number – the actual number, broken down into - // sections as per local convention
  • national_prefix - // – country code, if detected
  • area_code – - // region or area code, if detected
  • extension – - // phone extension (to be dialed after connection), if detected
- PHONE_NUMBER = 9; - - // Address

- // The metadata identifies the street number and locality plus whichever - // additional elements appear in the text:
    - //
  • street_number – street number
  • - //
  • locality – city or town
  • - //
  • street_name – street/route name, if detected
  • - //
  • postal_code – postal code, if detected
  • - //
  • country – country, if detected
  • - //
  • broad_region – administrative area, such as the - // state, if detected
  • narrow_region – smaller - // administrative area, such as county, if detected
  • - //
  • sublocality – used in Asian addresses to demark a - // district within a city, if detected
- ADDRESS = 10; - - // Date

- // The metadata identifies the components of the date:
    - //
  • year – four digit year, if detected
  • - //
  • month – two digit month number, if detected
  • - //
  • day – two digit day number, if detected
- DATE = 11; - - // Number

- // The metadata is the number itself. - NUMBER = 12; - - // Price

- // The metadata identifies the value and currency. - PRICE = 13; - } - - // The representative name for the entity. - string name = 1; - - // The entity type. - Type type = 2; - - // Metadata associated with the entity. - // - // For most entity types, the metadata is a Wikipedia URL (`wikipedia_url`) - // and Knowledge Graph MID (`mid`), if they are available. For the metadata - // associated with other entity types, see the Type table below. - map metadata = 3; - - // The salience score associated with the entity in the [0, 1.0] range. - // - // The salience score for an entity provides information about the - // importance or centrality of that entity to the entire document text. - // Scores closer to 0 are less salient, while scores closer to 1.0 are highly - // salient. - float salience = 4; - - // The mentions of this entity in the input document. The API currently - // supports proper noun mentions. - repeated EntityMention mentions = 5; - - // For calls to [AnalyzeEntitySentiment][] or if - // [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v1.AnnotateTextRequest.Features.extract_entity_sentiment] is set to - // true, this field will contain the aggregate sentiment expressed for this - // entity in the provided document. - Sentiment sentiment = 6; -} - -// Represents the text encoding that the caller uses to process the output. -// Providing an `EncodingType` is recommended because the API provides the -// beginning offsets for various outputs, such as tokens and mentions, and -// languages that natively use different text encodings may access offsets -// differently. -enum EncodingType { - // If `EncodingType` is not specified, encoding-dependent information (such as - // `begin_offset`) will be set at `-1`. - NONE = 0; - - // Encoding-dependent information (such as `begin_offset`) is calculated based - // on the UTF-8 encoding of the input. C++ and Go are examples of languages - // that use this encoding natively. - UTF8 = 1; - - // Encoding-dependent information (such as `begin_offset`) is calculated based - // on the UTF-16 encoding of the input. Java and JavaScript are examples of - // languages that use this encoding natively. - UTF16 = 2; - - // Encoding-dependent information (such as `begin_offset`) is calculated based - // on the UTF-32 encoding of the input. Python is an example of a language - // that uses this encoding natively. - UTF32 = 3; -} - -// Represents the smallest syntactic building block of the text. -message Token { - // The token text. - TextSpan text = 1; - - // Parts of speech tag for this token. - PartOfSpeech part_of_speech = 2; - - // Dependency tree parse for this token. - DependencyEdge dependency_edge = 3; - - // [Lemma](https://en.wikipedia.org/wiki/Lemma_%28morphology%29) of the token. - string lemma = 4; -} - -// Represents the feeling associated with the entire text or entities in -// the text. -message Sentiment { - // A non-negative number in the [0, +inf) range, which represents - // the absolute magnitude of sentiment regardless of score (positive or - // negative). - float magnitude = 2; - - // Sentiment score between -1.0 (negative sentiment) and 1.0 - // (positive sentiment). - float score = 3; -} - -// Represents part of speech information for a token. Parts of speech -// are as defined in -// http://www.lrec-conf.org/proceedings/lrec2012/pdf/274_Paper.pdf -message PartOfSpeech { - // The part of speech tags enum. - enum Tag { - // Unknown - UNKNOWN = 0; - - // Adjective - ADJ = 1; - - // Adposition (preposition and postposition) - ADP = 2; - - // Adverb - ADV = 3; - - // Conjunction - CONJ = 4; - - // Determiner - DET = 5; - - // Noun (common and proper) - NOUN = 6; - - // Cardinal number - NUM = 7; - - // Pronoun - PRON = 8; - - // Particle or other function word - PRT = 9; - - // Punctuation - PUNCT = 10; - - // Verb (all tenses and modes) - VERB = 11; - - // Other: foreign words, typos, abbreviations - X = 12; - - // Affix - AFFIX = 13; - } - - // The characteristic of a verb that expresses time flow during an event. - enum Aspect { - // Aspect is not applicable in the analyzed language or is not predicted. - ASPECT_UNKNOWN = 0; - - // Perfective - PERFECTIVE = 1; - - // Imperfective - IMPERFECTIVE = 2; - - // Progressive - PROGRESSIVE = 3; - } - - // The grammatical function performed by a noun or pronoun in a phrase, - // clause, or sentence. In some languages, other parts of speech, such as - // adjective and determiner, take case inflection in agreement with the noun. - enum Case { - // Case is not applicable in the analyzed language or is not predicted. - CASE_UNKNOWN = 0; - - // Accusative - ACCUSATIVE = 1; - - // Adverbial - ADVERBIAL = 2; - - // Complementive - COMPLEMENTIVE = 3; - - // Dative - DATIVE = 4; - - // Genitive - GENITIVE = 5; - - // Instrumental - INSTRUMENTAL = 6; - - // Locative - LOCATIVE = 7; - - // Nominative - NOMINATIVE = 8; - - // Oblique - OBLIQUE = 9; - - // Partitive - PARTITIVE = 10; - - // Prepositional - PREPOSITIONAL = 11; - - // Reflexive - REFLEXIVE_CASE = 12; - - // Relative - RELATIVE_CASE = 13; - - // Vocative - VOCATIVE = 14; - } - - // Depending on the language, Form can be categorizing different forms of - // verbs, adjectives, adverbs, etc. For example, categorizing inflected - // endings of verbs and adjectives or distinguishing between short and long - // forms of adjectives and participles - enum Form { - // Form is not applicable in the analyzed language or is not predicted. - FORM_UNKNOWN = 0; - - // Adnomial - ADNOMIAL = 1; - - // Auxiliary - AUXILIARY = 2; - - // Complementizer - COMPLEMENTIZER = 3; - - // Final ending - FINAL_ENDING = 4; - - // Gerund - GERUND = 5; - - // Realis - REALIS = 6; - - // Irrealis - IRREALIS = 7; - - // Short form - SHORT = 8; - - // Long form - LONG = 9; - - // Order form - ORDER = 10; - - // Specific form - SPECIFIC = 11; - } - - // Gender classes of nouns reflected in the behaviour of associated words. - enum Gender { - // Gender is not applicable in the analyzed language or is not predicted. - GENDER_UNKNOWN = 0; - - // Feminine - FEMININE = 1; - - // Masculine - MASCULINE = 2; - - // Neuter - NEUTER = 3; - } - - // The grammatical feature of verbs, used for showing modality and attitude. - enum Mood { - // Mood is not applicable in the analyzed language or is not predicted. - MOOD_UNKNOWN = 0; - - // Conditional - CONDITIONAL_MOOD = 1; - - // Imperative - IMPERATIVE = 2; - - // Indicative - INDICATIVE = 3; - - // Interrogative - INTERROGATIVE = 4; - - // Jussive - JUSSIVE = 5; - - // Subjunctive - SUBJUNCTIVE = 6; - } - - // Count distinctions. - enum Number { - // Number is not applicable in the analyzed language or is not predicted. - NUMBER_UNKNOWN = 0; - - // Singular - SINGULAR = 1; - - // Plural - PLURAL = 2; - - // Dual - DUAL = 3; - } - - // The distinction between the speaker, second person, third person, etc. - enum Person { - // Person is not applicable in the analyzed language or is not predicted. - PERSON_UNKNOWN = 0; - - // First - FIRST = 1; - - // Second - SECOND = 2; - - // Third - THIRD = 3; - - // Reflexive - REFLEXIVE_PERSON = 4; - } - - // This category shows if the token is part of a proper name. - enum Proper { - // Proper is not applicable in the analyzed language or is not predicted. - PROPER_UNKNOWN = 0; - - // Proper - PROPER = 1; - - // Not proper - NOT_PROPER = 2; - } - - // Reciprocal features of a pronoun. - enum Reciprocity { - // Reciprocity is not applicable in the analyzed language or is not - // predicted. - RECIPROCITY_UNKNOWN = 0; - - // Reciprocal - RECIPROCAL = 1; - - // Non-reciprocal - NON_RECIPROCAL = 2; - } - - // Time reference. - enum Tense { - // Tense is not applicable in the analyzed language or is not predicted. - TENSE_UNKNOWN = 0; - - // Conditional - CONDITIONAL_TENSE = 1; - - // Future - FUTURE = 2; - - // Past - PAST = 3; - - // Present - PRESENT = 4; - - // Imperfect - IMPERFECT = 5; - - // Pluperfect - PLUPERFECT = 6; - } - - // The relationship between the action that a verb expresses and the - // participants identified by its arguments. - enum Voice { - // Voice is not applicable in the analyzed language or is not predicted. - VOICE_UNKNOWN = 0; - - // Active - ACTIVE = 1; - - // Causative - CAUSATIVE = 2; - - // Passive - PASSIVE = 3; - } - - // The part of speech tag. - Tag tag = 1; - - // The grammatical aspect. - Aspect aspect = 2; - - // The grammatical case. - Case case = 3; - - // The grammatical form. - Form form = 4; - - // The grammatical gender. - Gender gender = 5; - - // The grammatical mood. - Mood mood = 6; - - // The grammatical number. - Number number = 7; - - // The grammatical person. - Person person = 8; - - // The grammatical properness. - Proper proper = 9; - - // The grammatical reciprocity. - Reciprocity reciprocity = 10; - - // The grammatical tense. - Tense tense = 11; - - // The grammatical voice. - Voice voice = 12; -} - -// Represents dependency parse tree information for a token. (For more -// information on dependency labels, see -// http://www.aclweb.org/anthology/P13-2017 -message DependencyEdge { - // The parse label enum for the token. - enum Label { - // Unknown - UNKNOWN = 0; - - // Abbreviation modifier - ABBREV = 1; - - // Adjectival complement - ACOMP = 2; - - // Adverbial clause modifier - ADVCL = 3; - - // Adverbial modifier - ADVMOD = 4; - - // Adjectival modifier of an NP - AMOD = 5; - - // Appositional modifier of an NP - APPOS = 6; - - // Attribute dependent of a copular verb - ATTR = 7; - - // Auxiliary (non-main) verb - AUX = 8; - - // Passive auxiliary - AUXPASS = 9; - - // Coordinating conjunction - CC = 10; - - // Clausal complement of a verb or adjective - CCOMP = 11; - - // Conjunct - CONJ = 12; - - // Clausal subject - CSUBJ = 13; - - // Clausal passive subject - CSUBJPASS = 14; - - // Dependency (unable to determine) - DEP = 15; - - // Determiner - DET = 16; - - // Discourse - DISCOURSE = 17; - - // Direct object - DOBJ = 18; - - // Expletive - EXPL = 19; - - // Goes with (part of a word in a text not well edited) - GOESWITH = 20; - - // Indirect object - IOBJ = 21; - - // Marker (word introducing a subordinate clause) - MARK = 22; - - // Multi-word expression - MWE = 23; - - // Multi-word verbal expression - MWV = 24; - - // Negation modifier - NEG = 25; - - // Noun compound modifier - NN = 26; - - // Noun phrase used as an adverbial modifier - NPADVMOD = 27; - - // Nominal subject - NSUBJ = 28; - - // Passive nominal subject - NSUBJPASS = 29; - - // Numeric modifier of a noun - NUM = 30; - - // Element of compound number - NUMBER = 31; - - // Punctuation mark - P = 32; - - // Parataxis relation - PARATAXIS = 33; - - // Participial modifier - PARTMOD = 34; - - // The complement of a preposition is a clause - PCOMP = 35; - - // Object of a preposition - POBJ = 36; - - // Possession modifier - POSS = 37; - - // Postverbal negative particle - POSTNEG = 38; - - // Predicate complement - PRECOMP = 39; - - // Preconjunt - PRECONJ = 40; - - // Predeterminer - PREDET = 41; - - // Prefix - PREF = 42; - - // Prepositional modifier - PREP = 43; - - // The relationship between a verb and verbal morpheme - PRONL = 44; - - // Particle - PRT = 45; - - // Associative or possessive marker - PS = 46; - - // Quantifier phrase modifier - QUANTMOD = 47; - - // Relative clause modifier - RCMOD = 48; - - // Complementizer in relative clause - RCMODREL = 49; - - // Ellipsis without a preceding predicate - RDROP = 50; - - // Referent - REF = 51; - - // Remnant - REMNANT = 52; - - // Reparandum - REPARANDUM = 53; - - // Root - ROOT = 54; - - // Suffix specifying a unit of number - SNUM = 55; - - // Suffix - SUFF = 56; - - // Temporal modifier - TMOD = 57; - - // Topic marker - TOPIC = 58; - - // Clause headed by an infinite form of the verb that modifies a noun - VMOD = 59; - - // Vocative - VOCATIVE = 60; - - // Open clausal complement - XCOMP = 61; - - // Name suffix - SUFFIX = 62; - - // Name title - TITLE = 63; - - // Adverbial phrase modifier - ADVPHMOD = 64; - - // Causative auxiliary - AUXCAUS = 65; - - // Helper auxiliary - AUXVV = 66; - - // Rentaishi (Prenominal modifier) - DTMOD = 67; - - // Foreign words - FOREIGN = 68; - - // Keyword - KW = 69; - - // List for chains of comparable items - LIST = 70; - - // Nominalized clause - NOMC = 71; - - // Nominalized clausal subject - NOMCSUBJ = 72; - - // Nominalized clausal passive - NOMCSUBJPASS = 73; - - // Compound of numeric modifier - NUMC = 74; - - // Copula - COP = 75; - - // Dislocated relation (for fronted/topicalized elements) - DISLOCATED = 76; - - // Aspect marker - ASP = 77; - - // Genitive modifier - GMOD = 78; - - // Genitive object - GOBJ = 79; - - // Infinitival modifier - INFMOD = 80; - - // Measure - MES = 81; - - // Nominal complement of a noun - NCOMP = 82; - } - - // Represents the head of this token in the dependency tree. - // This is the index of the token which has an arc going to this token. - // The index is the position of the token in the array of tokens returned - // by the API method. If this token is a root token, then the - // `head_token_index` is its own index. - int32 head_token_index = 1; - - // The parse label for the token. - Label label = 2; -} - -// Represents a mention for an entity in the text. Currently, proper noun -// mentions are supported. -message EntityMention { - // The supported types of mentions. - enum Type { - // Unknown - TYPE_UNKNOWN = 0; - - // Proper name - PROPER = 1; - - // Common noun (or noun compound) - COMMON = 2; - } - - // The mention text. - TextSpan text = 1; - - // The type of the entity mention. - Type type = 2; - - // For calls to [AnalyzeEntitySentiment][] or if - // [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v1.AnnotateTextRequest.Features.extract_entity_sentiment] is set to - // true, this field will contain the sentiment expressed for this mention of - // the entity in the provided document. - Sentiment sentiment = 3; -} - -// Represents an output piece of text. -message TextSpan { - // The content of the output text. - string content = 1; - - // The API calculates the beginning offset of the content in the original - // document according to the [EncodingType][google.cloud.language.v1.EncodingType] specified in the API request. - int32 begin_offset = 2; -} - -// Represents a category returned from the text classifier. -message ClassificationCategory { - // The name of the category representing the document, from the [predefined - // taxonomy](https://cloud.google.com/natural-language/docs/categories). - string name = 1; - - // The classifier's confidence of the category. Number represents how certain - // the classifier is that this category represents the given text. - float confidence = 2; -} - -// The sentiment analysis request message. -message AnalyzeSentimentRequest { - // Input document. - Document document = 1 [(google.api.field_behavior) = REQUIRED]; - - // The encoding type used by the API to calculate sentence offsets. - EncodingType encoding_type = 2; -} - -// The sentiment analysis response message. -message AnalyzeSentimentResponse { - // The overall sentiment of the input document. - Sentiment document_sentiment = 1; - - // The language of the text, which will be the same as the language specified - // in the request or, if not specified, the automatically-detected language. - // See [Document.language][google.cloud.language.v1.Document.language] field for more details. - string language = 2; - - // The sentiment for all the sentences in the document. - repeated Sentence sentences = 3; -} - -// The entity-level sentiment analysis request message. -message AnalyzeEntitySentimentRequest { - // Input document. - Document document = 1 [(google.api.field_behavior) = REQUIRED]; - - // The encoding type used by the API to calculate offsets. - EncodingType encoding_type = 2; -} - -// The entity-level sentiment analysis response message. -message AnalyzeEntitySentimentResponse { - // The recognized entities in the input document with associated sentiments. - repeated Entity entities = 1; - - // The language of the text, which will be the same as the language specified - // in the request or, if not specified, the automatically-detected language. - // See [Document.language][google.cloud.language.v1.Document.language] field for more details. - string language = 2; -} - -// The entity analysis request message. -message AnalyzeEntitiesRequest { - // Input document. - Document document = 1 [(google.api.field_behavior) = REQUIRED]; - - // The encoding type used by the API to calculate offsets. - EncodingType encoding_type = 2; -} - -// The entity analysis response message. -message AnalyzeEntitiesResponse { - // The recognized entities in the input document. - repeated Entity entities = 1; - - // The language of the text, which will be the same as the language specified - // in the request or, if not specified, the automatically-detected language. - // See [Document.language][google.cloud.language.v1.Document.language] field for more details. - string language = 2; -} - -// The syntax analysis request message. -message AnalyzeSyntaxRequest { - // Input document. - Document document = 1 [(google.api.field_behavior) = REQUIRED]; - - // The encoding type used by the API to calculate offsets. - EncodingType encoding_type = 2; -} - -// The syntax analysis response message. -message AnalyzeSyntaxResponse { - // Sentences in the input document. - repeated Sentence sentences = 1; - - // Tokens, along with their syntactic information, in the input document. - repeated Token tokens = 2; - - // The language of the text, which will be the same as the language specified - // in the request or, if not specified, the automatically-detected language. - // See [Document.language][google.cloud.language.v1.Document.language] field for more details. - string language = 3; -} - -// The document classification request message. -message ClassifyTextRequest { - // Input document. - Document document = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// The document classification response message. -message ClassifyTextResponse { - // Categories representing the input document. - repeated ClassificationCategory categories = 1; -} - -// The request message for the text annotation API, which can perform multiple -// analysis types (sentiment, entities, and syntax) in one call. -message AnnotateTextRequest { - // All available features for sentiment, syntax, and semantic analysis. - // Setting each one to true will enable that specific analysis for the input. - message Features { - // Extract syntax information. - bool extract_syntax = 1; - - // Extract entities. - bool extract_entities = 2; - - // Extract document-level sentiment. - bool extract_document_sentiment = 3; - - // Extract entities and their associated sentiment. - bool extract_entity_sentiment = 4; - - // Classify the full document into categories. - bool classify_text = 6; - } - - // Input document. - Document document = 1 [(google.api.field_behavior) = REQUIRED]; - - // The enabled features. - Features features = 2 [(google.api.field_behavior) = REQUIRED]; - - // The encoding type used by the API to calculate offsets. - EncodingType encoding_type = 3; -} - -// The text annotations response message. -message AnnotateTextResponse { - // Sentences in the input document. Populated if the user enables - // [AnnotateTextRequest.Features.extract_syntax][google.cloud.language.v1.AnnotateTextRequest.Features.extract_syntax]. - repeated Sentence sentences = 1; - - // Tokens, along with their syntactic information, in the input document. - // Populated if the user enables - // [AnnotateTextRequest.Features.extract_syntax][google.cloud.language.v1.AnnotateTextRequest.Features.extract_syntax]. - repeated Token tokens = 2; - - // Entities, along with their semantic information, in the input document. - // Populated if the user enables - // [AnnotateTextRequest.Features.extract_entities][google.cloud.language.v1.AnnotateTextRequest.Features.extract_entities]. - repeated Entity entities = 3; - - // The overall sentiment for the document. Populated if the user enables - // [AnnotateTextRequest.Features.extract_document_sentiment][google.cloud.language.v1.AnnotateTextRequest.Features.extract_document_sentiment]. - Sentiment document_sentiment = 4; - - // The language of the text, which will be the same as the language specified - // in the request or, if not specified, the automatically-detected language. - // See [Document.language][google.cloud.language.v1.Document.language] field for more details. - string language = 5; - - // Categories identified in the input document. - repeated ClassificationCategory categories = 6; -} diff --git a/owl-bot-staging/v1/samples/generated/v1/language_service.analyze_entities.js b/owl-bot-staging/v1/samples/generated/v1/language_service.analyze_entities.js deleted file mode 100644 index c51b1483..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/language_service.analyze_entities.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(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/owl-bot-staging/v1/samples/generated/v1/language_service.analyze_entity_sentiment.js b/owl-bot-staging/v1/samples/generated/v1/language_service.analyze_entity_sentiment.js deleted file mode 100644 index 59d03409..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/language_service.analyze_entity_sentiment.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(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/owl-bot-staging/v1/samples/generated/v1/language_service.analyze_sentiment.js b/owl-bot-staging/v1/samples/generated/v1/language_service.analyze_sentiment.js deleted file mode 100644 index e16a69be..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/language_service.analyze_sentiment.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(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/owl-bot-staging/v1/samples/generated/v1/language_service.analyze_syntax.js b/owl-bot-staging/v1/samples/generated/v1/language_service.analyze_syntax.js deleted file mode 100644 index 89bc540e..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/language_service.analyze_syntax.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(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/owl-bot-staging/v1/samples/generated/v1/language_service.annotate_text.js b/owl-bot-staging/v1/samples/generated/v1/language_service.annotate_text.js deleted file mode 100644 index fb978dde..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/language_service.annotate_text.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(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/owl-bot-staging/v1/samples/generated/v1/language_service.classify_text.js b/owl-bot-staging/v1/samples/generated/v1/language_service.classify_text.js deleted file mode 100644 index 81a04f8c..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/language_service.classify_text.js +++ /dev/null @@ -1,58 +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(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/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.language.v1.json b/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.language.v1.json deleted file mode 100644 index 6f66069f..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.language.v1.json +++ /dev/null @@ -1,279 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-language", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.language.v1", - "version": "v1" - } - ] - }, - "snippets": [ - { - "regionTag": "language_v1_generated_LanguageService_AnalyzeSentiment_async", - "title": "LanguageService analyzeSentiment Sample", - "origin": "API_DEFINITION", - "description": " Analyzes the sentiment of the provided text.", - "canonical": true, - "file": "language_service.analyze_sentiment.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AnalyzeSentiment", - "fullName": "google.cloud.language.v1.LanguageService.AnalyzeSentiment", - "async": true, - "parameters": [ - { - "name": "document", - "type": ".google.cloud.language.v1.Document" - }, - { - "name": "encoding_type", - "type": ".google.cloud.language.v1.EncodingType" - } - ], - "resultType": ".google.cloud.language.v1.AnalyzeSentimentResponse", - "client": { - "shortName": "LanguageServiceClient", - "fullName": "google.cloud.language.v1.LanguageServiceClient" - }, - "method": { - "shortName": "AnalyzeSentiment", - "fullName": "google.cloud.language.v1.LanguageService.AnalyzeSentiment", - "service": { - "shortName": "LanguageService", - "fullName": "google.cloud.language.v1.LanguageService" - } - } - } - }, - { - "regionTag": "language_v1_generated_LanguageService_AnalyzeEntities_async", - "title": "LanguageService analyzeEntities Sample", - "origin": "API_DEFINITION", - "description": " Finds named entities (currently proper names and common nouns) in the text along with entity types, salience, mentions for each entity, and other properties.", - "canonical": true, - "file": "language_service.analyze_entities.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AnalyzeEntities", - "fullName": "google.cloud.language.v1.LanguageService.AnalyzeEntities", - "async": true, - "parameters": [ - { - "name": "document", - "type": ".google.cloud.language.v1.Document" - }, - { - "name": "encoding_type", - "type": ".google.cloud.language.v1.EncodingType" - } - ], - "resultType": ".google.cloud.language.v1.AnalyzeEntitiesResponse", - "client": { - "shortName": "LanguageServiceClient", - "fullName": "google.cloud.language.v1.LanguageServiceClient" - }, - "method": { - "shortName": "AnalyzeEntities", - "fullName": "google.cloud.language.v1.LanguageService.AnalyzeEntities", - "service": { - "shortName": "LanguageService", - "fullName": "google.cloud.language.v1.LanguageService" - } - } - } - }, - { - "regionTag": "language_v1_generated_LanguageService_AnalyzeEntitySentiment_async", - "title": "LanguageService analyzeEntitySentiment Sample", - "origin": "API_DEFINITION", - "description": " Finds entities, similar to [AnalyzeEntities][google.cloud.language.v1.LanguageService.AnalyzeEntities] in the text and analyzes sentiment associated with each entity and its mentions.", - "canonical": true, - "file": "language_service.analyze_entity_sentiment.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AnalyzeEntitySentiment", - "fullName": "google.cloud.language.v1.LanguageService.AnalyzeEntitySentiment", - "async": true, - "parameters": [ - { - "name": "document", - "type": ".google.cloud.language.v1.Document" - }, - { - "name": "encoding_type", - "type": ".google.cloud.language.v1.EncodingType" - } - ], - "resultType": ".google.cloud.language.v1.AnalyzeEntitySentimentResponse", - "client": { - "shortName": "LanguageServiceClient", - "fullName": "google.cloud.language.v1.LanguageServiceClient" - }, - "method": { - "shortName": "AnalyzeEntitySentiment", - "fullName": "google.cloud.language.v1.LanguageService.AnalyzeEntitySentiment", - "service": { - "shortName": "LanguageService", - "fullName": "google.cloud.language.v1.LanguageService" - } - } - } - }, - { - "regionTag": "language_v1_generated_LanguageService_AnalyzeSyntax_async", - "title": "LanguageService analyzeSyntax Sample", - "origin": "API_DEFINITION", - "description": " Analyzes the syntax of the text and provides sentence boundaries and tokenization along with part of speech tags, dependency trees, and other properties.", - "canonical": true, - "file": "language_service.analyze_syntax.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AnalyzeSyntax", - "fullName": "google.cloud.language.v1.LanguageService.AnalyzeSyntax", - "async": true, - "parameters": [ - { - "name": "document", - "type": ".google.cloud.language.v1.Document" - }, - { - "name": "encoding_type", - "type": ".google.cloud.language.v1.EncodingType" - } - ], - "resultType": ".google.cloud.language.v1.AnalyzeSyntaxResponse", - "client": { - "shortName": "LanguageServiceClient", - "fullName": "google.cloud.language.v1.LanguageServiceClient" - }, - "method": { - "shortName": "AnalyzeSyntax", - "fullName": "google.cloud.language.v1.LanguageService.AnalyzeSyntax", - "service": { - "shortName": "LanguageService", - "fullName": "google.cloud.language.v1.LanguageService" - } - } - } - }, - { - "regionTag": "language_v1_generated_LanguageService_ClassifyText_async", - "title": "LanguageService classifyText Sample", - "origin": "API_DEFINITION", - "description": " Classifies a document into categories.", - "canonical": true, - "file": "language_service.classify_text.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 50, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ClassifyText", - "fullName": "google.cloud.language.v1.LanguageService.ClassifyText", - "async": true, - "parameters": [ - { - "name": "document", - "type": ".google.cloud.language.v1.Document" - } - ], - "resultType": ".google.cloud.language.v1.ClassifyTextResponse", - "client": { - "shortName": "LanguageServiceClient", - "fullName": "google.cloud.language.v1.LanguageServiceClient" - }, - "method": { - "shortName": "ClassifyText", - "fullName": "google.cloud.language.v1.LanguageService.ClassifyText", - "service": { - "shortName": "LanguageService", - "fullName": "google.cloud.language.v1.LanguageService" - } - } - } - }, - { - "regionTag": "language_v1_generated_LanguageService_AnnotateText_async", - "title": "LanguageService annotateText Sample", - "origin": "API_DEFINITION", - "description": " A convenience method that provides all the features that analyzeSentiment, analyzeEntities, and analyzeSyntax provide in one call.", - "canonical": true, - "file": "language_service.annotate_text.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AnnotateText", - "fullName": "google.cloud.language.v1.LanguageService.AnnotateText", - "async": true, - "parameters": [ - { - "name": "document", - "type": ".google.cloud.language.v1.Document" - }, - { - "name": "features", - "type": ".google.cloud.language.v1.AnnotateTextRequest.Features" - }, - { - "name": "encoding_type", - "type": ".google.cloud.language.v1.EncodingType" - } - ], - "resultType": ".google.cloud.language.v1.AnnotateTextResponse", - "client": { - "shortName": "LanguageServiceClient", - "fullName": "google.cloud.language.v1.LanguageServiceClient" - }, - "method": { - "shortName": "AnnotateText", - "fullName": "google.cloud.language.v1.LanguageService.AnnotateText", - "service": { - "shortName": "LanguageService", - "fullName": "google.cloud.language.v1.LanguageService" - } - } - } - } - ] -} diff --git a/owl-bot-staging/v1/src/index.ts b/owl-bot-staging/v1/src/index.ts deleted file mode 100644 index 25e95ead..00000000 --- a/owl-bot-staging/v1/src/index.ts +++ /dev/null @@ -1,25 +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 LanguageServiceClient = v1.LanguageServiceClient; -type LanguageServiceClient = v1.LanguageServiceClient; -export {v1, LanguageServiceClient}; -export default {v1, LanguageServiceClient}; -import * as protos from '../protos/protos'; -export {protos} 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 fc97e120..00000000 --- a/owl-bot-staging/v1/src/v1/gapic_metadata.json +++ /dev/null @@ -1,83 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.language.v1", - "libraryPackage": "@google-cloud/language", - "services": { - "LanguageService": { - "clients": { - "grpc": { - "libraryClient": "LanguageServiceClient", - "rpcs": { - "AnalyzeSentiment": { - "methods": [ - "analyzeSentiment" - ] - }, - "AnalyzeEntities": { - "methods": [ - "analyzeEntities" - ] - }, - "AnalyzeEntitySentiment": { - "methods": [ - "analyzeEntitySentiment" - ] - }, - "AnalyzeSyntax": { - "methods": [ - "analyzeSyntax" - ] - }, - "ClassifyText": { - "methods": [ - "classifyText" - ] - }, - "AnnotateText": { - "methods": [ - "annotateText" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "LanguageServiceClient", - "rpcs": { - "AnalyzeSentiment": { - "methods": [ - "analyzeSentiment" - ] - }, - "AnalyzeEntities": { - "methods": [ - "analyzeEntities" - ] - }, - "AnalyzeEntitySentiment": { - "methods": [ - "analyzeEntitySentiment" - ] - }, - "AnalyzeSyntax": { - "methods": [ - "analyzeSyntax" - ] - }, - "ClassifyText": { - "methods": [ - "classifyText" - ] - }, - "AnnotateText": { - "methods": [ - "annotateText" - ] - } - } - } - } - } - } -} 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 7e077a20..00000000 --- a/owl-bot-staging/v1/src/v1/index.ts +++ /dev/null @@ -1,19 +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 {LanguageServiceClient} from './language_service_client'; diff --git a/owl-bot-staging/v1/src/v1/language_service_client.ts b/owl-bot-staging/v1/src/v1/language_service_client.ts deleted file mode 100644 index 032639fd..00000000 --- a/owl-bot-staging/v1/src/v1/language_service_client.ts +++ /dev/null @@ -1,708 +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 * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax'; - -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1/language_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './language_service_client_config.json'; - -const version = require('../../../package.json').version; - -/** - * Provides text analysis operations such as sentiment analysis and entity - * recognition. - * @class - * @memberof v1 - */ -export class LanguageServiceClient { - 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}; - languageServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of LanguageServiceClient. - * - * @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}. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof LanguageServiceClient; - 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; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth 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); - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.language.v1.LanguageService', 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 = gax.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.languageServiceStub) { - return this.languageServiceStub; - } - - // Put together the "service stub" for - // google.cloud.language.v1.LanguageService. - this.languageServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.language.v1.LanguageService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.language.v1.LanguageService, - 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 languageServiceStubMethods = - ['analyzeSentiment', 'analyzeEntities', 'analyzeEntitySentiment', 'analyzeSyntax', 'classifyText', 'annotateText']; - for (const methodName of languageServiceStubMethods) { - const callPromise = this.languageServiceStub.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 = - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.languageServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'language.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 'language.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-language', - '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 -- - // ------------------- -/** - * 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): - Promise<[ - protos.google.cloud.language.v1.IAnalyzeSentimentResponse, - protos.google.cloud.language.v1.IAnalyzeSentimentRequest|undefined, {}|undefined - ]>; - analyzeSentiment( - request: protos.google.cloud.language.v1.IAnalyzeSentimentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.language.v1.IAnalyzeSentimentResponse, - protos.google.cloud.language.v1.IAnalyzeSentimentRequest|null|undefined, - {}|null|undefined>): void; - analyzeSentiment( - request: protos.google.cloud.language.v1.IAnalyzeSentimentRequest, - callback: Callback< - protos.google.cloud.language.v1.IAnalyzeSentimentResponse, - protos.google.cloud.language.v1.IAnalyzeSentimentRequest|null|undefined, - {}|null|undefined>): void; - analyzeSentiment( - request?: protos.google.cloud.language.v1.IAnalyzeSentimentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.language.v1.IAnalyzeSentimentResponse, - protos.google.cloud.language.v1.IAnalyzeSentimentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.language.v1.IAnalyzeSentimentResponse, - protos.google.cloud.language.v1.IAnalyzeSentimentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.language.v1.IAnalyzeSentimentResponse, - protos.google.cloud.language.v1.IAnalyzeSentimentRequest|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.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): - Promise<[ - protos.google.cloud.language.v1.IAnalyzeEntitiesResponse, - protos.google.cloud.language.v1.IAnalyzeEntitiesRequest|undefined, {}|undefined - ]>; - analyzeEntities( - request: protos.google.cloud.language.v1.IAnalyzeEntitiesRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.language.v1.IAnalyzeEntitiesResponse, - protos.google.cloud.language.v1.IAnalyzeEntitiesRequest|null|undefined, - {}|null|undefined>): void; - analyzeEntities( - request: protos.google.cloud.language.v1.IAnalyzeEntitiesRequest, - callback: Callback< - protos.google.cloud.language.v1.IAnalyzeEntitiesResponse, - protos.google.cloud.language.v1.IAnalyzeEntitiesRequest|null|undefined, - {}|null|undefined>): void; - analyzeEntities( - request?: protos.google.cloud.language.v1.IAnalyzeEntitiesRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.language.v1.IAnalyzeEntitiesResponse, - protos.google.cloud.language.v1.IAnalyzeEntitiesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.language.v1.IAnalyzeEntitiesResponse, - protos.google.cloud.language.v1.IAnalyzeEntitiesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.language.v1.IAnalyzeEntitiesResponse, - protos.google.cloud.language.v1.IAnalyzeEntitiesRequest|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.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): - Promise<[ - protos.google.cloud.language.v1.IAnalyzeEntitySentimentResponse, - protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest|undefined, {}|undefined - ]>; - analyzeEntitySentiment( - request: protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.language.v1.IAnalyzeEntitySentimentResponse, - protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest|null|undefined, - {}|null|undefined>): void; - analyzeEntitySentiment( - request: protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest, - callback: Callback< - protos.google.cloud.language.v1.IAnalyzeEntitySentimentResponse, - protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest|null|undefined, - {}|null|undefined>): void; - analyzeEntitySentiment( - request?: protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.language.v1.IAnalyzeEntitySentimentResponse, - protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.language.v1.IAnalyzeEntitySentimentResponse, - protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.language.v1.IAnalyzeEntitySentimentResponse, - protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest|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.analyzeEntitySentiment(request, options, 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): - Promise<[ - protos.google.cloud.language.v1.IAnalyzeSyntaxResponse, - protos.google.cloud.language.v1.IAnalyzeSyntaxRequest|undefined, {}|undefined - ]>; - analyzeSyntax( - request: protos.google.cloud.language.v1.IAnalyzeSyntaxRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.language.v1.IAnalyzeSyntaxResponse, - protos.google.cloud.language.v1.IAnalyzeSyntaxRequest|null|undefined, - {}|null|undefined>): void; - analyzeSyntax( - request: protos.google.cloud.language.v1.IAnalyzeSyntaxRequest, - callback: Callback< - protos.google.cloud.language.v1.IAnalyzeSyntaxResponse, - protos.google.cloud.language.v1.IAnalyzeSyntaxRequest|null|undefined, - {}|null|undefined>): void; - analyzeSyntax( - request?: protos.google.cloud.language.v1.IAnalyzeSyntaxRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.language.v1.IAnalyzeSyntaxResponse, - protos.google.cloud.language.v1.IAnalyzeSyntaxRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.language.v1.IAnalyzeSyntaxResponse, - protos.google.cloud.language.v1.IAnalyzeSyntaxRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.language.v1.IAnalyzeSyntaxResponse, - protos.google.cloud.language.v1.IAnalyzeSyntaxRequest|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.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): - Promise<[ - protos.google.cloud.language.v1.IClassifyTextResponse, - protos.google.cloud.language.v1.IClassifyTextRequest|undefined, {}|undefined - ]>; - classifyText( - request: protos.google.cloud.language.v1.IClassifyTextRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.language.v1.IClassifyTextResponse, - protos.google.cloud.language.v1.IClassifyTextRequest|null|undefined, - {}|null|undefined>): void; - classifyText( - request: protos.google.cloud.language.v1.IClassifyTextRequest, - callback: Callback< - protos.google.cloud.language.v1.IClassifyTextResponse, - protos.google.cloud.language.v1.IClassifyTextRequest|null|undefined, - {}|null|undefined>): void; - classifyText( - request?: protos.google.cloud.language.v1.IClassifyTextRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.language.v1.IClassifyTextResponse, - protos.google.cloud.language.v1.IClassifyTextRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.language.v1.IClassifyTextResponse, - protos.google.cloud.language.v1.IClassifyTextRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.language.v1.IClassifyTextResponse, - protos.google.cloud.language.v1.IClassifyTextRequest|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.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): - Promise<[ - protos.google.cloud.language.v1.IAnnotateTextResponse, - protos.google.cloud.language.v1.IAnnotateTextRequest|undefined, {}|undefined - ]>; - annotateText( - request: protos.google.cloud.language.v1.IAnnotateTextRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.language.v1.IAnnotateTextResponse, - protos.google.cloud.language.v1.IAnnotateTextRequest|null|undefined, - {}|null|undefined>): void; - annotateText( - request: protos.google.cloud.language.v1.IAnnotateTextRequest, - callback: Callback< - protos.google.cloud.language.v1.IAnnotateTextResponse, - protos.google.cloud.language.v1.IAnnotateTextRequest|null|undefined, - {}|null|undefined>): void; - annotateText( - request?: protos.google.cloud.language.v1.IAnnotateTextRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.language.v1.IAnnotateTextResponse, - protos.google.cloud.language.v1.IAnnotateTextRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.language.v1.IAnnotateTextResponse, - protos.google.cloud.language.v1.IAnnotateTextRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.language.v1.IAnnotateTextResponse, - protos.google.cloud.language.v1.IAnnotateTextRequest|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.annotateText(request, options, callback); - } - - - /** - * 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.languageServiceStub && !this._terminated) { - return this.languageServiceStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1/src/v1/language_service_client_config.json b/owl-bot-staging/v1/src/v1/language_service_client_config.json deleted file mode 100644 index 4ee37da9..00000000 --- a/owl-bot-staging/v1/src/v1/language_service_client_config.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "interfaces": { - "google.cloud.language.v1.LanguageService": { - "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": { - "AnalyzeSentiment": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "AnalyzeEntities": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "AnalyzeEntitySentiment": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "AnalyzeSyntax": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ClassifyText": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "AnnotateText": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1/src/v1/language_service_proto_list.json b/owl-bot-staging/v1/src/v1/language_service_proto_list.json deleted file mode 100644 index 04560528..00000000 --- a/owl-bot-staging/v1/src/v1/language_service_proto_list.json +++ /dev/null @@ -1,3 +0,0 @@ -[ - "../../protos/google/cloud/language/v1/language_service.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 d89f290c..00000000 --- a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js +++ /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. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const language = require('@google-cloud/language'); - -function main() { - const languageServiceClient = new language.LanguageServiceClient(); -} - -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 67dcd47c..00000000 --- a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +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 {LanguageServiceClient} from '@google-cloud/language'; - -// check that the client class type name can be used -function doStuffWithLanguageServiceClient(client: LanguageServiceClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const languageServiceClient = new LanguageServiceClient(); - doStuffWithLanguageServiceClient(languageServiceClient); -} - -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 8ec45222..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_language_service_v1.ts b/owl-bot-staging/v1/test/gapic_language_service_v1.ts deleted file mode 100644 index 82493bce..00000000 --- a/owl-bot-staging/v1/test/gapic_language_service_v1.ts +++ /dev/null @@ -1,567 +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 languageserviceModule from '../src'; - -import {protobuf} from 'google-gax'; - -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); -} - -describe('v1.LanguageServiceClient', () => { - it('has servicePath', () => { - const servicePath = languageserviceModule.v1.LanguageServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = languageserviceModule.v1.LanguageServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = languageserviceModule.v1.LanguageServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new languageserviceModule.v1.LanguageServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.languageServiceStub, undefined); - await client.initialize(); - assert(client.languageServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.languageServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.languageServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new languageserviceModule.v1.LanguageServiceClient({ - 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 languageserviceModule.v1.LanguageServiceClient({ - 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('analyzeSentiment', () => { - it('invokes analyzeSentiment without error', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeSentimentRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeSentimentResponse()); - client.innerApiCalls.analyzeSentiment = stubSimpleCall(expectedResponse); - const [response] = await client.analyzeSentiment(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.analyzeSentiment as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes analyzeSentiment without error using callback', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeSentimentRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeSentimentResponse()); - client.innerApiCalls.analyzeSentiment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.analyzeSentiment( - request, - (err?: Error|null, result?: protos.google.cloud.language.v1.IAnalyzeSentimentResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.analyzeSentiment as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes analyzeSentiment with error', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeSentimentRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.analyzeSentiment = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.analyzeSentiment(request), expectedError); - assert((client.innerApiCalls.analyzeSentiment as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes analyzeSentiment with closed client', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeSentimentRequest()); - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.analyzeSentiment(request), expectedError); - }); - }); - - describe('analyzeEntities', () => { - it('invokes analyzeEntities without error', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeEntitiesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeEntitiesResponse()); - client.innerApiCalls.analyzeEntities = stubSimpleCall(expectedResponse); - const [response] = await client.analyzeEntities(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.analyzeEntities as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes analyzeEntities without error using callback', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeEntitiesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeEntitiesResponse()); - client.innerApiCalls.analyzeEntities = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.analyzeEntities( - request, - (err?: Error|null, result?: protos.google.cloud.language.v1.IAnalyzeEntitiesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.analyzeEntities as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes analyzeEntities with error', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeEntitiesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.analyzeEntities = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.analyzeEntities(request), expectedError); - assert((client.innerApiCalls.analyzeEntities as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes analyzeEntities with closed client', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeEntitiesRequest()); - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.analyzeEntities(request), expectedError); - }); - }); - - describe('analyzeEntitySentiment', () => { - it('invokes analyzeEntitySentiment without error', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeEntitySentimentRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeEntitySentimentResponse()); - client.innerApiCalls.analyzeEntitySentiment = stubSimpleCall(expectedResponse); - const [response] = await client.analyzeEntitySentiment(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.analyzeEntitySentiment as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes analyzeEntitySentiment without error using callback', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeEntitySentimentRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeEntitySentimentResponse()); - client.innerApiCalls.analyzeEntitySentiment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.analyzeEntitySentiment( - request, - (err?: Error|null, result?: protos.google.cloud.language.v1.IAnalyzeEntitySentimentResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.analyzeEntitySentiment as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes analyzeEntitySentiment with error', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeEntitySentimentRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.analyzeEntitySentiment = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.analyzeEntitySentiment(request), expectedError); - assert((client.innerApiCalls.analyzeEntitySentiment as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes analyzeEntitySentiment with closed client', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeEntitySentimentRequest()); - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.analyzeEntitySentiment(request), expectedError); - }); - }); - - describe('analyzeSyntax', () => { - it('invokes analyzeSyntax without error', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeSyntaxRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeSyntaxResponse()); - client.innerApiCalls.analyzeSyntax = stubSimpleCall(expectedResponse); - const [response] = await client.analyzeSyntax(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.analyzeSyntax as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes analyzeSyntax without error using callback', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeSyntaxRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeSyntaxResponse()); - client.innerApiCalls.analyzeSyntax = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.analyzeSyntax( - request, - (err?: Error|null, result?: protos.google.cloud.language.v1.IAnalyzeSyntaxResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.analyzeSyntax as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes analyzeSyntax with error', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeSyntaxRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.analyzeSyntax = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.analyzeSyntax(request), expectedError); - assert((client.innerApiCalls.analyzeSyntax as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes analyzeSyntax with closed client', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1.AnalyzeSyntaxRequest()); - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.analyzeSyntax(request), expectedError); - }); - }); - - describe('classifyText', () => { - it('invokes classifyText without error', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1.ClassifyTextRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1.ClassifyTextResponse()); - client.innerApiCalls.classifyText = stubSimpleCall(expectedResponse); - const [response] = await client.classifyText(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.classifyText as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes classifyText without error using callback', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1.ClassifyTextRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1.ClassifyTextResponse()); - client.innerApiCalls.classifyText = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.classifyText( - request, - (err?: Error|null, result?: protos.google.cloud.language.v1.IClassifyTextResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.classifyText as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes classifyText with error', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1.ClassifyTextRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.classifyText = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.classifyText(request), expectedError); - assert((client.innerApiCalls.classifyText as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes classifyText with closed client', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1.ClassifyTextRequest()); - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.classifyText(request), expectedError); - }); - }); - - describe('annotateText', () => { - it('invokes annotateText without error', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1.AnnotateTextRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1.AnnotateTextResponse()); - client.innerApiCalls.annotateText = stubSimpleCall(expectedResponse); - const [response] = await client.annotateText(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.annotateText as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes annotateText without error using callback', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1.AnnotateTextRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1.AnnotateTextResponse()); - client.innerApiCalls.annotateText = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.annotateText( - request, - (err?: Error|null, result?: protos.google.cloud.language.v1.IAnnotateTextResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.annotateText as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes annotateText with error', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1.AnnotateTextRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.annotateText = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.annotateText(request), expectedError); - assert((client.innerApiCalls.annotateText as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes annotateText with closed client', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1.AnnotateTextRequest()); - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.annotateText(request), expectedError); - }); - }); -}); 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 c90df106..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: 'LanguageService', - filename: './language-service.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/v1beta2/.eslintignore b/owl-bot-staging/v1beta2/.eslintignore deleted file mode 100644 index cfc348ec..00000000 --- a/owl-bot-staging/v1beta2/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/v1beta2/.eslintrc.json b/owl-bot-staging/v1beta2/.eslintrc.json deleted file mode 100644 index 78215349..00000000 --- a/owl-bot-staging/v1beta2/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/v1beta2/.gitignore b/owl-bot-staging/v1beta2/.gitignore deleted file mode 100644 index 5d32b237..00000000 --- a/owl-bot-staging/v1beta2/.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/v1beta2/.jsdoc.js b/owl-bot-staging/v1beta2/.jsdoc.js deleted file mode 100644 index 79611132..00000000 --- a/owl-bot-staging/v1beta2/.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/language', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/v1beta2/.mocharc.js b/owl-bot-staging/v1beta2/.mocharc.js deleted file mode 100644 index 481c522b..00000000 --- a/owl-bot-staging/v1beta2/.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/v1beta2/.prettierrc.js b/owl-bot-staging/v1beta2/.prettierrc.js deleted file mode 100644 index 494e1478..00000000 --- a/owl-bot-staging/v1beta2/.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/v1beta2/README.md b/owl-bot-staging/v1beta2/README.md deleted file mode 100644 index 7287da54..00000000 --- a/owl-bot-staging/v1beta2/README.md +++ /dev/null @@ -1 +0,0 @@ -Language: Nodejs Client diff --git a/owl-bot-staging/v1beta2/linkinator.config.json b/owl-bot-staging/v1beta2/linkinator.config.json deleted file mode 100644 index befd23c8..00000000 --- a/owl-bot-staging/v1beta2/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/v1beta2/package.json b/owl-bot-staging/v1beta2/package.json deleted file mode 100644 index 1b45ee6a..00000000 --- a/owl-bot-staging/v1beta2/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "@google-cloud/language", - "version": "0.1.0", - "description": "Language client for Node.js", - "repository": "googleapis/nodejs-language", - "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 language", - "language", - "language service" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/", - "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.1.1" - }, - "devDependencies": { - "@types/mocha": "^9.1.0", - "@types/node": "^16.0.0", - "@types/sinon": "^10.0.8", - "c8": "^7.11.0", - "gts": "^3.1.0", - "jsdoc": "^3.6.7", - "jsdoc-fresh": "^1.1.1", - "jsdoc-region-tag": "^1.3.1", - "linkinator": "^3.0.0", - "mocha": "^9.1.4", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^13.0.0", - "ts-loader": "^9.2.6", - "typescript": "^4.5.5", - "webpack": "^5.67.0", - "webpack-cli": "^4.9.1" - }, - "engines": { - "node": ">=v12" - } -} diff --git a/owl-bot-staging/v1beta2/protos/google/cloud/language/v1beta2/language_service.proto b/owl-bot-staging/v1beta2/protos/google/cloud/language/v1beta2/language_service.proto deleted file mode 100644 index bd4167a3..00000000 --- a/owl-bot-staging/v1beta2/protos/google/cloud/language/v1beta2/language_service.proto +++ /dev/null @@ -1,1134 +0,0 @@ -// Copyright 2019 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.language.v1beta2; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/protobuf/timestamp.proto"; - -option go_package = "google.golang.org/genproto/googleapis/cloud/language/v1beta2;language"; -option java_multiple_files = true; -option java_outer_classname = "LanguageServiceProto"; -option java_package = "com.google.cloud.language.v1beta2"; - -// Provides text analysis operations such as sentiment analysis and entity -// recognition. -service LanguageService { - option (google.api.default_host) = "language.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-language," - "https://www.googleapis.com/auth/cloud-platform"; - - // Analyzes the sentiment of the provided text. - rpc AnalyzeSentiment(AnalyzeSentimentRequest) returns (AnalyzeSentimentResponse) { - option (google.api.http) = { - post: "/v1beta2/documents:analyzeSentiment" - body: "*" - }; - option (google.api.method_signature) = "document,encoding_type"; - option (google.api.method_signature) = "document"; - } - - // Finds named entities (currently proper names and common nouns) in the text - // along with entity types, salience, mentions for each entity, and - // other properties. - rpc AnalyzeEntities(AnalyzeEntitiesRequest) returns (AnalyzeEntitiesResponse) { - option (google.api.http) = { - post: "/v1beta2/documents:analyzeEntities" - body: "*" - }; - option (google.api.method_signature) = "document,encoding_type"; - option (google.api.method_signature) = "document"; - } - - // Finds entities, similar to [AnalyzeEntities][google.cloud.language.v1beta2.LanguageService.AnalyzeEntities] in the text and analyzes - // sentiment associated with each entity and its mentions. - rpc AnalyzeEntitySentiment(AnalyzeEntitySentimentRequest) returns (AnalyzeEntitySentimentResponse) { - option (google.api.http) = { - post: "/v1beta2/documents:analyzeEntitySentiment" - body: "*" - }; - option (google.api.method_signature) = "document,encoding_type"; - option (google.api.method_signature) = "document"; - } - - // Analyzes the syntax of the text and provides sentence boundaries and - // tokenization along with part-of-speech tags, dependency trees, and other - // properties. - rpc AnalyzeSyntax(AnalyzeSyntaxRequest) returns (AnalyzeSyntaxResponse) { - option (google.api.http) = { - post: "/v1beta2/documents:analyzeSyntax" - body: "*" - }; - option (google.api.method_signature) = "document,encoding_type"; - option (google.api.method_signature) = "document"; - } - - // Classifies a document into categories. - rpc ClassifyText(ClassifyTextRequest) returns (ClassifyTextResponse) { - option (google.api.http) = { - post: "/v1beta2/documents:classifyText" - body: "*" - }; - option (google.api.method_signature) = "document"; - } - - // A convenience method that provides all syntax, sentiment, entity, and - // classification features in one call. - rpc AnnotateText(AnnotateTextRequest) returns (AnnotateTextResponse) { - option (google.api.http) = { - post: "/v1beta2/documents:annotateText" - body: "*" - }; - option (google.api.method_signature) = "document,features,encoding_type"; - option (google.api.method_signature) = "document,features"; - } -} - - -// -// Represents the input to API methods. -message Document { - // The document types enum. - enum Type { - // The content type is not specified. - TYPE_UNSPECIFIED = 0; - - // Plain text - PLAIN_TEXT = 1; - - // HTML - HTML = 2; - } - - // Required. If the type is not set or is `TYPE_UNSPECIFIED`, - // returns an `INVALID_ARGUMENT` error. - Type type = 1; - - // The source of the document: a string containing the content or a - // Google Cloud Storage URI. - oneof source { - // The content of the input in string format. - // Cloud audit logging exempt since it is based on user data. - string content = 2; - - // The Google Cloud Storage URI where the file content is located. - // This URI must be of the form: gs://bucket_name/object_name. For more - // details, see https://cloud.google.com/storage/docs/reference-uris. - // NOTE: Cloud Storage object versioning is not supported. - string gcs_content_uri = 3; - } - - // The language of the document (if not specified, the language is - // automatically detected). Both ISO and BCP-47 language codes are - // accepted.
- // [Language - // Support](https://cloud.google.com/natural-language/docs/languages) lists - // currently supported languages for each API method. If the language (either - // specified by the caller or automatically detected) is not supported by the - // called API method, an `INVALID_ARGUMENT` error is returned. - string language = 4; -} - -// Represents a sentence in the input document. -message Sentence { - // The sentence text. - TextSpan text = 1; - - // For calls to [AnalyzeSentiment][] or if - // [AnnotateTextRequest.Features.extract_document_sentiment][google.cloud.language.v1beta2.AnnotateTextRequest.Features.extract_document_sentiment] is set to - // true, this field will contain the sentiment for the sentence. - Sentiment sentiment = 2; -} - -// Represents a phrase in the text that is a known entity, such as -// a person, an organization, or location. The API associates information, such -// as salience and mentions, with entities. -message Entity { - // The type of the entity. For most entity types, the associated metadata is a - // Wikipedia URL (`wikipedia_url`) and Knowledge Graph MID (`mid`). The table - // below lists the associated fields for entities that have different - // metadata. - enum Type { - // Unknown - UNKNOWN = 0; - - // Person - PERSON = 1; - - // Location - LOCATION = 2; - - // Organization - ORGANIZATION = 3; - - // Event - EVENT = 4; - - // Artwork - WORK_OF_ART = 5; - - // Consumer product - CONSUMER_GOOD = 6; - - // Other types of entities - OTHER = 7; - - // Phone number - // - // The metadata lists the phone number, formatted according to local - // convention, plus whichever additional elements appear in the text: - // - // * `number` - the actual number, broken down into sections as per local - // convention - // * `national_prefix` - country code, if detected - // * `area_code` - region or area code, if detected - // * `extension` - phone extension (to be dialed after connection), if - // detected - PHONE_NUMBER = 9; - - // Address - // - // The metadata identifies the street number and locality plus whichever - // additional elements appear in the text: - // - // * `street_number` - street number - // * `locality` - city or town - // * `street_name` - street/route name, if detected - // * `postal_code` - postal code, if detected - // * `country` - country, if detected< - // * `broad_region` - administrative area, such as the state, if detected - // * `narrow_region` - smaller administrative area, such as county, if - // detected - // * `sublocality` - used in Asian addresses to demark a district within a - // city, if detected - ADDRESS = 10; - - // Date - // - // The metadata identifies the components of the date: - // - // * `year` - four digit year, if detected - // * `month` - two digit month number, if detected - // * `day` - two digit day number, if detected - DATE = 11; - - // Number - // - // The metadata is the number itself. - NUMBER = 12; - - // Price - // - // The metadata identifies the `value` and `currency`. - PRICE = 13; - } - - // The representative name for the entity. - string name = 1; - - // The entity type. - Type type = 2; - - // Metadata associated with the entity. - // - // For most entity types, the metadata is a Wikipedia URL (`wikipedia_url`) - // and Knowledge Graph MID (`mid`), if they are available. For the metadata - // associated with other entity types, see the Type table below. - map metadata = 3; - - // The salience score associated with the entity in the [0, 1.0] range. - // - // The salience score for an entity provides information about the - // importance or centrality of that entity to the entire document text. - // Scores closer to 0 are less salient, while scores closer to 1.0 are highly - // salient. - float salience = 4; - - // The mentions of this entity in the input document. The API currently - // supports proper noun mentions. - repeated EntityMention mentions = 5; - - // For calls to [AnalyzeEntitySentiment][] or if - // [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v1beta2.AnnotateTextRequest.Features.extract_entity_sentiment] is set to - // true, this field will contain the aggregate sentiment expressed for this - // entity in the provided document. - Sentiment sentiment = 6; -} - -// Represents the smallest syntactic building block of the text. -message Token { - // The token text. - TextSpan text = 1; - - // Parts of speech tag for this token. - PartOfSpeech part_of_speech = 2; - - // Dependency tree parse for this token. - DependencyEdge dependency_edge = 3; - - // [Lemma](https://en.wikipedia.org/wiki/Lemma_%28morphology%29) of the token. - string lemma = 4; -} - -// Represents the text encoding that the caller uses to process the output. -// Providing an `EncodingType` is recommended because the API provides the -// beginning offsets for various outputs, such as tokens and mentions, and -// languages that natively use different text encodings may access offsets -// differently. -enum EncodingType { - // If `EncodingType` is not specified, encoding-dependent information (such as - // `begin_offset`) will be set at `-1`. - NONE = 0; - - // Encoding-dependent information (such as `begin_offset`) is calculated based - // on the UTF-8 encoding of the input. C++ and Go are examples of languages - // that use this encoding natively. - UTF8 = 1; - - // Encoding-dependent information (such as `begin_offset`) is calculated based - // on the UTF-16 encoding of the input. Java and JavaScript are examples of - // languages that use this encoding natively. - UTF16 = 2; - - // Encoding-dependent information (such as `begin_offset`) is calculated based - // on the UTF-32 encoding of the input. Python is an example of a language - // that uses this encoding natively. - UTF32 = 3; -} - -// Represents the feeling associated with the entire text or entities in -// the text. -// Next ID: 6 -message Sentiment { - // A non-negative number in the [0, +inf) range, which represents - // the absolute magnitude of sentiment regardless of score (positive or - // negative). - float magnitude = 2; - - // Sentiment score between -1.0 (negative sentiment) and 1.0 - // (positive sentiment). - float score = 3; -} - -// Represents part of speech information for a token. -message PartOfSpeech { - // The part of speech tags enum. - enum Tag { - // Unknown - UNKNOWN = 0; - - // Adjective - ADJ = 1; - - // Adposition (preposition and postposition) - ADP = 2; - - // Adverb - ADV = 3; - - // Conjunction - CONJ = 4; - - // Determiner - DET = 5; - - // Noun (common and proper) - NOUN = 6; - - // Cardinal number - NUM = 7; - - // Pronoun - PRON = 8; - - // Particle or other function word - PRT = 9; - - // Punctuation - PUNCT = 10; - - // Verb (all tenses and modes) - VERB = 11; - - // Other: foreign words, typos, abbreviations - X = 12; - - // Affix - AFFIX = 13; - } - - // The characteristic of a verb that expresses time flow during an event. - enum Aspect { - // Aspect is not applicable in the analyzed language or is not predicted. - ASPECT_UNKNOWN = 0; - - // Perfective - PERFECTIVE = 1; - - // Imperfective - IMPERFECTIVE = 2; - - // Progressive - PROGRESSIVE = 3; - } - - // The grammatical function performed by a noun or pronoun in a phrase, - // clause, or sentence. In some languages, other parts of speech, such as - // adjective and determiner, take case inflection in agreement with the noun. - enum Case { - // Case is not applicable in the analyzed language or is not predicted. - CASE_UNKNOWN = 0; - - // Accusative - ACCUSATIVE = 1; - - // Adverbial - ADVERBIAL = 2; - - // Complementive - COMPLEMENTIVE = 3; - - // Dative - DATIVE = 4; - - // Genitive - GENITIVE = 5; - - // Instrumental - INSTRUMENTAL = 6; - - // Locative - LOCATIVE = 7; - - // Nominative - NOMINATIVE = 8; - - // Oblique - OBLIQUE = 9; - - // Partitive - PARTITIVE = 10; - - // Prepositional - PREPOSITIONAL = 11; - - // Reflexive - REFLEXIVE_CASE = 12; - - // Relative - RELATIVE_CASE = 13; - - // Vocative - VOCATIVE = 14; - } - - // Depending on the language, Form can be categorizing different forms of - // verbs, adjectives, adverbs, etc. For example, categorizing inflected - // endings of verbs and adjectives or distinguishing between short and long - // forms of adjectives and participles - enum Form { - // Form is not applicable in the analyzed language or is not predicted. - FORM_UNKNOWN = 0; - - // Adnomial - ADNOMIAL = 1; - - // Auxiliary - AUXILIARY = 2; - - // Complementizer - COMPLEMENTIZER = 3; - - // Final ending - FINAL_ENDING = 4; - - // Gerund - GERUND = 5; - - // Realis - REALIS = 6; - - // Irrealis - IRREALIS = 7; - - // Short form - SHORT = 8; - - // Long form - LONG = 9; - - // Order form - ORDER = 10; - - // Specific form - SPECIFIC = 11; - } - - // Gender classes of nouns reflected in the behaviour of associated words. - enum Gender { - // Gender is not applicable in the analyzed language or is not predicted. - GENDER_UNKNOWN = 0; - - // Feminine - FEMININE = 1; - - // Masculine - MASCULINE = 2; - - // Neuter - NEUTER = 3; - } - - // The grammatical feature of verbs, used for showing modality and attitude. - enum Mood { - // Mood is not applicable in the analyzed language or is not predicted. - MOOD_UNKNOWN = 0; - - // Conditional - CONDITIONAL_MOOD = 1; - - // Imperative - IMPERATIVE = 2; - - // Indicative - INDICATIVE = 3; - - // Interrogative - INTERROGATIVE = 4; - - // Jussive - JUSSIVE = 5; - - // Subjunctive - SUBJUNCTIVE = 6; - } - - // Count distinctions. - enum Number { - // Number is not applicable in the analyzed language or is not predicted. - NUMBER_UNKNOWN = 0; - - // Singular - SINGULAR = 1; - - // Plural - PLURAL = 2; - - // Dual - DUAL = 3; - } - - // The distinction between the speaker, second person, third person, etc. - enum Person { - // Person is not applicable in the analyzed language or is not predicted. - PERSON_UNKNOWN = 0; - - // First - FIRST = 1; - - // Second - SECOND = 2; - - // Third - THIRD = 3; - - // Reflexive - REFLEXIVE_PERSON = 4; - } - - // This category shows if the token is part of a proper name. - enum Proper { - // Proper is not applicable in the analyzed language or is not predicted. - PROPER_UNKNOWN = 0; - - // Proper - PROPER = 1; - - // Not proper - NOT_PROPER = 2; - } - - // Reciprocal features of a pronoun. - enum Reciprocity { - // Reciprocity is not applicable in the analyzed language or is not - // predicted. - RECIPROCITY_UNKNOWN = 0; - - // Reciprocal - RECIPROCAL = 1; - - // Non-reciprocal - NON_RECIPROCAL = 2; - } - - // Time reference. - enum Tense { - // Tense is not applicable in the analyzed language or is not predicted. - TENSE_UNKNOWN = 0; - - // Conditional - CONDITIONAL_TENSE = 1; - - // Future - FUTURE = 2; - - // Past - PAST = 3; - - // Present - PRESENT = 4; - - // Imperfect - IMPERFECT = 5; - - // Pluperfect - PLUPERFECT = 6; - } - - // The relationship between the action that a verb expresses and the - // participants identified by its arguments. - enum Voice { - // Voice is not applicable in the analyzed language or is not predicted. - VOICE_UNKNOWN = 0; - - // Active - ACTIVE = 1; - - // Causative - CAUSATIVE = 2; - - // Passive - PASSIVE = 3; - } - - // The part of speech tag. - Tag tag = 1; - - // The grammatical aspect. - Aspect aspect = 2; - - // The grammatical case. - Case case = 3; - - // The grammatical form. - Form form = 4; - - // The grammatical gender. - Gender gender = 5; - - // The grammatical mood. - Mood mood = 6; - - // The grammatical number. - Number number = 7; - - // The grammatical person. - Person person = 8; - - // The grammatical properness. - Proper proper = 9; - - // The grammatical reciprocity. - Reciprocity reciprocity = 10; - - // The grammatical tense. - Tense tense = 11; - - // The grammatical voice. - Voice voice = 12; -} - -// Represents dependency parse tree information for a token. -message DependencyEdge { - // The parse label enum for the token. - enum Label { - // Unknown - UNKNOWN = 0; - - // Abbreviation modifier - ABBREV = 1; - - // Adjectival complement - ACOMP = 2; - - // Adverbial clause modifier - ADVCL = 3; - - // Adverbial modifier - ADVMOD = 4; - - // Adjectival modifier of an NP - AMOD = 5; - - // Appositional modifier of an NP - APPOS = 6; - - // Attribute dependent of a copular verb - ATTR = 7; - - // Auxiliary (non-main) verb - AUX = 8; - - // Passive auxiliary - AUXPASS = 9; - - // Coordinating conjunction - CC = 10; - - // Clausal complement of a verb or adjective - CCOMP = 11; - - // Conjunct - CONJ = 12; - - // Clausal subject - CSUBJ = 13; - - // Clausal passive subject - CSUBJPASS = 14; - - // Dependency (unable to determine) - DEP = 15; - - // Determiner - DET = 16; - - // Discourse - DISCOURSE = 17; - - // Direct object - DOBJ = 18; - - // Expletive - EXPL = 19; - - // Goes with (part of a word in a text not well edited) - GOESWITH = 20; - - // Indirect object - IOBJ = 21; - - // Marker (word introducing a subordinate clause) - MARK = 22; - - // Multi-word expression - MWE = 23; - - // Multi-word verbal expression - MWV = 24; - - // Negation modifier - NEG = 25; - - // Noun compound modifier - NN = 26; - - // Noun phrase used as an adverbial modifier - NPADVMOD = 27; - - // Nominal subject - NSUBJ = 28; - - // Passive nominal subject - NSUBJPASS = 29; - - // Numeric modifier of a noun - NUM = 30; - - // Element of compound number - NUMBER = 31; - - // Punctuation mark - P = 32; - - // Parataxis relation - PARATAXIS = 33; - - // Participial modifier - PARTMOD = 34; - - // The complement of a preposition is a clause - PCOMP = 35; - - // Object of a preposition - POBJ = 36; - - // Possession modifier - POSS = 37; - - // Postverbal negative particle - POSTNEG = 38; - - // Predicate complement - PRECOMP = 39; - - // Preconjunt - PRECONJ = 40; - - // Predeterminer - PREDET = 41; - - // Prefix - PREF = 42; - - // Prepositional modifier - PREP = 43; - - // The relationship between a verb and verbal morpheme - PRONL = 44; - - // Particle - PRT = 45; - - // Associative or possessive marker - PS = 46; - - // Quantifier phrase modifier - QUANTMOD = 47; - - // Relative clause modifier - RCMOD = 48; - - // Complementizer in relative clause - RCMODREL = 49; - - // Ellipsis without a preceding predicate - RDROP = 50; - - // Referent - REF = 51; - - // Remnant - REMNANT = 52; - - // Reparandum - REPARANDUM = 53; - - // Root - ROOT = 54; - - // Suffix specifying a unit of number - SNUM = 55; - - // Suffix - SUFF = 56; - - // Temporal modifier - TMOD = 57; - - // Topic marker - TOPIC = 58; - - // Clause headed by an infinite form of the verb that modifies a noun - VMOD = 59; - - // Vocative - VOCATIVE = 60; - - // Open clausal complement - XCOMP = 61; - - // Name suffix - SUFFIX = 62; - - // Name title - TITLE = 63; - - // Adverbial phrase modifier - ADVPHMOD = 64; - - // Causative auxiliary - AUXCAUS = 65; - - // Helper auxiliary - AUXVV = 66; - - // Rentaishi (Prenominal modifier) - DTMOD = 67; - - // Foreign words - FOREIGN = 68; - - // Keyword - KW = 69; - - // List for chains of comparable items - LIST = 70; - - // Nominalized clause - NOMC = 71; - - // Nominalized clausal subject - NOMCSUBJ = 72; - - // Nominalized clausal passive - NOMCSUBJPASS = 73; - - // Compound of numeric modifier - NUMC = 74; - - // Copula - COP = 75; - - // Dislocated relation (for fronted/topicalized elements) - DISLOCATED = 76; - - // Aspect marker - ASP = 77; - - // Genitive modifier - GMOD = 78; - - // Genitive object - GOBJ = 79; - - // Infinitival modifier - INFMOD = 80; - - // Measure - MES = 81; - - // Nominal complement of a noun - NCOMP = 82; - } - - // Represents the head of this token in the dependency tree. - // This is the index of the token which has an arc going to this token. - // The index is the position of the token in the array of tokens returned - // by the API method. If this token is a root token, then the - // `head_token_index` is its own index. - int32 head_token_index = 1; - - // The parse label for the token. - Label label = 2; -} - -// Represents a mention for an entity in the text. Currently, proper noun -// mentions are supported. -message EntityMention { - // The supported types of mentions. - enum Type { - // Unknown - TYPE_UNKNOWN = 0; - - // Proper name - PROPER = 1; - - // Common noun (or noun compound) - COMMON = 2; - } - - // The mention text. - TextSpan text = 1; - - // The type of the entity mention. - Type type = 2; - - // For calls to [AnalyzeEntitySentiment][] or if - // [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v1beta2.AnnotateTextRequest.Features.extract_entity_sentiment] is set to - // true, this field will contain the sentiment expressed for this mention of - // the entity in the provided document. - Sentiment sentiment = 3; -} - -// Represents an output piece of text. -message TextSpan { - // The content of the output text. - string content = 1; - - // The API calculates the beginning offset of the content in the original - // document according to the [EncodingType][google.cloud.language.v1beta2.EncodingType] specified in the API request. - int32 begin_offset = 2; -} - -// Represents a category returned from the text classifier. -message ClassificationCategory { - // The name of the category representing the document, from the [predefined - // taxonomy](https://cloud.google.com/natural-language/docs/categories). - string name = 1; - - // The classifier's confidence of the category. Number represents how certain - // the classifier is that this category represents the given text. - float confidence = 2; -} - -// The sentiment analysis request message. -message AnalyzeSentimentRequest { - // Required. Input document. - Document document = 1 [(google.api.field_behavior) = REQUIRED]; - - // The encoding type used by the API to calculate sentence offsets for the - // sentence sentiment. - EncodingType encoding_type = 2; -} - -// The sentiment analysis response message. -message AnalyzeSentimentResponse { - // The overall sentiment of the input document. - Sentiment document_sentiment = 1; - - // The language of the text, which will be the same as the language specified - // in the request or, if not specified, the automatically-detected language. - // See [Document.language][google.cloud.language.v1beta2.Document.language] field for more details. - string language = 2; - - // The sentiment for all the sentences in the document. - repeated Sentence sentences = 3; -} - -// The entity-level sentiment analysis request message. -message AnalyzeEntitySentimentRequest { - // Required. Input document. - Document document = 1 [(google.api.field_behavior) = REQUIRED]; - - // The encoding type used by the API to calculate offsets. - EncodingType encoding_type = 2; -} - -// The entity-level sentiment analysis response message. -message AnalyzeEntitySentimentResponse { - // The recognized entities in the input document with associated sentiments. - repeated Entity entities = 1; - - // The language of the text, which will be the same as the language specified - // in the request or, if not specified, the automatically-detected language. - // See [Document.language][google.cloud.language.v1beta2.Document.language] field for more details. - string language = 2; -} - -// The entity analysis request message. -message AnalyzeEntitiesRequest { - // Required. Input document. - Document document = 1 [(google.api.field_behavior) = REQUIRED]; - - // The encoding type used by the API to calculate offsets. - EncodingType encoding_type = 2; -} - -// The entity analysis response message. -message AnalyzeEntitiesResponse { - // The recognized entities in the input document. - repeated Entity entities = 1; - - // The language of the text, which will be the same as the language specified - // in the request or, if not specified, the automatically-detected language. - // See [Document.language][google.cloud.language.v1beta2.Document.language] field for more details. - string language = 2; -} - -// The syntax analysis request message. -message AnalyzeSyntaxRequest { - // Required. Input document. - Document document = 1 [(google.api.field_behavior) = REQUIRED]; - - // The encoding type used by the API to calculate offsets. - EncodingType encoding_type = 2; -} - -// The syntax analysis response message. -message AnalyzeSyntaxResponse { - // Sentences in the input document. - repeated Sentence sentences = 1; - - // Tokens, along with their syntactic information, in the input document. - repeated Token tokens = 2; - - // The language of the text, which will be the same as the language specified - // in the request or, if not specified, the automatically-detected language. - // See [Document.language][google.cloud.language.v1beta2.Document.language] field for more details. - string language = 3; -} - -// The document classification request message. -message ClassifyTextRequest { - // Required. Input document. - Document document = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// The document classification response message. -message ClassifyTextResponse { - // Categories representing the input document. - repeated ClassificationCategory categories = 1; -} - -// The request message for the text annotation API, which can perform multiple -// analysis types (sentiment, entities, and syntax) in one call. -message AnnotateTextRequest { - // All available features for sentiment, syntax, and semantic analysis. - // Setting each one to true will enable that specific analysis for the input. - // Next ID: 10 - message Features { - // Extract syntax information. - bool extract_syntax = 1; - - // Extract entities. - bool extract_entities = 2; - - // Extract document-level sentiment. - bool extract_document_sentiment = 3; - - // Extract entities and their associated sentiment. - bool extract_entity_sentiment = 4; - - // Classify the full document into categories. If this is true, - // the API will use the default model which classifies into a - // [predefined - // taxonomy](https://cloud.google.com/natural-language/docs/categories). - bool classify_text = 6; - } - - // Required. Input document. - Document document = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. The enabled features. - Features features = 2 [(google.api.field_behavior) = REQUIRED]; - - // The encoding type used by the API to calculate offsets. - EncodingType encoding_type = 3; -} - -// The text annotations response message. -message AnnotateTextResponse { - // Sentences in the input document. Populated if the user enables - // [AnnotateTextRequest.Features.extract_syntax][google.cloud.language.v1beta2.AnnotateTextRequest.Features.extract_syntax]. - repeated Sentence sentences = 1; - - // Tokens, along with their syntactic information, in the input document. - // Populated if the user enables - // [AnnotateTextRequest.Features.extract_syntax][google.cloud.language.v1beta2.AnnotateTextRequest.Features.extract_syntax]. - repeated Token tokens = 2; - - // Entities, along with their semantic information, in the input document. - // Populated if the user enables - // [AnnotateTextRequest.Features.extract_entities][google.cloud.language.v1beta2.AnnotateTextRequest.Features.extract_entities]. - repeated Entity entities = 3; - - // The overall sentiment for the document. Populated if the user enables - // [AnnotateTextRequest.Features.extract_document_sentiment][google.cloud.language.v1beta2.AnnotateTextRequest.Features.extract_document_sentiment]. - Sentiment document_sentiment = 4; - - // The language of the text, which will be the same as the language specified - // in the request or, if not specified, the automatically-detected language. - // See [Document.language][google.cloud.language.v1beta2.Document.language] field for more details. - string language = 5; - - // Categories identified in the input document. - repeated ClassificationCategory categories = 6; -} diff --git a/owl-bot-staging/v1beta2/samples/generated/v1beta2/language_service.analyze_entities.js b/owl-bot-staging/v1beta2/samples/generated/v1beta2/language_service.analyze_entities.js deleted file mode 100644 index 61da1c26..00000000 --- a/owl-bot-staging/v1beta2/samples/generated/v1beta2/language_service.analyze_entities.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(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/owl-bot-staging/v1beta2/samples/generated/v1beta2/language_service.analyze_entity_sentiment.js b/owl-bot-staging/v1beta2/samples/generated/v1beta2/language_service.analyze_entity_sentiment.js deleted file mode 100644 index f7fbf3b4..00000000 --- a/owl-bot-staging/v1beta2/samples/generated/v1beta2/language_service.analyze_entity_sentiment.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(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/owl-bot-staging/v1beta2/samples/generated/v1beta2/language_service.analyze_sentiment.js b/owl-bot-staging/v1beta2/samples/generated/v1beta2/language_service.analyze_sentiment.js deleted file mode 100644 index 8bf110ba..00000000 --- a/owl-bot-staging/v1beta2/samples/generated/v1beta2/language_service.analyze_sentiment.js +++ /dev/null @@ -1,63 +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(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/owl-bot-staging/v1beta2/samples/generated/v1beta2/language_service.analyze_syntax.js b/owl-bot-staging/v1beta2/samples/generated/v1beta2/language_service.analyze_syntax.js deleted file mode 100644 index 2d928214..00000000 --- a/owl-bot-staging/v1beta2/samples/generated/v1beta2/language_service.analyze_syntax.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(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/owl-bot-staging/v1beta2/samples/generated/v1beta2/language_service.annotate_text.js b/owl-bot-staging/v1beta2/samples/generated/v1beta2/language_service.annotate_text.js deleted file mode 100644 index b8b0239a..00000000 --- a/owl-bot-staging/v1beta2/samples/generated/v1beta2/language_service.annotate_text.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(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/owl-bot-staging/v1beta2/samples/generated/v1beta2/language_service.classify_text.js b/owl-bot-staging/v1beta2/samples/generated/v1beta2/language_service.classify_text.js deleted file mode 100644 index e7b868ca..00000000 --- a/owl-bot-staging/v1beta2/samples/generated/v1beta2/language_service.classify_text.js +++ /dev/null @@ -1,58 +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(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/owl-bot-staging/v1beta2/samples/generated/v1beta2/snippet_metadata.google.cloud.language.v1beta2.json b/owl-bot-staging/v1beta2/samples/generated/v1beta2/snippet_metadata.google.cloud.language.v1beta2.json deleted file mode 100644 index b46b91a8..00000000 --- a/owl-bot-staging/v1beta2/samples/generated/v1beta2/snippet_metadata.google.cloud.language.v1beta2.json +++ /dev/null @@ -1,279 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-language", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.language.v1beta2", - "version": "v1beta2" - } - ] - }, - "snippets": [ - { - "regionTag": "language_v1beta2_generated_LanguageService_AnalyzeSentiment_async", - "title": "LanguageService analyzeSentiment Sample", - "origin": "API_DEFINITION", - "description": " Analyzes the sentiment of the provided text.", - "canonical": true, - "file": "language_service.analyze_sentiment.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AnalyzeSentiment", - "fullName": "google.cloud.language.v1beta2.LanguageService.AnalyzeSentiment", - "async": true, - "parameters": [ - { - "name": "document", - "type": ".google.cloud.language.v1beta2.Document" - }, - { - "name": "encoding_type", - "type": ".google.cloud.language.v1beta2.EncodingType" - } - ], - "resultType": ".google.cloud.language.v1beta2.AnalyzeSentimentResponse", - "client": { - "shortName": "LanguageServiceClient", - "fullName": "google.cloud.language.v1beta2.LanguageServiceClient" - }, - "method": { - "shortName": "AnalyzeSentiment", - "fullName": "google.cloud.language.v1beta2.LanguageService.AnalyzeSentiment", - "service": { - "shortName": "LanguageService", - "fullName": "google.cloud.language.v1beta2.LanguageService" - } - } - } - }, - { - "regionTag": "language_v1beta2_generated_LanguageService_AnalyzeEntities_async", - "title": "LanguageService analyzeEntities Sample", - "origin": "API_DEFINITION", - "description": " Finds named entities (currently proper names and common nouns) in the text along with entity types, salience, mentions for each entity, and other properties.", - "canonical": true, - "file": "language_service.analyze_entities.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AnalyzeEntities", - "fullName": "google.cloud.language.v1beta2.LanguageService.AnalyzeEntities", - "async": true, - "parameters": [ - { - "name": "document", - "type": ".google.cloud.language.v1beta2.Document" - }, - { - "name": "encoding_type", - "type": ".google.cloud.language.v1beta2.EncodingType" - } - ], - "resultType": ".google.cloud.language.v1beta2.AnalyzeEntitiesResponse", - "client": { - "shortName": "LanguageServiceClient", - "fullName": "google.cloud.language.v1beta2.LanguageServiceClient" - }, - "method": { - "shortName": "AnalyzeEntities", - "fullName": "google.cloud.language.v1beta2.LanguageService.AnalyzeEntities", - "service": { - "shortName": "LanguageService", - "fullName": "google.cloud.language.v1beta2.LanguageService" - } - } - } - }, - { - "regionTag": "language_v1beta2_generated_LanguageService_AnalyzeEntitySentiment_async", - "title": "LanguageService analyzeEntitySentiment Sample", - "origin": "API_DEFINITION", - "description": " Finds entities, similar to [AnalyzeEntities][google.cloud.language.v1beta2.LanguageService.AnalyzeEntities] in the text and analyzes sentiment associated with each entity and its mentions.", - "canonical": true, - "file": "language_service.analyze_entity_sentiment.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AnalyzeEntitySentiment", - "fullName": "google.cloud.language.v1beta2.LanguageService.AnalyzeEntitySentiment", - "async": true, - "parameters": [ - { - "name": "document", - "type": ".google.cloud.language.v1beta2.Document" - }, - { - "name": "encoding_type", - "type": ".google.cloud.language.v1beta2.EncodingType" - } - ], - "resultType": ".google.cloud.language.v1beta2.AnalyzeEntitySentimentResponse", - "client": { - "shortName": "LanguageServiceClient", - "fullName": "google.cloud.language.v1beta2.LanguageServiceClient" - }, - "method": { - "shortName": "AnalyzeEntitySentiment", - "fullName": "google.cloud.language.v1beta2.LanguageService.AnalyzeEntitySentiment", - "service": { - "shortName": "LanguageService", - "fullName": "google.cloud.language.v1beta2.LanguageService" - } - } - } - }, - { - "regionTag": "language_v1beta2_generated_LanguageService_AnalyzeSyntax_async", - "title": "LanguageService analyzeSyntax Sample", - "origin": "API_DEFINITION", - "description": " Analyzes the syntax of the text and provides sentence boundaries and tokenization along with part-of-speech tags, dependency trees, and other properties.", - "canonical": true, - "file": "language_service.analyze_syntax.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AnalyzeSyntax", - "fullName": "google.cloud.language.v1beta2.LanguageService.AnalyzeSyntax", - "async": true, - "parameters": [ - { - "name": "document", - "type": ".google.cloud.language.v1beta2.Document" - }, - { - "name": "encoding_type", - "type": ".google.cloud.language.v1beta2.EncodingType" - } - ], - "resultType": ".google.cloud.language.v1beta2.AnalyzeSyntaxResponse", - "client": { - "shortName": "LanguageServiceClient", - "fullName": "google.cloud.language.v1beta2.LanguageServiceClient" - }, - "method": { - "shortName": "AnalyzeSyntax", - "fullName": "google.cloud.language.v1beta2.LanguageService.AnalyzeSyntax", - "service": { - "shortName": "LanguageService", - "fullName": "google.cloud.language.v1beta2.LanguageService" - } - } - } - }, - { - "regionTag": "language_v1beta2_generated_LanguageService_ClassifyText_async", - "title": "LanguageService classifyText Sample", - "origin": "API_DEFINITION", - "description": " Classifies a document into categories.", - "canonical": true, - "file": "language_service.classify_text.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 50, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ClassifyText", - "fullName": "google.cloud.language.v1beta2.LanguageService.ClassifyText", - "async": true, - "parameters": [ - { - "name": "document", - "type": ".google.cloud.language.v1beta2.Document" - } - ], - "resultType": ".google.cloud.language.v1beta2.ClassifyTextResponse", - "client": { - "shortName": "LanguageServiceClient", - "fullName": "google.cloud.language.v1beta2.LanguageServiceClient" - }, - "method": { - "shortName": "ClassifyText", - "fullName": "google.cloud.language.v1beta2.LanguageService.ClassifyText", - "service": { - "shortName": "LanguageService", - "fullName": "google.cloud.language.v1beta2.LanguageService" - } - } - } - }, - { - "regionTag": "language_v1beta2_generated_LanguageService_AnnotateText_async", - "title": "LanguageService annotateText Sample", - "origin": "API_DEFINITION", - "description": " A convenience method that provides all syntax, sentiment, entity, and classification features in one call.", - "canonical": true, - "file": "language_service.annotate_text.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AnnotateText", - "fullName": "google.cloud.language.v1beta2.LanguageService.AnnotateText", - "async": true, - "parameters": [ - { - "name": "document", - "type": ".google.cloud.language.v1beta2.Document" - }, - { - "name": "features", - "type": ".google.cloud.language.v1beta2.AnnotateTextRequest.Features" - }, - { - "name": "encoding_type", - "type": ".google.cloud.language.v1beta2.EncodingType" - } - ], - "resultType": ".google.cloud.language.v1beta2.AnnotateTextResponse", - "client": { - "shortName": "LanguageServiceClient", - "fullName": "google.cloud.language.v1beta2.LanguageServiceClient" - }, - "method": { - "shortName": "AnnotateText", - "fullName": "google.cloud.language.v1beta2.LanguageService.AnnotateText", - "service": { - "shortName": "LanguageService", - "fullName": "google.cloud.language.v1beta2.LanguageService" - } - } - } - } - ] -} diff --git a/owl-bot-staging/v1beta2/src/index.ts b/owl-bot-staging/v1beta2/src/index.ts deleted file mode 100644 index 6905ecd4..00000000 --- a/owl-bot-staging/v1beta2/src/index.ts +++ /dev/null @@ -1,25 +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 v1beta2 from './v1beta2'; -const LanguageServiceClient = v1beta2.LanguageServiceClient; -type LanguageServiceClient = v1beta2.LanguageServiceClient; -export {v1beta2, LanguageServiceClient}; -export default {v1beta2, LanguageServiceClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/v1beta2/src/v1beta2/gapic_metadata.json b/owl-bot-staging/v1beta2/src/v1beta2/gapic_metadata.json deleted file mode 100644 index cc37c24c..00000000 --- a/owl-bot-staging/v1beta2/src/v1beta2/gapic_metadata.json +++ /dev/null @@ -1,83 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.language.v1beta2", - "libraryPackage": "@google-cloud/language", - "services": { - "LanguageService": { - "clients": { - "grpc": { - "libraryClient": "LanguageServiceClient", - "rpcs": { - "AnalyzeSentiment": { - "methods": [ - "analyzeSentiment" - ] - }, - "AnalyzeEntities": { - "methods": [ - "analyzeEntities" - ] - }, - "AnalyzeEntitySentiment": { - "methods": [ - "analyzeEntitySentiment" - ] - }, - "AnalyzeSyntax": { - "methods": [ - "analyzeSyntax" - ] - }, - "ClassifyText": { - "methods": [ - "classifyText" - ] - }, - "AnnotateText": { - "methods": [ - "annotateText" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "LanguageServiceClient", - "rpcs": { - "AnalyzeSentiment": { - "methods": [ - "analyzeSentiment" - ] - }, - "AnalyzeEntities": { - "methods": [ - "analyzeEntities" - ] - }, - "AnalyzeEntitySentiment": { - "methods": [ - "analyzeEntitySentiment" - ] - }, - "AnalyzeSyntax": { - "methods": [ - "analyzeSyntax" - ] - }, - "ClassifyText": { - "methods": [ - "classifyText" - ] - }, - "AnnotateText": { - "methods": [ - "annotateText" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/v1beta2/src/v1beta2/index.ts b/owl-bot-staging/v1beta2/src/v1beta2/index.ts deleted file mode 100644 index 7e077a20..00000000 --- a/owl-bot-staging/v1beta2/src/v1beta2/index.ts +++ /dev/null @@ -1,19 +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 {LanguageServiceClient} from './language_service_client'; diff --git a/owl-bot-staging/v1beta2/src/v1beta2/language_service_client.ts b/owl-bot-staging/v1beta2/src/v1beta2/language_service_client.ts deleted file mode 100644 index 7f72e5ef..00000000 --- a/owl-bot-staging/v1beta2/src/v1beta2/language_service_client.ts +++ /dev/null @@ -1,709 +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 * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax'; - -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1beta2/language_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './language_service_client_config.json'; - -const version = require('../../../package.json').version; - -/** - * Provides text analysis operations such as sentiment analysis and entity - * recognition. - * @class - * @memberof v1beta2 - */ -export class LanguageServiceClient { - 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}; - languageServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of LanguageServiceClient. - * - * @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}. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof LanguageServiceClient; - 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; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth 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); - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.language.v1beta2.LanguageService', 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 = gax.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.languageServiceStub) { - return this.languageServiceStub; - } - - // Put together the "service stub" for - // google.cloud.language.v1beta2.LanguageService. - this.languageServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.language.v1beta2.LanguageService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.language.v1beta2.LanguageService, - 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 languageServiceStubMethods = - ['analyzeSentiment', 'analyzeEntities', 'analyzeEntitySentiment', 'analyzeSyntax', 'classifyText', 'annotateText']; - for (const methodName of languageServiceStubMethods) { - const callPromise = this.languageServiceStub.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 = - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.languageServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'language.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 'language.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-language', - '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 -- - // ------------------- -/** - * 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): - Promise<[ - protos.google.cloud.language.v1beta2.IAnalyzeSentimentResponse, - protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest|undefined, {}|undefined - ]>; - analyzeSentiment( - request: protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.language.v1beta2.IAnalyzeSentimentResponse, - protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest|null|undefined, - {}|null|undefined>): void; - analyzeSentiment( - request: protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest, - callback: Callback< - protos.google.cloud.language.v1beta2.IAnalyzeSentimentResponse, - protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest|null|undefined, - {}|null|undefined>): void; - analyzeSentiment( - request?: protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.language.v1beta2.IAnalyzeSentimentResponse, - protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.language.v1beta2.IAnalyzeSentimentResponse, - protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.language.v1beta2.IAnalyzeSentimentResponse, - protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest|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.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): - Promise<[ - protos.google.cloud.language.v1beta2.IAnalyzeEntitiesResponse, - protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest|undefined, {}|undefined - ]>; - analyzeEntities( - request: protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.language.v1beta2.IAnalyzeEntitiesResponse, - protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest|null|undefined, - {}|null|undefined>): void; - analyzeEntities( - request: protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest, - callback: Callback< - protos.google.cloud.language.v1beta2.IAnalyzeEntitiesResponse, - protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest|null|undefined, - {}|null|undefined>): void; - analyzeEntities( - request?: protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.language.v1beta2.IAnalyzeEntitiesResponse, - protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.language.v1beta2.IAnalyzeEntitiesResponse, - protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.language.v1beta2.IAnalyzeEntitiesResponse, - protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest|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.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): - Promise<[ - protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentResponse, - protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest|undefined, {}|undefined - ]>; - analyzeEntitySentiment( - request: protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentResponse, - protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest|null|undefined, - {}|null|undefined>): void; - analyzeEntitySentiment( - request: protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest, - callback: Callback< - protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentResponse, - protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest|null|undefined, - {}|null|undefined>): void; - analyzeEntitySentiment( - request?: protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentResponse, - protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentResponse, - protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentResponse, - protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest|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.analyzeEntitySentiment(request, options, 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): - Promise<[ - protos.google.cloud.language.v1beta2.IAnalyzeSyntaxResponse, - protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest|undefined, {}|undefined - ]>; - analyzeSyntax( - request: protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.language.v1beta2.IAnalyzeSyntaxResponse, - protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest|null|undefined, - {}|null|undefined>): void; - analyzeSyntax( - request: protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest, - callback: Callback< - protos.google.cloud.language.v1beta2.IAnalyzeSyntaxResponse, - protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest|null|undefined, - {}|null|undefined>): void; - analyzeSyntax( - request?: protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.language.v1beta2.IAnalyzeSyntaxResponse, - protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.language.v1beta2.IAnalyzeSyntaxResponse, - protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.language.v1beta2.IAnalyzeSyntaxResponse, - protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest|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.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): - Promise<[ - protos.google.cloud.language.v1beta2.IClassifyTextResponse, - protos.google.cloud.language.v1beta2.IClassifyTextRequest|undefined, {}|undefined - ]>; - classifyText( - request: protos.google.cloud.language.v1beta2.IClassifyTextRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.language.v1beta2.IClassifyTextResponse, - protos.google.cloud.language.v1beta2.IClassifyTextRequest|null|undefined, - {}|null|undefined>): void; - classifyText( - request: protos.google.cloud.language.v1beta2.IClassifyTextRequest, - callback: Callback< - protos.google.cloud.language.v1beta2.IClassifyTextResponse, - protos.google.cloud.language.v1beta2.IClassifyTextRequest|null|undefined, - {}|null|undefined>): void; - classifyText( - request?: protos.google.cloud.language.v1beta2.IClassifyTextRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.language.v1beta2.IClassifyTextResponse, - protos.google.cloud.language.v1beta2.IClassifyTextRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.language.v1beta2.IClassifyTextResponse, - protos.google.cloud.language.v1beta2.IClassifyTextRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.language.v1beta2.IClassifyTextResponse, - protos.google.cloud.language.v1beta2.IClassifyTextRequest|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.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): - Promise<[ - protos.google.cloud.language.v1beta2.IAnnotateTextResponse, - protos.google.cloud.language.v1beta2.IAnnotateTextRequest|undefined, {}|undefined - ]>; - annotateText( - request: protos.google.cloud.language.v1beta2.IAnnotateTextRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.language.v1beta2.IAnnotateTextResponse, - protos.google.cloud.language.v1beta2.IAnnotateTextRequest|null|undefined, - {}|null|undefined>): void; - annotateText( - request: protos.google.cloud.language.v1beta2.IAnnotateTextRequest, - callback: Callback< - protos.google.cloud.language.v1beta2.IAnnotateTextResponse, - protos.google.cloud.language.v1beta2.IAnnotateTextRequest|null|undefined, - {}|null|undefined>): void; - annotateText( - request?: protos.google.cloud.language.v1beta2.IAnnotateTextRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.language.v1beta2.IAnnotateTextResponse, - protos.google.cloud.language.v1beta2.IAnnotateTextRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.language.v1beta2.IAnnotateTextResponse, - protos.google.cloud.language.v1beta2.IAnnotateTextRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.language.v1beta2.IAnnotateTextResponse, - protos.google.cloud.language.v1beta2.IAnnotateTextRequest|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.annotateText(request, options, callback); - } - - - /** - * 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.languageServiceStub && !this._terminated) { - return this.languageServiceStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1beta2/src/v1beta2/language_service_client_config.json b/owl-bot-staging/v1beta2/src/v1beta2/language_service_client_config.json deleted file mode 100644 index a2671a61..00000000 --- a/owl-bot-staging/v1beta2/src/v1beta2/language_service_client_config.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "interfaces": { - "google.cloud.language.v1beta2.LanguageService": { - "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": { - "AnalyzeSentiment": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "AnalyzeEntities": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "AnalyzeEntitySentiment": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "AnalyzeSyntax": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ClassifyText": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "AnnotateText": { - "timeout_millis": 600000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1beta2/src/v1beta2/language_service_proto_list.json b/owl-bot-staging/v1beta2/src/v1beta2/language_service_proto_list.json deleted file mode 100644 index d5314f41..00000000 --- a/owl-bot-staging/v1beta2/src/v1beta2/language_service_proto_list.json +++ /dev/null @@ -1,3 +0,0 @@ -[ - "../../protos/google/cloud/language/v1beta2/language_service.proto" -] diff --git a/owl-bot-staging/v1beta2/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1beta2/system-test/fixtures/sample/src/index.js deleted file mode 100644 index d89f290c..00000000 --- a/owl-bot-staging/v1beta2/system-test/fixtures/sample/src/index.js +++ /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. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const language = require('@google-cloud/language'); - -function main() { - const languageServiceClient = new language.LanguageServiceClient(); -} - -main(); diff --git a/owl-bot-staging/v1beta2/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1beta2/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 67dcd47c..00000000 --- a/owl-bot-staging/v1beta2/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +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 {LanguageServiceClient} from '@google-cloud/language'; - -// check that the client class type name can be used -function doStuffWithLanguageServiceClient(client: LanguageServiceClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const languageServiceClient = new LanguageServiceClient(); - doStuffWithLanguageServiceClient(languageServiceClient); -} - -main(); diff --git a/owl-bot-staging/v1beta2/system-test/install.ts b/owl-bot-staging/v1beta2/system-test/install.ts deleted file mode 100644 index 8ec45222..00000000 --- a/owl-bot-staging/v1beta2/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/v1beta2/test/gapic_language_service_v1beta2.ts b/owl-bot-staging/v1beta2/test/gapic_language_service_v1beta2.ts deleted file mode 100644 index 9a4cbee5..00000000 --- a/owl-bot-staging/v1beta2/test/gapic_language_service_v1beta2.ts +++ /dev/null @@ -1,567 +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 languageserviceModule from '../src'; - -import {protobuf} from 'google-gax'; - -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); -} - -describe('v1beta2.LanguageServiceClient', () => { - it('has servicePath', () => { - const servicePath = languageserviceModule.v1beta2.LanguageServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = languageserviceModule.v1beta2.LanguageServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = languageserviceModule.v1beta2.LanguageServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.languageServiceStub, undefined); - await client.initialize(); - assert(client.languageServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.languageServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.languageServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - 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 languageserviceModule.v1beta2.LanguageServiceClient({ - 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('analyzeSentiment', () => { - it('invokes analyzeSentiment without error', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeSentimentRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeSentimentResponse()); - client.innerApiCalls.analyzeSentiment = stubSimpleCall(expectedResponse); - const [response] = await client.analyzeSentiment(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.analyzeSentiment as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes analyzeSentiment without error using callback', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeSentimentRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeSentimentResponse()); - client.innerApiCalls.analyzeSentiment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.analyzeSentiment( - request, - (err?: Error|null, result?: protos.google.cloud.language.v1beta2.IAnalyzeSentimentResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.analyzeSentiment as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes analyzeSentiment with error', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeSentimentRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.analyzeSentiment = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.analyzeSentiment(request), expectedError); - assert((client.innerApiCalls.analyzeSentiment as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes analyzeSentiment with closed client', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeSentimentRequest()); - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.analyzeSentiment(request), expectedError); - }); - }); - - describe('analyzeEntities', () => { - it('invokes analyzeEntities without error', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeEntitiesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeEntitiesResponse()); - client.innerApiCalls.analyzeEntities = stubSimpleCall(expectedResponse); - const [response] = await client.analyzeEntities(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.analyzeEntities as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes analyzeEntities without error using callback', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeEntitiesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeEntitiesResponse()); - client.innerApiCalls.analyzeEntities = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.analyzeEntities( - request, - (err?: Error|null, result?: protos.google.cloud.language.v1beta2.IAnalyzeEntitiesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.analyzeEntities as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes analyzeEntities with error', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeEntitiesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.analyzeEntities = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.analyzeEntities(request), expectedError); - assert((client.innerApiCalls.analyzeEntities as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes analyzeEntities with closed client', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeEntitiesRequest()); - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.analyzeEntities(request), expectedError); - }); - }); - - describe('analyzeEntitySentiment', () => { - it('invokes analyzeEntitySentiment without error', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeEntitySentimentRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeEntitySentimentResponse()); - client.innerApiCalls.analyzeEntitySentiment = stubSimpleCall(expectedResponse); - const [response] = await client.analyzeEntitySentiment(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.analyzeEntitySentiment as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes analyzeEntitySentiment without error using callback', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeEntitySentimentRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeEntitySentimentResponse()); - client.innerApiCalls.analyzeEntitySentiment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.analyzeEntitySentiment( - request, - (err?: Error|null, result?: protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.analyzeEntitySentiment as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes analyzeEntitySentiment with error', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeEntitySentimentRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.analyzeEntitySentiment = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.analyzeEntitySentiment(request), expectedError); - assert((client.innerApiCalls.analyzeEntitySentiment as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes analyzeEntitySentiment with closed client', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeEntitySentimentRequest()); - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.analyzeEntitySentiment(request), expectedError); - }); - }); - - describe('analyzeSyntax', () => { - it('invokes analyzeSyntax without error', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeSyntaxRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeSyntaxResponse()); - client.innerApiCalls.analyzeSyntax = stubSimpleCall(expectedResponse); - const [response] = await client.analyzeSyntax(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.analyzeSyntax as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes analyzeSyntax without error using callback', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeSyntaxRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeSyntaxResponse()); - client.innerApiCalls.analyzeSyntax = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.analyzeSyntax( - request, - (err?: Error|null, result?: protos.google.cloud.language.v1beta2.IAnalyzeSyntaxResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.analyzeSyntax as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes analyzeSyntax with error', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeSyntaxRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.analyzeSyntax = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.analyzeSyntax(request), expectedError); - assert((client.innerApiCalls.analyzeSyntax as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes analyzeSyntax with closed client', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnalyzeSyntaxRequest()); - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.analyzeSyntax(request), expectedError); - }); - }); - - describe('classifyText', () => { - it('invokes classifyText without error', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.ClassifyTextRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1beta2.ClassifyTextResponse()); - client.innerApiCalls.classifyText = stubSimpleCall(expectedResponse); - const [response] = await client.classifyText(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.classifyText as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes classifyText without error using callback', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.ClassifyTextRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1beta2.ClassifyTextResponse()); - client.innerApiCalls.classifyText = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.classifyText( - request, - (err?: Error|null, result?: protos.google.cloud.language.v1beta2.IClassifyTextResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.classifyText as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes classifyText with error', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.ClassifyTextRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.classifyText = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.classifyText(request), expectedError); - assert((client.innerApiCalls.classifyText as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes classifyText with closed client', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.ClassifyTextRequest()); - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.classifyText(request), expectedError); - }); - }); - - describe('annotateText', () => { - it('invokes annotateText without error', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnnotateTextRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnnotateTextResponse()); - client.innerApiCalls.annotateText = stubSimpleCall(expectedResponse); - const [response] = await client.annotateText(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.annotateText as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes annotateText without error using callback', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnnotateTextRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnnotateTextResponse()); - client.innerApiCalls.annotateText = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.annotateText( - request, - (err?: Error|null, result?: protos.google.cloud.language.v1beta2.IAnnotateTextResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.annotateText as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes annotateText with error', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnnotateTextRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.annotateText = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.annotateText(request), expectedError); - assert((client.innerApiCalls.annotateText as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes annotateText with closed client', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.language.v1beta2.AnnotateTextRequest()); - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.annotateText(request), expectedError); - }); - }); -}); diff --git a/owl-bot-staging/v1beta2/tsconfig.json b/owl-bot-staging/v1beta2/tsconfig.json deleted file mode 100644 index c78f1c88..00000000 --- a/owl-bot-staging/v1beta2/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/v1beta2/webpack.config.js b/owl-bot-staging/v1beta2/webpack.config.js deleted file mode 100644 index c90df106..00000000 --- a/owl-bot-staging/v1beta2/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: 'LanguageService', - filename: './language-service.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/language_service_client.ts b/src/v1/language_service_client.ts index b1dcca7f..37a8960f 100644 --- a/src/v1/language_service_client.ts +++ b/src/v1/language_service_client.ts @@ -61,7 +61,7 @@ export class LanguageServiceClient { * * @param {object} [options] - The configuration object. * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * 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] @@ -84,11 +84,10 @@ export class LanguageServiceClient { * API remote host. * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. + * @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}. */ constructor(opts?: ClientOptions) { // Ensure that options include all the required fields. diff --git a/src/v1beta2/language_service_client.ts b/src/v1beta2/language_service_client.ts index 8eed5d7d..9116a66b 100644 --- a/src/v1beta2/language_service_client.ts +++ b/src/v1beta2/language_service_client.ts @@ -61,7 +61,7 @@ export class LanguageServiceClient { * * @param {object} [options] - The configuration object. * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * 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] @@ -84,11 +84,10 @@ export class LanguageServiceClient { * API remote host. * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. + * @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}. */ constructor(opts?: ClientOptions) { // Ensure that options include all the required fields.