From bf639824aab6a9e805bb4bfb49348e6fa0c69144 Mon Sep 17 00:00:00 2001 From: Daniel Azuma Date: Sat, 14 Mar 2020 09:58:55 -0700 Subject: [PATCH] feat(language)!: use clients created by the new generator Release-As: 1.0.0 --- google-cloud-language/.gitignore | 23 +- google-cloud-language/.repo-metadata.json | 3 - google-cloud-language/.rubocop.yml | 9 +- google-cloud-language/.yardopts | 1 + google-cloud-language/AUTHENTICATION.md | 102 +- google-cloud-language/Gemfile | 6 + google-cloud-language/MIGRATING.md | 217 ++++ google-cloud-language/README.md | 11 +- google-cloud-language/Rakefile | 6 +- .../v1/language_service_smoke_test.rb | 13 +- .../google-cloud-language.gemspec | 17 +- .../lib/google-cloud-language.rb | 35 + .../lib/google/cloud/language.rb | 153 +-- .../lib/google/cloud/language/v1.rb | 148 --- .../google/cloud/language/v1/credentials.rb | 41 - .../cloud/language/v1/language_service.rb | 1039 ---------------- .../language/v1/language_service_client.rb | 451 ------- .../v1/language_service_client_config.json | 56 - .../cloud/language/v1/language_service_pb.rb | 403 ------- .../v1/language_service_services_pb.rb | 64 - .../lib/google/cloud/language/v1beta2.rb | 160 --- .../cloud/language/v1beta2/credentials.rb | 41 - .../language/v1beta2/language_service.rb | 1049 ----------------- .../v1beta2/language_service_client.rb | 451 ------- .../language_service_client_config.json | 56 - .../language/v1beta2/language_service_pb.rb | 404 ------- .../v1beta2/language_service_services_pb.rb | 64 - google-cloud-language/synth.metadata | 50 - google-cloud-language/synth.py | 240 ---- .../test/google/cloud/language/client_test.rb | 30 + .../v1/language_service_client_test.rb | 517 -------- .../v1beta2/language_service_client_test.rb | 517 -------- .../google/cloud/language/version_test.rb | 22 + google-cloud-language/test/helper.rb | 20 + 34 files changed, 464 insertions(+), 5955 deletions(-) create mode 100644 google-cloud-language/MIGRATING.md create mode 100644 google-cloud-language/lib/google-cloud-language.rb delete mode 100644 google-cloud-language/lib/google/cloud/language/v1.rb delete mode 100644 google-cloud-language/lib/google/cloud/language/v1/credentials.rb delete mode 100644 google-cloud-language/lib/google/cloud/language/v1/doc/google/cloud/language/v1/language_service.rb delete mode 100644 google-cloud-language/lib/google/cloud/language/v1/language_service_client.rb delete mode 100644 google-cloud-language/lib/google/cloud/language/v1/language_service_client_config.json delete mode 100644 google-cloud-language/lib/google/cloud/language/v1/language_service_pb.rb delete mode 100644 google-cloud-language/lib/google/cloud/language/v1/language_service_services_pb.rb delete mode 100644 google-cloud-language/lib/google/cloud/language/v1beta2.rb delete mode 100644 google-cloud-language/lib/google/cloud/language/v1beta2/credentials.rb delete mode 100644 google-cloud-language/lib/google/cloud/language/v1beta2/doc/google/cloud/language/v1beta2/language_service.rb delete mode 100644 google-cloud-language/lib/google/cloud/language/v1beta2/language_service_client.rb delete mode 100644 google-cloud-language/lib/google/cloud/language/v1beta2/language_service_client_config.json delete mode 100644 google-cloud-language/lib/google/cloud/language/v1beta2/language_service_pb.rb delete mode 100644 google-cloud-language/lib/google/cloud/language/v1beta2/language_service_services_pb.rb delete mode 100644 google-cloud-language/synth.metadata delete mode 100644 google-cloud-language/synth.py create mode 100644 google-cloud-language/test/google/cloud/language/client_test.rb delete mode 100644 google-cloud-language/test/google/cloud/language/v1/language_service_client_test.rb delete mode 100644 google-cloud-language/test/google/cloud/language/v1beta2/language_service_client_test.rb create mode 100644 google-cloud-language/test/google/cloud/language/version_test.rb create mode 100644 google-cloud-language/test/helper.rb diff --git a/google-cloud-language/.gitignore b/google-cloud-language/.gitignore index e9bdb1b8aea1..0135b6bc6cfc 100644 --- a/google-cloud-language/.gitignore +++ b/google-cloud-language/.gitignore @@ -1,13 +1,22 @@ +# Ignore bundler lockfiles Gemfile.lock -coverage/* +gems.locked + +# Ignore documentation output doc/* -pkg/* -html/* -jsondoc/* +.yardoc/* -# Ignore YARD stuffs -.yardoc +# Ignore test output +coverage/* -# IDE settings +# Ignore build artifacts +pkg/* + +# Ignore files commonly present in certain dev environments +.vagrant +.DS_STORE .idea *.iml + +# Ignore synth output +__pycache__ diff --git a/google-cloud-language/.repo-metadata.json b/google-cloud-language/.repo-metadata.json index 06adc50f9b7d..ae2cfbffa475 100644 --- a/google-cloud-language/.repo-metadata.json +++ b/google-cloud-language/.repo-metadata.json @@ -2,8 +2,5 @@ "name": "language", "language": "ruby", "distribution_name": "google-cloud-language", - "module_name": "Language", - "module_name_credentials": "Language::V1", - "env_var_prefix": "LANGUAGE", "client_documentation": "https://googleapis.dev/ruby/google-cloud-language/latest" } diff --git a/google-cloud-language/.rubocop.yml b/google-cloud-language/.rubocop.yml index 479e3cf32168..129eecc6fe6c 100644 --- a/google-cloud-language/.rubocop.yml +++ b/google-cloud-language/.rubocop.yml @@ -3,11 +3,12 @@ inherit_gem: AllCops: Exclude: - - "google-cloud-language.gemspec" - - "lib/google/**/*" - - "Rakefile" - "test/**/*" - - "acceptance/**/*" + - "Rakefile" Documentation: Enabled: false + +Naming/FileName: + Exclude: + - lib/google-cloud-language.rb diff --git a/google-cloud-language/.yardopts b/google-cloud-language/.yardopts index ae562d785764..7e79418f7a94 100644 --- a/google-cloud-language/.yardopts +++ b/google-cloud-language/.yardopts @@ -8,4 +8,5 @@ - README.md AUTHENTICATION.md +MIGRATING.md LICENSE diff --git a/google-cloud-language/AUTHENTICATION.md b/google-cloud-language/AUTHENTICATION.md index f00c90c11d61..915d1e074c47 100644 --- a/google-cloud-language/AUTHENTICATION.md +++ b/google-cloud-language/AUTHENTICATION.md @@ -1,16 +1,17 @@ # Authentication -In general, the google-cloud-language library uses [Service -Account](https://cloud.google.com/iam/docs/creating-managing-service-accounts) -credentials to connect to Google Cloud services. When running within [Google -Cloud Platform environments](#google-cloud-platform-environments) +In general, the google-cloud-language library uses +[Service Account](https://cloud.google.com/iam/docs/creating-managing-service-accounts) +credentials to connect to Google Cloud services. When running within +[Google Cloud Platform environments](#google-cloud-platform-environments) the credentials will be discovered automatically. When running on other environments, the Service Account credentials can be specified by providing the -path to the [JSON -keyfile](https://cloud.google.com/iam/docs/managing-service-account-keys) for -the account (or the JSON itself) in [environment -variables](#environment-variables). Additionally, Cloud SDK credentials can also -be discovered automatically, but this is only recommended during development. +path to the +[JSON keyfile](https://cloud.google.com/iam/docs/managing-service-account-keys) +for the account (or the JSON itself) in +[environment variables](#environment-variables). +Additionally, Cloud SDK credentials can also be discovered automatically, but +this is only recommended during development. ## Quickstart @@ -26,23 +27,14 @@ export LANGUAGE_CREDENTIALS=/path/to/json` ```ruby require "google/cloud/language" -client = Google::Cloud::Language.new +client = Google::Cloud::Language.language_service ``` ## Project and Credential Lookup The google-cloud-language library aims to make authentication as simple as possible, and provides several mechanisms to configure your system -without providing **Project ID** and **Service Account Credentials** directly in -code. - -**Project ID** is discovered in the following order: - -1. Specify project ID in method arguments -2. Specify project ID in configuration -3. Discover project ID in environment variables -4. Discover GCP project ID -5. Discover project ID in credentials JSON +without providing **Service Account Credentials** directly in code. **Credentials** are discovered in the following order: @@ -57,26 +49,21 @@ code. When running on Google Cloud Platform (GCP), including Google Compute Engine (GCE), Google Kubernetes Engine (GKE), Google App Engine (GAE), Google Cloud Functions -(GCF) and Cloud Run, the **Project ID** and **Credentials** and are discovered -automatically. Code should be written as if already authenticated. +(GCF) and Cloud Run, the **Credentials** and are discovered automatically. Code +should be written as if already authenticated. ### Environment Variables -The **Project ID** and **Credentials JSON** can be placed in environment -variables instead of declaring them directly in code. Each service has its own -environment variable, allowing for different service accounts to be used for -different services. (See the READMEs for the individual service gems for -details.) The path to the **Credentials JSON** file can be stored in the -environment variable, or the **Credentials JSON** itself can be stored for -environments such as Docker containers where writing files is difficult or not -encouraged. - -The environment variables that google-cloud-language checks for project ID are: - -1. `LANGUAGE_PROJECT` -2. `GOOGLE_CLOUD_PROJECT` +The **Credentials JSON** can be placed in environment variables instead of +declaring them directly in code. Each service has its own environment variable, +allowing for different service accounts to be used for different services. +(See the READMEs for the individual service gems for details.) The path to the +**Credentials JSON** file can be stored in the environment variable, or the +**Credentials JSON** itself can be stored for environments such as Docker +containers where writing files is difficult or not encouraged. -The environment variables that google-cloud-language checks for credentials are configured on {Google::Cloud::Language::V1::Credentials}: +The environment variables that google-cloud-language checks for credentials are +configured on the service Credentials class. 1. `LANGUAGE_CREDENTIALS` - Path to JSON file, or JSON contents 2. `LANGUAGE_KEYFILE` - Path to JSON file, or JSON contents @@ -87,25 +74,35 @@ The environment variables that google-cloud-language checks for credentials are ```ruby require "google/cloud/language" -ENV["LANGUAGE_PROJECT"] = "my-project-id" ENV["LANGUAGE_CREDENTIALS"] = "path/to/keyfile.json" -client = Google::Cloud::Language.new +client = Google::Cloud::Language.language_service ``` ### Configuration -The **Project ID** and **Credentials JSON** can be configured instead of placing them in environment variables or providing them as arguments. +The **Credentials JSON** can be configured instead of placing them in +environment variables or providing them as arguments. You can set credentials +on individual client initialization: + +```ruby +require "google/cloud/language" + +client = Google::Cloud::Language.language_service do |config| + config.credentials = "path/to/keyfile.json" +end +``` + +Or globally for all clients: ```ruby require "google/cloud/language" Google::Cloud::Language.configure do |config| - config.project_id = "my-project-id" config.credentials = "path/to/keyfile.json" end -client = Google::Cloud::Language.new +client = Google::Cloud::Language.language_service ``` ### Cloud SDK @@ -134,24 +131,24 @@ To configure your system for this, simply: ## Creating a Service Account -Google Cloud requires a **Project ID** and **Service Account Credentials** to -connect to the APIs. You will use the **Project ID** and **JSON key file** to -connect to most services with google-cloud-language. +Google Cloud requires **Service Account Credentials** to connect to the APIs. +You will use the **JSON key file** to connect to most services with +google-cloud-language. -If you are not running this client within [Google Cloud Platform -environments](#google-cloud-platform-environments), you need a Google -Developers service account. +If you are not running this client within +[Google Cloud Platform environments](#google-cloud-platform-environments), +you need a Google Developers service account. 1. Visit the [Google Developers Console][dev-console]. -1. Create a new project or click on an existing project. -1. Activate the slide-out navigation tray and select **API Manager**. From +2. Create a new project or click on an existing project. +3. Activate the slide-out navigation tray and select **API Manager**. From here, you will enable the APIs that your application requires. ![Enable the APIs that your application requires][enable-apis] *Note: You may need to enable billing in order to use these services.* -1. Select **Credentials** from the side navigation. +4. Select **Credentials** from the side navigation. You should see a screen like one of the following. @@ -170,8 +167,3 @@ Developers service account. The key file you download will be used by this library to authenticate API requests and should be stored in a secure location. - -## Troubleshooting - -If you're having trouble authenticating you can ask for help by following the -{file:TROUBLESHOOTING.md Troubleshooting Guide}. diff --git a/google-cloud-language/Gemfile b/google-cloud-language/Gemfile index 32a59dd0b2e1..9d6de8e9853c 100644 --- a/google-cloud-language/Gemfile +++ b/google-cloud-language/Gemfile @@ -2,6 +2,12 @@ source "https://rubygems.org" gemspec +gem "google-cloud-core", path: "../google-cloud-core" +gem "google-cloud-env", path: "../google-cloud-env" +gem "google-cloud-errors", path: "../google-cloud-errors" +gem "google-cloud-language-v1", path: "../google-cloud-language-v1" +gem "google-cloud-language-v1beta2", path: "../google-cloud-language-v1beta2" + gem "rake" # Pin minitest to 5.11.x to avoid warnings emitted by 5.12. diff --git a/google-cloud-language/MIGRATING.md b/google-cloud-language/MIGRATING.md new file mode 100644 index 000000000000..081d2c736483 --- /dev/null +++ b/google-cloud-language/MIGRATING.md @@ -0,0 +1,217 @@ +## Migrating to google-cloud-language 1.0 + +The 1.0 release of the google-cloud-language client is a significant upgrade +based on a next-gen code generator. If you have used earlier versions of this +library, there have been a number of significant changes that may require +updates to calling code. This document will describe the changes that have been +made, and what you need to do to update your usage. + +To summarize: + + * The library has been broken out into three libraries. The new gems + `google-cloud-language-v1` and `google-cloud-language-v1beta2` contain the + actual client classes for versions V1 and V1beta2 of the Natural Language + service, and the gem `google-cloud-language` now simply provides a + convenience wrapper. See [Library Structure](#library-structure) for more + info. + * This library uses a new configuration mechanism giving you closer control + over endpoint address, network timeouts, and retry. See + [Client Configuration](#client-configuration) for more info. Furthermore, + when creating a client object, you can customize its configuration in a + block rather than passing arguments to the constructor. See + [Creating Clients](#creating-clients) for more info. + * Previously, methods typically had at least one positional argument. Now, + all arguments are keyword arguments. Additionally, you can pass a proto + request object instead of separate arguments. See + [Passing Arguments](#passing-arguments) for more info. + * Some classes have moved into different namespaces. See + [Class Namespaces](#class-namespaces) for more info. + +### Library Structure + +Older 0.x releases of the `google-cloud-language` gem were all-in-one gems that +included potentially multiple clients for multiple versions of the Natural +Language service. The `Google::Cloud::Language.new()` factory method would +return you an instance of a `Google::Cloud::Language::V1::LanguageServiceClient` +object for the V1 version of the service, or a +`Google::Cloud::Language::V1beta2::LanguageServiceClient` object for the +V1beta2 version of the service. All these classes were defined in the same gem. + +With the 1.0 release, the `google-cloud-language` gem still provides factory +methods for obtaining clients. (The method signatures will have changed. See +[Creating Clients](#creating-clients) for details.) However, the actual client +classes have been moved into separate gems, on per service version. The +`Google::Cloud::Language::V1::LanguageService::Client` class, along with its +helpers and data types, are now part of the `google-cloud-language-v1` gem. +Similarly, the `Google::Cloud::Language::V1beta2::LanguageService::Client` +class is part of the `google-cloud-language-v1beta2` gem. + +For normal usage, you can continue to install the `google-cloud-language` gem +and continue to use factory methods to create clients. This will remain the +easiest way to use the Natural Language client. However, you may alternatively +choose to install only one of the versioned gems. For example, if you know you +will only use `V1` of the service, you can install `google-cloud-language-v1` +by itself, and construct instances of the +`Google::Cloud::Language::V1::LanguageService::Client` client class directly. + +### Client Configuration + +In older releases, if you wanted to customize performance parameters or +low-level behavior of the client (such as credentials, timeouts, or +instrumentation), you would pass a variety of keyword arguments to the client +constructor. It was also extremely difficult to customize the default settings. + +With the 1.0 release, a configuration interface provides access to these +parameters, both global defaults and per-client settings. For example, to set +global credentials and default timeout for all language V1 clients: + +``` +Google::Cloud::Language::V1::LanguageService::Client.configure do |config| + config.credentials = "/path/to/credentials.json" + config.timeout = 10_000 +end +``` + +Individual RPCs can also be configured independently. For example, to set the +timeout for the `analyze_sentiment` call: + +``` +Google::Cloud::Language::V1::LanguageService::Client.configure do |config| + config.rpcs.analyze_sentinment.timeout = 20_000 +end +``` + +### Creating Clients + +In older releases, to create a client object, you would use the +`Google::Cloud::Language.new` class method. Keyword arguments were available to +select a service version and to configure parameters such as credentials and +timeouts. + +Wiht the 1.0 release, use the `Google::Cloud::Language.language_service` class +method to create a client object. You may select a service version using the +`:version` keyword argument. However, other configuration parameters should be +set in a configuration block when you create the client. + +Old: +``` +client = Google::Cloud::Language.new credentials: "/path/to/credentials.json" +``` + +New: +``` +client = Google::Cloud::Language.language_service do |config| + config.credentials = "/path/to/credentials.json" +end +``` + +The configuration block is optional. If you do not provide it, or you do not +set some configuration parameters, then the default configuration is used. See +[Client Configuration](#client-configuration). + +### Passing Arguments + +In older releases, certain required arguments would be passed as positional +arguments, while most optional arguments would be passed as keyword arguments. + +With the 1.0 release, all RPC arguments are passed as keyword arguments, +regardless of whether they are required or optional. For example: + +Old: +``` +client = Google::Cloud::Language.new + +document = { + content: "I love API calls!", + type: Google::Cloud::Language::V1::Document::Type::PLAIN_TEXT +} +encoding = Google:Cloud::Language::V1::EncodingType::UTF8 + +# Document is a positional argument, while encoding_type is a keyword argument. +response = client.analyze_sentiment document, encoding_type: encoding +``` + +New: +``` +client = Google::Cloud::Language.new + +document = { + content: "I love API calls!", + type: Google::Cloud::Language::V1::Document::Type::PLAIN_TEXT +} +encoding = Google:Cloud::Language::V1::EncodingType::UTF8 + +# Both document and encoding_type are keyword arguments. +response = client.analyze_sentiment document: document, encoding_type: encoding +``` + +In the 1.0 release, it is also possible to pass a request object, either +as a hash or as a protocol buffer. + +New: +``` +client = Google::Cloud::Language.new + +request = Google::Cloud::Language::V1::AnalyzeSentimentRequest.new( + document: { + content: "I love API calls!", + type: Google::Cloud::Language::V1::Document::Type::PLAIN_TEXT + }, + encoding_type: Google:Cloud::Language::V1::EncodingType::UTF8 +) + +# Pass a request object as a positional argument: +response = client.analyze_sentiment request +``` + +Finally, in older releases, to provide call options, you would pass a +`Google::Gax::CallOptions` object with the `:options` keyword argument. In the +1.0 release, pass call options using a _second set_ of keyword arguments. + +Old: +``` +client = Google::Cloud::Language.new + +document = { + content: "I love API calls!", + type: Google::Cloud::Language::V1::Document::Type::PLAIN_TEXT +} + +options = Google::Gax::CallOptions.new timeout: 10_000 + +response = client.analyze_sentiment document, options: options +``` + +New: +``` +client = Google::Cloud::Language.new + +document = { + content: "I love API calls!", + type: Google::Cloud::Language::V1::Document::Type::PLAIN_TEXT +} +encoding = Google:Cloud::Language::V1::EncodingType::UTF8 + +# Use a hash to wrap the normal call arguments (or pass a request object), and +# then add further keyword arguments for the call options. +response = client.analyze_sentiment( + { document: document, encoding_type: encoding }, + timeout: 10_000 +) +``` + +### Class Namespaces + +In older releases, the client object was of class +`Google::Cloud::Language::V1::LanguageServiceClient`. +In the 1.0 release, the client object is of class +`Google::Cloud::Language::V1::LanguageService::Client`. +Note that most users will use the `Google::Cloud::Language.language_service` +factory method to create instances of the client object, so you may not need to +reference the actual class directly. + +In older releases, the credentials object was of class +`Google::Cloud::Language::V1::Credentials`. +In the 1.0 release, the credentials object is of class +`Google::Cloud::Language::V1::LanguageService::Credentials`. +Again, most users will not need to reference this class directly. diff --git a/google-cloud-language/README.md b/google-cloud-language/README.md index b5f9ffbaf010..5dc0a260a9f2 100644 --- a/google-cloud-language/README.md +++ b/google-cloud-language/README.md @@ -3,7 +3,7 @@ [Cloud Natural Language API][Product Documentation]: Provides natural language understanding technologies, such as sentiment analysis, entity recognition, entity sentiment analysis, and other text -annotations, to developers. +annotations. - [Client Library Documentation][] - [Product Documentation][] @@ -30,8 +30,17 @@ $ gem install google-cloud-language to see the full list of Cloud APIs that we cover. [Client Library Documentation]: https://googleapis.dev/ruby/google-cloud-language/latest +[V1 Client Documentation]: https://googleapis.dev/ruby/google-cloud-language-v1/latest +[V1beta2 Client Documentation]: https://googleapis.dev/ruby/google-cloud-language-v1beta2/latest [Product Documentation]: https://cloud.google.com/natural-language +## Migrating from 0.x versions + +The 1.0 release of the google-cloud-language client is a significant upgrade +based on a next-gen code generator. If you have used earlier versions of this +library, there have been a number of changes that may require updates to +calling code. See the MIGRATING.md document for more information. + ## Enabling Logging To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library. diff --git a/google-cloud-language/Rakefile b/google-cloud-language/Rakefile index 8b78eb558a99..32bfd304352a 100644 --- a/google-cloud-language/Rakefile +++ b/google-cloud-language/Rakefile @@ -20,6 +20,7 @@ RuboCop::RakeTask.new require "rake/testtask" desc "Run tests." Rake::TestTask.new do |t| + t.libs << "test" t.test_files = FileList["test/**/*_test.rb"] t.warning = false end @@ -79,9 +80,8 @@ task :acceptance, :project, :keyfile do |t, args| if project.nil? || keyfile.nil? fail "You must provide a project and keyfile. e.g. rake acceptance[test123, /path/to/keyfile.json] or LANGUAGE_TEST_PROJECT=test123 LANGUAGE_TEST_KEYFILE=/path/to/keyfile.json rake acceptance" end - require "google/cloud/language/v1/credentials" - (Google::Cloud::Language::V1::Credentials::PATH_ENV_VARS + - Google::Cloud::Language::V1::Credentials::JSON_ENV_VARS).each do |path| + require "google/cloud/language/v1/language_service/credentials" + Google::Cloud::Language::V1::LanguageService::Credentials.env_vars.each do |path| ENV[path] = nil end ENV["LANGUAGE_PROJECT"] = project diff --git a/google-cloud-language/acceptance/google/cloud/language/v1/language_service_smoke_test.rb b/google-cloud-language/acceptance/google/cloud/language/v1/language_service_smoke_test.rb index e1b142fa15be..7568e8efd516 100644 --- a/google-cloud-language/acceptance/google/cloud/language/v1/language_service_smoke_test.rb +++ b/google-cloud-language/acceptance/google/cloud/language/v1/language_service_smoke_test.rb @@ -12,8 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -# AUTO GENERATED BY GAPIC - require "simplecov" require "minitest/autorun" require "minitest/spec" @@ -22,11 +20,10 @@ describe "LanguageServiceSmokeTest v1" do it "runs one smoke test with analyze_sentiment" do - - language_service_client = Google::Cloud::Language.new(version: :v1) - content = "Hello, world!" - type = :PLAIN_TEXT - document = { content: content, type: type } - response = language_service_client.analyze_sentiment(document) + language_service_client = Google::Cloud::Language.language_service version: :v1 + document = { content: "Hello, world!", type: :PLAIN_TEXT } + response = language_service_client.analyze_sentiment document: document + response.document_sentiment.score.must_be_kind_of Numeric + response.language.must_equal "en" end end diff --git a/google-cloud-language/google-cloud-language.gemspec b/google-cloud-language/google-cloud-language.gemspec index 09bf96bc2082..8c9fc96c1d58 100644 --- a/google-cloud-language/google-cloud-language.gemspec +++ b/google-cloud-language/google-cloud-language.gemspec @@ -1,6 +1,7 @@ # -*- ruby -*- # encoding: utf-8 -require File.expand_path("../lib/google/cloud/language/version", __FILE__) + +require File.expand_path("lib/google/cloud/language/version", __dir__) Gem::Specification.new do |gem| gem.name = "google-cloud-language" @@ -16,18 +17,22 @@ Gem::Specification.new do |gem| gem.platform = Gem::Platform::RUBY gem.files = `git ls-files -- lib/*`.split("\n") + - ["README.md", "AUTHENTICATION.md", "LICENSE", ".yardopts"] + ["README.md", "AUTHENTICATION.md", "MIGRATING.md", "LICENSE", ".yardopts"] gem.require_paths = ["lib"] gem.required_ruby_version = ">= 2.4" - gem.add_dependency "google-gax", "~> 1.8" - gem.add_dependency "googleapis-common-protos", ">= 1.3.9", "< 2.0" - gem.add_dependency "googleapis-common-protos-types", ">= 1.0.4", "< 2.0" + gem.add_dependency "google-cloud-core", "~> 1.5" + gem.add_dependency "google-cloud-language-v1", "~> 0.0" + gem.add_dependency "google-cloud-language-v1beta2", "~> 0.0" + gem.add_development_dependency "autotest-suffix", "~> 1.1" + gem.add_development_dependency "google-style", "~> 1.24.0" gem.add_development_dependency "minitest", "~> 5.10" + gem.add_development_dependency "minitest-autotest", "~> 1.0" + gem.add_development_dependency "minitest-focus", "~> 1.1" + gem.add_development_dependency "minitest-rg", "~> 5.2" gem.add_development_dependency "redcarpet", "~> 3.0" - gem.add_development_dependency "google-style", "~> 1.24.0" gem.add_development_dependency "simplecov", "~> 0.9" gem.add_development_dependency "yard", "~> 0.9" end diff --git a/google-cloud-language/lib/google-cloud-language.rb b/google-cloud-language/lib/google-cloud-language.rb new file mode 100644 index 000000000000..fc986aca7a02 --- /dev/null +++ b/google-cloud-language/lib/google-cloud-language.rb @@ -0,0 +1,35 @@ +# Copyright 2020 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 here to be autorequired by bundler, but the library and all +# dependencies won't be loaded until required and used. + + +gem "google-cloud-core" +require "google/cloud" unless defined? Google::Cloud.new +require "google/cloud/config" +require "googleauth" + +# Set the default configuration +Google::Cloud.configure.add_config! :language do |config| + config.add_field! :credentials, nil, match: [String, Hash, Google::Auth::Credentials] + config.add_field! :lib_name, nil, match: String + config.add_field! :lib_version, nil, match: String + config.add_field! :interceptors, nil, match: Array + config.add_field! :timeout, nil, match: Numeric + config.add_field! :metadata, nil, match: Hash + config.add_field! :retry_policy, nil, match: [Hash, Proc] +end diff --git a/google-cloud-language/lib/google/cloud/language.rb b/google-cloud-language/lib/google/cloud/language.rb index bde8480e2de6..88cfad7bfed5 100644 --- a/google-cloud-language/lib/google/cloud/language.rb +++ b/google-cloud-language/lib/google/cloud/language.rb @@ -13,134 +13,53 @@ # limitations under the License. -require "google/gax" -require "pathname" +require "google-cloud-language" module Google module Cloud - # rubocop:disable LineLength - ## # # Ruby Client for Cloud Natural Language API - # - # [Cloud Natural Language API][Product Documentation]: - # Provides natural language understanding technologies, such as sentiment - # analysis, entity recognition, entity sentiment analysis, and other text - # annotations, to developers. - # - [Product Documentation][] - # - # ## Quick Start - # In order to use this library, you first need to go through the following - # steps: - # - # 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project) - # 2. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project) - # 3. [Enable the Cloud Natural Language API.](https://console.cloud.google.com/apis/library/language.googleapis.com) - # 4. [Setup Authentication.](https://googleapis.dev/ruby/google-cloud-language/latest/file.AUTHENTICATION.html) - # - # ### Installation - # ``` - # $ gem install google-cloud-language - # ``` - # - # ### Next Steps - # - Read the [Cloud Natural Language API Product documentation][Product Documentation] - # to learn more about the product and see How-to Guides. - # - View this [repository's main README](https://github.com/googleapis/google-cloud-ruby/blob/master/README.md) - # to see the full list of Cloud APIs that we cover. - # - # [Product Documentation]: https://cloud.google.com/natural-language - # - # ## Enabling Logging - # - # To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library. - # The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/stdlib-2.5.0/libdoc/logger/rdoc/Logger.html) as shown below, - # or a [`Google::Cloud::Logging::Logger`](https://googleapis.dev/ruby/google-cloud-logging/latest) - # that will write logs to [Stackdriver Logging](https://cloud.google.com/logging/). See [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb) - # and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information. - # - # Configuring a Ruby stdlib logger: - # - # ```ruby - # require "logger" - # - # module MyLogger - # LOGGER = Logger.new $stderr, level: Logger::WARN - # def logger - # LOGGER - # end - # end - # - # # Define a gRPC module-level logger method before grpc/logconfig.rb loads. - # module GRPC - # extend MyLogger - # end - # ``` - # module Language - # rubocop:enable LineLength - - FILE_DIR = File.realdirpath(Pathname.new(__FILE__).join("..").join("language")) + ## + # Create a new `LanguageService::Client` object. + # + # @param version [String, Symbol] The API version to create the client instance. Optional. If not provided + # defaults to `:v1`, which will return an instance of + # [Google::Cloud::Language::V1::LanguageService::Client](https://googleapis.dev/ruby/google-cloud-language-v1/latest/Google/Cloud/Language/V1/LanguageService/Client.html). + # + # @return [LanguageService::Client] A client object for the specified version. + # + def self.language_service version: :v1, &block + require "google/cloud/language/#{version.to_s.downcase}" - AVAILABLE_VERSIONS = Dir["#{FILE_DIR}/*"] - .select { |file| File.directory?(file) } - .select { |dir| Google::Gax::VERSION_MATCHER.match(File.basename(dir)) } - .select { |dir| File.exist?(dir + ".rb") } - .map { |dir| File.basename(dir) } + package_name = Google::Cloud::Language + .constants + .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") } + .first + package_module = Google::Cloud::Language.const_get package_name + package_module.const_get(:LanguageService).const_get(:Client).new(&block) + end ## - # Provides text analysis operations such as sentiment analysis and entity - # recognition. + # Configure the language library. + # + # The following configuration parameters are supported: + # + # * `credentials` - (String, Hash, Google::Auth::Credentials) The path to the keyfile as a String, the contents of + # the keyfile as a Hash, or a Google::Auth::Credentials object. + # * `lib_name` (String) + # * `lib_version` (String) + # * `interceptors` (Array) + # * `timeout` - (Integer) Default timeout to use in requests. + # * `metadata` (Hash) + # * `retry_policy` (Hash, Proc) + # + # @return [Google::Cloud::Config] The configuration object the Google::Cloud::Language library uses. # - # @param version [Symbol, String] - # The major version of the service to be used. By default :v1 - # is used. - # @overload new(version:, credentials:, scopes:, client_config:, timeout:) - # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc] - # Provides the means for authenticating requests made by the client. This parameter can - # be many types. - # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for - # authenticating requests made by this client. - # A `String` will be treated as the path to the keyfile to be used for the construction of - # credentials for this client. - # A `Hash` will be treated as the contents of a keyfile to be used for the construction of - # credentials for this client. - # A `GRPC::Core::Channel` will be used to make calls through. - # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials - # should already be composed with a `GRPC::Core::CallCredentials` object. - # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the - # metadata for requests, generally, to give OAuth credentials. - # @param scopes [Array] - # The OAuth scopes for this service. This parameter is ignored if - # an updater_proc is supplied. - # @param client_config [Hash] - # A Hash for call options for each method. See - # Google::Gax#construct_settings for the structure of - # this data. Falls back to the default config if not specified - # or the specified config is missing data points. - # @param timeout [Numeric] - # The default timeout, in seconds, for calls made through this client. - # @param metadata [Hash] - # Default metadata to be sent with each request. This can be overridden on a per call basis. - # @param service_address [String] - # Override for the service hostname, or `nil` to leave as the default. - # @param service_port [Integer] - # Override for the service port, or `nil` to leave as the default. - # @param exception_transformer [Proc] - # An optional proc that intercepts any exceptions raised during an API call to inject - # custom error handling. - def self.new(*args, version: :v1, **kwargs) - unless AVAILABLE_VERSIONS.include?(version.to_s.downcase) - raise "The version: #{version} is not available. The available versions " \ - "are: [#{AVAILABLE_VERSIONS.join(", ")}]" - end + def self.configure + yield Google::Cloud.configure.language if block_given? - require "#{FILE_DIR}/#{version.to_s.downcase}" - version_module = Google::Cloud::Language - .constants - .select {|sym| sym.to_s.downcase == version.to_s.downcase} - .first - Google::Cloud::Language.const_get(version_module).new(*args, **kwargs) + Google::Cloud.configure.language end end end diff --git a/google-cloud-language/lib/google/cloud/language/v1.rb b/google-cloud-language/lib/google/cloud/language/v1.rb deleted file mode 100644 index 51c55d0db4f3..000000000000 --- a/google-cloud-language/lib/google/cloud/language/v1.rb +++ /dev/null @@ -1,148 +0,0 @@ -# Copyright 2020 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. - - -require "google/cloud/language/v1/language_service_client" - -module Google - module Cloud - module Language - # rubocop:disable LineLength - - ## - # # Ruby Client for Cloud Natural Language API - # - # [Cloud Natural Language API][Product Documentation]: - # Provides natural language understanding technologies, such as sentiment - # analysis, entity recognition, entity sentiment analysis, and other text - # annotations, to developers. - # - [Product Documentation][] - # - # ## Quick Start - # In order to use this library, you first need to go through the following - # steps: - # - # 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project) - # 2. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project) - # 3. [Enable the Cloud Natural Language API.](https://console.cloud.google.com/apis/library/language.googleapis.com) - # 4. [Setup Authentication.](https://googleapis.dev/ruby/google-cloud-language/latest/file.AUTHENTICATION.html) - # - # ### Installation - # ``` - # $ gem install google-cloud-language - # ``` - # - # ### Next Steps - # - Read the [Cloud Natural Language API Product documentation][Product Documentation] - # to learn more about the product and see How-to Guides. - # - View this [repository's main README](https://github.com/googleapis/google-cloud-ruby/blob/master/README.md) - # to see the full list of Cloud APIs that we cover. - # - # [Product Documentation]: https://cloud.google.com/natural-language - # - # ## Enabling Logging - # - # To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library. - # The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/stdlib-2.5.0/libdoc/logger/rdoc/Logger.html) as shown below, - # or a [`Google::Cloud::Logging::Logger`](https://googleapis.dev/ruby/google-cloud-logging/latest) - # that will write logs to [Stackdriver Logging](https://cloud.google.com/logging/). See [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb) - # and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information. - # - # Configuring a Ruby stdlib logger: - # - # ```ruby - # require "logger" - # - # module MyLogger - # LOGGER = Logger.new $stderr, level: Logger::WARN - # def logger - # LOGGER - # end - # end - # - # # Define a gRPC module-level logger method before grpc/logconfig.rb loads. - # module GRPC - # extend MyLogger - # end - # ``` - # - module V1 - # rubocop:enable LineLength - - ## - # Provides text analysis operations such as sentiment analysis and entity - # recognition. - # - # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc] - # Provides the means for authenticating requests made by the client. This parameter can - # be many types. - # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for - # authenticating requests made by this client. - # A `String` will be treated as the path to the keyfile to be used for the construction of - # credentials for this client. - # A `Hash` will be treated as the contents of a keyfile to be used for the construction of - # credentials for this client. - # A `GRPC::Core::Channel` will be used to make calls through. - # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials - # should already be composed with a `GRPC::Core::CallCredentials` object. - # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the - # metadata for requests, generally, to give OAuth credentials. - # @param scopes [Array] - # The OAuth scopes for this service. This parameter is ignored if - # an updater_proc is supplied. - # @param client_config [Hash] - # A Hash for call options for each method. See - # Google::Gax#construct_settings for the structure of - # this data. Falls back to the default config if not specified - # or the specified config is missing data points. - # @param timeout [Numeric] - # The default timeout, in seconds, for calls made through this client. - # @param metadata [Hash] - # Default metadata to be sent with each request. This can be overridden on a per call basis. - # @param service_address [String] - # Override for the service hostname, or `nil` to leave as the default. - # @param service_port [Integer] - # Override for the service port, or `nil` to leave as the default. - # @param exception_transformer [Proc] - # An optional proc that intercepts any exceptions raised during an API call to inject - # custom error handling. - def self.new \ - credentials: nil, - scopes: nil, - client_config: nil, - timeout: nil, - metadata: nil, - service_address: nil, - service_port: nil, - exception_transformer: nil, - lib_name: nil, - lib_version: nil - kwargs = { - credentials: credentials, - scopes: scopes, - client_config: client_config, - timeout: timeout, - metadata: metadata, - exception_transformer: exception_transformer, - lib_name: lib_name, - service_address: service_address, - service_port: service_port, - lib_version: lib_version - }.select { |_, v| v != nil } - Google::Cloud::Language::V1::LanguageServiceClient.new(**kwargs) - end - end - end - end -end diff --git a/google-cloud-language/lib/google/cloud/language/v1/credentials.rb b/google-cloud-language/lib/google/cloud/language/v1/credentials.rb deleted file mode 100644 index 1c7efc65f310..000000000000 --- a/google-cloud-language/lib/google/cloud/language/v1/credentials.rb +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright 2020 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. - - -require "googleauth" - -module Google - module Cloud - module Language - module V1 - class Credentials < Google::Auth::Credentials - SCOPE = [ - "https://www.googleapis.com/auth/cloud-platform" - ].freeze - PATH_ENV_VARS = %w(LANGUAGE_CREDENTIALS - LANGUAGE_KEYFILE - GOOGLE_CLOUD_CREDENTIALS - GOOGLE_CLOUD_KEYFILE - GCLOUD_KEYFILE) - JSON_ENV_VARS = %w(LANGUAGE_CREDENTIALS_JSON - LANGUAGE_KEYFILE_JSON - GOOGLE_CLOUD_CREDENTIALS_JSON - GOOGLE_CLOUD_KEYFILE_JSON - GCLOUD_KEYFILE_JSON) - DEFAULT_PATHS = ["~/.config/gcloud/application_default_credentials.json"] - end - end - end - end -end diff --git a/google-cloud-language/lib/google/cloud/language/v1/doc/google/cloud/language/v1/language_service.rb b/google-cloud-language/lib/google/cloud/language/v1/doc/google/cloud/language/v1/language_service.rb deleted file mode 100644 index f5530294a2d0..000000000000 --- a/google-cloud-language/lib/google/cloud/language/v1/doc/google/cloud/language/v1/language_service.rb +++ /dev/null @@ -1,1039 +0,0 @@ -# Copyright 2020 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. - - -module Google - module Cloud - module Language - module V1 - # ================================================================ # - # - # Represents the input to API methods. - # @!attribute [rw] type - # @return [Google::Cloud::Language::V1::Document::Type] - # Required. If the type is not set or is `TYPE_UNSPECIFIED`, - # returns an `INVALID_ARGUMENT` error. - # @!attribute [rw] content - # @return [String] - # The content of the input in string format. - # Cloud audit logging exempt since it is based on user data. - # @!attribute [rw] gcs_content_uri - # @return [String] - # 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. - # @!attribute [rw] language - # @return [String] - # 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. - class Document - # The document types enum. - module Type - # The content type is not specified. - TYPE_UNSPECIFIED = 0 - - # Plain text - PLAIN_TEXT = 1 - - # HTML - HTML = 2 - end - end - - # Represents a sentence in the input document. - # @!attribute [rw] text - # @return [Google::Cloud::Language::V1::TextSpan] - # The sentence text. - # @!attribute [rw] sentiment - # @return [Google::Cloud::Language::V1::Sentiment] - # For calls to {AnalyzeSentiment} or if - # {Google::Cloud::Language::V1::AnnotateTextRequest::Features#extract_document_sentiment AnnotateTextRequest::Features#extract_document_sentiment} is set to - # true, this field will contain the sentiment for the sentence. - class Sentence; end - - # 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. - # @!attribute [rw] name - # @return [String] - # The representative name for the entity. - # @!attribute [rw] type - # @return [Google::Cloud::Language::V1::Entity::Type] - # The entity type. - # @!attribute [rw] metadata - # @return [Hash{String => String}] - # 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. - # @!attribute [rw] salience - # @return [Float] - # 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. - # @!attribute [rw] mentions - # @return [Array] - # The mentions of this entity in the input document. The API currently - # supports proper noun mentions. - # @!attribute [rw] sentiment - # @return [Google::Cloud::Language::V1::Sentiment] - # For calls to {AnalyzeEntitySentiment} or if - # {Google::Cloud::Language::V1::AnnotateTextRequest::Features#extract_entity_sentiment AnnotateTextRequest::Features#extract_entity_sentiment} is set to - # true, this field will contain the aggregate sentiment expressed for this - # entity in the provided document. - class 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. - module 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 - end - end - - # Represents the smallest syntactic building block of the text. - # @!attribute [rw] text - # @return [Google::Cloud::Language::V1::TextSpan] - # The token text. - # @!attribute [rw] part_of_speech - # @return [Google::Cloud::Language::V1::PartOfSpeech] - # Parts of speech tag for this token. - # @!attribute [rw] dependency_edge - # @return [Google::Cloud::Language::V1::DependencyEdge] - # Dependency tree parse for this token. - # @!attribute [rw] lemma - # @return [String] - # [Lemma](https://en.wikipedia.org/wiki/Lemma_%28morphology%29) of the token. - class Token; end - - # Represents the feeling associated with the entire text or entities in - # the text. - # @!attribute [rw] magnitude - # @return [Float] - # A non-negative number in the [0, +inf) range, which represents - # the absolute magnitude of sentiment regardless of score (positive or - # negative). - # @!attribute [rw] score - # @return [Float] - # Sentiment score between -1.0 (negative sentiment) and 1.0 - # (positive sentiment). - class Sentiment; end - - # 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 - # @!attribute [rw] tag - # @return [Google::Cloud::Language::V1::PartOfSpeech::Tag] - # The part of speech tag. - # @!attribute [rw] aspect - # @return [Google::Cloud::Language::V1::PartOfSpeech::Aspect] - # The grammatical aspect. - # @!attribute [rw] case - # @return [Google::Cloud::Language::V1::PartOfSpeech::Case] - # The grammatical case. - # @!attribute [rw] form - # @return [Google::Cloud::Language::V1::PartOfSpeech::Form] - # The grammatical form. - # @!attribute [rw] gender - # @return [Google::Cloud::Language::V1::PartOfSpeech::Gender] - # The grammatical gender. - # @!attribute [rw] mood - # @return [Google::Cloud::Language::V1::PartOfSpeech::Mood] - # The grammatical mood. - # @!attribute [rw] number - # @return [Google::Cloud::Language::V1::PartOfSpeech::Number] - # The grammatical number. - # @!attribute [rw] person - # @return [Google::Cloud::Language::V1::PartOfSpeech::Person] - # The grammatical person. - # @!attribute [rw] proper - # @return [Google::Cloud::Language::V1::PartOfSpeech::Proper] - # The grammatical properness. - # @!attribute [rw] reciprocity - # @return [Google::Cloud::Language::V1::PartOfSpeech::Reciprocity] - # The grammatical reciprocity. - # @!attribute [rw] tense - # @return [Google::Cloud::Language::V1::PartOfSpeech::Tense] - # The grammatical tense. - # @!attribute [rw] voice - # @return [Google::Cloud::Language::V1::PartOfSpeech::Voice] - # The grammatical voice. - class PartOfSpeech - # The characteristic of a verb that expresses time flow during an event. - module 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 - end - - # 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. - module 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 - end - - # 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 - module 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 - end - - # Gender classes of nouns reflected in the behaviour of associated words. - module 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 - end - - # The grammatical feature of verbs, used for showing modality and attitude. - module 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 - end - - # Count distinctions. - module 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 - end - - # The distinction between the speaker, second person, third person, etc. - module 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 - end - - # This category shows if the token is part of a proper name. - module Proper - # Proper is not applicable in the analyzed language or is not predicted. - PROPER_UNKNOWN = 0 - - # Proper - PROPER = 1 - - # Not proper - NOT_PROPER = 2 - end - - # Reciprocal features of a pronoun. - module Reciprocity - # Reciprocity is not applicable in the analyzed language or is not - # predicted. - RECIPROCITY_UNKNOWN = 0 - - # Reciprocal - RECIPROCAL = 1 - - # Non-reciprocal - NON_RECIPROCAL = 2 - end - - # The part of speech tags enum. - module 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 - end - - # Time reference. - module 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 - end - - # The relationship between the action that a verb expresses and the - # participants identified by its arguments. - module 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 - end - end - - # Represents dependency parse tree information for a token. (For more - # information on dependency labels, see - # http://www.aclweb.org/anthology/P13-2017 - # @!attribute [rw] head_token_index - # @return [Integer] - # 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. - # @!attribute [rw] label - # @return [Google::Cloud::Language::V1::DependencyEdge::Label] - # The parse label for the token. - class DependencyEdge - # The parse label enum for the token. - module 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 - end - end - - # Represents a mention for an entity in the text. Currently, proper noun - # mentions are supported. - # @!attribute [rw] text - # @return [Google::Cloud::Language::V1::TextSpan] - # The mention text. - # @!attribute [rw] type - # @return [Google::Cloud::Language::V1::EntityMention::Type] - # The type of the entity mention. - # @!attribute [rw] sentiment - # @return [Google::Cloud::Language::V1::Sentiment] - # For calls to {AnalyzeEntitySentiment} or if - # {Google::Cloud::Language::V1::AnnotateTextRequest::Features#extract_entity_sentiment 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. - class EntityMention - # The supported types of mentions. - module Type - # Unknown - TYPE_UNKNOWN = 0 - - # Proper name - PROPER = 1 - - # Common noun (or noun compound) - COMMON = 2 - end - end - - # Represents an output piece of text. - # @!attribute [rw] content - # @return [String] - # The content of the output text. - # @!attribute [rw] begin_offset - # @return [Integer] - # The API calculates the beginning offset of the content in the original - # document according to the {Google::Cloud::Language::V1::EncodingType EncodingType} specified in the API request. - class TextSpan; end - - # Represents a category returned from the text classifier. - # @!attribute [rw] name - # @return [String] - # The name of the category representing the document, from the [predefined - # taxonomy](/natural-language/docs/categories). - # @!attribute [rw] confidence - # @return [Float] - # The classifier's confidence of the category. Number represents how certain - # the classifier is that this category represents the given text. - class ClassificationCategory; end - - # The sentiment analysis request message. - # @!attribute [rw] document - # @return [Google::Cloud::Language::V1::Document] - # Input document. - # @!attribute [rw] encoding_type - # @return [Google::Cloud::Language::V1::EncodingType] - # The encoding type used by the API to calculate sentence offsets. - class AnalyzeSentimentRequest; end - - # The sentiment analysis response message. - # @!attribute [rw] document_sentiment - # @return [Google::Cloud::Language::V1::Sentiment] - # The overall sentiment of the input document. - # @!attribute [rw] language - # @return [String] - # 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 {Google::Cloud::Language::V1::Document#language Document#language} field for more details. - # @!attribute [rw] sentences - # @return [Array] - # The sentiment for all the sentences in the document. - class AnalyzeSentimentResponse; end - - # The entity-level sentiment analysis request message. - # @!attribute [rw] document - # @return [Google::Cloud::Language::V1::Document] - # Input document. - # @!attribute [rw] encoding_type - # @return [Google::Cloud::Language::V1::EncodingType] - # The encoding type used by the API to calculate offsets. - class AnalyzeEntitySentimentRequest; end - - # The entity-level sentiment analysis response message. - # @!attribute [rw] entities - # @return [Array] - # The recognized entities in the input document with associated sentiments. - # @!attribute [rw] language - # @return [String] - # 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 {Google::Cloud::Language::V1::Document#language Document#language} field for more details. - class AnalyzeEntitySentimentResponse; end - - # The entity analysis request message. - # @!attribute [rw] document - # @return [Google::Cloud::Language::V1::Document] - # Input document. - # @!attribute [rw] encoding_type - # @return [Google::Cloud::Language::V1::EncodingType] - # The encoding type used by the API to calculate offsets. - class AnalyzeEntitiesRequest; end - - # The entity analysis response message. - # @!attribute [rw] entities - # @return [Array] - # The recognized entities in the input document. - # @!attribute [rw] language - # @return [String] - # 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 {Google::Cloud::Language::V1::Document#language Document#language} field for more details. - class AnalyzeEntitiesResponse; end - - # The syntax analysis request message. - # @!attribute [rw] document - # @return [Google::Cloud::Language::V1::Document] - # Input document. - # @!attribute [rw] encoding_type - # @return [Google::Cloud::Language::V1::EncodingType] - # The encoding type used by the API to calculate offsets. - class AnalyzeSyntaxRequest; end - - # The syntax analysis response message. - # @!attribute [rw] sentences - # @return [Array] - # Sentences in the input document. - # @!attribute [rw] tokens - # @return [Array] - # Tokens, along with their syntactic information, in the input document. - # @!attribute [rw] language - # @return [String] - # 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 {Google::Cloud::Language::V1::Document#language Document#language} field for more details. - class AnalyzeSyntaxResponse; end - - # The document classification request message. - # @!attribute [rw] document - # @return [Google::Cloud::Language::V1::Document] - # Input document. - class ClassifyTextRequest; end - - # The document classification response message. - # @!attribute [rw] categories - # @return [Array] - # Categories representing the input document. - class ClassifyTextResponse; end - - # The request message for the text annotation API, which can perform multiple - # analysis types (sentiment, entities, and syntax) in one call. - # @!attribute [rw] document - # @return [Google::Cloud::Language::V1::Document] - # Input document. - # @!attribute [rw] features - # @return [Google::Cloud::Language::V1::AnnotateTextRequest::Features] - # The enabled features. - # @!attribute [rw] encoding_type - # @return [Google::Cloud::Language::V1::EncodingType] - # The encoding type used by the API to calculate offsets. - class AnnotateTextRequest - # All available features for sentiment, syntax, and semantic analysis. - # Setting each one to true will enable that specific analysis for the input. - # @!attribute [rw] extract_syntax - # @return [true, false] - # Extract syntax information. - # @!attribute [rw] extract_entities - # @return [true, false] - # Extract entities. - # @!attribute [rw] extract_document_sentiment - # @return [true, false] - # Extract document-level sentiment. - # @!attribute [rw] extract_entity_sentiment - # @return [true, false] - # Extract entities and their associated sentiment. - # @!attribute [rw] classify_text - # @return [true, false] - # Classify the full document into categories. - class Features; end - end - - # The text annotations response message. - # @!attribute [rw] sentences - # @return [Array] - # Sentences in the input document. Populated if the user enables - # {Google::Cloud::Language::V1::AnnotateTextRequest::Features#extract_syntax AnnotateTextRequest::Features#extract_syntax}. - # @!attribute [rw] tokens - # @return [Array] - # Tokens, along with their syntactic information, in the input document. - # Populated if the user enables - # {Google::Cloud::Language::V1::AnnotateTextRequest::Features#extract_syntax AnnotateTextRequest::Features#extract_syntax}. - # @!attribute [rw] entities - # @return [Array] - # Entities, along with their semantic information, in the input document. - # Populated if the user enables - # {Google::Cloud::Language::V1::AnnotateTextRequest::Features#extract_entities AnnotateTextRequest::Features#extract_entities}. - # @!attribute [rw] document_sentiment - # @return [Google::Cloud::Language::V1::Sentiment] - # The overall sentiment for the document. Populated if the user enables - # {Google::Cloud::Language::V1::AnnotateTextRequest::Features#extract_document_sentiment AnnotateTextRequest::Features#extract_document_sentiment}. - # @!attribute [rw] language - # @return [String] - # 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 {Google::Cloud::Language::V1::Document#language Document#language} field for more details. - # @!attribute [rw] categories - # @return [Array] - # Categories identified in the input document. - class AnnotateTextResponse; end - - # 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. - module 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 - end - end - end - end -end \ No newline at end of file diff --git a/google-cloud-language/lib/google/cloud/language/v1/language_service_client.rb b/google-cloud-language/lib/google/cloud/language/v1/language_service_client.rb deleted file mode 100644 index 446583b1705a..000000000000 --- a/google-cloud-language/lib/google/cloud/language/v1/language_service_client.rb +++ /dev/null @@ -1,451 +0,0 @@ -# Copyright 2020 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. -# -# EDITING INSTRUCTIONS -# This file was generated from the file -# https://github.com/googleapis/googleapis/blob/master/google/cloud/language/v1/language_service.proto, -# and updates to that file get reflected here through a refresh process. -# For the short term, the refresh process will only be runnable by Google -# engineers. - - -require "json" -require "pathname" - -require "google/gax" - -require "google/cloud/language/v1/language_service_pb" -require "google/cloud/language/v1/credentials" -require "google/cloud/language/version" - -module Google - module Cloud - module Language - module V1 - # Provides text analysis operations such as sentiment analysis and entity - # recognition. - # - # @!attribute [r] language_service_stub - # @return [Google::Cloud::Language::V1::LanguageService::Stub] - class LanguageServiceClient - # @private - attr_reader :language_service_stub - - # The default address of the service. - SERVICE_ADDRESS = "language.googleapis.com".freeze - - # The default port of the service. - DEFAULT_SERVICE_PORT = 443 - - # The default set of gRPC interceptors. - GRPC_INTERCEPTORS = [] - - DEFAULT_TIMEOUT = 30 - - # The scopes needed to make gRPC calls to all of the methods defined in - # this service. - ALL_SCOPES = [ - "https://www.googleapis.com/auth/cloud-language", - "https://www.googleapis.com/auth/cloud-platform" - ].freeze - - - # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc] - # Provides the means for authenticating requests made by the client. This parameter can - # be many types. - # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for - # authenticating requests made by this client. - # A `String` will be treated as the path to the keyfile to be used for the construction of - # credentials for this client. - # A `Hash` will be treated as the contents of a keyfile to be used for the construction of - # credentials for this client. - # A `GRPC::Core::Channel` will be used to make calls through. - # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials - # should already be composed with a `GRPC::Core::CallCredentials` object. - # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the - # metadata for requests, generally, to give OAuth credentials. - # @param scopes [Array] - # The OAuth scopes for this service. This parameter is ignored if - # an updater_proc is supplied. - # @param client_config [Hash] - # A Hash for call options for each method. See - # Google::Gax#construct_settings for the structure of - # this data. Falls back to the default config if not specified - # or the specified config is missing data points. - # @param timeout [Numeric] - # The default timeout, in seconds, for calls made through this client. - # @param metadata [Hash] - # Default metadata to be sent with each request. This can be overridden on a per call basis. - # @param service_address [String] - # Override for the service hostname, or `nil` to leave as the default. - # @param service_port [Integer] - # Override for the service port, or `nil` to leave as the default. - # @param exception_transformer [Proc] - # An optional proc that intercepts any exceptions raised during an API call to inject - # custom error handling. - def initialize \ - credentials: nil, - scopes: ALL_SCOPES, - client_config: {}, - timeout: DEFAULT_TIMEOUT, - metadata: nil, - service_address: nil, - service_port: nil, - exception_transformer: nil, - lib_name: nil, - lib_version: "" - # These require statements are intentionally placed here to initialize - # the gRPC module only when it's required. - # See https://github.com/googleapis/toolkit/issues/446 - require "google/gax/grpc" - require "google/cloud/language/v1/language_service_services_pb" - - credentials ||= Google::Cloud::Language::V1::Credentials.default - - if credentials.is_a?(String) || credentials.is_a?(Hash) - updater_proc = Google::Cloud::Language::V1::Credentials.new(credentials).updater_proc - end - if credentials.is_a?(GRPC::Core::Channel) - channel = credentials - end - if credentials.is_a?(GRPC::Core::ChannelCredentials) - chan_creds = credentials - end - if credentials.is_a?(Proc) - updater_proc = credentials - end - if credentials.is_a?(Google::Auth::Credentials) - updater_proc = credentials.updater_proc - end - - package_version = Google::Cloud::Language::VERSION - - google_api_client = "gl-ruby/#{RUBY_VERSION}" - google_api_client << " #{lib_name}/#{lib_version}" if lib_name - google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}" - google_api_client << " grpc/#{GRPC::VERSION}" - google_api_client.freeze - - headers = { :"x-goog-api-client" => google_api_client } - if credentials.respond_to?(:quota_project_id) && credentials.quota_project_id - headers[:"x-goog-user-project"] = credentials.quota_project_id - end - headers.merge!(metadata) unless metadata.nil? - client_config_file = Pathname.new(__dir__).join( - "language_service_client_config.json" - ) - defaults = client_config_file.open do |f| - Google::Gax.construct_settings( - "google.cloud.language.v1.LanguageService", - JSON.parse(f.read), - client_config, - Google::Gax::Grpc::STATUS_CODE_NAMES, - timeout, - errors: Google::Gax::Grpc::API_ERRORS, - metadata: headers - ) - end - - # Allow overriding the service path/port in subclasses. - service_path = service_address || self.class::SERVICE_ADDRESS - port = service_port || self.class::DEFAULT_SERVICE_PORT - interceptors = self.class::GRPC_INTERCEPTORS - @language_service_stub = Google::Gax::Grpc.create_stub( - service_path, - port, - chan_creds: chan_creds, - channel: channel, - updater_proc: updater_proc, - scopes: scopes, - interceptors: interceptors, - &Google::Cloud::Language::V1::LanguageService::Stub.method(:new) - ) - - @analyze_sentiment = Google::Gax.create_api_call( - @language_service_stub.method(:analyze_sentiment), - defaults["analyze_sentiment"], - exception_transformer: exception_transformer - ) - @analyze_entities = Google::Gax.create_api_call( - @language_service_stub.method(:analyze_entities), - defaults["analyze_entities"], - exception_transformer: exception_transformer - ) - @analyze_entity_sentiment = Google::Gax.create_api_call( - @language_service_stub.method(:analyze_entity_sentiment), - defaults["analyze_entity_sentiment"], - exception_transformer: exception_transformer - ) - @analyze_syntax = Google::Gax.create_api_call( - @language_service_stub.method(:analyze_syntax), - defaults["analyze_syntax"], - exception_transformer: exception_transformer - ) - @classify_text = Google::Gax.create_api_call( - @language_service_stub.method(:classify_text), - defaults["classify_text"], - exception_transformer: exception_transformer - ) - @annotate_text = Google::Gax.create_api_call( - @language_service_stub.method(:annotate_text), - defaults["annotate_text"], - exception_transformer: exception_transformer - ) - end - - # Service calls - - # Analyzes the sentiment of the provided text. - # - # @param document [Google::Cloud::Language::V1::Document | Hash] - # Input document. - # A hash of the same form as `Google::Cloud::Language::V1::Document` - # can also be provided. - # @param encoding_type [Google::Cloud::Language::V1::EncodingType] - # The encoding type used by the API to calculate sentence offsets. - # @param options [Google::Gax::CallOptions] - # Overrides the default settings for this call, e.g, timeout, - # retries, etc. - # @yield [result, operation] Access the result along with the RPC operation - # @yieldparam result [Google::Cloud::Language::V1::AnalyzeSentimentResponse] - # @yieldparam operation [GRPC::ActiveCall::Operation] - # @return [Google::Cloud::Language::V1::AnalyzeSentimentResponse] - # @raise [Google::Gax::GaxError] if the RPC is aborted. - # @example - # require "google/cloud/language" - # - # language_client = Google::Cloud::Language.new(version: :v1) - # - # # TODO: Initialize `document`: - # document = {} - # response = language_client.analyze_sentiment(document) - - def analyze_sentiment \ - document, - encoding_type: nil, - options: nil, - &block - req = { - document: document, - encoding_type: encoding_type - }.delete_if { |_, v| v.nil? } - req = Google::Gax::to_proto(req, Google::Cloud::Language::V1::AnalyzeSentimentRequest) - @analyze_sentiment.call(req, options, &block) - end - - # 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 document [Google::Cloud::Language::V1::Document | Hash] - # Input document. - # A hash of the same form as `Google::Cloud::Language::V1::Document` - # can also be provided. - # @param encoding_type [Google::Cloud::Language::V1::EncodingType] - # The encoding type used by the API to calculate offsets. - # @param options [Google::Gax::CallOptions] - # Overrides the default settings for this call, e.g, timeout, - # retries, etc. - # @yield [result, operation] Access the result along with the RPC operation - # @yieldparam result [Google::Cloud::Language::V1::AnalyzeEntitiesResponse] - # @yieldparam operation [GRPC::ActiveCall::Operation] - # @return [Google::Cloud::Language::V1::AnalyzeEntitiesResponse] - # @raise [Google::Gax::GaxError] if the RPC is aborted. - # @example - # require "google/cloud/language" - # - # language_client = Google::Cloud::Language.new(version: :v1) - # - # # TODO: Initialize `document`: - # document = {} - # response = language_client.analyze_entities(document) - - def analyze_entities \ - document, - encoding_type: nil, - options: nil, - &block - req = { - document: document, - encoding_type: encoding_type - }.delete_if { |_, v| v.nil? } - req = Google::Gax::to_proto(req, Google::Cloud::Language::V1::AnalyzeEntitiesRequest) - @analyze_entities.call(req, options, &block) - end - - # Finds entities, similar to {Google::Cloud::Language::V1::LanguageService::AnalyzeEntities AnalyzeEntities} in the text and analyzes - # sentiment associated with each entity and its mentions. - # - # @param document [Google::Cloud::Language::V1::Document | Hash] - # Input document. - # A hash of the same form as `Google::Cloud::Language::V1::Document` - # can also be provided. - # @param encoding_type [Google::Cloud::Language::V1::EncodingType] - # The encoding type used by the API to calculate offsets. - # @param options [Google::Gax::CallOptions] - # Overrides the default settings for this call, e.g, timeout, - # retries, etc. - # @yield [result, operation] Access the result along with the RPC operation - # @yieldparam result [Google::Cloud::Language::V1::AnalyzeEntitySentimentResponse] - # @yieldparam operation [GRPC::ActiveCall::Operation] - # @return [Google::Cloud::Language::V1::AnalyzeEntitySentimentResponse] - # @raise [Google::Gax::GaxError] if the RPC is aborted. - # @example - # require "google/cloud/language" - # - # language_client = Google::Cloud::Language.new(version: :v1) - # - # # TODO: Initialize `document`: - # document = {} - # response = language_client.analyze_entity_sentiment(document) - - def analyze_entity_sentiment \ - document, - encoding_type: nil, - options: nil, - &block - req = { - document: document, - encoding_type: encoding_type - }.delete_if { |_, v| v.nil? } - req = Google::Gax::to_proto(req, Google::Cloud::Language::V1::AnalyzeEntitySentimentRequest) - @analyze_entity_sentiment.call(req, options, &block) - end - - # Analyzes the syntax of the text and provides sentence boundaries and - # tokenization along with part of speech tags, dependency trees, and other - # properties. - # - # @param document [Google::Cloud::Language::V1::Document | Hash] - # Input document. - # A hash of the same form as `Google::Cloud::Language::V1::Document` - # can also be provided. - # @param encoding_type [Google::Cloud::Language::V1::EncodingType] - # The encoding type used by the API to calculate offsets. - # @param options [Google::Gax::CallOptions] - # Overrides the default settings for this call, e.g, timeout, - # retries, etc. - # @yield [result, operation] Access the result along with the RPC operation - # @yieldparam result [Google::Cloud::Language::V1::AnalyzeSyntaxResponse] - # @yieldparam operation [GRPC::ActiveCall::Operation] - # @return [Google::Cloud::Language::V1::AnalyzeSyntaxResponse] - # @raise [Google::Gax::GaxError] if the RPC is aborted. - # @example - # require "google/cloud/language" - # - # language_client = Google::Cloud::Language.new(version: :v1) - # - # # TODO: Initialize `document`: - # document = {} - # response = language_client.analyze_syntax(document) - - def analyze_syntax \ - document, - encoding_type: nil, - options: nil, - &block - req = { - document: document, - encoding_type: encoding_type - }.delete_if { |_, v| v.nil? } - req = Google::Gax::to_proto(req, Google::Cloud::Language::V1::AnalyzeSyntaxRequest) - @analyze_syntax.call(req, options, &block) - end - - # Classifies a document into categories. - # - # @param document [Google::Cloud::Language::V1::Document | Hash] - # Input document. - # A hash of the same form as `Google::Cloud::Language::V1::Document` - # can also be provided. - # @param options [Google::Gax::CallOptions] - # Overrides the default settings for this call, e.g, timeout, - # retries, etc. - # @yield [result, operation] Access the result along with the RPC operation - # @yieldparam result [Google::Cloud::Language::V1::ClassifyTextResponse] - # @yieldparam operation [GRPC::ActiveCall::Operation] - # @return [Google::Cloud::Language::V1::ClassifyTextResponse] - # @raise [Google::Gax::GaxError] if the RPC is aborted. - # @example - # require "google/cloud/language" - # - # language_client = Google::Cloud::Language.new(version: :v1) - # - # # TODO: Initialize `document`: - # document = {} - # response = language_client.classify_text(document) - - def classify_text \ - document, - options: nil, - &block - req = { - document: document - }.delete_if { |_, v| v.nil? } - req = Google::Gax::to_proto(req, Google::Cloud::Language::V1::ClassifyTextRequest) - @classify_text.call(req, options, &block) - end - - # A convenience method that provides all the features that analyzeSentiment, - # analyzeEntities, and analyzeSyntax provide in one call. - # - # @param document [Google::Cloud::Language::V1::Document | Hash] - # Input document. - # A hash of the same form as `Google::Cloud::Language::V1::Document` - # can also be provided. - # @param features [Google::Cloud::Language::V1::AnnotateTextRequest::Features | Hash] - # The enabled features. - # A hash of the same form as `Google::Cloud::Language::V1::AnnotateTextRequest::Features` - # can also be provided. - # @param encoding_type [Google::Cloud::Language::V1::EncodingType] - # The encoding type used by the API to calculate offsets. - # @param options [Google::Gax::CallOptions] - # Overrides the default settings for this call, e.g, timeout, - # retries, etc. - # @yield [result, operation] Access the result along with the RPC operation - # @yieldparam result [Google::Cloud::Language::V1::AnnotateTextResponse] - # @yieldparam operation [GRPC::ActiveCall::Operation] - # @return [Google::Cloud::Language::V1::AnnotateTextResponse] - # @raise [Google::Gax::GaxError] if the RPC is aborted. - # @example - # require "google/cloud/language" - # - # language_client = Google::Cloud::Language.new(version: :v1) - # - # # TODO: Initialize `document`: - # document = {} - # - # # TODO: Initialize `features`: - # features = {} - # response = language_client.annotate_text(document, features) - - def annotate_text \ - document, - features, - encoding_type: nil, - options: nil, - &block - req = { - document: document, - features: features, - encoding_type: encoding_type - }.delete_if { |_, v| v.nil? } - req = Google::Gax::to_proto(req, Google::Cloud::Language::V1::AnnotateTextRequest) - @annotate_text.call(req, options, &block) - end - end - end - end - end -end diff --git a/google-cloud-language/lib/google/cloud/language/v1/language_service_client_config.json b/google-cloud-language/lib/google/cloud/language/v1/language_service_client_config.json deleted file mode 100644 index d370c9322e79..000000000000 --- a/google-cloud-language/lib/google/cloud/language/v1/language_service_client_config.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "interfaces": { - "google.cloud.language.v1.LanguageService": { - "retry_codes": { - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "non_idempotent": [] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 20000, - "rpc_timeout_multiplier": 1.0, - "max_rpc_timeout_millis": 20000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "AnalyzeSentiment": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "AnalyzeEntities": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "AnalyzeEntitySentiment": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "AnalyzeSyntax": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ClassifyText": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "AnnotateText": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/google-cloud-language/lib/google/cloud/language/v1/language_service_pb.rb b/google-cloud-language/lib/google/cloud/language/v1/language_service_pb.rb deleted file mode 100644 index 516d409811f3..000000000000 --- a/google-cloud-language/lib/google/cloud/language/v1/language_service_pb.rb +++ /dev/null @@ -1,403 +0,0 @@ -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: google/cloud/language/v1/language_service.proto - - -require 'google/protobuf' - -require 'google/api/annotations_pb' -require 'google/api/client_pb' -require 'google/api/field_behavior_pb' -Google::Protobuf::DescriptorPool.generated_pool.build do - add_message "google.cloud.language.v1.Document" do - optional :type, :enum, 1, "google.cloud.language.v1.Document.Type" - optional :language, :string, 4 - oneof :source do - optional :content, :string, 2 - optional :gcs_content_uri, :string, 3 - end - end - add_enum "google.cloud.language.v1.Document.Type" do - value :TYPE_UNSPECIFIED, 0 - value :PLAIN_TEXT, 1 - value :HTML, 2 - end - add_message "google.cloud.language.v1.Sentence" do - optional :text, :message, 1, "google.cloud.language.v1.TextSpan" - optional :sentiment, :message, 2, "google.cloud.language.v1.Sentiment" - end - add_message "google.cloud.language.v1.Entity" do - optional :name, :string, 1 - optional :type, :enum, 2, "google.cloud.language.v1.Entity.Type" - map :metadata, :string, :string, 3 - optional :salience, :float, 4 - repeated :mentions, :message, 5, "google.cloud.language.v1.EntityMention" - optional :sentiment, :message, 6, "google.cloud.language.v1.Sentiment" - end - add_enum "google.cloud.language.v1.Entity.Type" do - value :UNKNOWN, 0 - value :PERSON, 1 - value :LOCATION, 2 - value :ORGANIZATION, 3 - value :EVENT, 4 - value :WORK_OF_ART, 5 - value :CONSUMER_GOOD, 6 - value :OTHER, 7 - value :PHONE_NUMBER, 9 - value :ADDRESS, 10 - value :DATE, 11 - value :NUMBER, 12 - value :PRICE, 13 - end - add_message "google.cloud.language.v1.Token" do - optional :text, :message, 1, "google.cloud.language.v1.TextSpan" - optional :part_of_speech, :message, 2, "google.cloud.language.v1.PartOfSpeech" - optional :dependency_edge, :message, 3, "google.cloud.language.v1.DependencyEdge" - optional :lemma, :string, 4 - end - add_message "google.cloud.language.v1.Sentiment" do - optional :magnitude, :float, 2 - optional :score, :float, 3 - end - add_message "google.cloud.language.v1.PartOfSpeech" do - optional :tag, :enum, 1, "google.cloud.language.v1.PartOfSpeech.Tag" - optional :aspect, :enum, 2, "google.cloud.language.v1.PartOfSpeech.Aspect" - optional :case, :enum, 3, "google.cloud.language.v1.PartOfSpeech.Case" - optional :form, :enum, 4, "google.cloud.language.v1.PartOfSpeech.Form" - optional :gender, :enum, 5, "google.cloud.language.v1.PartOfSpeech.Gender" - optional :mood, :enum, 6, "google.cloud.language.v1.PartOfSpeech.Mood" - optional :number, :enum, 7, "google.cloud.language.v1.PartOfSpeech.Number" - optional :person, :enum, 8, "google.cloud.language.v1.PartOfSpeech.Person" - optional :proper, :enum, 9, "google.cloud.language.v1.PartOfSpeech.Proper" - optional :reciprocity, :enum, 10, "google.cloud.language.v1.PartOfSpeech.Reciprocity" - optional :tense, :enum, 11, "google.cloud.language.v1.PartOfSpeech.Tense" - optional :voice, :enum, 12, "google.cloud.language.v1.PartOfSpeech.Voice" - end - add_enum "google.cloud.language.v1.PartOfSpeech.Tag" do - value :UNKNOWN, 0 - value :ADJ, 1 - value :ADP, 2 - value :ADV, 3 - value :CONJ, 4 - value :DET, 5 - value :NOUN, 6 - value :NUM, 7 - value :PRON, 8 - value :PRT, 9 - value :PUNCT, 10 - value :VERB, 11 - value :X, 12 - value :AFFIX, 13 - end - add_enum "google.cloud.language.v1.PartOfSpeech.Aspect" do - value :ASPECT_UNKNOWN, 0 - value :PERFECTIVE, 1 - value :IMPERFECTIVE, 2 - value :PROGRESSIVE, 3 - end - add_enum "google.cloud.language.v1.PartOfSpeech.Case" do - value :CASE_UNKNOWN, 0 - value :ACCUSATIVE, 1 - value :ADVERBIAL, 2 - value :COMPLEMENTIVE, 3 - value :DATIVE, 4 - value :GENITIVE, 5 - value :INSTRUMENTAL, 6 - value :LOCATIVE, 7 - value :NOMINATIVE, 8 - value :OBLIQUE, 9 - value :PARTITIVE, 10 - value :PREPOSITIONAL, 11 - value :REFLEXIVE_CASE, 12 - value :RELATIVE_CASE, 13 - value :VOCATIVE, 14 - end - add_enum "google.cloud.language.v1.PartOfSpeech.Form" do - value :FORM_UNKNOWN, 0 - value :ADNOMIAL, 1 - value :AUXILIARY, 2 - value :COMPLEMENTIZER, 3 - value :FINAL_ENDING, 4 - value :GERUND, 5 - value :REALIS, 6 - value :IRREALIS, 7 - value :SHORT, 8 - value :LONG, 9 - value :ORDER, 10 - value :SPECIFIC, 11 - end - add_enum "google.cloud.language.v1.PartOfSpeech.Gender" do - value :GENDER_UNKNOWN, 0 - value :FEMININE, 1 - value :MASCULINE, 2 - value :NEUTER, 3 - end - add_enum "google.cloud.language.v1.PartOfSpeech.Mood" do - value :MOOD_UNKNOWN, 0 - value :CONDITIONAL_MOOD, 1 - value :IMPERATIVE, 2 - value :INDICATIVE, 3 - value :INTERROGATIVE, 4 - value :JUSSIVE, 5 - value :SUBJUNCTIVE, 6 - end - add_enum "google.cloud.language.v1.PartOfSpeech.Number" do - value :NUMBER_UNKNOWN, 0 - value :SINGULAR, 1 - value :PLURAL, 2 - value :DUAL, 3 - end - add_enum "google.cloud.language.v1.PartOfSpeech.Person" do - value :PERSON_UNKNOWN, 0 - value :FIRST, 1 - value :SECOND, 2 - value :THIRD, 3 - value :REFLEXIVE_PERSON, 4 - end - add_enum "google.cloud.language.v1.PartOfSpeech.Proper" do - value :PROPER_UNKNOWN, 0 - value :PROPER, 1 - value :NOT_PROPER, 2 - end - add_enum "google.cloud.language.v1.PartOfSpeech.Reciprocity" do - value :RECIPROCITY_UNKNOWN, 0 - value :RECIPROCAL, 1 - value :NON_RECIPROCAL, 2 - end - add_enum "google.cloud.language.v1.PartOfSpeech.Tense" do - value :TENSE_UNKNOWN, 0 - value :CONDITIONAL_TENSE, 1 - value :FUTURE, 2 - value :PAST, 3 - value :PRESENT, 4 - value :IMPERFECT, 5 - value :PLUPERFECT, 6 - end - add_enum "google.cloud.language.v1.PartOfSpeech.Voice" do - value :VOICE_UNKNOWN, 0 - value :ACTIVE, 1 - value :CAUSATIVE, 2 - value :PASSIVE, 3 - end - add_message "google.cloud.language.v1.DependencyEdge" do - optional :head_token_index, :int32, 1 - optional :label, :enum, 2, "google.cloud.language.v1.DependencyEdge.Label" - end - add_enum "google.cloud.language.v1.DependencyEdge.Label" do - value :UNKNOWN, 0 - value :ABBREV, 1 - value :ACOMP, 2 - value :ADVCL, 3 - value :ADVMOD, 4 - value :AMOD, 5 - value :APPOS, 6 - value :ATTR, 7 - value :AUX, 8 - value :AUXPASS, 9 - value :CC, 10 - value :CCOMP, 11 - value :CONJ, 12 - value :CSUBJ, 13 - value :CSUBJPASS, 14 - value :DEP, 15 - value :DET, 16 - value :DISCOURSE, 17 - value :DOBJ, 18 - value :EXPL, 19 - value :GOESWITH, 20 - value :IOBJ, 21 - value :MARK, 22 - value :MWE, 23 - value :MWV, 24 - value :NEG, 25 - value :NN, 26 - value :NPADVMOD, 27 - value :NSUBJ, 28 - value :NSUBJPASS, 29 - value :NUM, 30 - value :NUMBER, 31 - value :P, 32 - value :PARATAXIS, 33 - value :PARTMOD, 34 - value :PCOMP, 35 - value :POBJ, 36 - value :POSS, 37 - value :POSTNEG, 38 - value :PRECOMP, 39 - value :PRECONJ, 40 - value :PREDET, 41 - value :PREF, 42 - value :PREP, 43 - value :PRONL, 44 - value :PRT, 45 - value :PS, 46 - value :QUANTMOD, 47 - value :RCMOD, 48 - value :RCMODREL, 49 - value :RDROP, 50 - value :REF, 51 - value :REMNANT, 52 - value :REPARANDUM, 53 - value :ROOT, 54 - value :SNUM, 55 - value :SUFF, 56 - value :TMOD, 57 - value :TOPIC, 58 - value :VMOD, 59 - value :VOCATIVE, 60 - value :XCOMP, 61 - value :SUFFIX, 62 - value :TITLE, 63 - value :ADVPHMOD, 64 - value :AUXCAUS, 65 - value :AUXVV, 66 - value :DTMOD, 67 - value :FOREIGN, 68 - value :KW, 69 - value :LIST, 70 - value :NOMC, 71 - value :NOMCSUBJ, 72 - value :NOMCSUBJPASS, 73 - value :NUMC, 74 - value :COP, 75 - value :DISLOCATED, 76 - value :ASP, 77 - value :GMOD, 78 - value :GOBJ, 79 - value :INFMOD, 80 - value :MES, 81 - value :NCOMP, 82 - end - add_message "google.cloud.language.v1.EntityMention" do - optional :text, :message, 1, "google.cloud.language.v1.TextSpan" - optional :type, :enum, 2, "google.cloud.language.v1.EntityMention.Type" - optional :sentiment, :message, 3, "google.cloud.language.v1.Sentiment" - end - add_enum "google.cloud.language.v1.EntityMention.Type" do - value :TYPE_UNKNOWN, 0 - value :PROPER, 1 - value :COMMON, 2 - end - add_message "google.cloud.language.v1.TextSpan" do - optional :content, :string, 1 - optional :begin_offset, :int32, 2 - end - add_message "google.cloud.language.v1.ClassificationCategory" do - optional :name, :string, 1 - optional :confidence, :float, 2 - end - add_message "google.cloud.language.v1.AnalyzeSentimentRequest" do - optional :document, :message, 1, "google.cloud.language.v1.Document" - optional :encoding_type, :enum, 2, "google.cloud.language.v1.EncodingType" - end - add_message "google.cloud.language.v1.AnalyzeSentimentResponse" do - optional :document_sentiment, :message, 1, "google.cloud.language.v1.Sentiment" - optional :language, :string, 2 - repeated :sentences, :message, 3, "google.cloud.language.v1.Sentence" - end - add_message "google.cloud.language.v1.AnalyzeEntitySentimentRequest" do - optional :document, :message, 1, "google.cloud.language.v1.Document" - optional :encoding_type, :enum, 2, "google.cloud.language.v1.EncodingType" - end - add_message "google.cloud.language.v1.AnalyzeEntitySentimentResponse" do - repeated :entities, :message, 1, "google.cloud.language.v1.Entity" - optional :language, :string, 2 - end - add_message "google.cloud.language.v1.AnalyzeEntitiesRequest" do - optional :document, :message, 1, "google.cloud.language.v1.Document" - optional :encoding_type, :enum, 2, "google.cloud.language.v1.EncodingType" - end - add_message "google.cloud.language.v1.AnalyzeEntitiesResponse" do - repeated :entities, :message, 1, "google.cloud.language.v1.Entity" - optional :language, :string, 2 - end - add_message "google.cloud.language.v1.AnalyzeSyntaxRequest" do - optional :document, :message, 1, "google.cloud.language.v1.Document" - optional :encoding_type, :enum, 2, "google.cloud.language.v1.EncodingType" - end - add_message "google.cloud.language.v1.AnalyzeSyntaxResponse" do - repeated :sentences, :message, 1, "google.cloud.language.v1.Sentence" - repeated :tokens, :message, 2, "google.cloud.language.v1.Token" - optional :language, :string, 3 - end - add_message "google.cloud.language.v1.ClassifyTextRequest" do - optional :document, :message, 1, "google.cloud.language.v1.Document" - end - add_message "google.cloud.language.v1.ClassifyTextResponse" do - repeated :categories, :message, 1, "google.cloud.language.v1.ClassificationCategory" - end - add_message "google.cloud.language.v1.AnnotateTextRequest" do - optional :document, :message, 1, "google.cloud.language.v1.Document" - optional :features, :message, 2, "google.cloud.language.v1.AnnotateTextRequest.Features" - optional :encoding_type, :enum, 3, "google.cloud.language.v1.EncodingType" - end - add_message "google.cloud.language.v1.AnnotateTextRequest.Features" do - optional :extract_syntax, :bool, 1 - optional :extract_entities, :bool, 2 - optional :extract_document_sentiment, :bool, 3 - optional :extract_entity_sentiment, :bool, 4 - optional :classify_text, :bool, 6 - end - add_message "google.cloud.language.v1.AnnotateTextResponse" do - repeated :sentences, :message, 1, "google.cloud.language.v1.Sentence" - repeated :tokens, :message, 2, "google.cloud.language.v1.Token" - repeated :entities, :message, 3, "google.cloud.language.v1.Entity" - optional :document_sentiment, :message, 4, "google.cloud.language.v1.Sentiment" - optional :language, :string, 5 - repeated :categories, :message, 6, "google.cloud.language.v1.ClassificationCategory" - end - add_enum "google.cloud.language.v1.EncodingType" do - value :NONE, 0 - value :UTF8, 1 - value :UTF16, 2 - value :UTF32, 3 - end -end - -module Google - module Cloud - module Language - module V1 - Document = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1.Document").msgclass - Document::Type = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1.Document.Type").enummodule - Sentence = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1.Sentence").msgclass - Entity = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1.Entity").msgclass - Entity::Type = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1.Entity.Type").enummodule - Token = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1.Token").msgclass - Sentiment = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1.Sentiment").msgclass - PartOfSpeech = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1.PartOfSpeech").msgclass - PartOfSpeech::Tag = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1.PartOfSpeech.Tag").enummodule - PartOfSpeech::Aspect = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1.PartOfSpeech.Aspect").enummodule - PartOfSpeech::Case = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1.PartOfSpeech.Case").enummodule - PartOfSpeech::Form = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1.PartOfSpeech.Form").enummodule - PartOfSpeech::Gender = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1.PartOfSpeech.Gender").enummodule - PartOfSpeech::Mood = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1.PartOfSpeech.Mood").enummodule - PartOfSpeech::Number = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1.PartOfSpeech.Number").enummodule - PartOfSpeech::Person = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1.PartOfSpeech.Person").enummodule - PartOfSpeech::Proper = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1.PartOfSpeech.Proper").enummodule - PartOfSpeech::Reciprocity = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1.PartOfSpeech.Reciprocity").enummodule - PartOfSpeech::Tense = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1.PartOfSpeech.Tense").enummodule - PartOfSpeech::Voice = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1.PartOfSpeech.Voice").enummodule - DependencyEdge = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1.DependencyEdge").msgclass - DependencyEdge::Label = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1.DependencyEdge.Label").enummodule - EntityMention = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1.EntityMention").msgclass - EntityMention::Type = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1.EntityMention.Type").enummodule - TextSpan = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1.TextSpan").msgclass - ClassificationCategory = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1.ClassificationCategory").msgclass - AnalyzeSentimentRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1.AnalyzeSentimentRequest").msgclass - AnalyzeSentimentResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1.AnalyzeSentimentResponse").msgclass - AnalyzeEntitySentimentRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1.AnalyzeEntitySentimentRequest").msgclass - AnalyzeEntitySentimentResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1.AnalyzeEntitySentimentResponse").msgclass - AnalyzeEntitiesRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1.AnalyzeEntitiesRequest").msgclass - AnalyzeEntitiesResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1.AnalyzeEntitiesResponse").msgclass - AnalyzeSyntaxRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1.AnalyzeSyntaxRequest").msgclass - AnalyzeSyntaxResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1.AnalyzeSyntaxResponse").msgclass - ClassifyTextRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1.ClassifyTextRequest").msgclass - ClassifyTextResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1.ClassifyTextResponse").msgclass - AnnotateTextRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1.AnnotateTextRequest").msgclass - AnnotateTextRequest::Features = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1.AnnotateTextRequest.Features").msgclass - AnnotateTextResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1.AnnotateTextResponse").msgclass - EncodingType = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1.EncodingType").enummodule - end - end - end -end diff --git a/google-cloud-language/lib/google/cloud/language/v1/language_service_services_pb.rb b/google-cloud-language/lib/google/cloud/language/v1/language_service_services_pb.rb deleted file mode 100644 index bf442d74b2e3..000000000000 --- a/google-cloud-language/lib/google/cloud/language/v1/language_service_services_pb.rb +++ /dev/null @@ -1,64 +0,0 @@ -# Generated by the protocol buffer compiler. DO NOT EDIT! -# Source: google/cloud/language/v1/language_service.proto for package 'google.cloud.language.v1' -# Original file comments: -# 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. -# -# - - -require 'grpc' -require 'google/cloud/language/v1/language_service_pb' - -module Google - module Cloud - module Language - module V1 - module LanguageService - # Provides text analysis operations such as sentiment analysis and entity - # recognition. - class Service - - include GRPC::GenericService - - self.marshal_class_method = :encode - self.unmarshal_class_method = :decode - self.service_name = 'google.cloud.language.v1.LanguageService' - - # Analyzes the sentiment of the provided text. - rpc :AnalyzeSentiment, AnalyzeSentimentRequest, AnalyzeSentimentResponse - # 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, AnalyzeEntitiesResponse - # 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, AnalyzeEntitySentimentResponse - # 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, AnalyzeSyntaxResponse - # Classifies a document into categories. - rpc :ClassifyText, ClassifyTextRequest, ClassifyTextResponse - # A convenience method that provides all the features that analyzeSentiment, - # analyzeEntities, and analyzeSyntax provide in one call. - rpc :AnnotateText, AnnotateTextRequest, AnnotateTextResponse - end - - Stub = Service.rpc_stub_class - end - end - end - end -end diff --git a/google-cloud-language/lib/google/cloud/language/v1beta2.rb b/google-cloud-language/lib/google/cloud/language/v1beta2.rb deleted file mode 100644 index 1ebbde10e8d9..000000000000 --- a/google-cloud-language/lib/google/cloud/language/v1beta2.rb +++ /dev/null @@ -1,160 +0,0 @@ -# Copyright 2020 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. - - -require "google/cloud/language/v1beta2/language_service_client" - -module Google - module Cloud - module Language - # rubocop:disable LineLength - - ## - # # Ruby Client for Google Cloud Natural Language API - # - # [Google Cloud Natural Language API][Product Documentation]: - # Google Cloud Natural Language API provides natural language understanding - # technologies to developers. Examples include sentiment analysis, entity - # recognition, and text annotations. - # - [Product Documentation][] - # - # ## Quick Start - # In order to use this library, you first need to go through the following - # steps: - # - # 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project) - # 2. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project) - # 3. [Enable the Google Cloud Natural Language API.](https://console.cloud.google.com/apis/library/language.googleapis.com) - # 4. [Setup Authentication.](https://googleapis.dev/ruby/google-cloud-language/latest/file.AUTHENTICATION.html) - # - # ### Installation - # ``` - # $ gem install google-cloud-language - # ``` - # - # ### Preview - # #### LanguageServiceClient - # ```rb - # require "google/cloud/language" - # - # language_client = Google::Cloud::Language.new(version: :v1beta2) - # content = "Hello, world!" - # type = :PLAIN_TEXT - # document = { content: content, type: type } - # response = language_client.analyze_sentiment(document) - # ``` - # - # ### Next Steps - # - Read the [Google Cloud Natural Language API Product documentation][Product Documentation] - # to learn more about the product and see How-to Guides. - # - View this [repository's main README](https://github.com/googleapis/google-cloud-ruby/blob/master/README.md) - # to see the full list of Cloud APIs that we cover. - # - # [Product Documentation]: https://cloud.google.com/natural-language - # - # ## Enabling Logging - # - # To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library. - # The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/stdlib-2.5.0/libdoc/logger/rdoc/Logger.html) as shown below, - # or a [`Google::Cloud::Logging::Logger`](https://googleapis.dev/ruby/google-cloud-logging/latest) - # that will write logs to [Stackdriver Logging](https://cloud.google.com/logging/). See [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb) - # and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information. - # - # Configuring a Ruby stdlib logger: - # - # ```ruby - # require "logger" - # - # module MyLogger - # LOGGER = Logger.new $stderr, level: Logger::WARN - # def logger - # LOGGER - # end - # end - # - # # Define a gRPC module-level logger method before grpc/logconfig.rb loads. - # module GRPC - # extend MyLogger - # end - # ``` - # - module V1beta2 - # rubocop:enable LineLength - - ## - # Provides text analysis operations such as sentiment analysis and entity - # recognition. - # - # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc] - # Provides the means for authenticating requests made by the client. This parameter can - # be many types. - # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for - # authenticating requests made by this client. - # A `String` will be treated as the path to the keyfile to be used for the construction of - # credentials for this client. - # A `Hash` will be treated as the contents of a keyfile to be used for the construction of - # credentials for this client. - # A `GRPC::Core::Channel` will be used to make calls through. - # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials - # should already be composed with a `GRPC::Core::CallCredentials` object. - # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the - # metadata for requests, generally, to give OAuth credentials. - # @param scopes [Array] - # The OAuth scopes for this service. This parameter is ignored if - # an updater_proc is supplied. - # @param client_config [Hash] - # A Hash for call options for each method. See - # Google::Gax#construct_settings for the structure of - # this data. Falls back to the default config if not specified - # or the specified config is missing data points. - # @param timeout [Numeric] - # The default timeout, in seconds, for calls made through this client. - # @param metadata [Hash] - # Default metadata to be sent with each request. This can be overridden on a per call basis. - # @param service_address [String] - # Override for the service hostname, or `nil` to leave as the default. - # @param service_port [Integer] - # Override for the service port, or `nil` to leave as the default. - # @param exception_transformer [Proc] - # An optional proc that intercepts any exceptions raised during an API call to inject - # custom error handling. - def self.new \ - credentials: nil, - scopes: nil, - client_config: nil, - timeout: nil, - metadata: nil, - service_address: nil, - service_port: nil, - exception_transformer: nil, - lib_name: nil, - lib_version: nil - kwargs = { - credentials: credentials, - scopes: scopes, - client_config: client_config, - timeout: timeout, - metadata: metadata, - exception_transformer: exception_transformer, - lib_name: lib_name, - service_address: service_address, - service_port: service_port, - lib_version: lib_version - }.select { |_, v| v != nil } - Google::Cloud::Language::V1beta2::LanguageServiceClient.new(**kwargs) - end - end - end - end -end diff --git a/google-cloud-language/lib/google/cloud/language/v1beta2/credentials.rb b/google-cloud-language/lib/google/cloud/language/v1beta2/credentials.rb deleted file mode 100644 index 89d4ddcbf1a9..000000000000 --- a/google-cloud-language/lib/google/cloud/language/v1beta2/credentials.rb +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright 2020 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. - - -require "googleauth" - -module Google - module Cloud - module Language - module V1beta2 - class Credentials < Google::Auth::Credentials - SCOPE = [ - "https://www.googleapis.com/auth/cloud-platform" - ].freeze - PATH_ENV_VARS = %w(LANGUAGE_CREDENTIALS - LANGUAGE_KEYFILE - GOOGLE_CLOUD_CREDENTIALS - GOOGLE_CLOUD_KEYFILE - GCLOUD_KEYFILE) - JSON_ENV_VARS = %w(LANGUAGE_CREDENTIALS_JSON - LANGUAGE_KEYFILE_JSON - GOOGLE_CLOUD_CREDENTIALS_JSON - GOOGLE_CLOUD_KEYFILE_JSON - GCLOUD_KEYFILE_JSON) - DEFAULT_PATHS = ["~/.config/gcloud/application_default_credentials.json"] - end - end - end - end -end diff --git a/google-cloud-language/lib/google/cloud/language/v1beta2/doc/google/cloud/language/v1beta2/language_service.rb b/google-cloud-language/lib/google/cloud/language/v1beta2/doc/google/cloud/language/v1beta2/language_service.rb deleted file mode 100644 index f1433fd0ee70..000000000000 --- a/google-cloud-language/lib/google/cloud/language/v1beta2/doc/google/cloud/language/v1beta2/language_service.rb +++ /dev/null @@ -1,1049 +0,0 @@ -# Copyright 2020 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. - - -module Google - module Cloud - module Language - module V1beta2 - # ================================================================ # - # - # Represents the input to API methods. - # @!attribute [rw] type - # @return [Google::Cloud::Language::V1beta2::Document::Type] - # Required. If the type is not set or is `TYPE_UNSPECIFIED`, - # returns an `INVALID_ARGUMENT` error. - # @!attribute [rw] content - # @return [String] - # The content of the input in string format. - # Cloud audit logging exempt since it is based on user data. - # @!attribute [rw] gcs_content_uri - # @return [String] - # 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. - # @!attribute [rw] language - # @return [String] - # 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. - class Document - # The document types enum. - module Type - # The content type is not specified. - TYPE_UNSPECIFIED = 0 - - # Plain text - PLAIN_TEXT = 1 - - # HTML - HTML = 2 - end - end - - # Represents a sentence in the input document. - # @!attribute [rw] text - # @return [Google::Cloud::Language::V1beta2::TextSpan] - # The sentence text. - # @!attribute [rw] sentiment - # @return [Google::Cloud::Language::V1beta2::Sentiment] - # For calls to {AnalyzeSentiment} or if - # {Google::Cloud::Language::V1beta2::AnnotateTextRequest::Features#extract_document_sentiment AnnotateTextRequest::Features#extract_document_sentiment} is set to - # true, this field will contain the sentiment for the sentence. - class Sentence; end - - # 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. - # @!attribute [rw] name - # @return [String] - # The representative name for the entity. - # @!attribute [rw] type - # @return [Google::Cloud::Language::V1beta2::Entity::Type] - # The entity type. - # @!attribute [rw] metadata - # @return [Hash{String => String}] - # 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. - # @!attribute [rw] salience - # @return [Float] - # 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. - # @!attribute [rw] mentions - # @return [Array] - # The mentions of this entity in the input document. The API currently - # supports proper noun mentions. - # @!attribute [rw] sentiment - # @return [Google::Cloud::Language::V1beta2::Sentiment] - # For calls to {AnalyzeEntitySentiment} or if - # {Google::Cloud::Language::V1beta2::AnnotateTextRequest::Features#extract_entity_sentiment AnnotateTextRequest::Features#extract_entity_sentiment} is set to - # true, this field will contain the aggregate sentiment expressed for this - # entity in the provided document. - class 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. - module 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 - end - end - - # Represents the smallest syntactic building block of the text. - # @!attribute [rw] text - # @return [Google::Cloud::Language::V1beta2::TextSpan] - # The token text. - # @!attribute [rw] part_of_speech - # @return [Google::Cloud::Language::V1beta2::PartOfSpeech] - # Parts of speech tag for this token. - # @!attribute [rw] dependency_edge - # @return [Google::Cloud::Language::V1beta2::DependencyEdge] - # Dependency tree parse for this token. - # @!attribute [rw] lemma - # @return [String] - # [Lemma](https://en.wikipedia.org/wiki/Lemma_%28morphology%29) of the token. - class Token; end - - # Represents the feeling associated with the entire text or entities in - # the text. - # Next ID: 6 - # @!attribute [rw] magnitude - # @return [Float] - # A non-negative number in the [0, +inf) range, which represents - # the absolute magnitude of sentiment regardless of score (positive or - # negative). - # @!attribute [rw] score - # @return [Float] - # Sentiment score between -1.0 (negative sentiment) and 1.0 - # (positive sentiment). - class Sentiment; end - - # Represents part of speech information for a token. - # @!attribute [rw] tag - # @return [Google::Cloud::Language::V1beta2::PartOfSpeech::Tag] - # The part of speech tag. - # @!attribute [rw] aspect - # @return [Google::Cloud::Language::V1beta2::PartOfSpeech::Aspect] - # The grammatical aspect. - # @!attribute [rw] case - # @return [Google::Cloud::Language::V1beta2::PartOfSpeech::Case] - # The grammatical case. - # @!attribute [rw] form - # @return [Google::Cloud::Language::V1beta2::PartOfSpeech::Form] - # The grammatical form. - # @!attribute [rw] gender - # @return [Google::Cloud::Language::V1beta2::PartOfSpeech::Gender] - # The grammatical gender. - # @!attribute [rw] mood - # @return [Google::Cloud::Language::V1beta2::PartOfSpeech::Mood] - # The grammatical mood. - # @!attribute [rw] number - # @return [Google::Cloud::Language::V1beta2::PartOfSpeech::Number] - # The grammatical number. - # @!attribute [rw] person - # @return [Google::Cloud::Language::V1beta2::PartOfSpeech::Person] - # The grammatical person. - # @!attribute [rw] proper - # @return [Google::Cloud::Language::V1beta2::PartOfSpeech::Proper] - # The grammatical properness. - # @!attribute [rw] reciprocity - # @return [Google::Cloud::Language::V1beta2::PartOfSpeech::Reciprocity] - # The grammatical reciprocity. - # @!attribute [rw] tense - # @return [Google::Cloud::Language::V1beta2::PartOfSpeech::Tense] - # The grammatical tense. - # @!attribute [rw] voice - # @return [Google::Cloud::Language::V1beta2::PartOfSpeech::Voice] - # The grammatical voice. - class PartOfSpeech - # The characteristic of a verb that expresses time flow during an event. - module 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 - end - - # 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. - module 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 - end - - # 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 - module 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 - end - - # Gender classes of nouns reflected in the behaviour of associated words. - module 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 - end - - # The grammatical feature of verbs, used for showing modality and attitude. - module 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 - end - - # Count distinctions. - module 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 - end - - # The distinction between the speaker, second person, third person, etc. - module 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 - end - - # This category shows if the token is part of a proper name. - module Proper - # Proper is not applicable in the analyzed language or is not predicted. - PROPER_UNKNOWN = 0 - - # Proper - PROPER = 1 - - # Not proper - NOT_PROPER = 2 - end - - # Reciprocal features of a pronoun. - module Reciprocity - # Reciprocity is not applicable in the analyzed language or is not - # predicted. - RECIPROCITY_UNKNOWN = 0 - - # Reciprocal - RECIPROCAL = 1 - - # Non-reciprocal - NON_RECIPROCAL = 2 - end - - # The part of speech tags enum. - module 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 - end - - # Time reference. - module 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 - end - - # The relationship between the action that a verb expresses and the - # participants identified by its arguments. - module 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 - end - end - - # Represents dependency parse tree information for a token. - # @!attribute [rw] head_token_index - # @return [Integer] - # 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. - # @!attribute [rw] label - # @return [Google::Cloud::Language::V1beta2::DependencyEdge::Label] - # The parse label for the token. - class DependencyEdge - # The parse label enum for the token. - module 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 - end - end - - # Represents a mention for an entity in the text. Currently, proper noun - # mentions are supported. - # @!attribute [rw] text - # @return [Google::Cloud::Language::V1beta2::TextSpan] - # The mention text. - # @!attribute [rw] type - # @return [Google::Cloud::Language::V1beta2::EntityMention::Type] - # The type of the entity mention. - # @!attribute [rw] sentiment - # @return [Google::Cloud::Language::V1beta2::Sentiment] - # For calls to {AnalyzeEntitySentiment} or if - # {Google::Cloud::Language::V1beta2::AnnotateTextRequest::Features#extract_entity_sentiment 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. - class EntityMention - # The supported types of mentions. - module Type - # Unknown - TYPE_UNKNOWN = 0 - - # Proper name - PROPER = 1 - - # Common noun (or noun compound) - COMMON = 2 - end - end - - # Represents an output piece of text. - # @!attribute [rw] content - # @return [String] - # The content of the output text. - # @!attribute [rw] begin_offset - # @return [Integer] - # The API calculates the beginning offset of the content in the original - # document according to the {Google::Cloud::Language::V1beta2::EncodingType EncodingType} specified in the API request. - class TextSpan; end - - # Represents a category returned from the text classifier. - # @!attribute [rw] name - # @return [String] - # The name of the category representing the document, from the [predefined - # taxonomy](/natural-language/docs/categories). - # @!attribute [rw] confidence - # @return [Float] - # The classifier's confidence of the category. Number represents how certain - # the classifier is that this category represents the given text. - class ClassificationCategory; end - - # The sentiment analysis request message. - # @!attribute [rw] document - # @return [Google::Cloud::Language::V1beta2::Document] - # Required. Input document. - # @!attribute [rw] encoding_type - # @return [Google::Cloud::Language::V1beta2::EncodingType] - # The encoding type used by the API to calculate sentence offsets for the - # sentence sentiment. - class AnalyzeSentimentRequest; end - - # The sentiment analysis response message. - # @!attribute [rw] document_sentiment - # @return [Google::Cloud::Language::V1beta2::Sentiment] - # The overall sentiment of the input document. - # @!attribute [rw] language - # @return [String] - # 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 {Google::Cloud::Language::V1beta2::Document#language Document#language} field for more details. - # @!attribute [rw] sentences - # @return [Array] - # The sentiment for all the sentences in the document. - class AnalyzeSentimentResponse; end - - # The entity-level sentiment analysis request message. - # @!attribute [rw] document - # @return [Google::Cloud::Language::V1beta2::Document] - # Required. Input document. - # @!attribute [rw] encoding_type - # @return [Google::Cloud::Language::V1beta2::EncodingType] - # The encoding type used by the API to calculate offsets. - class AnalyzeEntitySentimentRequest; end - - # The entity-level sentiment analysis response message. - # @!attribute [rw] entities - # @return [Array] - # The recognized entities in the input document with associated sentiments. - # @!attribute [rw] language - # @return [String] - # 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 {Google::Cloud::Language::V1beta2::Document#language Document#language} field for more details. - class AnalyzeEntitySentimentResponse; end - - # The entity analysis request message. - # @!attribute [rw] document - # @return [Google::Cloud::Language::V1beta2::Document] - # Required. Input document. - # @!attribute [rw] encoding_type - # @return [Google::Cloud::Language::V1beta2::EncodingType] - # The encoding type used by the API to calculate offsets. - class AnalyzeEntitiesRequest; end - - # The entity analysis response message. - # @!attribute [rw] entities - # @return [Array] - # The recognized entities in the input document. - # @!attribute [rw] language - # @return [String] - # 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 {Google::Cloud::Language::V1beta2::Document#language Document#language} field for more details. - class AnalyzeEntitiesResponse; end - - # The syntax analysis request message. - # @!attribute [rw] document - # @return [Google::Cloud::Language::V1beta2::Document] - # Required. Input document. - # @!attribute [rw] encoding_type - # @return [Google::Cloud::Language::V1beta2::EncodingType] - # The encoding type used by the API to calculate offsets. - class AnalyzeSyntaxRequest; end - - # The syntax analysis response message. - # @!attribute [rw] sentences - # @return [Array] - # Sentences in the input document. - # @!attribute [rw] tokens - # @return [Array] - # Tokens, along with their syntactic information, in the input document. - # @!attribute [rw] language - # @return [String] - # 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 {Google::Cloud::Language::V1beta2::Document#language Document#language} field for more details. - class AnalyzeSyntaxResponse; end - - # The document classification request message. - # @!attribute [rw] document - # @return [Google::Cloud::Language::V1beta2::Document] - # Required. Input document. - class ClassifyTextRequest; end - - # The document classification response message. - # @!attribute [rw] categories - # @return [Array] - # Categories representing the input document. - class ClassifyTextResponse; end - - # The request message for the text annotation API, which can perform multiple - # analysis types (sentiment, entities, and syntax) in one call. - # @!attribute [rw] document - # @return [Google::Cloud::Language::V1beta2::Document] - # Required. Input document. - # @!attribute [rw] features - # @return [Google::Cloud::Language::V1beta2::AnnotateTextRequest::Features] - # Required. The enabled features. - # @!attribute [rw] encoding_type - # @return [Google::Cloud::Language::V1beta2::EncodingType] - # The encoding type used by the API to calculate offsets. - class 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 - # @!attribute [rw] extract_syntax - # @return [true, false] - # Extract syntax information. - # @!attribute [rw] extract_entities - # @return [true, false] - # Extract entities. - # @!attribute [rw] extract_document_sentiment - # @return [true, false] - # Extract document-level sentiment. - # @!attribute [rw] extract_entity_sentiment - # @return [true, false] - # Extract entities and their associated sentiment. - # @!attribute [rw] classify_text - # @return [true, false] - # 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). - class Features; end - end - - # The text annotations response message. - # @!attribute [rw] sentences - # @return [Array] - # Sentences in the input document. Populated if the user enables - # {Google::Cloud::Language::V1beta2::AnnotateTextRequest::Features#extract_syntax AnnotateTextRequest::Features#extract_syntax}. - # @!attribute [rw] tokens - # @return [Array] - # Tokens, along with their syntactic information, in the input document. - # Populated if the user enables - # {Google::Cloud::Language::V1beta2::AnnotateTextRequest::Features#extract_syntax AnnotateTextRequest::Features#extract_syntax}. - # @!attribute [rw] entities - # @return [Array] - # Entities, along with their semantic information, in the input document. - # Populated if the user enables - # {Google::Cloud::Language::V1beta2::AnnotateTextRequest::Features#extract_entities AnnotateTextRequest::Features#extract_entities}. - # @!attribute [rw] document_sentiment - # @return [Google::Cloud::Language::V1beta2::Sentiment] - # The overall sentiment for the document. Populated if the user enables - # {Google::Cloud::Language::V1beta2::AnnotateTextRequest::Features#extract_document_sentiment AnnotateTextRequest::Features#extract_document_sentiment}. - # @!attribute [rw] language - # @return [String] - # 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 {Google::Cloud::Language::V1beta2::Document#language Document#language} field for more details. - # @!attribute [rw] categories - # @return [Array] - # Categories identified in the input document. - class AnnotateTextResponse; end - - # 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. - module 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 - end - end - end - end -end \ No newline at end of file diff --git a/google-cloud-language/lib/google/cloud/language/v1beta2/language_service_client.rb b/google-cloud-language/lib/google/cloud/language/v1beta2/language_service_client.rb deleted file mode 100644 index 513142b2d242..000000000000 --- a/google-cloud-language/lib/google/cloud/language/v1beta2/language_service_client.rb +++ /dev/null @@ -1,451 +0,0 @@ -# Copyright 2020 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. -# -# EDITING INSTRUCTIONS -# This file was generated from the file -# https://github.com/googleapis/googleapis/blob/master/google/cloud/language/v1beta2/language_service.proto, -# and updates to that file get reflected here through a refresh process. -# For the short term, the refresh process will only be runnable by Google -# engineers. - - -require "json" -require "pathname" - -require "google/gax" - -require "google/cloud/language/v1beta2/language_service_pb" -require "google/cloud/language/v1beta2/credentials" -require "google/cloud/language/version" - -module Google - module Cloud - module Language - module V1beta2 - # Provides text analysis operations such as sentiment analysis and entity - # recognition. - # - # @!attribute [r] language_service_stub - # @return [Google::Cloud::Language::V1beta2::LanguageService::Stub] - class LanguageServiceClient - # @private - attr_reader :language_service_stub - - # The default address of the service. - SERVICE_ADDRESS = "language.googleapis.com".freeze - - # The default port of the service. - DEFAULT_SERVICE_PORT = 443 - - # The default set of gRPC interceptors. - GRPC_INTERCEPTORS = [] - - DEFAULT_TIMEOUT = 30 - - # The scopes needed to make gRPC calls to all of the methods defined in - # this service. - ALL_SCOPES = [ - "https://www.googleapis.com/auth/cloud-platform" - ].freeze - - - # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc] - # Provides the means for authenticating requests made by the client. This parameter can - # be many types. - # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for - # authenticating requests made by this client. - # A `String` will be treated as the path to the keyfile to be used for the construction of - # credentials for this client. - # A `Hash` will be treated as the contents of a keyfile to be used for the construction of - # credentials for this client. - # A `GRPC::Core::Channel` will be used to make calls through. - # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials - # should already be composed with a `GRPC::Core::CallCredentials` object. - # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the - # metadata for requests, generally, to give OAuth credentials. - # @param scopes [Array] - # The OAuth scopes for this service. This parameter is ignored if - # an updater_proc is supplied. - # @param client_config [Hash] - # A Hash for call options for each method. See - # Google::Gax#construct_settings for the structure of - # this data. Falls back to the default config if not specified - # or the specified config is missing data points. - # @param timeout [Numeric] - # The default timeout, in seconds, for calls made through this client. - # @param metadata [Hash] - # Default metadata to be sent with each request. This can be overridden on a per call basis. - # @param service_address [String] - # Override for the service hostname, or `nil` to leave as the default. - # @param service_port [Integer] - # Override for the service port, or `nil` to leave as the default. - # @param exception_transformer [Proc] - # An optional proc that intercepts any exceptions raised during an API call to inject - # custom error handling. - def initialize \ - credentials: nil, - scopes: ALL_SCOPES, - client_config: {}, - timeout: DEFAULT_TIMEOUT, - metadata: nil, - service_address: nil, - service_port: nil, - exception_transformer: nil, - lib_name: nil, - lib_version: "" - # These require statements are intentionally placed here to initialize - # the gRPC module only when it's required. - # See https://github.com/googleapis/toolkit/issues/446 - require "google/gax/grpc" - require "google/cloud/language/v1beta2/language_service_services_pb" - - credentials ||= Google::Cloud::Language::V1beta2::Credentials.default - - if credentials.is_a?(String) || credentials.is_a?(Hash) - updater_proc = Google::Cloud::Language::V1beta2::Credentials.new(credentials).updater_proc - end - if credentials.is_a?(GRPC::Core::Channel) - channel = credentials - end - if credentials.is_a?(GRPC::Core::ChannelCredentials) - chan_creds = credentials - end - if credentials.is_a?(Proc) - updater_proc = credentials - end - if credentials.is_a?(Google::Auth::Credentials) - updater_proc = credentials.updater_proc - end - - package_version = Google::Cloud::Language::VERSION - - google_api_client = "gl-ruby/#{RUBY_VERSION}" - google_api_client << " #{lib_name}/#{lib_version}" if lib_name - google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}" - google_api_client << " grpc/#{GRPC::VERSION}" - google_api_client.freeze - - headers = { :"x-goog-api-client" => google_api_client } - if credentials.respond_to?(:quota_project_id) && credentials.quota_project_id - headers[:"x-goog-user-project"] = credentials.quota_project_id - end - headers.merge!(metadata) unless metadata.nil? - client_config_file = Pathname.new(__dir__).join( - "language_service_client_config.json" - ) - defaults = client_config_file.open do |f| - Google::Gax.construct_settings( - "google.cloud.language.v1beta2.LanguageService", - JSON.parse(f.read), - client_config, - Google::Gax::Grpc::STATUS_CODE_NAMES, - timeout, - errors: Google::Gax::Grpc::API_ERRORS, - metadata: headers - ) - end - - # Allow overriding the service path/port in subclasses. - service_path = service_address || self.class::SERVICE_ADDRESS - port = service_port || self.class::DEFAULT_SERVICE_PORT - interceptors = self.class::GRPC_INTERCEPTORS - @language_service_stub = Google::Gax::Grpc.create_stub( - service_path, - port, - chan_creds: chan_creds, - channel: channel, - updater_proc: updater_proc, - scopes: scopes, - interceptors: interceptors, - &Google::Cloud::Language::V1beta2::LanguageService::Stub.method(:new) - ) - - @analyze_sentiment = Google::Gax.create_api_call( - @language_service_stub.method(:analyze_sentiment), - defaults["analyze_sentiment"], - exception_transformer: exception_transformer - ) - @analyze_entities = Google::Gax.create_api_call( - @language_service_stub.method(:analyze_entities), - defaults["analyze_entities"], - exception_transformer: exception_transformer - ) - @analyze_entity_sentiment = Google::Gax.create_api_call( - @language_service_stub.method(:analyze_entity_sentiment), - defaults["analyze_entity_sentiment"], - exception_transformer: exception_transformer - ) - @analyze_syntax = Google::Gax.create_api_call( - @language_service_stub.method(:analyze_syntax), - defaults["analyze_syntax"], - exception_transformer: exception_transformer - ) - @classify_text = Google::Gax.create_api_call( - @language_service_stub.method(:classify_text), - defaults["classify_text"], - exception_transformer: exception_transformer - ) - @annotate_text = Google::Gax.create_api_call( - @language_service_stub.method(:annotate_text), - defaults["annotate_text"], - exception_transformer: exception_transformer - ) - end - - # Service calls - - # Analyzes the sentiment of the provided text. - # - # @param document [Google::Cloud::Language::V1beta2::Document | Hash] - # Required. Input document. - # A hash of the same form as `Google::Cloud::Language::V1beta2::Document` - # can also be provided. - # @param encoding_type [Google::Cloud::Language::V1beta2::EncodingType] - # The encoding type used by the API to calculate sentence offsets for the - # sentence sentiment. - # @param options [Google::Gax::CallOptions] - # Overrides the default settings for this call, e.g, timeout, - # retries, etc. - # @yield [result, operation] Access the result along with the RPC operation - # @yieldparam result [Google::Cloud::Language::V1beta2::AnalyzeSentimentResponse] - # @yieldparam operation [GRPC::ActiveCall::Operation] - # @return [Google::Cloud::Language::V1beta2::AnalyzeSentimentResponse] - # @raise [Google::Gax::GaxError] if the RPC is aborted. - # @example - # require "google/cloud/language" - # - # language_client = Google::Cloud::Language.new(version: :v1beta2) - # - # # TODO: Initialize `document`: - # document = {} - # response = language_client.analyze_sentiment(document) - - def analyze_sentiment \ - document, - encoding_type: nil, - options: nil, - &block - req = { - document: document, - encoding_type: encoding_type - }.delete_if { |_, v| v.nil? } - req = Google::Gax::to_proto(req, Google::Cloud::Language::V1beta2::AnalyzeSentimentRequest) - @analyze_sentiment.call(req, options, &block) - end - - # 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 document [Google::Cloud::Language::V1beta2::Document | Hash] - # Required. Input document. - # A hash of the same form as `Google::Cloud::Language::V1beta2::Document` - # can also be provided. - # @param encoding_type [Google::Cloud::Language::V1beta2::EncodingType] - # The encoding type used by the API to calculate offsets. - # @param options [Google::Gax::CallOptions] - # Overrides the default settings for this call, e.g, timeout, - # retries, etc. - # @yield [result, operation] Access the result along with the RPC operation - # @yieldparam result [Google::Cloud::Language::V1beta2::AnalyzeEntitiesResponse] - # @yieldparam operation [GRPC::ActiveCall::Operation] - # @return [Google::Cloud::Language::V1beta2::AnalyzeEntitiesResponse] - # @raise [Google::Gax::GaxError] if the RPC is aborted. - # @example - # require "google/cloud/language" - # - # language_client = Google::Cloud::Language.new(version: :v1beta2) - # - # # TODO: Initialize `document`: - # document = {} - # response = language_client.analyze_entities(document) - - def analyze_entities \ - document, - encoding_type: nil, - options: nil, - &block - req = { - document: document, - encoding_type: encoding_type - }.delete_if { |_, v| v.nil? } - req = Google::Gax::to_proto(req, Google::Cloud::Language::V1beta2::AnalyzeEntitiesRequest) - @analyze_entities.call(req, options, &block) - end - - # Finds entities, similar to {Google::Cloud::Language::V1beta2::LanguageService::AnalyzeEntities AnalyzeEntities} in the text and analyzes - # sentiment associated with each entity and its mentions. - # - # @param document [Google::Cloud::Language::V1beta2::Document | Hash] - # Required. Input document. - # A hash of the same form as `Google::Cloud::Language::V1beta2::Document` - # can also be provided. - # @param encoding_type [Google::Cloud::Language::V1beta2::EncodingType] - # The encoding type used by the API to calculate offsets. - # @param options [Google::Gax::CallOptions] - # Overrides the default settings for this call, e.g, timeout, - # retries, etc. - # @yield [result, operation] Access the result along with the RPC operation - # @yieldparam result [Google::Cloud::Language::V1beta2::AnalyzeEntitySentimentResponse] - # @yieldparam operation [GRPC::ActiveCall::Operation] - # @return [Google::Cloud::Language::V1beta2::AnalyzeEntitySentimentResponse] - # @raise [Google::Gax::GaxError] if the RPC is aborted. - # @example - # require "google/cloud/language" - # - # language_client = Google::Cloud::Language.new(version: :v1beta2) - # - # # TODO: Initialize `document`: - # document = {} - # response = language_client.analyze_entity_sentiment(document) - - def analyze_entity_sentiment \ - document, - encoding_type: nil, - options: nil, - &block - req = { - document: document, - encoding_type: encoding_type - }.delete_if { |_, v| v.nil? } - req = Google::Gax::to_proto(req, Google::Cloud::Language::V1beta2::AnalyzeEntitySentimentRequest) - @analyze_entity_sentiment.call(req, options, &block) - end - - # Analyzes the syntax of the text and provides sentence boundaries and - # tokenization along with part-of-speech tags, dependency trees, and other - # properties. - # - # @param document [Google::Cloud::Language::V1beta2::Document | Hash] - # Required. Input document. - # A hash of the same form as `Google::Cloud::Language::V1beta2::Document` - # can also be provided. - # @param encoding_type [Google::Cloud::Language::V1beta2::EncodingType] - # The encoding type used by the API to calculate offsets. - # @param options [Google::Gax::CallOptions] - # Overrides the default settings for this call, e.g, timeout, - # retries, etc. - # @yield [result, operation] Access the result along with the RPC operation - # @yieldparam result [Google::Cloud::Language::V1beta2::AnalyzeSyntaxResponse] - # @yieldparam operation [GRPC::ActiveCall::Operation] - # @return [Google::Cloud::Language::V1beta2::AnalyzeSyntaxResponse] - # @raise [Google::Gax::GaxError] if the RPC is aborted. - # @example - # require "google/cloud/language" - # - # language_client = Google::Cloud::Language.new(version: :v1beta2) - # - # # TODO: Initialize `document`: - # document = {} - # response = language_client.analyze_syntax(document) - - def analyze_syntax \ - document, - encoding_type: nil, - options: nil, - &block - req = { - document: document, - encoding_type: encoding_type - }.delete_if { |_, v| v.nil? } - req = Google::Gax::to_proto(req, Google::Cloud::Language::V1beta2::AnalyzeSyntaxRequest) - @analyze_syntax.call(req, options, &block) - end - - # Classifies a document into categories. - # - # @param document [Google::Cloud::Language::V1beta2::Document | Hash] - # Required. Input document. - # A hash of the same form as `Google::Cloud::Language::V1beta2::Document` - # can also be provided. - # @param options [Google::Gax::CallOptions] - # Overrides the default settings for this call, e.g, timeout, - # retries, etc. - # @yield [result, operation] Access the result along with the RPC operation - # @yieldparam result [Google::Cloud::Language::V1beta2::ClassifyTextResponse] - # @yieldparam operation [GRPC::ActiveCall::Operation] - # @return [Google::Cloud::Language::V1beta2::ClassifyTextResponse] - # @raise [Google::Gax::GaxError] if the RPC is aborted. - # @example - # require "google/cloud/language" - # - # language_client = Google::Cloud::Language.new(version: :v1beta2) - # - # # TODO: Initialize `document`: - # document = {} - # response = language_client.classify_text(document) - - def classify_text \ - document, - options: nil, - &block - req = { - document: document - }.delete_if { |_, v| v.nil? } - req = Google::Gax::to_proto(req, Google::Cloud::Language::V1beta2::ClassifyTextRequest) - @classify_text.call(req, options, &block) - end - - # A convenience method that provides all syntax, sentiment, entity, and - # classification features in one call. - # - # @param document [Google::Cloud::Language::V1beta2::Document | Hash] - # Required. Input document. - # A hash of the same form as `Google::Cloud::Language::V1beta2::Document` - # can also be provided. - # @param features [Google::Cloud::Language::V1beta2::AnnotateTextRequest::Features | Hash] - # Required. The enabled features. - # A hash of the same form as `Google::Cloud::Language::V1beta2::AnnotateTextRequest::Features` - # can also be provided. - # @param encoding_type [Google::Cloud::Language::V1beta2::EncodingType] - # The encoding type used by the API to calculate offsets. - # @param options [Google::Gax::CallOptions] - # Overrides the default settings for this call, e.g, timeout, - # retries, etc. - # @yield [result, operation] Access the result along with the RPC operation - # @yieldparam result [Google::Cloud::Language::V1beta2::AnnotateTextResponse] - # @yieldparam operation [GRPC::ActiveCall::Operation] - # @return [Google::Cloud::Language::V1beta2::AnnotateTextResponse] - # @raise [Google::Gax::GaxError] if the RPC is aborted. - # @example - # require "google/cloud/language" - # - # language_client = Google::Cloud::Language.new(version: :v1beta2) - # - # # TODO: Initialize `document`: - # document = {} - # - # # TODO: Initialize `features`: - # features = {} - # response = language_client.annotate_text(document, features) - - def annotate_text \ - document, - features, - encoding_type: nil, - options: nil, - &block - req = { - document: document, - features: features, - encoding_type: encoding_type - }.delete_if { |_, v| v.nil? } - req = Google::Gax::to_proto(req, Google::Cloud::Language::V1beta2::AnnotateTextRequest) - @annotate_text.call(req, options, &block) - end - end - end - end - end -end diff --git a/google-cloud-language/lib/google/cloud/language/v1beta2/language_service_client_config.json b/google-cloud-language/lib/google/cloud/language/v1beta2/language_service_client_config.json deleted file mode 100644 index 100eba5ffde5..000000000000 --- a/google-cloud-language/lib/google/cloud/language/v1beta2/language_service_client_config.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "interfaces": { - "google.cloud.language.v1beta2.LanguageService": { - "retry_codes": { - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "non_idempotent": [] - }, - "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.0, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "AnalyzeSentiment": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "AnalyzeEntities": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "AnalyzeEntitySentiment": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "AnalyzeSyntax": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ClassifyText": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "AnnotateText": { - "timeout_millis": 30000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/google-cloud-language/lib/google/cloud/language/v1beta2/language_service_pb.rb b/google-cloud-language/lib/google/cloud/language/v1beta2/language_service_pb.rb deleted file mode 100644 index 4befd799e58f..000000000000 --- a/google-cloud-language/lib/google/cloud/language/v1beta2/language_service_pb.rb +++ /dev/null @@ -1,404 +0,0 @@ -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: google/cloud/language/v1beta2/language_service.proto - - -require 'google/protobuf' - -require 'google/api/annotations_pb' -require 'google/api/client_pb' -require 'google/api/field_behavior_pb' -require 'google/protobuf/timestamp_pb' -Google::Protobuf::DescriptorPool.generated_pool.build do - add_message "google.cloud.language.v1beta2.Document" do - optional :type, :enum, 1, "google.cloud.language.v1beta2.Document.Type" - optional :language, :string, 4 - oneof :source do - optional :content, :string, 2 - optional :gcs_content_uri, :string, 3 - end - end - add_enum "google.cloud.language.v1beta2.Document.Type" do - value :TYPE_UNSPECIFIED, 0 - value :PLAIN_TEXT, 1 - value :HTML, 2 - end - add_message "google.cloud.language.v1beta2.Sentence" do - optional :text, :message, 1, "google.cloud.language.v1beta2.TextSpan" - optional :sentiment, :message, 2, "google.cloud.language.v1beta2.Sentiment" - end - add_message "google.cloud.language.v1beta2.Entity" do - optional :name, :string, 1 - optional :type, :enum, 2, "google.cloud.language.v1beta2.Entity.Type" - map :metadata, :string, :string, 3 - optional :salience, :float, 4 - repeated :mentions, :message, 5, "google.cloud.language.v1beta2.EntityMention" - optional :sentiment, :message, 6, "google.cloud.language.v1beta2.Sentiment" - end - add_enum "google.cloud.language.v1beta2.Entity.Type" do - value :UNKNOWN, 0 - value :PERSON, 1 - value :LOCATION, 2 - value :ORGANIZATION, 3 - value :EVENT, 4 - value :WORK_OF_ART, 5 - value :CONSUMER_GOOD, 6 - value :OTHER, 7 - value :PHONE_NUMBER, 9 - value :ADDRESS, 10 - value :DATE, 11 - value :NUMBER, 12 - value :PRICE, 13 - end - add_message "google.cloud.language.v1beta2.Token" do - optional :text, :message, 1, "google.cloud.language.v1beta2.TextSpan" - optional :part_of_speech, :message, 2, "google.cloud.language.v1beta2.PartOfSpeech" - optional :dependency_edge, :message, 3, "google.cloud.language.v1beta2.DependencyEdge" - optional :lemma, :string, 4 - end - add_message "google.cloud.language.v1beta2.Sentiment" do - optional :magnitude, :float, 2 - optional :score, :float, 3 - end - add_message "google.cloud.language.v1beta2.PartOfSpeech" do - optional :tag, :enum, 1, "google.cloud.language.v1beta2.PartOfSpeech.Tag" - optional :aspect, :enum, 2, "google.cloud.language.v1beta2.PartOfSpeech.Aspect" - optional :case, :enum, 3, "google.cloud.language.v1beta2.PartOfSpeech.Case" - optional :form, :enum, 4, "google.cloud.language.v1beta2.PartOfSpeech.Form" - optional :gender, :enum, 5, "google.cloud.language.v1beta2.PartOfSpeech.Gender" - optional :mood, :enum, 6, "google.cloud.language.v1beta2.PartOfSpeech.Mood" - optional :number, :enum, 7, "google.cloud.language.v1beta2.PartOfSpeech.Number" - optional :person, :enum, 8, "google.cloud.language.v1beta2.PartOfSpeech.Person" - optional :proper, :enum, 9, "google.cloud.language.v1beta2.PartOfSpeech.Proper" - optional :reciprocity, :enum, 10, "google.cloud.language.v1beta2.PartOfSpeech.Reciprocity" - optional :tense, :enum, 11, "google.cloud.language.v1beta2.PartOfSpeech.Tense" - optional :voice, :enum, 12, "google.cloud.language.v1beta2.PartOfSpeech.Voice" - end - add_enum "google.cloud.language.v1beta2.PartOfSpeech.Tag" do - value :UNKNOWN, 0 - value :ADJ, 1 - value :ADP, 2 - value :ADV, 3 - value :CONJ, 4 - value :DET, 5 - value :NOUN, 6 - value :NUM, 7 - value :PRON, 8 - value :PRT, 9 - value :PUNCT, 10 - value :VERB, 11 - value :X, 12 - value :AFFIX, 13 - end - add_enum "google.cloud.language.v1beta2.PartOfSpeech.Aspect" do - value :ASPECT_UNKNOWN, 0 - value :PERFECTIVE, 1 - value :IMPERFECTIVE, 2 - value :PROGRESSIVE, 3 - end - add_enum "google.cloud.language.v1beta2.PartOfSpeech.Case" do - value :CASE_UNKNOWN, 0 - value :ACCUSATIVE, 1 - value :ADVERBIAL, 2 - value :COMPLEMENTIVE, 3 - value :DATIVE, 4 - value :GENITIVE, 5 - value :INSTRUMENTAL, 6 - value :LOCATIVE, 7 - value :NOMINATIVE, 8 - value :OBLIQUE, 9 - value :PARTITIVE, 10 - value :PREPOSITIONAL, 11 - value :REFLEXIVE_CASE, 12 - value :RELATIVE_CASE, 13 - value :VOCATIVE, 14 - end - add_enum "google.cloud.language.v1beta2.PartOfSpeech.Form" do - value :FORM_UNKNOWN, 0 - value :ADNOMIAL, 1 - value :AUXILIARY, 2 - value :COMPLEMENTIZER, 3 - value :FINAL_ENDING, 4 - value :GERUND, 5 - value :REALIS, 6 - value :IRREALIS, 7 - value :SHORT, 8 - value :LONG, 9 - value :ORDER, 10 - value :SPECIFIC, 11 - end - add_enum "google.cloud.language.v1beta2.PartOfSpeech.Gender" do - value :GENDER_UNKNOWN, 0 - value :FEMININE, 1 - value :MASCULINE, 2 - value :NEUTER, 3 - end - add_enum "google.cloud.language.v1beta2.PartOfSpeech.Mood" do - value :MOOD_UNKNOWN, 0 - value :CONDITIONAL_MOOD, 1 - value :IMPERATIVE, 2 - value :INDICATIVE, 3 - value :INTERROGATIVE, 4 - value :JUSSIVE, 5 - value :SUBJUNCTIVE, 6 - end - add_enum "google.cloud.language.v1beta2.PartOfSpeech.Number" do - value :NUMBER_UNKNOWN, 0 - value :SINGULAR, 1 - value :PLURAL, 2 - value :DUAL, 3 - end - add_enum "google.cloud.language.v1beta2.PartOfSpeech.Person" do - value :PERSON_UNKNOWN, 0 - value :FIRST, 1 - value :SECOND, 2 - value :THIRD, 3 - value :REFLEXIVE_PERSON, 4 - end - add_enum "google.cloud.language.v1beta2.PartOfSpeech.Proper" do - value :PROPER_UNKNOWN, 0 - value :PROPER, 1 - value :NOT_PROPER, 2 - end - add_enum "google.cloud.language.v1beta2.PartOfSpeech.Reciprocity" do - value :RECIPROCITY_UNKNOWN, 0 - value :RECIPROCAL, 1 - value :NON_RECIPROCAL, 2 - end - add_enum "google.cloud.language.v1beta2.PartOfSpeech.Tense" do - value :TENSE_UNKNOWN, 0 - value :CONDITIONAL_TENSE, 1 - value :FUTURE, 2 - value :PAST, 3 - value :PRESENT, 4 - value :IMPERFECT, 5 - value :PLUPERFECT, 6 - end - add_enum "google.cloud.language.v1beta2.PartOfSpeech.Voice" do - value :VOICE_UNKNOWN, 0 - value :ACTIVE, 1 - value :CAUSATIVE, 2 - value :PASSIVE, 3 - end - add_message "google.cloud.language.v1beta2.DependencyEdge" do - optional :head_token_index, :int32, 1 - optional :label, :enum, 2, "google.cloud.language.v1beta2.DependencyEdge.Label" - end - add_enum "google.cloud.language.v1beta2.DependencyEdge.Label" do - value :UNKNOWN, 0 - value :ABBREV, 1 - value :ACOMP, 2 - value :ADVCL, 3 - value :ADVMOD, 4 - value :AMOD, 5 - value :APPOS, 6 - value :ATTR, 7 - value :AUX, 8 - value :AUXPASS, 9 - value :CC, 10 - value :CCOMP, 11 - value :CONJ, 12 - value :CSUBJ, 13 - value :CSUBJPASS, 14 - value :DEP, 15 - value :DET, 16 - value :DISCOURSE, 17 - value :DOBJ, 18 - value :EXPL, 19 - value :GOESWITH, 20 - value :IOBJ, 21 - value :MARK, 22 - value :MWE, 23 - value :MWV, 24 - value :NEG, 25 - value :NN, 26 - value :NPADVMOD, 27 - value :NSUBJ, 28 - value :NSUBJPASS, 29 - value :NUM, 30 - value :NUMBER, 31 - value :P, 32 - value :PARATAXIS, 33 - value :PARTMOD, 34 - value :PCOMP, 35 - value :POBJ, 36 - value :POSS, 37 - value :POSTNEG, 38 - value :PRECOMP, 39 - value :PRECONJ, 40 - value :PREDET, 41 - value :PREF, 42 - value :PREP, 43 - value :PRONL, 44 - value :PRT, 45 - value :PS, 46 - value :QUANTMOD, 47 - value :RCMOD, 48 - value :RCMODREL, 49 - value :RDROP, 50 - value :REF, 51 - value :REMNANT, 52 - value :REPARANDUM, 53 - value :ROOT, 54 - value :SNUM, 55 - value :SUFF, 56 - value :TMOD, 57 - value :TOPIC, 58 - value :VMOD, 59 - value :VOCATIVE, 60 - value :XCOMP, 61 - value :SUFFIX, 62 - value :TITLE, 63 - value :ADVPHMOD, 64 - value :AUXCAUS, 65 - value :AUXVV, 66 - value :DTMOD, 67 - value :FOREIGN, 68 - value :KW, 69 - value :LIST, 70 - value :NOMC, 71 - value :NOMCSUBJ, 72 - value :NOMCSUBJPASS, 73 - value :NUMC, 74 - value :COP, 75 - value :DISLOCATED, 76 - value :ASP, 77 - value :GMOD, 78 - value :GOBJ, 79 - value :INFMOD, 80 - value :MES, 81 - value :NCOMP, 82 - end - add_message "google.cloud.language.v1beta2.EntityMention" do - optional :text, :message, 1, "google.cloud.language.v1beta2.TextSpan" - optional :type, :enum, 2, "google.cloud.language.v1beta2.EntityMention.Type" - optional :sentiment, :message, 3, "google.cloud.language.v1beta2.Sentiment" - end - add_enum "google.cloud.language.v1beta2.EntityMention.Type" do - value :TYPE_UNKNOWN, 0 - value :PROPER, 1 - value :COMMON, 2 - end - add_message "google.cloud.language.v1beta2.TextSpan" do - optional :content, :string, 1 - optional :begin_offset, :int32, 2 - end - add_message "google.cloud.language.v1beta2.ClassificationCategory" do - optional :name, :string, 1 - optional :confidence, :float, 2 - end - add_message "google.cloud.language.v1beta2.AnalyzeSentimentRequest" do - optional :document, :message, 1, "google.cloud.language.v1beta2.Document" - optional :encoding_type, :enum, 2, "google.cloud.language.v1beta2.EncodingType" - end - add_message "google.cloud.language.v1beta2.AnalyzeSentimentResponse" do - optional :document_sentiment, :message, 1, "google.cloud.language.v1beta2.Sentiment" - optional :language, :string, 2 - repeated :sentences, :message, 3, "google.cloud.language.v1beta2.Sentence" - end - add_message "google.cloud.language.v1beta2.AnalyzeEntitySentimentRequest" do - optional :document, :message, 1, "google.cloud.language.v1beta2.Document" - optional :encoding_type, :enum, 2, "google.cloud.language.v1beta2.EncodingType" - end - add_message "google.cloud.language.v1beta2.AnalyzeEntitySentimentResponse" do - repeated :entities, :message, 1, "google.cloud.language.v1beta2.Entity" - optional :language, :string, 2 - end - add_message "google.cloud.language.v1beta2.AnalyzeEntitiesRequest" do - optional :document, :message, 1, "google.cloud.language.v1beta2.Document" - optional :encoding_type, :enum, 2, "google.cloud.language.v1beta2.EncodingType" - end - add_message "google.cloud.language.v1beta2.AnalyzeEntitiesResponse" do - repeated :entities, :message, 1, "google.cloud.language.v1beta2.Entity" - optional :language, :string, 2 - end - add_message "google.cloud.language.v1beta2.AnalyzeSyntaxRequest" do - optional :document, :message, 1, "google.cloud.language.v1beta2.Document" - optional :encoding_type, :enum, 2, "google.cloud.language.v1beta2.EncodingType" - end - add_message "google.cloud.language.v1beta2.AnalyzeSyntaxResponse" do - repeated :sentences, :message, 1, "google.cloud.language.v1beta2.Sentence" - repeated :tokens, :message, 2, "google.cloud.language.v1beta2.Token" - optional :language, :string, 3 - end - add_message "google.cloud.language.v1beta2.ClassifyTextRequest" do - optional :document, :message, 1, "google.cloud.language.v1beta2.Document" - end - add_message "google.cloud.language.v1beta2.ClassifyTextResponse" do - repeated :categories, :message, 1, "google.cloud.language.v1beta2.ClassificationCategory" - end - add_message "google.cloud.language.v1beta2.AnnotateTextRequest" do - optional :document, :message, 1, "google.cloud.language.v1beta2.Document" - optional :features, :message, 2, "google.cloud.language.v1beta2.AnnotateTextRequest.Features" - optional :encoding_type, :enum, 3, "google.cloud.language.v1beta2.EncodingType" - end - add_message "google.cloud.language.v1beta2.AnnotateTextRequest.Features" do - optional :extract_syntax, :bool, 1 - optional :extract_entities, :bool, 2 - optional :extract_document_sentiment, :bool, 3 - optional :extract_entity_sentiment, :bool, 4 - optional :classify_text, :bool, 6 - end - add_message "google.cloud.language.v1beta2.AnnotateTextResponse" do - repeated :sentences, :message, 1, "google.cloud.language.v1beta2.Sentence" - repeated :tokens, :message, 2, "google.cloud.language.v1beta2.Token" - repeated :entities, :message, 3, "google.cloud.language.v1beta2.Entity" - optional :document_sentiment, :message, 4, "google.cloud.language.v1beta2.Sentiment" - optional :language, :string, 5 - repeated :categories, :message, 6, "google.cloud.language.v1beta2.ClassificationCategory" - end - add_enum "google.cloud.language.v1beta2.EncodingType" do - value :NONE, 0 - value :UTF8, 1 - value :UTF16, 2 - value :UTF32, 3 - end -end - -module Google - module Cloud - module Language - module V1beta2 - Document = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.Document").msgclass - Document::Type = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.Document.Type").enummodule - Sentence = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.Sentence").msgclass - Entity = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.Entity").msgclass - Entity::Type = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.Entity.Type").enummodule - Token = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.Token").msgclass - Sentiment = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.Sentiment").msgclass - PartOfSpeech = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.PartOfSpeech").msgclass - PartOfSpeech::Tag = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.PartOfSpeech.Tag").enummodule - PartOfSpeech::Aspect = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.PartOfSpeech.Aspect").enummodule - PartOfSpeech::Case = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.PartOfSpeech.Case").enummodule - PartOfSpeech::Form = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.PartOfSpeech.Form").enummodule - PartOfSpeech::Gender = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.PartOfSpeech.Gender").enummodule - PartOfSpeech::Mood = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.PartOfSpeech.Mood").enummodule - PartOfSpeech::Number = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.PartOfSpeech.Number").enummodule - PartOfSpeech::Person = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.PartOfSpeech.Person").enummodule - PartOfSpeech::Proper = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.PartOfSpeech.Proper").enummodule - PartOfSpeech::Reciprocity = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.PartOfSpeech.Reciprocity").enummodule - PartOfSpeech::Tense = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.PartOfSpeech.Tense").enummodule - PartOfSpeech::Voice = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.PartOfSpeech.Voice").enummodule - DependencyEdge = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.DependencyEdge").msgclass - DependencyEdge::Label = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.DependencyEdge.Label").enummodule - EntityMention = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.EntityMention").msgclass - EntityMention::Type = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.EntityMention.Type").enummodule - TextSpan = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.TextSpan").msgclass - ClassificationCategory = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.ClassificationCategory").msgclass - AnalyzeSentimentRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.AnalyzeSentimentRequest").msgclass - AnalyzeSentimentResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.AnalyzeSentimentResponse").msgclass - AnalyzeEntitySentimentRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.AnalyzeEntitySentimentRequest").msgclass - AnalyzeEntitySentimentResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.AnalyzeEntitySentimentResponse").msgclass - AnalyzeEntitiesRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.AnalyzeEntitiesRequest").msgclass - AnalyzeEntitiesResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.AnalyzeEntitiesResponse").msgclass - AnalyzeSyntaxRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.AnalyzeSyntaxRequest").msgclass - AnalyzeSyntaxResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.AnalyzeSyntaxResponse").msgclass - ClassifyTextRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.ClassifyTextRequest").msgclass - ClassifyTextResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.ClassifyTextResponse").msgclass - AnnotateTextRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.AnnotateTextRequest").msgclass - AnnotateTextRequest::Features = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.AnnotateTextRequest.Features").msgclass - AnnotateTextResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.AnnotateTextResponse").msgclass - EncodingType = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.language.v1beta2.EncodingType").enummodule - end - end - end -end diff --git a/google-cloud-language/lib/google/cloud/language/v1beta2/language_service_services_pb.rb b/google-cloud-language/lib/google/cloud/language/v1beta2/language_service_services_pb.rb deleted file mode 100644 index af1855b1ac73..000000000000 --- a/google-cloud-language/lib/google/cloud/language/v1beta2/language_service_services_pb.rb +++ /dev/null @@ -1,64 +0,0 @@ -# Generated by the protocol buffer compiler. DO NOT EDIT! -# Source: google/cloud/language/v1beta2/language_service.proto for package 'google.cloud.language.v1beta2' -# Original file comments: -# 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. -# -# - - -require 'grpc' -require 'google/cloud/language/v1beta2/language_service_pb' - -module Google - module Cloud - module Language - module V1beta2 - module LanguageService - # Provides text analysis operations such as sentiment analysis and entity - # recognition. - class Service - - include GRPC::GenericService - - self.marshal_class_method = :encode - self.unmarshal_class_method = :decode - self.service_name = 'google.cloud.language.v1beta2.LanguageService' - - # Analyzes the sentiment of the provided text. - rpc :AnalyzeSentiment, AnalyzeSentimentRequest, AnalyzeSentimentResponse - # 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, AnalyzeEntitiesResponse - # 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, AnalyzeEntitySentimentResponse - # 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, AnalyzeSyntaxResponse - # Classifies a document into categories. - rpc :ClassifyText, ClassifyTextRequest, ClassifyTextResponse - # A convenience method that provides all syntax, sentiment, entity, and - # classification features in one call. - rpc :AnnotateText, AnnotateTextRequest, AnnotateTextResponse - end - - Stub = Service.rpc_stub_class - end - end - end - end -end diff --git a/google-cloud-language/synth.metadata b/google-cloud-language/synth.metadata deleted file mode 100644 index 20928eb9356d..000000000000 --- a/google-cloud-language/synth.metadata +++ /dev/null @@ -1,50 +0,0 @@ -{ - "updateTime": "2020-03-10T10:43:07.916399Z", - "sources": [ - { - "generator": { - "name": "artman", - "version": "1.1.0", - "dockerImage": "googleapis/artman@sha256:f54b7644a1d2e7a37b23f5c0dfe9bba473e41c675002a507a244389e27487ca9" - } - }, - { - "git": { - "name": "googleapis", - "remote": "https://github.com/googleapis/googleapis.git", - "sha": "365c029b8cdb63f7751b92ab490f1976e616105c", - "internalRef": "300038469", - "log": "365c029b8cdb63f7751b92ab490f1976e616105c\nAdd CC targets to the kms protos.\n\nThese are needed by go/tink.\n\nPiperOrigin-RevId: 300038469\n\n4ba9aa8a4a1413b88dca5a8fa931824ee9c284e6\nExpose logo recognition API proto for GA.\n\nPiperOrigin-RevId: 299971671\n\n1c9fc2c9e03dadf15f16b1c4f570955bdcebe00e\nAdding ruby_package option to accessapproval.proto for the Ruby client libraries generation.\n\nPiperOrigin-RevId: 299955924\n\n1cc6f0a7bfb147e6f2ede911d9b01e7a9923b719\nbuild(google/maps/routes): generate api clients\n\nPiperOrigin-RevId: 299955905\n\n29a47c965aac79e3fe8e3314482ca0b5967680f0\nIncrease timeout to 1hr for method `dropRange` in bigtable/admin/v2, which is\nsynced with the timeout setting in gapic_yaml.\n\nPiperOrigin-RevId: 299917154\n\n8f631c4c70a60a9c7da3749511ee4ad432b62898\nbuild(google/maps/roads/v1op): move go to monorepo pattern\n\nPiperOrigin-RevId: 299885195\n\nd66816518844ebbf63504c9e8dfc7133921dd2cd\nbuild(google/maps/roads/v1op): Add bazel build files to generate clients.\n\nPiperOrigin-RevId: 299851148\n\naf7dff701fabe029672168649c62356cf1bb43d0\nAdd LogPlayerReports and LogImpressions to Playable Locations service\n\nPiperOrigin-RevId: 299724050\n\nb6927fca808f38df32a642c560082f5bf6538ced\nUpdate BigQuery Connection API v1beta1 proto: added credential to CloudSqlProperties.\n\nPiperOrigin-RevId: 299503150\n\n91e1fb5ef9829c0c7a64bfa5bde330e6ed594378\nchore: update protobuf (protoc) version to 3.11.2\n\nPiperOrigin-RevId: 299404145\n\n30e36b4bee6749c4799f4fc1a51cc8f058ba167d\nUpdate cloud asset api v1p4beta1.\n\nPiperOrigin-RevId: 299399890\n\nffbb493674099f265693872ae250711b2238090c\nfeat: cloudbuild/v1 add new fields and annotate OUTPUT_OUT fields.\n\nPiperOrigin-RevId: 299397780\n\nbc973a15818e00c19e121959832676e9b7607456\nbazel: Fix broken common dependency\n\nPiperOrigin-RevId: 299397431\n\n71094a343e3b962e744aa49eb9338219537474e4\nchore: bigtable/admin/v2 publish retry config\n\nPiperOrigin-RevId: 299391875\n\n8f488efd7bda33885cb674ddd023b3678c40bd82\nfeat: Migrate logging to GAPIC v2; release new features.\n\nIMPORTANT: This is a breaking change for client libraries\nin all languages.\n\nCommitter: @lukesneeringer, @jskeet\nPiperOrigin-RevId: 299370279\n\n007605bf9ad3a1fd775014ebefbf7f1e6b31ee71\nUpdate API for bigqueryreservation v1beta1.\n- Adds flex capacity commitment plan to CapacityCommitment.\n- Adds methods for getting and updating BiReservations.\n- Adds methods for updating/splitting/merging CapacityCommitments.\n\nPiperOrigin-RevId: 299368059\n\nf0b581b5bdf803e45201ecdb3688b60e381628a8\nfix: recommendationengine/v1beta1 update some comments\n\nPiperOrigin-RevId: 299181282\n\n10e9a0a833dc85ff8f05b2c67ebe5ac785fe04ff\nbuild: add generated BUILD file for Routes Preferred API\n\nPiperOrigin-RevId: 299164808\n\n86738c956a8238d7c77f729be78b0ed887a6c913\npublish v1p1beta1: update with absolute address in comments\n\nPiperOrigin-RevId: 299152383\n\n73d9f2ad4591de45c2e1f352bc99d70cbd2a6d95\npublish v1: update with absolute address in comments\n\nPiperOrigin-RevId: 299147194\n\nd2158f24cb77b0b0ccfe68af784c6a628705e3c6\npublish v1beta2: update with absolute address in comments\n\nPiperOrigin-RevId: 299147086\n\n7fca61292c11b4cd5b352cee1a50bf88819dd63b\npublish v1p2beta1: update with absolute address in comments\n\nPiperOrigin-RevId: 299146903\n\n583b7321624736e2c490e328f4b1957335779295\npublish v1p3beta1: update with absolute address in comments\n\nPiperOrigin-RevId: 299146674\n\n638253bf86d1ce1c314108a089b7351440c2f0bf\nfix: add java_multiple_files option for automl text_sentiment.proto\n\nPiperOrigin-RevId: 298971070\n\n373d655703bf914fb8b0b1cc4071d772bac0e0d1\nUpdate Recs AI Beta public bazel file\n\nPiperOrigin-RevId: 298961623\n\ndcc5d00fc8a8d8b56f16194d7c682027b2c66a3b\nfix: add java_multiple_files option for automl classification.proto\n\nPiperOrigin-RevId: 298953301\n\na3f791827266f3496a6a5201d58adc4bb265c2a3\nchore: automl/v1 publish annotations and retry config\n\nPiperOrigin-RevId: 298942178\n\n01c681586d8d6dbd60155289b587aee678530bd9\nMark return_immediately in PullRequest deprecated.\n\nPiperOrigin-RevId: 298893281\n\nc9f5e9c4bfed54bbd09227e990e7bded5f90f31c\nRemove out of date documentation for predicate support on the Storage API\n\nPiperOrigin-RevId: 298883309\n\nfd5b3b8238d783b04692a113ffe07c0363f5de0f\ngenerate webrisk v1 proto\n\nPiperOrigin-RevId: 298847934\n\n541b1ded4abadcc38e8178680b0677f65594ea6f\nUpdate cloud asset api v1p4beta1.\n\nPiperOrigin-RevId: 298686266\n\nc0d171acecb4f5b0bfd2c4ca34fc54716574e300\n Updated to include the Notification v1 API.\n\nPiperOrigin-RevId: 298652775\n\n2346a9186c0bff2c9cc439f2459d558068637e05\nAdd Service Directory v1beta1 protos and configs\n\nPiperOrigin-RevId: 298625638\n\na78ed801b82a5c6d9c5368e24b1412212e541bb7\nPublishing v3 protos and configs.\n\nPiperOrigin-RevId: 298607357\n\n4a180bfff8a21645b3a935c2756e8d6ab18a74e0\nautoml/v1beta1 publish proto updates\n\nPiperOrigin-RevId: 298484782\n\n6de6e938b7df1cd62396563a067334abeedb9676\nchore: use the latest gapic-generator and protoc-java-resource-name-plugin in Bazel workspace.\n\nPiperOrigin-RevId: 298474513\n\n244ab2b83a82076a1fa7be63b7e0671af73f5c02\nAdds service config definition for bigqueryreservation v1\n\nPiperOrigin-RevId: 298455048\n\n83c6f84035ee0f80eaa44d8b688a010461cc4080\nUpdate google/api/auth.proto to make AuthProvider to have JwtLocation\n\nPiperOrigin-RevId: 297918498\n\ne9e90a787703ec5d388902e2cb796aaed3a385b4\nDialogflow weekly v2/v2beta1 library update:\n - adding get validation result\n - adding field mask override control for output audio config\nImportant updates are also posted at:\nhttps://cloud.google.com/dialogflow/docs/release-notes\n\nPiperOrigin-RevId: 297671458\n\n1a2b05cc3541a5f7714529c665aecc3ea042c646\nAdding .yaml and .json config files.\n\nPiperOrigin-RevId: 297570622\n\ndfe1cf7be44dee31d78f78e485d8c95430981d6e\nPublish `QueryOptions` proto.\n\nIntroduced a `query_options` input in `ExecuteSqlRequest`.\n\nPiperOrigin-RevId: 297497710\n\ndafc905f71e5d46f500b41ed715aad585be062c3\npubsub: revert pull init_rpc_timeout & max_rpc_timeout back to 25 seconds and reset multiplier to 1.0\n\nPiperOrigin-RevId: 297486523\n\nf077632ba7fee588922d9e8717ee272039be126d\nfirestore: add update_transform\n\nPiperOrigin-RevId: 297405063\n\n0aba1900ffef672ec5f0da677cf590ee5686e13b\ncluster: use square brace for cross-reference\n\nPiperOrigin-RevId: 297204568\n\n5dac2da18f6325cbaed54603c43f0667ecd50247\nRestore retry params in gapic config because securitycenter has non-standard default retry params.\nRestore a few retry codes for some idempotent methods.\n\nPiperOrigin-RevId: 297196720\n\n1eb61455530252bba8b2c8d4bc9832960e5a56f6\npubsub: v1 replace IAM HTTP rules\n\nPiperOrigin-RevId: 297188590\n\n80b2d25f8d43d9d47024ff06ead7f7166548a7ba\nDialogflow weekly v2/v2beta1 library update:\n - updates to mega agent api\n - adding field mask override control for output audio config\nImportant updates are also posted at:\nhttps://cloud.google.com/dialogflow/docs/release-notes\n\nPiperOrigin-RevId: 297187629\n\n0b1876b35e98f560f9c9ca9797955f020238a092\nUse an older version of protoc-docs-plugin that is compatible with the specified gapic-generator and protobuf versions.\n\nprotoc-docs-plugin >=0.4.0 (see commit https://github.com/googleapis/protoc-docs-plugin/commit/979f03ede6678c487337f3d7e88bae58df5207af) is incompatible with protobuf 3.9.1.\n\nPiperOrigin-RevId: 296986742\n\n1e47e676cddbbd8d93f19ba0665af15b5532417e\nFix: Restore a method signature for UpdateCluster\n\nPiperOrigin-RevId: 296901854\n\n7f910bcc4fc4704947ccfd3ceed015d16b9e00c2\nUpdate Dataproc v1beta2 client.\n\nPiperOrigin-RevId: 296451205\n\nde287524405a3dce124d301634731584fc0432d7\nFix: Reinstate method signatures that had been missed off some RPCs\nFix: Correct resource types for two fields\n\nPiperOrigin-RevId: 296435091\n\ne5bc9566ae057fb4c92f8b7e047f1c8958235b53\nDeprecate the endpoint_uris field, as it is unused.\n\nPiperOrigin-RevId: 296357191\n\n8c12e2b4dca94e12bff9f538bdac29524ff7ef7a\nUpdate Dataproc v1 client.\n\nPiperOrigin-RevId: 296336662\n\n17567c4a1ef0a9b50faa87024d66f8acbb561089\nRemoving erroneous comment, a la https://github.com/googleapis/java-speech/pull/103\n\nPiperOrigin-RevId: 296332968\n\n3eaaaf8626ce5b0c0bc7eee05e143beffa373b01\nAdd BUILD.bazel for v1 secretmanager.googleapis.com\n\nPiperOrigin-RevId: 296274723\n\ne76149c3d992337f85eeb45643106aacae7ede82\nMove securitycenter v1 to use generate from annotations.\n\nPiperOrigin-RevId: 296266862\n\n203740c78ac69ee07c3bf6be7408048751f618f8\nAdd StackdriverLoggingConfig field to Cloud Tasks v2 API.\n\nPiperOrigin-RevId: 296256388\n\ne4117d5e9ed8bbca28da4a60a94947ca51cb2083\nCreate a Bazel BUILD file for the google.actions.type export.\n\nPiperOrigin-RevId: 296212567\n\na9639a0a9854fd6e1be08bba1ac3897f4f16cb2f\nAdd secretmanager.googleapis.com v1 protos\n\nPiperOrigin-RevId: 295983266\n\nce4f4c21d9dd2bfab18873a80449b9d9851efde8\nasset: v1p1beta1 remove SearchResources and SearchIamPolicies\n\nPiperOrigin-RevId: 295861722\n\ncb61d6c2d070b589980c779b68ffca617f789116\nasset: v1p1beta1 remove SearchResources and SearchIamPolicies\n\nPiperOrigin-RevId: 295855449\n\nab2685d8d3a0e191dc8aef83df36773c07cb3d06\nfix: Dataproc v1 - AutoscalingPolicy annotation\n\nThis adds the second resource name pattern to the\nAutoscalingPolicy resource.\n\nCommitter: @lukesneeringer\nPiperOrigin-RevId: 295738415\n\n8a1020bf6828f6e3c84c3014f2c51cb62b739140\nUpdate cloud asset api v1p4beta1.\n\nPiperOrigin-RevId: 295286165\n\n5cfa105206e77670369e4b2225597386aba32985\nAdd service control related proto build rule.\n\nPiperOrigin-RevId: 295262088\n\nee4dddf805072004ab19ac94df2ce669046eec26\nmonitoring v3: Add prefix \"https://cloud.google.com/\" into the link for global access\ncl 295167522, get ride of synth.py hacks\n\nPiperOrigin-RevId: 295238095\n\nd9835e922ea79eed8497db270d2f9f85099a519c\nUpdate some minor docs changes about user event proto\n\nPiperOrigin-RevId: 295185610\n\n5f311e416e69c170243de722023b22f3df89ec1c\nfix: use correct PHP package name in gapic configuration\n\nPiperOrigin-RevId: 295161330\n\n6cdd74dcdb071694da6a6b5a206e3a320b62dd11\npubsub: v1 add client config annotations and retry config\n\nPiperOrigin-RevId: 295158776\n\n5169f46d9f792e2934d9fa25c36d0515b4fd0024\nAdded cloud asset api v1p4beta1.\n\nPiperOrigin-RevId: 295026522\n\n56b55aa8818cd0a532a7d779f6ef337ba809ccbd\nFix: Resource annotations for CreateTimeSeriesRequest and ListTimeSeriesRequest should refer to valid resources. TimeSeries is not a named resource.\n\nPiperOrigin-RevId: 294931650\n\n0646bc775203077226c2c34d3e4d50cc4ec53660\nRemove unnecessary languages from bigquery-related artman configuration files.\n\nPiperOrigin-RevId: 294809380\n\n8b78aa04382e3d4147112ad6d344666771bb1909\nUpdate backend.proto for schemes and protocol\n\nPiperOrigin-RevId: 294788800\n\n80b8f8b3de2359831295e24e5238641a38d8488f\nAdds artman config files for bigquerystorage endpoints v1beta2, v1alpha2, v1\n\nPiperOrigin-RevId: 294763931\n\n2c17ac33b226194041155bb5340c3f34733f1b3a\nAdd parameter to sample generated for UpdateInstance. Related to https://github.com/googleapis/python-redis/issues/4\n\nPiperOrigin-RevId: 294734008\n\nd5e8a8953f2acdfe96fb15e85eb2f33739623957\nMove bigquery datatransfer to gapic v2.\n\nPiperOrigin-RevId: 294703703\n\nefd36705972cfcd7d00ab4c6dfa1135bafacd4ae\nfix: Add two annotations that we missed.\n\nPiperOrigin-RevId: 294664231\n\n8a36b928873ff9c05b43859b9d4ea14cd205df57\nFix: Define the \"bigquery.googleapis.com/Table\" resource in the BigQuery Storage API (v1beta2).\n\nPiperOrigin-RevId: 294459768\n\nc7a3caa2c40c49f034a3c11079dd90eb24987047\nFix: Define the \"bigquery.googleapis.com/Table\" resource in the BigQuery Storage API (v1).\n\nPiperOrigin-RevId: 294456889\n\n5006247aa157e59118833658084345ee59af7c09\nFix: Make deprecated fields optional\nFix: Deprecate SetLoggingServiceRequest.zone in line with the comments\nFeature: Add resource name method signatures where appropriate\n\nPiperOrigin-RevId: 294383128\n\neabba40dac05c5cbe0fca3a35761b17e372036c4\nFix: C# and PHP package/namespace capitalization for BigQuery Storage v1.\n\nPiperOrigin-RevId: 294382444\n\nf8d9a858a7a55eba8009a23aa3f5cc5fe5e88dde\nfix: artman configuration file for bigtable-admin\n\nPiperOrigin-RevId: 294322616\n\n0f29555d1cfcf96add5c0b16b089235afbe9b1a9\nAPI definition for (not-yet-launched) GCS gRPC.\n\nPiperOrigin-RevId: 294321472\n\nfcc86bee0e84dc11e9abbff8d7c3529c0626f390\nfix: Bigtable Admin v2\n\nChange LRO metadata from PartialUpdateInstanceMetadata\nto UpdateInstanceMetadata. (Otherwise, it will not build.)\n\nPiperOrigin-RevId: 294264582\n\n6d9361eae2ebb3f42d8c7ce5baf4bab966fee7c0\nrefactor: Add annotations to Bigtable Admin v2.\n\nPiperOrigin-RevId: 294243406\n\nad7616f3fc8e123451c8b3a7987bc91cea9e6913\nFix: Resource type in CreateLogMetricRequest should use logging.googleapis.com.\nFix: ListLogEntries should have a method signature for convenience of calling it.\n\nPiperOrigin-RevId: 294222165\n\n63796fcbb08712676069e20a3e455c9f7aa21026\nFix: Remove extraneous resource definition for cloudkms.googleapis.com/CryptoKey.\n\nPiperOrigin-RevId: 294176658\n\ne7d8a694f4559201e6913f6610069cb08b39274e\nDepend on the latest gapic-generator and resource names plugin.\n\nThis fixes the very old an very annoying bug: https://github.com/googleapis/gapic-generator/pull/3087\n\nPiperOrigin-RevId: 293903652\n\n806b2854a966d55374ee26bb0cef4e30eda17b58\nfix: correct capitalization of Ruby namespaces in SecurityCenter V1p1beta1\n\nPiperOrigin-RevId: 293903613\n\n1b83c92462b14d67a7644e2980f723112472e03a\nPublish annotations and grpc service config for Logging API.\n\nPiperOrigin-RevId: 293893514\n\ne46f761cd6ec15a9e3d5ed4ff321a4bcba8e8585\nGenerate the Bazel build file for recommendengine public api\n\nPiperOrigin-RevId: 293710856\n\n68477017c4173c98addac0373950c6aa9d7b375f\nMake `language_code` optional for UpdateIntentRequest and BatchUpdateIntentsRequest.\n\nThe comments and proto annotations describe this parameter as optional.\n\nPiperOrigin-RevId: 293703548\n\n16f823f578bca4e845a19b88bb9bc5870ea71ab2\nAdd BUILD.bazel files for managedidentities API\n\nPiperOrigin-RevId: 293698246\n\n2f53fd8178c9a9de4ad10fae8dd17a7ba36133f2\nAdd v1p1beta1 config file\n\nPiperOrigin-RevId: 293696729\n\n052b274138fce2be80f97b6dcb83ab343c7c8812\nAdd source field for user event and add field behavior annotations\n\nPiperOrigin-RevId: 293693115\n\n1e89732b2d69151b1b3418fff3d4cc0434f0dded\ndatacatalog: v1beta1 add three new RPCs to gapic v1beta1 config\n\nPiperOrigin-RevId: 293692823\n\n9c8bd09bbdc7c4160a44f1fbab279b73cd7a2337\nchange the name of AccessApproval service to AccessApprovalAdmin\n\nPiperOrigin-RevId: 293690934\n\n2e23b8fbc45f5d9e200572ca662fe1271bcd6760\nAdd ListEntryGroups method, add http bindings to support entry group tagging, and update some comments.\n\nPiperOrigin-RevId: 293666452\n\n0275e38a4ca03a13d3f47a9613aac8c8b0d3f1f2\nAdd proto_package field to managedidentities API. It is needed for APIs that still depend on artman generation.\n\nPiperOrigin-RevId: 293643323\n\n4cdfe8278cb6f308106580d70648001c9146e759\nRegenerating public protos for Data Catalog to add new Custom Type Entry feature.\n\nPiperOrigin-RevId: 293614782\n\n45d2a569ab526a1fad3720f95eefb1c7330eaada\nEnable client generation for v1 ManagedIdentities API.\n\nPiperOrigin-RevId: 293515675\n\n2c17086b77e6f3bcf04a1f65758dfb0c3da1568f\nAdd the Actions on Google common types (//google/actions/type/*).\n\nPiperOrigin-RevId: 293478245\n\n781aadb932e64a12fb6ead7cd842698d99588433\nDialogflow weekly v2/v2beta1 library update:\n- Documentation updates\nImportant updates are also posted at\nhttps://cloud.google.com/dialogflow/docs/release-notes\n\nPiperOrigin-RevId: 293443396\n\ne2602608c9138c2fca24162720e67f9307c30b95\nDialogflow weekly v2/v2beta1 library update:\n- Documentation updates\nImportant updates are also posted at\nhttps://cloud.google.com/dialogflow/docs/release-notes\n\nPiperOrigin-RevId: 293442964\n\nc8aef82028d06b7992278fa9294c18570dc86c3d\nAdd cc_proto_library and cc_grpc_library targets for Bigtable protos.\n\nAlso fix indentation of cc_grpc_library targets in Spanner and IAM protos.\n\nPiperOrigin-RevId: 293440538\n\ne2faab04f4cb7f9755072330866689b1943a16e9\ncloudtasks: v2 replace non-standard retry params in gapic config v2\n\nPiperOrigin-RevId: 293424055\n\ndfb4097ea628a8470292c6590a4313aee0c675bd\nerrorreporting: v1beta1 add legacy artman config for php\n\nPiperOrigin-RevId: 293423790\n\nb18aed55b45bfe5b62476292c72759e6c3e573c6\nasset: v1p1beta1 updated comment for `page_size` limit.\n\nPiperOrigin-RevId: 293421386\n\nc9ef36b7956d9859a2fc86ad35fcaa16958ab44f\nbazel: Refactor CI build scripts\n\nPiperOrigin-RevId: 293387911\n\na8ed9d921fdddc61d8467bfd7c1668f0ad90435c\nfix: set Ruby module name for OrgPolicy\n\nPiperOrigin-RevId: 293257997\n\n6c7d28509bd8315de8af0889688ee20099594269\nredis: v1beta1 add UpgradeInstance and connect_mode field to Instance\n\nPiperOrigin-RevId: 293242878\n\nae0abed4fcb4c21f5cb67a82349a049524c4ef68\nredis: v1 add connect_mode field to Instance\n\nPiperOrigin-RevId: 293241914\n\n3f7a0d29b28ee9365771da2b66edf7fa2b4e9c56\nAdds service config definition for bigqueryreservation v1beta1\n\nPiperOrigin-RevId: 293234418\n\n0c88168d5ed6fe353a8cf8cbdc6bf084f6bb66a5\naddition of BUILD & configuration for accessapproval v1\n\nPiperOrigin-RevId: 293219198\n\n39bedc2e30f4778ce81193f6ba1fec56107bcfc4\naccessapproval: v1 publish protos\n\nPiperOrigin-RevId: 293167048\n\n69d9945330a5721cd679f17331a78850e2618226\nAdd file-level `Session` resource definition\n\nPiperOrigin-RevId: 293080182\n\nf6a1a6b417f39694275ca286110bc3c1ca4db0dc\nAdd file-level `Session` resource definition\n\nPiperOrigin-RevId: 293080178\n\n29d40b78e3dc1579b0b209463fbcb76e5767f72a\nExpose managedidentities/v1beta1/ API for client library usage.\n\nPiperOrigin-RevId: 292979741\n\na22129a1fb6e18056d576dfb7717aef74b63734a\nExpose managedidentities/v1/ API for client library usage.\n\nPiperOrigin-RevId: 292968186\n\nb5cbe4a4ba64ab19e6627573ff52057a1657773d\nSecurityCenter v1p1beta1: move file-level option on top to workaround protobuf.js bug.\n\nPiperOrigin-RevId: 292647187\n\nb224b317bf20c6a4fbc5030b4a969c3147f27ad3\nAdds API definitions for bigqueryreservation v1beta1.\n\nPiperOrigin-RevId: 292634722\n\nc1468702f9b17e20dd59007c0804a089b83197d2\nSynchronize new proto/yaml changes.\n\nPiperOrigin-RevId: 292626173\n\nffdfa4f55ab2f0afc11d0eb68f125ccbd5e404bd\nvision: v1p3beta1 publish annotations and retry config\n\nPiperOrigin-RevId: 292605599\n\n78f61482cd028fc1d9892aa5d89d768666a954cd\nvision: v1p1beta1 publish annotations and retry config\n\nPiperOrigin-RevId: 292605125\n\n60bb5a294a604fd1778c7ec87b265d13a7106171\nvision: v1p2beta1 publish annotations and retry config\n\nPiperOrigin-RevId: 292604980\n\n3bcf7aa79d45eb9ec29ab9036e9359ea325a7fc3\nvision: v1p4beta1 publish annotations and retry config\n\nPiperOrigin-RevId: 292604656\n\n2717b8a1c762b26911b45ecc2e4ee01d98401b28\nFix dataproc artman client library generation.\n\nPiperOrigin-RevId: 292555664\n\n7ac66d9be8a7d7de4f13566d8663978c9ee9dcd7\nAdd Dataproc Autoscaling API to V1.\n\nPiperOrigin-RevId: 292450564\n\n5d932b2c1be3a6ef487d094e3cf5c0673d0241dd\n- Improve documentation\n- Add a client_id field to StreamingPullRequest\n\nPiperOrigin-RevId: 292434036\n\neaff9fa8edec3e914995ce832b087039c5417ea7\nmonitoring: v3 publish annotations and client retry config\n\nPiperOrigin-RevId: 292425288\n\n70958bab8c5353870d31a23fb2c40305b050d3fe\nBigQuery Storage Read API v1 clients.\n\nPiperOrigin-RevId: 292407644\n\n7a15e7fe78ff4b6d5c9606a3264559e5bde341d1\nUpdate backend proto for Google Cloud Endpoints\n\nPiperOrigin-RevId: 292391607\n\n3ca2c014e24eb5111c8e7248b1e1eb833977c83d\nbazel: Add --flaky_test_attempts=3 argument to prevent CI failures caused by flaky tests\n\nPiperOrigin-RevId: 292382559\n\n9933347c1f677e81e19a844c2ef95bfceaf694fe\nbazel:Integrate latest protoc-java-resource-names-plugin changes (fix for PyYAML dependency in bazel rules)\n\nPiperOrigin-RevId: 292376626\n\nb835ab9d2f62c88561392aa26074c0b849fb0bd3\nasset: v1p2beta1 add client config annotations\n\n* remove unintentionally exposed RPCs\n* remove messages relevant to removed RPCs\n\nPiperOrigin-RevId: 292369593\n\nc1246a29e22b0f98e800a536b5b0da2d933a55f2\nUpdating v1 protos with the latest inline documentation (in comments) and config options. Also adding a per-service .yaml file.\n\nPiperOrigin-RevId: 292310790\n\nb491d07cadaae7cde5608321f913e5ca1459b32d\nRevert accidental local_repository change\n\nPiperOrigin-RevId: 292245373\n\naf3400a8cb6110025198b59a0f7d018ae3cda700\nUpdate gapic-generator dependency (prebuilt PHP binary support).\n\nPiperOrigin-RevId: 292243997\n\n341fd5690fae36f36cf626ef048fbcf4bbe7cee6\ngrafeas: v1 add resource_definition for the grafeas.io/Project and change references for Project.\n\nPiperOrigin-RevId: 292221998\n\n42e915ec2ece1cd37a590fbcd10aa2c0fb0e5b06\nUpdate the gapic-generator, protoc-java-resource-name-plugin and protoc-docs-plugin to the latest commit.\n\nPiperOrigin-RevId: 292182368\n\nf035f47250675d31492a09f4a7586cfa395520a7\nFix grafeas build and update build.sh script to include gerafeas.\n\nPiperOrigin-RevId: 292168753\n\n26ccb214b7bc4a716032a6266bcb0a9ca55d6dbb\nasset: v1p1beta1 add client config annotations and retry config\n\nPiperOrigin-RevId: 292154210\n\n974ee5c0b5d03e81a50dafcedf41e0efebb5b749\nasset: v1beta1 add client config annotations\n\nPiperOrigin-RevId: 292152573\n\ncf3b61102ed5f36b827bc82ec39be09525f018c8\n Fix to protos for v1p1beta1 release of Cloud Security Command Center\n\nPiperOrigin-RevId: 292034635\n\n4e1cfaa7c0fede9e65d64213ca3da1b1255816c0\nUpdate the public proto to support UTF-8 encoded id for CatalogService API, increase the ListCatalogItems deadline to 300s and some minor documentation change\n\nPiperOrigin-RevId: 292030970\n\n9c483584f8fd5a1b862ae07973f4cc7bb3e46648\nasset: add annotations to v1p1beta1\n\nPiperOrigin-RevId: 292009868\n\ne19209fac29731d0baf6d9ac23da1164f7bdca24\nAdd the google.rpc.context.AttributeContext message to the open source\ndirectories.\n\nPiperOrigin-RevId: 291999930\n\nae5662960573f279502bf98a108a35ba1175e782\noslogin API: move file level option on top of the file to avoid protobuf.js bug.\n\nPiperOrigin-RevId: 291990506\n\neba3897fff7c49ed85d3c47fc96fe96e47f6f684\nAdd cc_proto_library and cc_grpc_library targets for Spanner and IAM protos.\n\nPiperOrigin-RevId: 291988651\n\n8e981acfd9b97ea2f312f11bbaa7b6c16e412dea\nBeta launch for PersonDetection and FaceDetection features.\n\nPiperOrigin-RevId: 291821782\n\n994e067fae3b21e195f7da932b08fff806d70b5d\nasset: add annotations to v1p2beta1\n\nPiperOrigin-RevId: 291815259\n\n244e1d2c89346ca2e0701b39e65552330d68545a\nAdd Playable Locations service\n\nPiperOrigin-RevId: 291806349\n\n909f8f67963daf45dd88d020877fb9029b76788d\nasset: add annotations to v1beta2\n\nPiperOrigin-RevId: 291805301\n\n3c39a1d6e23c1ef63c7fba4019c25e76c40dfe19\nKMS: add file-level message for CryptoKeyPath, it is defined in gapic yaml but not\nin proto files.\n\nPiperOrigin-RevId: 291420695\n\nc6f3f350b8387f8d1b85ed4506f30187ebaaddc3\ncontaineranalysis: update v1beta1 and bazel build with annotations\n\nPiperOrigin-RevId: 291401900\n\n92887d74b44e4e636252b7b8477d0d2570cd82db\nfix: fix the location of grpc config file.\n\nPiperOrigin-RevId: 291396015\n\ne26cab8afd19d396b929039dac5d874cf0b5336c\nexpr: add default_host and method_signature annotations to CelService\n\nPiperOrigin-RevId: 291240093\n\n06093ae3952441c34ec176d1f7431b8765cec0be\nirm: fix v1alpha2 bazel build by adding missing proto imports\n\nPiperOrigin-RevId: 291227940\n\na8a2514af326e4673063f9a3c9d0ef1091c87e6c\nAdd proto annotation for cloud/irm API\n\nPiperOrigin-RevId: 291217859\n\n8d16f76de065f530d395a4c7eabbf766d6a120fd\nGenerate Memcache v1beta2 API protos and gRPC ServiceConfig files\n\nPiperOrigin-RevId: 291008516\n\n3af1dabd93df9a9f17bf3624d3b875c11235360b\ngrafeas: Add containeranalysis default_host to Grafeas service\n\nPiperOrigin-RevId: 290965849\n\nbe2663fa95e31cba67d0cd62611a6674db9f74b7\nfix(google/maps/roads): add missing opening bracket\n\nPiperOrigin-RevId: 290964086\n\nfacc26550a0af0696e0534bc9cae9df14275aa7c\nUpdating v2 protos with the latest inline documentation (in comments) and adding a per-service .yaml file.\n\nPiperOrigin-RevId: 290952261\n\ncda99c1f7dc5e4ca9b1caeae1dc330838cbc1461\nChange api_name to 'asset' for v1p1beta1\n\nPiperOrigin-RevId: 290800639\n\n94e9e90c303a820ce40643d9129e7f0d2054e8a1\nAdds Google Maps Road service\n\nPiperOrigin-RevId: 290795667\n\na3b23dcb2eaecce98c600c7d009451bdec52dbda\nrpc: new message ErrorInfo, other comment updates\n\nPiperOrigin-RevId: 290781668\n\n26420ef4e46c37f193c0fbe53d6ebac481de460e\nAdd proto definition for Org Policy v1.\n\nPiperOrigin-RevId: 290771923\n\n7f0dab8177cf371ae019a082e2512de7ac102888\nPublish Routes Preferred API v1 service definitions.\n\nPiperOrigin-RevId: 290326986\n\nad6e508d0728e1d1bca6e3f328cd562718cb772d\nFix: Qualify resource type references with \"jobs.googleapis.com/\"\n\nPiperOrigin-RevId: 290285762\n\n58e770d568a2b78168ddc19a874178fee8265a9d\ncts client library\n\nPiperOrigin-RevId: 290146169\n\naf9daa4c3b4c4a8b7133b81588dd9ffd37270af2\nAdd more programming language options to public proto\n\nPiperOrigin-RevId: 290144091\n\nd9f2bbf2df301ef84641d4cec7c828736a0bd907\ntalent: add missing resource.proto dep to Bazel build target\n\nPiperOrigin-RevId: 290143164\n\n3b3968237451d027b42471cd28884a5a1faed6c7\nAnnotate Talent API.\nAdd gRPC service config for retry.\nUpdate bazel file with google.api.resource dependency.\n\nPiperOrigin-RevId: 290125172\n\n0735b4b096872960568d1f366bfa75b7b0e1f1a3\nWeekly library update.\n\nPiperOrigin-RevId: 289939042\n\n8760d3d9a4543d7f9c0d1c7870aca08b116e4095\nWeekly library update.\n\nPiperOrigin-RevId: 289939020\n\n8607df842f782a901805187e02fff598145b0b0e\nChange Talent API timeout to 30s.\n\nPiperOrigin-RevId: 289912621\n\n908155991fe32570653bcb72ecfdcfc896642f41\nAdd Recommendations AI V1Beta1\n\nPiperOrigin-RevId: 289901914\n\n5c9a8c2bebd8b71aa66d1cc473edfaac837a2c78\nAdding no-arg method signatures for ListBillingAccounts and ListServices\n\nPiperOrigin-RevId: 289891136\n\n50b0e8286ac988b0593bd890eb31fef6ea2f5767\nlongrunning: add grpc service config and default_host annotation to operations.proto\n\nPiperOrigin-RevId: 289876944\n\n6cac27dabe51c54807b0401698c32d34998948a9\n Updating default deadline for Cloud Security Command Center's v1 APIs.\n\nPiperOrigin-RevId: 289875412\n\n" - } - }, - { - "template": { - "name": "ruby_library", - "origin": "synthtool.gcp", - "version": "2020.2.4" - } - } - ], - "destinations": [ - { - "client": { - "source": "googleapis", - "apiName": "language", - "apiVersion": "v1", - "language": "ruby", - "generator": "gapic", - "config": "google/cloud/language/artman_language_v1.yaml" - } - }, - { - "client": { - "source": "googleapis", - "apiName": "language", - "apiVersion": "v1beta2", - "language": "ruby", - "generator": "gapic", - "config": "google/cloud/language/artman_language_v1beta2.yaml" - } - } - ] -} \ No newline at end of file diff --git a/google-cloud-language/synth.py b/google-cloud-language/synth.py deleted file mode 100644 index 57349fad38c9..000000000000 --- a/google-cloud-language/synth.py +++ /dev/null @@ -1,240 +0,0 @@ -# Copyright 2018 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. - -"""This script is used to synthesize generated parts of this library.""" - -import synthtool as s -import synthtool.gcp as gcp -import synthtool.languages.ruby as ruby -import logging -import re -from textwrap import dedent - -logging.basicConfig(level=logging.DEBUG) - -gapic = gcp.GAPICGenerator() - -v1_library = gapic.ruby_library( - 'language', 'v1', - artman_output_name='google-cloud-ruby/google-cloud-language' -) -s.copy(v1_library / 'acceptance') -s.copy(v1_library / 'lib/google/cloud/language/v1') -s.copy(v1_library / 'lib/google/cloud/language/v1.rb') -s.copy(v1_library / 'lib/google/cloud/language/v1') -s.copy(v1_library / 'lib/google/cloud/language.rb') -s.copy(v1_library / 'test/google/cloud/language/v1') -s.copy(v1_library / 'README.md') -s.copy(v1_library / 'LICENSE') -s.copy(v1_library / '.gitignore') -s.copy(v1_library / '.yardopts') -s.copy(v1_library / 'google-cloud-language.gemspec', merge=ruby.merge_gemspec) - -v1beta2_library = gapic.ruby_library( - 'language', 'v1beta2', - artman_output_name='google-cloud-ruby/google-cloud-language' -) -s.copy(v1beta2_library / 'lib/google/cloud/language/v1beta2') -s.copy(v1beta2_library / 'lib/google/cloud/language/v1beta2.rb') -s.copy(v1beta2_library / 'lib/google/cloud/language/v1beta2') -s.copy(v1beta2_library / 'test/google/cloud/language/v1beta2') - -# Copy common templates -templates = gcp.CommonTemplates().ruby_library() -s.copy(templates) - -# Update gemspec to reflect Ruby 2.4 -ruby.update_gemspec('google-cloud-language.gemspec') - -# Update README to reflect Ruby 2.4 -s.replace( - 'README.md', - 'Ruby 2.3', - 'Ruby 2.4' -) - -# Support for service_address -s.replace( - [ - 'lib/google/cloud/language.rb', - 'lib/google/cloud/language/v*.rb', - 'lib/google/cloud/language/v*/*_client.rb' - ], - '\n(\\s+)#(\\s+)@param exception_transformer', - '\n\\1#\\2@param service_address [String]\n' + - '\\1#\\2 Override for the service hostname, or `nil` to leave as the default.\n' + - '\\1#\\2@param service_port [Integer]\n' + - '\\1#\\2 Override for the service port, or `nil` to leave as the default.\n' + - '\\1#\\2@param exception_transformer' -) -s.replace( - [ - 'lib/google/cloud/language/v*.rb', - 'lib/google/cloud/language/v*/*_client.rb' - ], - '\n(\\s+)metadata: nil,\n\\s+exception_transformer: nil,\n', - '\n\\1metadata: nil,\n\\1service_address: nil,\n\\1service_port: nil,\n\\1exception_transformer: nil,\n' -) -s.replace( - [ - 'lib/google/cloud/language/v*.rb', - 'lib/google/cloud/language/v*/*_client.rb' - ], - ',\n(\\s+)lib_name: lib_name,\n\\s+lib_version: lib_version', - ',\n\\1lib_name: lib_name,\n\\1service_address: service_address,\n\\1service_port: service_port,\n\\1lib_version: lib_version' -) -s.replace( - 'lib/google/cloud/language/v*/*_client.rb', - 'service_path = self\\.class::SERVICE_ADDRESS', - 'service_path = service_address || self.class::SERVICE_ADDRESS' -) -s.replace( - 'lib/google/cloud/language/v*/*_client.rb', - 'port = self\\.class::DEFAULT_SERVICE_PORT', - 'port = service_port || self.class::DEFAULT_SERVICE_PORT' -) - -# Ensure simplecov is required -s.replace( - ['test/**/*.rb', 'acceptance/**/*.rb'], - '\n\nrequire "minitest/autorun"\n', - '\n\nrequire "simplecov"\nrequire "minitest/autorun"\n' -) - -# Remove legacy release level from documentation -s.replace( - [ - 'README.md', - 'lib/google/cloud/**/*.rb' - ], - '\\s+\\(\\[\\w+\\]\\(https://github\\.com/(googleapis|GoogleCloudPlatform)/google-cloud-ruby#versioning\\)\\)', - '' -) - -# https://github.com/googleapis/gapic-generator/issues/2196 -s.replace( - [ - 'README.md', - 'lib/google/cloud/language.rb', - 'lib/google/cloud/language/v1.rb', - 'lib/google/cloud/language/v1beta2.rb' - ], - '\\[Product Documentation\\]: https://cloud\\.google\\.com/language\n', - '[Product Documentation]: https://cloud.google.com/natural-language\n') - -# https://github.com/googleapis/gapic-generator/issues/2243 -s.replace( - 'lib/google/cloud/language/*/*_client.rb', - '(\n\\s+class \\w+Client\n)(\\s+)(attr_reader :\\w+_stub)', - '\\1\\2# @private\n\\2\\3') - -# https://github.com/googleapis/gapic-generator/issues/2279 -s.replace( - 'lib/**/*.rb', - '\\A(((#[^\n]*)?\n)*# (Copyright \\d+|Generated by the protocol buffer compiler)[^\n]+\n(#[^\n]*\n)*\n)([^\n])', - '\\1\n\\6') - -# https://github.com/googleapis/gapic-generator/issues/2323 -s.replace( - [ - 'lib/**/*.rb', - 'README.md' - ], - 'https://github\\.com/GoogleCloudPlatform/google-cloud-ruby', - 'https://github.com/googleapis/google-cloud-ruby' -) -s.replace( - [ - 'lib/**/*.rb', - 'README.md' - ], - 'https://googlecloudplatform\\.github\\.io/google-cloud-ruby', - 'https://googleapis.github.io/google-cloud-ruby' -) - -s.replace( - 'lib/google/cloud/language/**/credentials.rb', - '\n'.join([ - '"https://www.googleapis.com/auth/cloud-language",', - ' "https://www.googleapis.com/auth/cloud-platform"' - ]), - '"https://www.googleapis.com/auth/cloud-platform"' -) - -s.replace( - 'google-cloud-language.gemspec', - 'gem.add_dependency "google-gax", "~> 1\\.[\\d\\.]+"', - "\n".join([ - 'gem.add_dependency "google-gax", "~> 1.8"', - ' gem.add_dependency "googleapis-common-protos", ">= 1.3.9", "< 2.0"', - ' gem.add_dependency "googleapis-common-protos-types", ">= 1.0.4", "< 2.0"' - ]) -) - -s.replace( - 'google-cloud-language.gemspec', - '"README.md", "LICENSE"', - '"README.md", "AUTHENTICATION.md", "LICENSE"' -) -s.replace( - '.yardopts', - 'README.md\n', - 'README.md\nAUTHENTICATION.md\nLICENSE\n' -) - -# https://github.com/googleapis/google-cloud-ruby/issues/3058 -s.replace( - 'google-cloud-language.gemspec', - '\nGem::Specification.new do', - 'require File.expand_path("../lib/google/cloud/language/version", __FILE__)\n\nGem::Specification.new do' -) -s.replace( - 'google-cloud-language.gemspec', - '(gem.version\s+=\s+).\d+.\d+.\d.*$', - '\\1Google::Cloud::Language::VERSION' -) -for version in ['v1', 'v1beta2']: - s.replace( - f'lib/google/cloud/language/{version}/*_client.rb', - f'(require \".*credentials\"\n)\n', - f'\\1require "google/cloud/language/version"\n\n' - ) - s.replace( - f'lib/google/cloud/language/{version}/*_client.rb', - 'Gem.loaded_specs\[.*\]\.version\.version', - 'Google::Cloud::Language::VERSION' - ) - -# Fix links for devsite migration -for file in ['lib/**/*.rb', '*.md']: - s.replace( - file, - 'https://googleapis.github.io/google-cloud-ruby/#/docs/google-cloud-logging/latest/google/cloud/logging/logger', - 'https://googleapis.dev/ruby/google-cloud-logging/latest' - ) -s.replace( - '*.md', - 'https://googleapis.github.io/google-cloud-ruby/#/docs/.*/authentication', - 'https://googleapis.dev/ruby/google-cloud-language/latest/file.AUTHENTICATION.html' -) -s.replace( - 'lib/**/*.rb', - 'https://googleapis.github.io/google-cloud-ruby/#/docs/.*/authentication', - 'https://googleapis.dev/ruby/google-cloud-language/latest/file.AUTHENTICATION.html' -) -s.replace( - 'README.md', - 'github.io/google-cloud-ruby/#/docs/google-cloud-language/latest/.*$', - 'dev/ruby/google-cloud-language/latest' -) diff --git a/google-cloud-language/test/google/cloud/language/client_test.rb b/google-cloud-language/test/google/cloud/language/client_test.rb new file mode 100644 index 000000000000..f48c86fe9e9b --- /dev/null +++ b/google-cloud-language/test/google/cloud/language/client_test.rb @@ -0,0 +1,30 @@ +# Copyright 2020 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. + +require "helper" +require "google/cloud/language" +require "gapic/common" +require "gapic/grpc" + +describe Google::Cloud::Language do + it "constructs a language client with the default version" do + Gapic::ServiceStub.stub :new, :stub do + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + client = Google::Cloud::Language.language_service do |config| + config.credentials = grpc_channel + end + client.must_be_kind_of Google::Cloud::Language::V1::LanguageService::Client + end + end +end diff --git a/google-cloud-language/test/google/cloud/language/v1/language_service_client_test.rb b/google-cloud-language/test/google/cloud/language/v1/language_service_client_test.rb deleted file mode 100644 index 340a43f7be96..000000000000 --- a/google-cloud-language/test/google/cloud/language/v1/language_service_client_test.rb +++ /dev/null @@ -1,517 +0,0 @@ -# Copyright 2020 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. - -require "simplecov" -require "minitest/autorun" -require "minitest/spec" - -require "google/gax" - -require "google/cloud/language" -require "google/cloud/language/v1/language_service_client" -require "google/cloud/language/v1/language_service_services_pb" - -class CustomTestError_v1 < StandardError; end - -# Mock for the GRPC::ClientStub class. -class MockGrpcClientStub_v1 - - # @param expected_symbol [Symbol] the symbol of the grpc method to be mocked. - # @param mock_method [Proc] The method that is being mocked. - def initialize(expected_symbol, mock_method) - @expected_symbol = expected_symbol - @mock_method = mock_method - end - - # This overrides the Object#method method to return the mocked method when the mocked method - # is being requested. For methods that aren't being tested, this method returns a proc that - # will raise an error when called. This is to assure that only the mocked grpc method is being - # called. - # - # @param symbol [Symbol] The symbol of the method being requested. - # @return [Proc] The proc of the requested method. If the requested method is not being mocked - # the proc returned will raise when called. - def method(symbol) - return @mock_method if symbol == @expected_symbol - - # The requested method is not being tested, raise if it called. - proc do - raise "The method #{symbol} was unexpectedly called during the " \ - "test for #{@expected_symbol}." - end - end -end - -class MockLanguageServiceCredentials_v1 < Google::Cloud::Language::V1::Credentials - def initialize(method_name) - @method_name = method_name - end - - def updater_proc - proc do - raise "The method `#{@method_name}` was trying to make a grpc request. This should not " \ - "happen since the grpc layer is being mocked." - end - end -end - -describe Google::Cloud::Language::V1::LanguageServiceClient do - - describe 'analyze_sentiment' do - custom_error = CustomTestError_v1.new "Custom test error for Google::Cloud::Language::V1::LanguageServiceClient#analyze_sentiment." - - it 'invokes analyze_sentiment without error' do - # Create request parameters - document = {} - - # Create expected grpc response - language = "language-1613589672" - expected_response = { language: language } - expected_response = Google::Gax::to_proto(expected_response, Google::Cloud::Language::V1::AnalyzeSentimentResponse) - - # Mock Grpc layer - mock_method = proc do |request| - assert_instance_of(Google::Cloud::Language::V1::AnalyzeSentimentRequest, request) - assert_equal(Google::Gax::to_proto(document, Google::Cloud::Language::V1::Document), request.document) - OpenStruct.new(execute: expected_response) - end - mock_stub = MockGrpcClientStub_v1.new(:analyze_sentiment, mock_method) - - # Mock auth layer - mock_credentials = MockLanguageServiceCredentials_v1.new("analyze_sentiment") - - Google::Cloud::Language::V1::LanguageService::Stub.stub(:new, mock_stub) do - Google::Cloud::Language::V1::Credentials.stub(:default, mock_credentials) do - client = Google::Cloud::Language.new(version: :v1) - - # Call method - response = client.analyze_sentiment(document) - - # Verify the response - assert_equal(expected_response, response) - - # Call method with block - client.analyze_sentiment(document) do |response, operation| - # Verify the response - assert_equal(expected_response, response) - refute_nil(operation) - end - end - end - end - - it 'invokes analyze_sentiment with error' do - # Create request parameters - document = {} - - # Mock Grpc layer - mock_method = proc do |request| - assert_instance_of(Google::Cloud::Language::V1::AnalyzeSentimentRequest, request) - assert_equal(Google::Gax::to_proto(document, Google::Cloud::Language::V1::Document), request.document) - raise custom_error - end - mock_stub = MockGrpcClientStub_v1.new(:analyze_sentiment, mock_method) - - # Mock auth layer - mock_credentials = MockLanguageServiceCredentials_v1.new("analyze_sentiment") - - Google::Cloud::Language::V1::LanguageService::Stub.stub(:new, mock_stub) do - Google::Cloud::Language::V1::Credentials.stub(:default, mock_credentials) do - client = Google::Cloud::Language.new(version: :v1) - - # Call method - err = assert_raises Google::Gax::GaxError, CustomTestError_v1 do - client.analyze_sentiment(document) - end - - # Verify the GaxError wrapped the custom error that was raised. - assert_match(custom_error.message, err.message) - end - end - end - end - - describe 'analyze_entities' do - custom_error = CustomTestError_v1.new "Custom test error for Google::Cloud::Language::V1::LanguageServiceClient#analyze_entities." - - it 'invokes analyze_entities without error' do - # Create request parameters - document = {} - - # Create expected grpc response - language = "language-1613589672" - expected_response = { language: language } - expected_response = Google::Gax::to_proto(expected_response, Google::Cloud::Language::V1::AnalyzeEntitiesResponse) - - # Mock Grpc layer - mock_method = proc do |request| - assert_instance_of(Google::Cloud::Language::V1::AnalyzeEntitiesRequest, request) - assert_equal(Google::Gax::to_proto(document, Google::Cloud::Language::V1::Document), request.document) - OpenStruct.new(execute: expected_response) - end - mock_stub = MockGrpcClientStub_v1.new(:analyze_entities, mock_method) - - # Mock auth layer - mock_credentials = MockLanguageServiceCredentials_v1.new("analyze_entities") - - Google::Cloud::Language::V1::LanguageService::Stub.stub(:new, mock_stub) do - Google::Cloud::Language::V1::Credentials.stub(:default, mock_credentials) do - client = Google::Cloud::Language.new(version: :v1) - - # Call method - response = client.analyze_entities(document) - - # Verify the response - assert_equal(expected_response, response) - - # Call method with block - client.analyze_entities(document) do |response, operation| - # Verify the response - assert_equal(expected_response, response) - refute_nil(operation) - end - end - end - end - - it 'invokes analyze_entities with error' do - # Create request parameters - document = {} - - # Mock Grpc layer - mock_method = proc do |request| - assert_instance_of(Google::Cloud::Language::V1::AnalyzeEntitiesRequest, request) - assert_equal(Google::Gax::to_proto(document, Google::Cloud::Language::V1::Document), request.document) - raise custom_error - end - mock_stub = MockGrpcClientStub_v1.new(:analyze_entities, mock_method) - - # Mock auth layer - mock_credentials = MockLanguageServiceCredentials_v1.new("analyze_entities") - - Google::Cloud::Language::V1::LanguageService::Stub.stub(:new, mock_stub) do - Google::Cloud::Language::V1::Credentials.stub(:default, mock_credentials) do - client = Google::Cloud::Language.new(version: :v1) - - # Call method - err = assert_raises Google::Gax::GaxError, CustomTestError_v1 do - client.analyze_entities(document) - end - - # Verify the GaxError wrapped the custom error that was raised. - assert_match(custom_error.message, err.message) - end - end - end - end - - describe 'analyze_entity_sentiment' do - custom_error = CustomTestError_v1.new "Custom test error for Google::Cloud::Language::V1::LanguageServiceClient#analyze_entity_sentiment." - - it 'invokes analyze_entity_sentiment without error' do - # Create request parameters - document = {} - - # Create expected grpc response - language = "language-1613589672" - expected_response = { language: language } - expected_response = Google::Gax::to_proto(expected_response, Google::Cloud::Language::V1::AnalyzeEntitySentimentResponse) - - # Mock Grpc layer - mock_method = proc do |request| - assert_instance_of(Google::Cloud::Language::V1::AnalyzeEntitySentimentRequest, request) - assert_equal(Google::Gax::to_proto(document, Google::Cloud::Language::V1::Document), request.document) - OpenStruct.new(execute: expected_response) - end - mock_stub = MockGrpcClientStub_v1.new(:analyze_entity_sentiment, mock_method) - - # Mock auth layer - mock_credentials = MockLanguageServiceCredentials_v1.new("analyze_entity_sentiment") - - Google::Cloud::Language::V1::LanguageService::Stub.stub(:new, mock_stub) do - Google::Cloud::Language::V1::Credentials.stub(:default, mock_credentials) do - client = Google::Cloud::Language.new(version: :v1) - - # Call method - response = client.analyze_entity_sentiment(document) - - # Verify the response - assert_equal(expected_response, response) - - # Call method with block - client.analyze_entity_sentiment(document) do |response, operation| - # Verify the response - assert_equal(expected_response, response) - refute_nil(operation) - end - end - end - end - - it 'invokes analyze_entity_sentiment with error' do - # Create request parameters - document = {} - - # Mock Grpc layer - mock_method = proc do |request| - assert_instance_of(Google::Cloud::Language::V1::AnalyzeEntitySentimentRequest, request) - assert_equal(Google::Gax::to_proto(document, Google::Cloud::Language::V1::Document), request.document) - raise custom_error - end - mock_stub = MockGrpcClientStub_v1.new(:analyze_entity_sentiment, mock_method) - - # Mock auth layer - mock_credentials = MockLanguageServiceCredentials_v1.new("analyze_entity_sentiment") - - Google::Cloud::Language::V1::LanguageService::Stub.stub(:new, mock_stub) do - Google::Cloud::Language::V1::Credentials.stub(:default, mock_credentials) do - client = Google::Cloud::Language.new(version: :v1) - - # Call method - err = assert_raises Google::Gax::GaxError, CustomTestError_v1 do - client.analyze_entity_sentiment(document) - end - - # Verify the GaxError wrapped the custom error that was raised. - assert_match(custom_error.message, err.message) - end - end - end - end - - describe 'analyze_syntax' do - custom_error = CustomTestError_v1.new "Custom test error for Google::Cloud::Language::V1::LanguageServiceClient#analyze_syntax." - - it 'invokes analyze_syntax without error' do - # Create request parameters - document = {} - - # Create expected grpc response - language = "language-1613589672" - expected_response = { language: language } - expected_response = Google::Gax::to_proto(expected_response, Google::Cloud::Language::V1::AnalyzeSyntaxResponse) - - # Mock Grpc layer - mock_method = proc do |request| - assert_instance_of(Google::Cloud::Language::V1::AnalyzeSyntaxRequest, request) - assert_equal(Google::Gax::to_proto(document, Google::Cloud::Language::V1::Document), request.document) - OpenStruct.new(execute: expected_response) - end - mock_stub = MockGrpcClientStub_v1.new(:analyze_syntax, mock_method) - - # Mock auth layer - mock_credentials = MockLanguageServiceCredentials_v1.new("analyze_syntax") - - Google::Cloud::Language::V1::LanguageService::Stub.stub(:new, mock_stub) do - Google::Cloud::Language::V1::Credentials.stub(:default, mock_credentials) do - client = Google::Cloud::Language.new(version: :v1) - - # Call method - response = client.analyze_syntax(document) - - # Verify the response - assert_equal(expected_response, response) - - # Call method with block - client.analyze_syntax(document) do |response, operation| - # Verify the response - assert_equal(expected_response, response) - refute_nil(operation) - end - end - end - end - - it 'invokes analyze_syntax with error' do - # Create request parameters - document = {} - - # Mock Grpc layer - mock_method = proc do |request| - assert_instance_of(Google::Cloud::Language::V1::AnalyzeSyntaxRequest, request) - assert_equal(Google::Gax::to_proto(document, Google::Cloud::Language::V1::Document), request.document) - raise custom_error - end - mock_stub = MockGrpcClientStub_v1.new(:analyze_syntax, mock_method) - - # Mock auth layer - mock_credentials = MockLanguageServiceCredentials_v1.new("analyze_syntax") - - Google::Cloud::Language::V1::LanguageService::Stub.stub(:new, mock_stub) do - Google::Cloud::Language::V1::Credentials.stub(:default, mock_credentials) do - client = Google::Cloud::Language.new(version: :v1) - - # Call method - err = assert_raises Google::Gax::GaxError, CustomTestError_v1 do - client.analyze_syntax(document) - end - - # Verify the GaxError wrapped the custom error that was raised. - assert_match(custom_error.message, err.message) - end - end - end - end - - describe 'classify_text' do - custom_error = CustomTestError_v1.new "Custom test error for Google::Cloud::Language::V1::LanguageServiceClient#classify_text." - - it 'invokes classify_text without error' do - # Create request parameters - document = {} - - # Create expected grpc response - expected_response = {} - expected_response = Google::Gax::to_proto(expected_response, Google::Cloud::Language::V1::ClassifyTextResponse) - - # Mock Grpc layer - mock_method = proc do |request| - assert_instance_of(Google::Cloud::Language::V1::ClassifyTextRequest, request) - assert_equal(Google::Gax::to_proto(document, Google::Cloud::Language::V1::Document), request.document) - OpenStruct.new(execute: expected_response) - end - mock_stub = MockGrpcClientStub_v1.new(:classify_text, mock_method) - - # Mock auth layer - mock_credentials = MockLanguageServiceCredentials_v1.new("classify_text") - - Google::Cloud::Language::V1::LanguageService::Stub.stub(:new, mock_stub) do - Google::Cloud::Language::V1::Credentials.stub(:default, mock_credentials) do - client = Google::Cloud::Language.new(version: :v1) - - # Call method - response = client.classify_text(document) - - # Verify the response - assert_equal(expected_response, response) - - # Call method with block - client.classify_text(document) do |response, operation| - # Verify the response - assert_equal(expected_response, response) - refute_nil(operation) - end - end - end - end - - it 'invokes classify_text with error' do - # Create request parameters - document = {} - - # Mock Grpc layer - mock_method = proc do |request| - assert_instance_of(Google::Cloud::Language::V1::ClassifyTextRequest, request) - assert_equal(Google::Gax::to_proto(document, Google::Cloud::Language::V1::Document), request.document) - raise custom_error - end - mock_stub = MockGrpcClientStub_v1.new(:classify_text, mock_method) - - # Mock auth layer - mock_credentials = MockLanguageServiceCredentials_v1.new("classify_text") - - Google::Cloud::Language::V1::LanguageService::Stub.stub(:new, mock_stub) do - Google::Cloud::Language::V1::Credentials.stub(:default, mock_credentials) do - client = Google::Cloud::Language.new(version: :v1) - - # Call method - err = assert_raises Google::Gax::GaxError, CustomTestError_v1 do - client.classify_text(document) - end - - # Verify the GaxError wrapped the custom error that was raised. - assert_match(custom_error.message, err.message) - end - end - end - end - - describe 'annotate_text' do - custom_error = CustomTestError_v1.new "Custom test error for Google::Cloud::Language::V1::LanguageServiceClient#annotate_text." - - it 'invokes annotate_text without error' do - # Create request parameters - document = {} - features = {} - - # Create expected grpc response - language = "language-1613589672" - expected_response = { language: language } - expected_response = Google::Gax::to_proto(expected_response, Google::Cloud::Language::V1::AnnotateTextResponse) - - # Mock Grpc layer - mock_method = proc do |request| - assert_instance_of(Google::Cloud::Language::V1::AnnotateTextRequest, request) - assert_equal(Google::Gax::to_proto(document, Google::Cloud::Language::V1::Document), request.document) - assert_equal(Google::Gax::to_proto(features, Google::Cloud::Language::V1::AnnotateTextRequest::Features), request.features) - OpenStruct.new(execute: expected_response) - end - mock_stub = MockGrpcClientStub_v1.new(:annotate_text, mock_method) - - # Mock auth layer - mock_credentials = MockLanguageServiceCredentials_v1.new("annotate_text") - - Google::Cloud::Language::V1::LanguageService::Stub.stub(:new, mock_stub) do - Google::Cloud::Language::V1::Credentials.stub(:default, mock_credentials) do - client = Google::Cloud::Language.new(version: :v1) - - # Call method - response = client.annotate_text(document, features) - - # Verify the response - assert_equal(expected_response, response) - - # Call method with block - client.annotate_text(document, features) do |response, operation| - # Verify the response - assert_equal(expected_response, response) - refute_nil(operation) - end - end - end - end - - it 'invokes annotate_text with error' do - # Create request parameters - document = {} - features = {} - - # Mock Grpc layer - mock_method = proc do |request| - assert_instance_of(Google::Cloud::Language::V1::AnnotateTextRequest, request) - assert_equal(Google::Gax::to_proto(document, Google::Cloud::Language::V1::Document), request.document) - assert_equal(Google::Gax::to_proto(features, Google::Cloud::Language::V1::AnnotateTextRequest::Features), request.features) - raise custom_error - end - mock_stub = MockGrpcClientStub_v1.new(:annotate_text, mock_method) - - # Mock auth layer - mock_credentials = MockLanguageServiceCredentials_v1.new("annotate_text") - - Google::Cloud::Language::V1::LanguageService::Stub.stub(:new, mock_stub) do - Google::Cloud::Language::V1::Credentials.stub(:default, mock_credentials) do - client = Google::Cloud::Language.new(version: :v1) - - # Call method - err = assert_raises Google::Gax::GaxError, CustomTestError_v1 do - client.annotate_text(document, features) - end - - # Verify the GaxError wrapped the custom error that was raised. - assert_match(custom_error.message, err.message) - end - end - end - end -end \ No newline at end of file diff --git a/google-cloud-language/test/google/cloud/language/v1beta2/language_service_client_test.rb b/google-cloud-language/test/google/cloud/language/v1beta2/language_service_client_test.rb deleted file mode 100644 index 87528ae30d52..000000000000 --- a/google-cloud-language/test/google/cloud/language/v1beta2/language_service_client_test.rb +++ /dev/null @@ -1,517 +0,0 @@ -# Copyright 2020 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. - -require "simplecov" -require "minitest/autorun" -require "minitest/spec" - -require "google/gax" - -require "google/cloud/language" -require "google/cloud/language/v1beta2/language_service_client" -require "google/cloud/language/v1beta2/language_service_services_pb" - -class CustomTestError_v1beta2 < StandardError; end - -# Mock for the GRPC::ClientStub class. -class MockGrpcClientStub_v1beta2 - - # @param expected_symbol [Symbol] the symbol of the grpc method to be mocked. - # @param mock_method [Proc] The method that is being mocked. - def initialize(expected_symbol, mock_method) - @expected_symbol = expected_symbol - @mock_method = mock_method - end - - # This overrides the Object#method method to return the mocked method when the mocked method - # is being requested. For methods that aren't being tested, this method returns a proc that - # will raise an error when called. This is to assure that only the mocked grpc method is being - # called. - # - # @param symbol [Symbol] The symbol of the method being requested. - # @return [Proc] The proc of the requested method. If the requested method is not being mocked - # the proc returned will raise when called. - def method(symbol) - return @mock_method if symbol == @expected_symbol - - # The requested method is not being tested, raise if it called. - proc do - raise "The method #{symbol} was unexpectedly called during the " \ - "test for #{@expected_symbol}." - end - end -end - -class MockLanguageServiceCredentials_v1beta2 < Google::Cloud::Language::V1beta2::Credentials - def initialize(method_name) - @method_name = method_name - end - - def updater_proc - proc do - raise "The method `#{@method_name}` was trying to make a grpc request. This should not " \ - "happen since the grpc layer is being mocked." - end - end -end - -describe Google::Cloud::Language::V1beta2::LanguageServiceClient do - - describe 'analyze_sentiment' do - custom_error = CustomTestError_v1beta2.new "Custom test error for Google::Cloud::Language::V1beta2::LanguageServiceClient#analyze_sentiment." - - it 'invokes analyze_sentiment without error' do - # Create request parameters - document = {} - - # Create expected grpc response - language = "language-1613589672" - expected_response = { language: language } - expected_response = Google::Gax::to_proto(expected_response, Google::Cloud::Language::V1beta2::AnalyzeSentimentResponse) - - # Mock Grpc layer - mock_method = proc do |request| - assert_instance_of(Google::Cloud::Language::V1beta2::AnalyzeSentimentRequest, request) - assert_equal(Google::Gax::to_proto(document, Google::Cloud::Language::V1beta2::Document), request.document) - OpenStruct.new(execute: expected_response) - end - mock_stub = MockGrpcClientStub_v1beta2.new(:analyze_sentiment, mock_method) - - # Mock auth layer - mock_credentials = MockLanguageServiceCredentials_v1beta2.new("analyze_sentiment") - - Google::Cloud::Language::V1beta2::LanguageService::Stub.stub(:new, mock_stub) do - Google::Cloud::Language::V1beta2::Credentials.stub(:default, mock_credentials) do - client = Google::Cloud::Language.new(version: :v1beta2) - - # Call method - response = client.analyze_sentiment(document) - - # Verify the response - assert_equal(expected_response, response) - - # Call method with block - client.analyze_sentiment(document) do |response, operation| - # Verify the response - assert_equal(expected_response, response) - refute_nil(operation) - end - end - end - end - - it 'invokes analyze_sentiment with error' do - # Create request parameters - document = {} - - # Mock Grpc layer - mock_method = proc do |request| - assert_instance_of(Google::Cloud::Language::V1beta2::AnalyzeSentimentRequest, request) - assert_equal(Google::Gax::to_proto(document, Google::Cloud::Language::V1beta2::Document), request.document) - raise custom_error - end - mock_stub = MockGrpcClientStub_v1beta2.new(:analyze_sentiment, mock_method) - - # Mock auth layer - mock_credentials = MockLanguageServiceCredentials_v1beta2.new("analyze_sentiment") - - Google::Cloud::Language::V1beta2::LanguageService::Stub.stub(:new, mock_stub) do - Google::Cloud::Language::V1beta2::Credentials.stub(:default, mock_credentials) do - client = Google::Cloud::Language.new(version: :v1beta2) - - # Call method - err = assert_raises Google::Gax::GaxError, CustomTestError_v1beta2 do - client.analyze_sentiment(document) - end - - # Verify the GaxError wrapped the custom error that was raised. - assert_match(custom_error.message, err.message) - end - end - end - end - - describe 'analyze_entities' do - custom_error = CustomTestError_v1beta2.new "Custom test error for Google::Cloud::Language::V1beta2::LanguageServiceClient#analyze_entities." - - it 'invokes analyze_entities without error' do - # Create request parameters - document = {} - - # Create expected grpc response - language = "language-1613589672" - expected_response = { language: language } - expected_response = Google::Gax::to_proto(expected_response, Google::Cloud::Language::V1beta2::AnalyzeEntitiesResponse) - - # Mock Grpc layer - mock_method = proc do |request| - assert_instance_of(Google::Cloud::Language::V1beta2::AnalyzeEntitiesRequest, request) - assert_equal(Google::Gax::to_proto(document, Google::Cloud::Language::V1beta2::Document), request.document) - OpenStruct.new(execute: expected_response) - end - mock_stub = MockGrpcClientStub_v1beta2.new(:analyze_entities, mock_method) - - # Mock auth layer - mock_credentials = MockLanguageServiceCredentials_v1beta2.new("analyze_entities") - - Google::Cloud::Language::V1beta2::LanguageService::Stub.stub(:new, mock_stub) do - Google::Cloud::Language::V1beta2::Credentials.stub(:default, mock_credentials) do - client = Google::Cloud::Language.new(version: :v1beta2) - - # Call method - response = client.analyze_entities(document) - - # Verify the response - assert_equal(expected_response, response) - - # Call method with block - client.analyze_entities(document) do |response, operation| - # Verify the response - assert_equal(expected_response, response) - refute_nil(operation) - end - end - end - end - - it 'invokes analyze_entities with error' do - # Create request parameters - document = {} - - # Mock Grpc layer - mock_method = proc do |request| - assert_instance_of(Google::Cloud::Language::V1beta2::AnalyzeEntitiesRequest, request) - assert_equal(Google::Gax::to_proto(document, Google::Cloud::Language::V1beta2::Document), request.document) - raise custom_error - end - mock_stub = MockGrpcClientStub_v1beta2.new(:analyze_entities, mock_method) - - # Mock auth layer - mock_credentials = MockLanguageServiceCredentials_v1beta2.new("analyze_entities") - - Google::Cloud::Language::V1beta2::LanguageService::Stub.stub(:new, mock_stub) do - Google::Cloud::Language::V1beta2::Credentials.stub(:default, mock_credentials) do - client = Google::Cloud::Language.new(version: :v1beta2) - - # Call method - err = assert_raises Google::Gax::GaxError, CustomTestError_v1beta2 do - client.analyze_entities(document) - end - - # Verify the GaxError wrapped the custom error that was raised. - assert_match(custom_error.message, err.message) - end - end - end - end - - describe 'analyze_entity_sentiment' do - custom_error = CustomTestError_v1beta2.new "Custom test error for Google::Cloud::Language::V1beta2::LanguageServiceClient#analyze_entity_sentiment." - - it 'invokes analyze_entity_sentiment without error' do - # Create request parameters - document = {} - - # Create expected grpc response - language = "language-1613589672" - expected_response = { language: language } - expected_response = Google::Gax::to_proto(expected_response, Google::Cloud::Language::V1beta2::AnalyzeEntitySentimentResponse) - - # Mock Grpc layer - mock_method = proc do |request| - assert_instance_of(Google::Cloud::Language::V1beta2::AnalyzeEntitySentimentRequest, request) - assert_equal(Google::Gax::to_proto(document, Google::Cloud::Language::V1beta2::Document), request.document) - OpenStruct.new(execute: expected_response) - end - mock_stub = MockGrpcClientStub_v1beta2.new(:analyze_entity_sentiment, mock_method) - - # Mock auth layer - mock_credentials = MockLanguageServiceCredentials_v1beta2.new("analyze_entity_sentiment") - - Google::Cloud::Language::V1beta2::LanguageService::Stub.stub(:new, mock_stub) do - Google::Cloud::Language::V1beta2::Credentials.stub(:default, mock_credentials) do - client = Google::Cloud::Language.new(version: :v1beta2) - - # Call method - response = client.analyze_entity_sentiment(document) - - # Verify the response - assert_equal(expected_response, response) - - # Call method with block - client.analyze_entity_sentiment(document) do |response, operation| - # Verify the response - assert_equal(expected_response, response) - refute_nil(operation) - end - end - end - end - - it 'invokes analyze_entity_sentiment with error' do - # Create request parameters - document = {} - - # Mock Grpc layer - mock_method = proc do |request| - assert_instance_of(Google::Cloud::Language::V1beta2::AnalyzeEntitySentimentRequest, request) - assert_equal(Google::Gax::to_proto(document, Google::Cloud::Language::V1beta2::Document), request.document) - raise custom_error - end - mock_stub = MockGrpcClientStub_v1beta2.new(:analyze_entity_sentiment, mock_method) - - # Mock auth layer - mock_credentials = MockLanguageServiceCredentials_v1beta2.new("analyze_entity_sentiment") - - Google::Cloud::Language::V1beta2::LanguageService::Stub.stub(:new, mock_stub) do - Google::Cloud::Language::V1beta2::Credentials.stub(:default, mock_credentials) do - client = Google::Cloud::Language.new(version: :v1beta2) - - # Call method - err = assert_raises Google::Gax::GaxError, CustomTestError_v1beta2 do - client.analyze_entity_sentiment(document) - end - - # Verify the GaxError wrapped the custom error that was raised. - assert_match(custom_error.message, err.message) - end - end - end - end - - describe 'analyze_syntax' do - custom_error = CustomTestError_v1beta2.new "Custom test error for Google::Cloud::Language::V1beta2::LanguageServiceClient#analyze_syntax." - - it 'invokes analyze_syntax without error' do - # Create request parameters - document = {} - - # Create expected grpc response - language = "language-1613589672" - expected_response = { language: language } - expected_response = Google::Gax::to_proto(expected_response, Google::Cloud::Language::V1beta2::AnalyzeSyntaxResponse) - - # Mock Grpc layer - mock_method = proc do |request| - assert_instance_of(Google::Cloud::Language::V1beta2::AnalyzeSyntaxRequest, request) - assert_equal(Google::Gax::to_proto(document, Google::Cloud::Language::V1beta2::Document), request.document) - OpenStruct.new(execute: expected_response) - end - mock_stub = MockGrpcClientStub_v1beta2.new(:analyze_syntax, mock_method) - - # Mock auth layer - mock_credentials = MockLanguageServiceCredentials_v1beta2.new("analyze_syntax") - - Google::Cloud::Language::V1beta2::LanguageService::Stub.stub(:new, mock_stub) do - Google::Cloud::Language::V1beta2::Credentials.stub(:default, mock_credentials) do - client = Google::Cloud::Language.new(version: :v1beta2) - - # Call method - response = client.analyze_syntax(document) - - # Verify the response - assert_equal(expected_response, response) - - # Call method with block - client.analyze_syntax(document) do |response, operation| - # Verify the response - assert_equal(expected_response, response) - refute_nil(operation) - end - end - end - end - - it 'invokes analyze_syntax with error' do - # Create request parameters - document = {} - - # Mock Grpc layer - mock_method = proc do |request| - assert_instance_of(Google::Cloud::Language::V1beta2::AnalyzeSyntaxRequest, request) - assert_equal(Google::Gax::to_proto(document, Google::Cloud::Language::V1beta2::Document), request.document) - raise custom_error - end - mock_stub = MockGrpcClientStub_v1beta2.new(:analyze_syntax, mock_method) - - # Mock auth layer - mock_credentials = MockLanguageServiceCredentials_v1beta2.new("analyze_syntax") - - Google::Cloud::Language::V1beta2::LanguageService::Stub.stub(:new, mock_stub) do - Google::Cloud::Language::V1beta2::Credentials.stub(:default, mock_credentials) do - client = Google::Cloud::Language.new(version: :v1beta2) - - # Call method - err = assert_raises Google::Gax::GaxError, CustomTestError_v1beta2 do - client.analyze_syntax(document) - end - - # Verify the GaxError wrapped the custom error that was raised. - assert_match(custom_error.message, err.message) - end - end - end - end - - describe 'classify_text' do - custom_error = CustomTestError_v1beta2.new "Custom test error for Google::Cloud::Language::V1beta2::LanguageServiceClient#classify_text." - - it 'invokes classify_text without error' do - # Create request parameters - document = {} - - # Create expected grpc response - expected_response = {} - expected_response = Google::Gax::to_proto(expected_response, Google::Cloud::Language::V1beta2::ClassifyTextResponse) - - # Mock Grpc layer - mock_method = proc do |request| - assert_instance_of(Google::Cloud::Language::V1beta2::ClassifyTextRequest, request) - assert_equal(Google::Gax::to_proto(document, Google::Cloud::Language::V1beta2::Document), request.document) - OpenStruct.new(execute: expected_response) - end - mock_stub = MockGrpcClientStub_v1beta2.new(:classify_text, mock_method) - - # Mock auth layer - mock_credentials = MockLanguageServiceCredentials_v1beta2.new("classify_text") - - Google::Cloud::Language::V1beta2::LanguageService::Stub.stub(:new, mock_stub) do - Google::Cloud::Language::V1beta2::Credentials.stub(:default, mock_credentials) do - client = Google::Cloud::Language.new(version: :v1beta2) - - # Call method - response = client.classify_text(document) - - # Verify the response - assert_equal(expected_response, response) - - # Call method with block - client.classify_text(document) do |response, operation| - # Verify the response - assert_equal(expected_response, response) - refute_nil(operation) - end - end - end - end - - it 'invokes classify_text with error' do - # Create request parameters - document = {} - - # Mock Grpc layer - mock_method = proc do |request| - assert_instance_of(Google::Cloud::Language::V1beta2::ClassifyTextRequest, request) - assert_equal(Google::Gax::to_proto(document, Google::Cloud::Language::V1beta2::Document), request.document) - raise custom_error - end - mock_stub = MockGrpcClientStub_v1beta2.new(:classify_text, mock_method) - - # Mock auth layer - mock_credentials = MockLanguageServiceCredentials_v1beta2.new("classify_text") - - Google::Cloud::Language::V1beta2::LanguageService::Stub.stub(:new, mock_stub) do - Google::Cloud::Language::V1beta2::Credentials.stub(:default, mock_credentials) do - client = Google::Cloud::Language.new(version: :v1beta2) - - # Call method - err = assert_raises Google::Gax::GaxError, CustomTestError_v1beta2 do - client.classify_text(document) - end - - # Verify the GaxError wrapped the custom error that was raised. - assert_match(custom_error.message, err.message) - end - end - end - end - - describe 'annotate_text' do - custom_error = CustomTestError_v1beta2.new "Custom test error for Google::Cloud::Language::V1beta2::LanguageServiceClient#annotate_text." - - it 'invokes annotate_text without error' do - # Create request parameters - document = {} - features = {} - - # Create expected grpc response - language = "language-1613589672" - expected_response = { language: language } - expected_response = Google::Gax::to_proto(expected_response, Google::Cloud::Language::V1beta2::AnnotateTextResponse) - - # Mock Grpc layer - mock_method = proc do |request| - assert_instance_of(Google::Cloud::Language::V1beta2::AnnotateTextRequest, request) - assert_equal(Google::Gax::to_proto(document, Google::Cloud::Language::V1beta2::Document), request.document) - assert_equal(Google::Gax::to_proto(features, Google::Cloud::Language::V1beta2::AnnotateTextRequest::Features), request.features) - OpenStruct.new(execute: expected_response) - end - mock_stub = MockGrpcClientStub_v1beta2.new(:annotate_text, mock_method) - - # Mock auth layer - mock_credentials = MockLanguageServiceCredentials_v1beta2.new("annotate_text") - - Google::Cloud::Language::V1beta2::LanguageService::Stub.stub(:new, mock_stub) do - Google::Cloud::Language::V1beta2::Credentials.stub(:default, mock_credentials) do - client = Google::Cloud::Language.new(version: :v1beta2) - - # Call method - response = client.annotate_text(document, features) - - # Verify the response - assert_equal(expected_response, response) - - # Call method with block - client.annotate_text(document, features) do |response, operation| - # Verify the response - assert_equal(expected_response, response) - refute_nil(operation) - end - end - end - end - - it 'invokes annotate_text with error' do - # Create request parameters - document = {} - features = {} - - # Mock Grpc layer - mock_method = proc do |request| - assert_instance_of(Google::Cloud::Language::V1beta2::AnnotateTextRequest, request) - assert_equal(Google::Gax::to_proto(document, Google::Cloud::Language::V1beta2::Document), request.document) - assert_equal(Google::Gax::to_proto(features, Google::Cloud::Language::V1beta2::AnnotateTextRequest::Features), request.features) - raise custom_error - end - mock_stub = MockGrpcClientStub_v1beta2.new(:annotate_text, mock_method) - - # Mock auth layer - mock_credentials = MockLanguageServiceCredentials_v1beta2.new("annotate_text") - - Google::Cloud::Language::V1beta2::LanguageService::Stub.stub(:new, mock_stub) do - Google::Cloud::Language::V1beta2::Credentials.stub(:default, mock_credentials) do - client = Google::Cloud::Language.new(version: :v1beta2) - - # Call method - err = assert_raises Google::Gax::GaxError, CustomTestError_v1beta2 do - client.annotate_text(document, features) - end - - # Verify the GaxError wrapped the custom error that was raised. - assert_match(custom_error.message, err.message) - end - end - end - end -end \ No newline at end of file diff --git a/google-cloud-language/test/google/cloud/language/version_test.rb b/google-cloud-language/test/google/cloud/language/version_test.rb new file mode 100644 index 000000000000..c81baf70bff8 --- /dev/null +++ b/google-cloud-language/test/google/cloud/language/version_test.rb @@ -0,0 +1,22 @@ +# Copyright 2020 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. + +require "helper" +require "google/cloud/language/version" + +describe Google::Cloud::Language, :version do + it "has a version" do + Google::Cloud::Language::VERSION.wont_be :nil? + end +end diff --git a/google-cloud-language/test/helper.rb b/google-cloud-language/test/helper.rb new file mode 100644 index 000000000000..2f2e9a42bef6 --- /dev/null +++ b/google-cloud-language/test/helper.rb @@ -0,0 +1,20 @@ +# Copyright 2020 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. + +require "simplecov" + +gem "minitest" +require "minitest/autorun" +require "minitest/focus" +require "minitest/rg"