google-cloud-language 0.30.0 → 0.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9c813d3d6dc9cd348fc0e4675a8f8009d66be0fae8b58f54a86a8a45cf1a62e5
4
- data.tar.gz: c6b760a0e3b995c747c2f7e65a30eec75bdefd4055b01d9498adff78fe4ae4b6
3
+ metadata.gz: 7f532d8ab84649089a92e38b04da722f32da7566702ad61a718dc219ea53329f
4
+ data.tar.gz: fd5a5f85f93953cbd8b2d63da476122c8f555f06256d591027f6eed810e03775
5
5
  SHA512:
6
- metadata.gz: a98d8fec21d9425b91d596f7c0a823b003f5226ef189ef75fb25f512afa2de7abec72bda65d479a57ea38472a83779d23261468b7d191c35f710ee983135dc64
7
- data.tar.gz: b7df25dc2271c9c1c793595a507e293ab55804f0ed7e4e03c0f1335e83448644c971f8e5daee9a69884a09262fc4cb7f2134f2c23c7651ffbb6eda3b9d7dc318
6
+ metadata.gz: b92b7b3be01f07ca31623a51bdea1b85e233310b71c16633c05a957519cab4ac7f08e69e6447b2532d3d1f00f7fdb48178370f86b6a5d31a17db4445dd47f79c
7
+ data.tar.gz: 9847f9d609799bdbad7f9260638fc48ef381b2323cd567e40168f382d4712a55daa0e5035397f44fb87d67822a14b552746db5a5fcd3d7a710fdc029498f32d4
data/.yardopts CHANGED
@@ -2,6 +2,7 @@
2
2
  --title=Google Cloud Natural Language API
3
3
  --exclude _pb\.rb$
4
4
  --markup markdown
5
+ --markup-provider redcarpet
5
6
 
6
7
  ./lib/**/*.rb
7
8
  -
data/README.md CHANGED
@@ -13,7 +13,7 @@ steps:
13
13
 
14
14
  1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
15
15
  2. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project)
16
- 3. [Enable the Google Cloud Natural Language API.](https://console.cloud.google.com/apis/api/language)
16
+ 3. [Enable the Google Cloud Natural Language API.](https://console.cloud.google.com/apis/library/language.googleapis.com)
17
17
  4. [Setup Authentication.](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud/master/guides/authentication)
18
18
 
19
19
  ### Installation
@@ -43,3 +43,40 @@ response = language_service_client.analyze_sentiment(document)
43
43
 
44
44
  [Client Library Documentation]: https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-language/latest/google/cloud/language/v1
45
45
  [Product Documentation]: https://cloud.google.com/natural-language
46
+
47
+ ## Enabling Logging
48
+
49
+ To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library.
50
+ 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,
51
+ or a [`Google::Cloud::Logging::Logger`](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-logging/latest/google/cloud/logging/logger)
52
+ 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)
53
+ and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
54
+
55
+ Configuring a Ruby stdlib logger:
56
+
57
+ ```ruby
58
+ require "logger"
59
+
60
+ module MyLogger
61
+ LOGGER = Logger.new $stderr, level: Logger::WARN
62
+ def logger
63
+ LOGGER
64
+ end
65
+ end
66
+
67
+ # Define a gRPC module-level logger method before grpc/logconfig.rb loads.
68
+ module GRPC
69
+ extend MyLogger
70
+ end
71
+ ```
72
+
73
+ ## Supported Ruby Versions
74
+
75
+ This library is supported on Ruby 2.3+.
76
+
77
+ Google provides official support for Ruby versions that are actively supported
78
+ by Ruby Core—that is, Ruby versions that are either in normal maintenance or
79
+ in security maintenance, and not end of life. Currently, this means Ruby 2.3
80
+ and later. Older versions of Ruby _may_ still work, but are unsupported and not
81
+ recommended. See https://www.ruby-lang.org/en/downloads/branches/ for details
82
+ about the Ruby support schedule.
@@ -20,7 +20,7 @@ module Google
20
20
  # rubocop:disable LineLength
21
21
 
22
22
  ##
23
- # # Ruby Client for Google Cloud Natural Language API ([Beta](https://github.com/GoogleCloudPlatform/google-cloud-ruby#versioning))
23
+ # # Ruby Client for Google Cloud Natural Language API ([Alpha](https://github.com/GoogleCloudPlatform/google-cloud-ruby#versioning))
24
24
  #
25
25
  # [Google Cloud Natural Language API][Product Documentation]:
26
26
  # Google Cloud Natural Language API provides natural language understanding
@@ -34,7 +34,7 @@ module Google
34
34
  #
35
35
  # 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
36
36
  # 2. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project)
37
- # 3. [Enable the Google Cloud Natural Language API.](https://console.cloud.google.com/apis/api/language)
37
+ # 3. [Enable the Google Cloud Natural Language API.](https://console.cloud.google.com/apis/library/language.googleapis.com)
38
38
  # 4. [Setup Authentication.](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud/master/guides/authentication)
39
39
  #
40
40
  # ### Preview
@@ -57,6 +57,31 @@ module Google
57
57
  #
58
58
  # [Product Documentation]: https://cloud.google.com/natural-language
59
59
  #
60
+ # ## Enabling Logging
61
+ #
62
+ # To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library.
63
+ # 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,
64
+ # or a [`Google::Cloud::Logging::Logger`](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-logging/latest/google/cloud/logging/logger)
65
+ # 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)
66
+ # and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
67
+ #
68
+ # Configuring a Ruby stdlib logger:
69
+ #
70
+ # ```ruby
71
+ # require "logger"
72
+ #
73
+ # module MyLogger
74
+ # LOGGER = Logger.new $stderr, level: Logger::WARN
75
+ # def logger
76
+ # LOGGER
77
+ # end
78
+ # end
79
+ #
80
+ # # Define a gRPC module-level logger method before grpc/logconfig.rb loads.
81
+ # module GRPC
82
+ # extend MyLogger
83
+ # end
84
+ # ```
60
85
  #
61
86
  module Language
62
87
  # rubocop:enable LineLength
@@ -101,6 +126,11 @@ module Google
101
126
  # or the specified config is missing data points.
102
127
  # @param timeout [Numeric]
103
128
  # The default timeout, in seconds, for calls made through this client.
129
+ # @param metadata [Hash]
130
+ # Default metadata to be sent with each request. This can be overridden on a per call basis.
131
+ # @param exception_transformer [Proc]
132
+ # An optional proc that intercepts any exceptions raised during an API call to inject
133
+ # custom error handling.
104
134
  def self.new(*args, version: :v1, **kwargs)
105
135
  unless AVAILABLE_VERSIONS.include?(version.to_s.downcase)
106
136
  raise "The version: #{version} is not available. The available versions " \
@@ -16,48 +16,73 @@ require "google/cloud/language/v1/language_service_client"
16
16
 
17
17
  module Google
18
18
  module Cloud
19
- # rubocop:disable LineLength
20
-
21
- ##
22
- # # Ruby Client for Google Cloud Natural Language API ([Beta](https://github.com/GoogleCloudPlatform/google-cloud-ruby#versioning))
23
- #
24
- # [Google Cloud Natural Language API][Product Documentation]:
25
- # Google Cloud Natural Language API provides natural language understanding
26
- # technologies to developers. Examples include sentiment analysis, entity
27
- # recognition, and text annotations.
28
- # - [Product Documentation][]
29
- #
30
- # ## Quick Start
31
- # In order to use this library, you first need to go through the following
32
- # steps:
33
- #
34
- # 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
35
- # 2. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project)
36
- # 3. [Enable the Google Cloud Natural Language API.](https://console.cloud.google.com/apis/api/language)
37
- # 4. [Setup Authentication.](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud/master/guides/authentication)
38
- #
39
- # ### Preview
40
- # #### LanguageServiceClient
41
- # ```rb
42
- # require "google/cloud/language/v1"
43
- #
44
- # language_service_client = Google::Cloud::Language::V1.new
45
- # content = "Hello, world!"
46
- # type = :PLAIN_TEXT
47
- # document = { content: content, type: type }
48
- # response = language_service_client.analyze_sentiment(document)
49
- # ```
50
- #
51
- # ### Next Steps
52
- # - Read the [Google Cloud Natural Language API Product documentation][Product Documentation]
53
- # to learn more about the product and see How-to Guides.
54
- # - View this [repository's main README](https://github.com/GoogleCloudPlatform/google-cloud-ruby/blob/master/README.md)
55
- # to see the full list of Cloud APIs that we cover.
56
- #
57
- # [Product Documentation]: https://cloud.google.com/natural-language
58
- #
59
- #
60
19
  module Language
20
+ # rubocop:disable LineLength
21
+
22
+ ##
23
+ # # Ruby Client for Google Cloud Natural Language API ([Alpha](https://github.com/GoogleCloudPlatform/google-cloud-ruby#versioning))
24
+ #
25
+ # [Google Cloud Natural Language API][Product Documentation]:
26
+ # Google Cloud Natural Language API provides natural language understanding
27
+ # technologies to developers. Examples include sentiment analysis, entity
28
+ # recognition, and text annotations.
29
+ # - [Product Documentation][]
30
+ #
31
+ # ## Quick Start
32
+ # In order to use this library, you first need to go through the following
33
+ # steps:
34
+ #
35
+ # 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
36
+ # 2. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project)
37
+ # 3. [Enable the Google Cloud Natural Language API.](https://console.cloud.google.com/apis/library/language.googleapis.com)
38
+ # 4. [Setup Authentication.](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud/master/guides/authentication)
39
+ #
40
+ # ### Preview
41
+ # #### LanguageServiceClient
42
+ # ```rb
43
+ # require "google/cloud/language"
44
+ #
45
+ # language_service_client = Google::Cloud::Language.new(version: :v1)
46
+ # content = "Hello, world!"
47
+ # type = :PLAIN_TEXT
48
+ # document = { content: content, type: type }
49
+ # response = language_service_client.analyze_sentiment(document)
50
+ # ```
51
+ #
52
+ # ### Next Steps
53
+ # - Read the [Google Cloud Natural Language API Product documentation][Product Documentation]
54
+ # to learn more about the product and see How-to Guides.
55
+ # - View this [repository's main README](https://github.com/GoogleCloudPlatform/google-cloud-ruby/blob/master/README.md)
56
+ # to see the full list of Cloud APIs that we cover.
57
+ #
58
+ # [Product Documentation]: https://cloud.google.com/natural-language
59
+ #
60
+ # ## Enabling Logging
61
+ #
62
+ # To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library.
63
+ # 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,
64
+ # or a [`Google::Cloud::Logging::Logger`](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-logging/latest/google/cloud/logging/logger)
65
+ # 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)
66
+ # and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
67
+ #
68
+ # Configuring a Ruby stdlib logger:
69
+ #
70
+ # ```ruby
71
+ # require "logger"
72
+ #
73
+ # module MyLogger
74
+ # LOGGER = Logger.new $stderr, level: Logger::WARN
75
+ # def logger
76
+ # LOGGER
77
+ # end
78
+ # end
79
+ #
80
+ # # Define a gRPC module-level logger method before grpc/logconfig.rb loads.
81
+ # module GRPC
82
+ # extend MyLogger
83
+ # end
84
+ # ```
85
+ #
61
86
  module V1
62
87
  # rubocop:enable LineLength
63
88
 
@@ -89,11 +114,18 @@ module Google
89
114
  # or the specified config is missing data points.
90
115
  # @param timeout [Numeric]
91
116
  # The default timeout, in seconds, for calls made through this client.
117
+ # @param metadata [Hash]
118
+ # Default metadata to be sent with each request. This can be overridden on a per call basis.
119
+ # @param exception_transformer [Proc]
120
+ # An optional proc that intercepts any exceptions raised during an API call to inject
121
+ # custom error handling.
92
122
  def self.new \
93
123
  credentials: nil,
94
124
  scopes: nil,
95
125
  client_config: nil,
96
126
  timeout: nil,
127
+ metadata: nil,
128
+ exception_transformer: nil,
97
129
  lib_name: nil,
98
130
  lib_version: nil
99
131
  kwargs = {
@@ -101,6 +133,8 @@ module Google
101
133
  scopes: scopes,
102
134
  client_config: client_config,
103
135
  timeout: timeout,
136
+ metadata: metadata,
137
+ exception_transformer: exception_transformer,
104
138
  lib_name: lib_name,
105
139
  lib_version: lib_version
106
140
  }.select { |_, v| v != nil }
@@ -0,0 +1,40 @@
1
+ # Copyright 2018 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require "googleauth"
16
+
17
+ module Google
18
+ module Cloud
19
+ module Language
20
+ module V1
21
+ class Credentials < Google::Auth::Credentials
22
+ SCOPE = [
23
+ "https://www.googleapis.com/auth/cloud-platform"
24
+ ].freeze
25
+ PATH_ENV_VARS = %w(LANGUAGE_CREDENTIALS
26
+ LANGUAGE_KEYFILE
27
+ GOOGLE_CLOUD_CREDENTIALS
28
+ GOOGLE_CLOUD_KEYFILE
29
+ GCLOUD_KEYFILE)
30
+ JSON_ENV_VARS = %w(LANGUAGE_CREDENTIALS_JSON
31
+ LANGUAGE_KEYFILE_JSON
32
+ GOOGLE_CLOUD_CREDENTIALS_JSON
33
+ GOOGLE_CLOUD_KEYFILE_JSON
34
+ GCLOUD_KEYFILE_JSON)
35
+ DEFAULT_PATHS = ["~/.config/gcloud/application_default_credentials.json"]
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -15,17 +15,6 @@
15
15
  module Google
16
16
  module Cloud
17
17
  module Language
18
- ##
19
- # # Google Cloud Natural Language API Contents
20
- #
21
- # | Class | Description |
22
- # | ----- | ----------- |
23
- # | [LanguageServiceClient][] | Provides text analysis operations such as sentiment analysis and entity recognition. |
24
- # | [Data Types][] | Data types for Google::Cloud::Language::V1 |
25
- #
26
- # [LanguageServiceClient]: https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-language/latest/google/cloud/language/v1/languageserviceclient
27
- # [Data Types]: https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-language/latest/google/cloud/language/v1/datatypes
28
- #
29
18
  module V1
30
19
  # ================================================================ #
31
20
  #
@@ -17,7 +17,7 @@ module Google
17
17
  # rubocop:disable LineLength
18
18
 
19
19
  ##
20
- # # Ruby Client for Google Cloud Natural Language API ([Beta](https://github.com/GoogleCloudPlatform/google-cloud-ruby#versioning))
20
+ # # Ruby Client for Google Cloud Natural Language API ([Alpha](https://github.com/GoogleCloudPlatform/google-cloud-ruby#versioning))
21
21
  #
22
22
  # [Google Cloud Natural Language API][Product Documentation]:
23
23
  # Google Cloud Natural Language API provides natural language understanding
@@ -31,7 +31,7 @@ module Google
31
31
  #
32
32
  # 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
33
33
  # 2. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project)
34
- # 3. [Enable the Google Cloud Natural Language API.](https://console.cloud.google.com/apis/api/language)
34
+ # 3. [Enable the Google Cloud Natural Language API.](https://console.cloud.google.com/apis/library/language.googleapis.com)
35
35
  # 4. [Setup Authentication.](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud/master/guides/authentication)
36
36
  #
37
37
  # ### Installation
@@ -59,6 +59,31 @@ module Google
59
59
  #
60
60
  # [Product Documentation]: https://cloud.google.com/natural-language
61
61
  #
62
+ # ## Enabling Logging
63
+ #
64
+ # To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library.
65
+ # 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,
66
+ # or a [`Google::Cloud::Logging::Logger`](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-logging/latest/google/cloud/logging/logger)
67
+ # 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)
68
+ # and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
69
+ #
70
+ # Configuring a Ruby stdlib logger:
71
+ #
72
+ # ```ruby
73
+ # require "logger"
74
+ #
75
+ # module MyLogger
76
+ # LOGGER = Logger.new $stderr, level: Logger::WARN
77
+ # def logger
78
+ # LOGGER
79
+ # end
80
+ # end
81
+ #
82
+ # # Define a gRPC module-level logger method before grpc/logconfig.rb loads.
83
+ # module GRPC
84
+ # extend MyLogger
85
+ # end
86
+ # ```
62
87
  #
63
88
  module Language
64
89
  module V1
@@ -25,7 +25,7 @@ require "pathname"
25
25
  require "google/gax"
26
26
 
27
27
  require "google/cloud/language/v1/language_service_pb"
28
- require "google/cloud/language/credentials"
28
+ require "google/cloud/language/v1/credentials"
29
29
 
30
30
  module Google
31
31
  module Cloud
@@ -45,6 +45,9 @@ module Google
45
45
  # The default port of the service.
46
46
  DEFAULT_SERVICE_PORT = 443
47
47
 
48
+ # The default set of gRPC interceptors.
49
+ GRPC_INTERCEPTORS = []
50
+
48
51
  DEFAULT_TIMEOUT = 30
49
52
 
50
53
  # The scopes needed to make gRPC calls to all of the methods defined in
@@ -78,11 +81,18 @@ module Google
78
81
  # or the specified config is missing data points.
79
82
  # @param timeout [Numeric]
80
83
  # The default timeout, in seconds, for calls made through this client.
84
+ # @param metadata [Hash]
85
+ # Default metadata to be sent with each request. This can be overridden on a per call basis.
86
+ # @param exception_transformer [Proc]
87
+ # An optional proc that intercepts any exceptions raised during an API call to inject
88
+ # custom error handling.
81
89
  def initialize \
82
90
  credentials: nil,
83
91
  scopes: ALL_SCOPES,
84
92
  client_config: {},
85
93
  timeout: DEFAULT_TIMEOUT,
94
+ metadata: nil,
95
+ exception_transformer: nil,
86
96
  lib_name: nil,
87
97
  lib_version: ""
88
98
  # These require statements are intentionally placed here to initialize
@@ -91,10 +101,10 @@ module Google
91
101
  require "google/gax/grpc"
92
102
  require "google/cloud/language/v1/language_service_services_pb"
93
103
 
94
- credentials ||= Google::Cloud::Language::Credentials.default
104
+ credentials ||= Google::Cloud::Language::V1::Credentials.default
95
105
 
96
106
  if credentials.is_a?(String) || credentials.is_a?(Hash)
97
- updater_proc = Google::Cloud::Language::Credentials.new(credentials).updater_proc
107
+ updater_proc = Google::Cloud::Language::V1::Credentials.new(credentials).updater_proc
98
108
  end
99
109
  if credentials.is_a?(GRPC::Core::Channel)
100
110
  channel = credentials
@@ -118,6 +128,7 @@ module Google
118
128
  google_api_client.freeze
119
129
 
120
130
  headers = { :"x-goog-api-client" => google_api_client }
131
+ headers.merge!(metadata) unless metadata.nil?
121
132
  client_config_file = Pathname.new(__dir__).join(
122
133
  "language_service_client_config.json"
123
134
  )
@@ -129,13 +140,14 @@ module Google
129
140
  Google::Gax::Grpc::STATUS_CODE_NAMES,
130
141
  timeout,
131
142
  errors: Google::Gax::Grpc::API_ERRORS,
132
- kwargs: headers
143
+ metadata: headers
133
144
  )
134
145
  end
135
146
 
136
147
  # Allow overriding the service path/port in subclasses.
137
148
  service_path = self.class::SERVICE_ADDRESS
138
149
  port = self.class::DEFAULT_SERVICE_PORT
150
+ interceptors = self.class::GRPC_INTERCEPTORS
139
151
  @language_service_stub = Google::Gax::Grpc.create_stub(
140
152
  service_path,
141
153
  port,
@@ -143,32 +155,39 @@ module Google
143
155
  channel: channel,
144
156
  updater_proc: updater_proc,
145
157
  scopes: scopes,
158
+ interceptors: interceptors,
146
159
  &Google::Cloud::Language::V1::LanguageService::Stub.method(:new)
147
160
  )
148
161
 
149
162
  @analyze_sentiment = Google::Gax.create_api_call(
150
163
  @language_service_stub.method(:analyze_sentiment),
151
- defaults["analyze_sentiment"]
164
+ defaults["analyze_sentiment"],
165
+ exception_transformer: exception_transformer
152
166
  )
153
167
  @analyze_entities = Google::Gax.create_api_call(
154
168
  @language_service_stub.method(:analyze_entities),
155
- defaults["analyze_entities"]
169
+ defaults["analyze_entities"],
170
+ exception_transformer: exception_transformer
156
171
  )
157
172
  @analyze_entity_sentiment = Google::Gax.create_api_call(
158
173
  @language_service_stub.method(:analyze_entity_sentiment),
159
- defaults["analyze_entity_sentiment"]
174
+ defaults["analyze_entity_sentiment"],
175
+ exception_transformer: exception_transformer
160
176
  )
161
177
  @analyze_syntax = Google::Gax.create_api_call(
162
178
  @language_service_stub.method(:analyze_syntax),
163
- defaults["analyze_syntax"]
179
+ defaults["analyze_syntax"],
180
+ exception_transformer: exception_transformer
164
181
  )
165
182
  @classify_text = Google::Gax.create_api_call(
166
183
  @language_service_stub.method(:classify_text),
167
- defaults["classify_text"]
184
+ defaults["classify_text"],
185
+ exception_transformer: exception_transformer
168
186
  )
169
187
  @annotate_text = Google::Gax.create_api_call(
170
188
  @language_service_stub.method(:annotate_text),
171
- defaults["annotate_text"]
189
+ defaults["annotate_text"],
190
+ exception_transformer: exception_transformer
172
191
  )
173
192
  end
174
193
 
@@ -185,25 +204,31 @@ module Google
185
204
  # @param options [Google::Gax::CallOptions]
186
205
  # Overrides the default settings for this call, e.g, timeout,
187
206
  # retries, etc.
207
+ # @yield [result, operation] Access the result along with the RPC operation
208
+ # @yieldparam result [Google::Cloud::Language::V1::AnalyzeSentimentResponse]
209
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
188
210
  # @return [Google::Cloud::Language::V1::AnalyzeSentimentResponse]
189
211
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
190
212
  # @example
191
- # require "google/cloud/language/v1"
213
+ # require "google/cloud/language"
214
+ #
215
+ # language_service_client = Google::Cloud::Language.new(version: :v1)
192
216
  #
193
- # language_service_client = Google::Cloud::Language::V1.new
217
+ # # TODO: Initialize +document+:
194
218
  # document = {}
195
219
  # response = language_service_client.analyze_sentiment(document)
196
220
 
197
221
  def analyze_sentiment \
198
222
  document,
199
223
  encoding_type: nil,
200
- options: nil
224
+ options: nil,
225
+ &block
201
226
  req = {
202
227
  document: document,
203
228
  encoding_type: encoding_type
204
229
  }.delete_if { |_, v| v.nil? }
205
230
  req = Google::Gax::to_proto(req, Google::Cloud::Language::V1::AnalyzeSentimentRequest)
206
- @analyze_sentiment.call(req, options)
231
+ @analyze_sentiment.call(req, options, &block)
207
232
  end
208
233
 
209
234
  # Finds named entities (currently proper names and common nouns) in the text
@@ -219,25 +244,31 @@ module Google
219
244
  # @param options [Google::Gax::CallOptions]
220
245
  # Overrides the default settings for this call, e.g, timeout,
221
246
  # retries, etc.
247
+ # @yield [result, operation] Access the result along with the RPC operation
248
+ # @yieldparam result [Google::Cloud::Language::V1::AnalyzeEntitiesResponse]
249
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
222
250
  # @return [Google::Cloud::Language::V1::AnalyzeEntitiesResponse]
223
251
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
224
252
  # @example
225
- # require "google/cloud/language/v1"
253
+ # require "google/cloud/language"
226
254
  #
227
- # language_service_client = Google::Cloud::Language::V1.new
255
+ # language_service_client = Google::Cloud::Language.new(version: :v1)
256
+ #
257
+ # # TODO: Initialize +document+:
228
258
  # document = {}
229
259
  # response = language_service_client.analyze_entities(document)
230
260
 
231
261
  def analyze_entities \
232
262
  document,
233
263
  encoding_type: nil,
234
- options: nil
264
+ options: nil,
265
+ &block
235
266
  req = {
236
267
  document: document,
237
268
  encoding_type: encoding_type
238
269
  }.delete_if { |_, v| v.nil? }
239
270
  req = Google::Gax::to_proto(req, Google::Cloud::Language::V1::AnalyzeEntitiesRequest)
240
- @analyze_entities.call(req, options)
271
+ @analyze_entities.call(req, options, &block)
241
272
  end
242
273
 
243
274
  # Finds entities, similar to {Google::Cloud::Language::V1::LanguageService::AnalyzeEntities AnalyzeEntities} in the text and analyzes
@@ -252,25 +283,31 @@ module Google
252
283
  # @param options [Google::Gax::CallOptions]
253
284
  # Overrides the default settings for this call, e.g, timeout,
254
285
  # retries, etc.
286
+ # @yield [result, operation] Access the result along with the RPC operation
287
+ # @yieldparam result [Google::Cloud::Language::V1::AnalyzeEntitySentimentResponse]
288
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
255
289
  # @return [Google::Cloud::Language::V1::AnalyzeEntitySentimentResponse]
256
290
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
257
291
  # @example
258
- # require "google/cloud/language/v1"
292
+ # require "google/cloud/language"
293
+ #
294
+ # language_service_client = Google::Cloud::Language.new(version: :v1)
259
295
  #
260
- # language_service_client = Google::Cloud::Language::V1.new
296
+ # # TODO: Initialize +document+:
261
297
  # document = {}
262
298
  # response = language_service_client.analyze_entity_sentiment(document)
263
299
 
264
300
  def analyze_entity_sentiment \
265
301
  document,
266
302
  encoding_type: nil,
267
- options: nil
303
+ options: nil,
304
+ &block
268
305
  req = {
269
306
  document: document,
270
307
  encoding_type: encoding_type
271
308
  }.delete_if { |_, v| v.nil? }
272
309
  req = Google::Gax::to_proto(req, Google::Cloud::Language::V1::AnalyzeEntitySentimentRequest)
273
- @analyze_entity_sentiment.call(req, options)
310
+ @analyze_entity_sentiment.call(req, options, &block)
274
311
  end
275
312
 
276
313
  # Analyzes the syntax of the text and provides sentence boundaries and
@@ -286,25 +323,31 @@ module Google
286
323
  # @param options [Google::Gax::CallOptions]
287
324
  # Overrides the default settings for this call, e.g, timeout,
288
325
  # retries, etc.
326
+ # @yield [result, operation] Access the result along with the RPC operation
327
+ # @yieldparam result [Google::Cloud::Language::V1::AnalyzeSyntaxResponse]
328
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
289
329
  # @return [Google::Cloud::Language::V1::AnalyzeSyntaxResponse]
290
330
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
291
331
  # @example
292
- # require "google/cloud/language/v1"
332
+ # require "google/cloud/language"
293
333
  #
294
- # language_service_client = Google::Cloud::Language::V1.new
334
+ # language_service_client = Google::Cloud::Language.new(version: :v1)
335
+ #
336
+ # # TODO: Initialize +document+:
295
337
  # document = {}
296
338
  # response = language_service_client.analyze_syntax(document)
297
339
 
298
340
  def analyze_syntax \
299
341
  document,
300
342
  encoding_type: nil,
301
- options: nil
343
+ options: nil,
344
+ &block
302
345
  req = {
303
346
  document: document,
304
347
  encoding_type: encoding_type
305
348
  }.delete_if { |_, v| v.nil? }
306
349
  req = Google::Gax::to_proto(req, Google::Cloud::Language::V1::AnalyzeSyntaxRequest)
307
- @analyze_syntax.call(req, options)
350
+ @analyze_syntax.call(req, options, &block)
308
351
  end
309
352
 
310
353
  # Classifies a document into categories.
@@ -316,23 +359,29 @@ module Google
316
359
  # @param options [Google::Gax::CallOptions]
317
360
  # Overrides the default settings for this call, e.g, timeout,
318
361
  # retries, etc.
362
+ # @yield [result, operation] Access the result along with the RPC operation
363
+ # @yieldparam result [Google::Cloud::Language::V1::ClassifyTextResponse]
364
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
319
365
  # @return [Google::Cloud::Language::V1::ClassifyTextResponse]
320
366
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
321
367
  # @example
322
- # require "google/cloud/language/v1"
368
+ # require "google/cloud/language"
369
+ #
370
+ # language_service_client = Google::Cloud::Language.new(version: :v1)
323
371
  #
324
- # language_service_client = Google::Cloud::Language::V1.new
372
+ # # TODO: Initialize +document+:
325
373
  # document = {}
326
374
  # response = language_service_client.classify_text(document)
327
375
 
328
376
  def classify_text \
329
377
  document,
330
- options: nil
378
+ options: nil,
379
+ &block
331
380
  req = {
332
381
  document: document
333
382
  }.delete_if { |_, v| v.nil? }
334
383
  req = Google::Gax::to_proto(req, Google::Cloud::Language::V1::ClassifyTextRequest)
335
- @classify_text.call(req, options)
384
+ @classify_text.call(req, options, &block)
336
385
  end
337
386
 
338
387
  # A convenience method that provides all the features that analyzeSentiment,
@@ -351,13 +400,20 @@ module Google
351
400
  # @param options [Google::Gax::CallOptions]
352
401
  # Overrides the default settings for this call, e.g, timeout,
353
402
  # retries, etc.
403
+ # @yield [result, operation] Access the result along with the RPC operation
404
+ # @yieldparam result [Google::Cloud::Language::V1::AnnotateTextResponse]
405
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
354
406
  # @return [Google::Cloud::Language::V1::AnnotateTextResponse]
355
407
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
356
408
  # @example
357
- # require "google/cloud/language/v1"
409
+ # require "google/cloud/language"
358
410
  #
359
- # language_service_client = Google::Cloud::Language::V1.new
411
+ # language_service_client = Google::Cloud::Language.new(version: :v1)
412
+ #
413
+ # # TODO: Initialize +document+:
360
414
  # document = {}
415
+ #
416
+ # # TODO: Initialize +features+:
361
417
  # features = {}
362
418
  # response = language_service_client.annotate_text(document, features)
363
419
 
@@ -365,14 +421,15 @@ module Google
365
421
  document,
366
422
  features,
367
423
  encoding_type: nil,
368
- options: nil
424
+ options: nil,
425
+ &block
369
426
  req = {
370
427
  document: document,
371
428
  features: features,
372
429
  encoding_type: encoding_type
373
430
  }.delete_if { |_, v| v.nil? }
374
431
  req = Google::Gax::to_proto(req, Google::Cloud::Language::V1::AnnotateTextRequest)
375
- @annotate_text.call(req, options)
432
+ @annotate_text.call(req, options, &block)
376
433
  end
377
434
  end
378
435
  end