google-cloud-dialogflow-v2 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +12 -0
  3. data/AUTHENTICATION.md +169 -0
  4. data/LICENSE.md +201 -0
  5. data/README.md +24 -0
  6. data/lib/google-cloud-dialogflow-v2.rb +1 -0
  7. data/lib/google/cloud/common_resources_pb.rb +15 -0
  8. data/lib/google/cloud/dialogflow/v2.rb +24 -0
  9. data/lib/google/cloud/dialogflow/v2/agent_pb.rb +122 -0
  10. data/lib/google/cloud/dialogflow/v2/agent_services_pb.rb +110 -0
  11. data/lib/google/cloud/dialogflow/v2/agents.rb +21 -0
  12. data/lib/google/cloud/dialogflow/v2/agents/client.rb +1047 -0
  13. data/lib/google/cloud/dialogflow/v2/agents/credentials.rb +53 -0
  14. data/lib/google/cloud/dialogflow/v2/agents/operations.rb +559 -0
  15. data/lib/google/cloud/dialogflow/v2/agents/paths.rb +59 -0
  16. data/lib/google/cloud/dialogflow/v2/audio_config_pb.rb +97 -0
  17. data/lib/google/cloud/dialogflow/v2/context_pb.rb +64 -0
  18. data/lib/google/cloud/dialogflow/v2/context_services_pb.rb +74 -0
  19. data/lib/google/cloud/dialogflow/v2/contexts.rb +20 -0
  20. data/lib/google/cloud/dialogflow/v2/contexts/client.rb +756 -0
  21. data/lib/google/cloud/dialogflow/v2/contexts/credentials.rb +53 -0
  22. data/lib/google/cloud/dialogflow/v2/contexts/paths.rb +50 -0
  23. data/lib/google/cloud/dialogflow/v2/entity_type_pb.rb +126 -0
  24. data/lib/google/cloud/dialogflow/v2/entity_type_services_pb.rb +104 -0
  25. data/lib/google/cloud/dialogflow/v2/entity_types.rb +21 -0
  26. data/lib/google/cloud/dialogflow/v2/entity_types/client.rb +1150 -0
  27. data/lib/google/cloud/dialogflow/v2/entity_types/credentials.rb +53 -0
  28. data/lib/google/cloud/dialogflow/v2/entity_types/operations.rb +559 -0
  29. data/lib/google/cloud/dialogflow/v2/entity_types/paths.rb +62 -0
  30. data/lib/google/cloud/dialogflow/v2/intent_pb.rb +368 -0
  31. data/lib/google/cloud/dialogflow/v2/intent_services_pb.rb +92 -0
  32. data/lib/google/cloud/dialogflow/v2/intents.rb +21 -0
  33. data/lib/google/cloud/dialogflow/v2/intents/client.rb +893 -0
  34. data/lib/google/cloud/dialogflow/v2/intents/credentials.rb +53 -0
  35. data/lib/google/cloud/dialogflow/v2/intents/operations.rb +559 -0
  36. data/lib/google/cloud/dialogflow/v2/intents/paths.rb +81 -0
  37. data/lib/google/cloud/dialogflow/v2/session_entity_type_pb.rb +66 -0
  38. data/lib/google/cloud/dialogflow/v2/session_entity_type_services_pb.rb +92 -0
  39. data/lib/google/cloud/dialogflow/v2/session_entity_types.rb +20 -0
  40. data/lib/google/cloud/dialogflow/v2/session_entity_types/client.rb +727 -0
  41. data/lib/google/cloud/dialogflow/v2/session_entity_types/credentials.rb +53 -0
  42. data/lib/google/cloud/dialogflow/v2/session_entity_types/paths.rb +69 -0
  43. data/lib/google/cloud/dialogflow/v2/session_pb.rb +142 -0
  44. data/lib/google/cloud/dialogflow/v2/session_services_pb.rb +55 -0
  45. data/lib/google/cloud/dialogflow/v2/sessions.rb +20 -0
  46. data/lib/google/cloud/dialogflow/v2/sessions/client.rb +472 -0
  47. data/lib/google/cloud/dialogflow/v2/sessions/credentials.rb +53 -0
  48. data/lib/google/cloud/dialogflow/v2/sessions/paths.rb +110 -0
  49. data/lib/google/cloud/dialogflow/v2/validation_result_pb.rb +37 -0
  50. data/lib/google/cloud/dialogflow/v2/version.rb +28 -0
  51. data/lib/google/cloud/dialogflow/v2/webhook_pb.rb +47 -0
  52. data/proto_docs/README.md +4 -0
  53. data/proto_docs/google/api/field_behavior.rb +59 -0
  54. data/proto_docs/google/api/resource.rb +247 -0
  55. data/proto_docs/google/cloud/dialogflow/v2/agent.rb +287 -0
  56. data/proto_docs/google/cloud/dialogflow/v2/audio_config.rb +363 -0
  57. data/proto_docs/google/cloud/dialogflow/v2/context.rb +144 -0
  58. data/proto_docs/google/cloud/dialogflow/v2/entity_type.rb +354 -0
  59. data/proto_docs/google/cloud/dialogflow/v2/intent.rb +1070 -0
  60. data/proto_docs/google/cloud/dialogflow/v2/session.rb +541 -0
  61. data/proto_docs/google/cloud/dialogflow/v2/session_entity_type.rb +155 -0
  62. data/proto_docs/google/cloud/dialogflow/v2/validation_result.rb +81 -0
  63. data/proto_docs/google/cloud/dialogflow/v2/webhook.rb +153 -0
  64. data/proto_docs/google/longrunning/operations.rb +150 -0
  65. data/proto_docs/google/protobuf/any.rb +137 -0
  66. data/proto_docs/google/protobuf/duration.rb +98 -0
  67. data/proto_docs/google/protobuf/empty.rb +36 -0
  68. data/proto_docs/google/protobuf/field_mask.rb +237 -0
  69. data/proto_docs/google/protobuf/struct.rb +96 -0
  70. data/proto_docs/google/rpc/status.rb +46 -0
  71. data/proto_docs/google/type/latlng.rb +38 -0
  72. metadata +225 -0
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "googleauth"
20
+
21
+
22
+ module Google
23
+ module Cloud
24
+ module Dialogflow
25
+ module V2
26
+ module Agents
27
+ # Credentials for the Agents API.
28
+ class Credentials < Google::Auth::Credentials
29
+ self.scope = [
30
+ "https://www.googleapis.com/auth/cloud-platform",
31
+ "https://www.googleapis.com/auth/dialogflow"
32
+ ]
33
+ self.env_vars = [
34
+ "DIALOGFLOW_CREDENTIALS",
35
+ "DIALOGFLOW_KEYFILE",
36
+ "GOOGLE_CLOUD_CREDENTIALS",
37
+ "GOOGLE_CLOUD_KEYFILE",
38
+ "GCLOUD_KEYFILE",
39
+ "DIALOGFLOW_CREDENTIALS_JSON",
40
+ "DIALOGFLOW_KEYFILE_JSON",
41
+ "GOOGLE_CLOUD_CREDENTIALS_JSON",
42
+ "GOOGLE_CLOUD_KEYFILE_JSON",
43
+ "GCLOUD_KEYFILE_JSON"
44
+ ]
45
+ self.paths = [
46
+ "~/.config/google_cloud/application_default_credentials.json"
47
+ ]
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,559 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "gapic/common"
20
+ require "gapic/operation"
21
+
22
+ require "google/cloud/dialogflow/v2/version"
23
+ require "google/cloud/dialogflow/v2/agents/client"
24
+ require "google/longrunning/operations_pb"
25
+
26
+
27
+ module Google
28
+ module Cloud
29
+ module Dialogflow
30
+ module V2
31
+ module Agents
32
+ # Service that implements Longrunning Operations API.
33
+ class Operations
34
+ # @private
35
+ attr_reader :operations_stub
36
+
37
+ ##
38
+ # Configuration for the Agents Operations API.
39
+ #
40
+ # @yield [config] Configure the Operations client.
41
+ # @yieldparam config [Operations::Configuration]
42
+ #
43
+ # @return [Operations::Configuration]
44
+ #
45
+ def self.configure
46
+ @configure ||= Operations::Configuration.new
47
+ yield @configure if block_given?
48
+ @configure
49
+ end
50
+
51
+ ##
52
+ # Configure the Agents Operations instance.
53
+ #
54
+ # The configuration is set to the derived mode, meaning that values can be changed,
55
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
56
+ # should be made on {Operations.configure}.
57
+ #
58
+ # @yield [config] Configure the Operations client.
59
+ # @yieldparam config [Operations::Configuration]
60
+ #
61
+ # @return [Operations::Configuration]
62
+ #
63
+ def configure
64
+ yield @config if block_given?
65
+ @config
66
+ end
67
+
68
+ ##
69
+ # Create a new Operations client object.
70
+ #
71
+ # @yield [config] Configure the Client client.
72
+ # @yieldparam config [Operations::Configuration]
73
+ #
74
+ def initialize
75
+ # These require statements are intentionally placed here to initialize
76
+ # the gRPC module only when it's required.
77
+ # See https://github.com/googleapis/toolkit/issues/446
78
+ require "gapic/grpc"
79
+ require "google/longrunning/operations_services_pb"
80
+
81
+ # Create the configuration object
82
+ @config = Configuration.new Operations.configure
83
+
84
+ # Yield the configuration if needed
85
+ yield @config if block_given?
86
+
87
+ # Create credentials
88
+ credentials = @config.credentials
89
+ credentials ||= Credentials.default scope: @config.scope
90
+ if credentials.is_a?(String) || credentials.is_a?(Hash)
91
+ credentials = Credentials.new credentials, scope: @config.scope
92
+ end
93
+
94
+ @operations_stub = Gapic::ServiceStub.new(
95
+ Google::Longrunning::Operations::Stub,
96
+ credentials: credentials,
97
+ endpoint: @config.endpoint,
98
+ channel_args: @config.channel_args,
99
+ interceptors: @config.interceptors
100
+ )
101
+ end
102
+
103
+ # Service calls
104
+
105
+ ##
106
+ # Lists operations that match the specified filter in the request. If the
107
+ # server doesn't support this method, it returns `UNIMPLEMENTED`.
108
+ #
109
+ # NOTE: the `name` binding below allows API services to override the binding
110
+ # to use different resource name schemes, such as `users/*/operations`.
111
+ #
112
+ # @overload list_operations(request, options = nil)
113
+ # @param request [Google::Longrunning::ListOperationsRequest | Hash]
114
+ # Lists operations that match the specified filter in the request. If the
115
+ # server doesn't support this method, it returns `UNIMPLEMENTED`.
116
+ #
117
+ # NOTE: the `name` binding below allows API services to override the binding
118
+ # to use different resource name schemes, such as `users/*/operations`.
119
+ # @param options [Gapic::CallOptions, Hash]
120
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
121
+ #
122
+ # @overload list_operations(name: nil, filter: nil, page_size: nil, page_token: nil)
123
+ # @param name [String]
124
+ # The name of the operation collection.
125
+ # @param filter [String]
126
+ # The standard list filter.
127
+ # @param page_size [Integer]
128
+ # The standard list page size.
129
+ # @param page_token [String]
130
+ # The standard list page token.
131
+ #
132
+ #
133
+ # @yield [response, operation] Access the result along with the RPC operation
134
+ # @yieldparam response [Gapic::PagedEnumerable<Gapic::Operation>]
135
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
136
+ #
137
+ # @return [Gapic::PagedEnumerable<Gapic::Operation>]
138
+ #
139
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
140
+ #
141
+ def list_operations request, options = nil
142
+ raise ArgumentError, "request must be provided" if request.nil?
143
+
144
+ request = Gapic::Protobuf.coerce request, to: Google::Longrunning::ListOperationsRequest
145
+
146
+ # Converts hash and nil to an options object
147
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
148
+
149
+ # Customize the options with defaults
150
+ metadata = @config.rpcs.list_operations.metadata.to_h
151
+
152
+ # Set x-goog-api-client and x-goog-user-project headers
153
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
154
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
155
+ gapic_version: ::Google::Cloud::Dialogflow::V2::VERSION
156
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
157
+
158
+ header_params = {
159
+ "name" => request.name
160
+ }
161
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
162
+ metadata[:"x-goog-request-params"] ||= request_params_header
163
+
164
+ options.apply_defaults timeout: @config.rpcs.list_operations.timeout,
165
+ metadata: metadata,
166
+ retry_policy: @config.rpcs.list_operations.retry_policy
167
+ options.apply_defaults metadata: @config.metadata,
168
+ retry_policy: @config.retry_policy
169
+
170
+ @operations_stub.call_rpc :list_operations, request, options: options do |response, operation|
171
+ wrap_lro_operation = ->(op_response) { Gapic::Operation.new op_response, @operations_client }
172
+ response = Gapic::PagedEnumerable.new @operations_stub, :list_operations, request, response, operation, options, format_resource: wrap_lro_operation
173
+ yield response, operation if block_given?
174
+ return response
175
+ end
176
+ rescue GRPC::BadStatus => e
177
+ raise Google::Cloud::Error.from_error(e)
178
+ end
179
+
180
+ ##
181
+ # Gets the latest state of a long-running operation. Clients can use this
182
+ # method to poll the operation result at intervals as recommended by the API
183
+ # service.
184
+ #
185
+ # @overload get_operation(request, options = nil)
186
+ # @param request [Google::Longrunning::GetOperationRequest | Hash]
187
+ # Gets the latest state of a long-running operation. Clients can use this
188
+ # method to poll the operation result at intervals as recommended by the API
189
+ # service.
190
+ # @param options [Gapic::CallOptions, Hash]
191
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
192
+ #
193
+ # @overload get_operation(name: nil)
194
+ # @param name [String]
195
+ # The name of the operation resource.
196
+ #
197
+ #
198
+ # @yield [response, operation] Access the result along with the RPC operation
199
+ # @yieldparam response [Gapic::Operation]
200
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
201
+ #
202
+ # @return [Gapic::Operation]
203
+ #
204
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
205
+ #
206
+ def get_operation request, options = nil
207
+ raise ArgumentError, "request must be provided" if request.nil?
208
+
209
+ request = Gapic::Protobuf.coerce request, to: Google::Longrunning::GetOperationRequest
210
+
211
+ # Converts hash and nil to an options object
212
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
213
+
214
+ # Customize the options with defaults
215
+ metadata = @config.rpcs.get_operation.metadata.to_h
216
+
217
+ # Set x-goog-api-client and x-goog-user-project headers
218
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
219
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
220
+ gapic_version: ::Google::Cloud::Dialogflow::V2::VERSION
221
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
222
+
223
+ header_params = {
224
+ "name" => request.name
225
+ }
226
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
227
+ metadata[:"x-goog-request-params"] ||= request_params_header
228
+
229
+ options.apply_defaults timeout: @config.rpcs.get_operation.timeout,
230
+ metadata: metadata,
231
+ retry_policy: @config.rpcs.get_operation.retry_policy
232
+ options.apply_defaults metadata: @config.metadata,
233
+ retry_policy: @config.retry_policy
234
+
235
+ @operations_stub.call_rpc :get_operation, request, options: options do |response, operation|
236
+ response = Gapic::Operation.new response, @operations_client, options: options
237
+ yield response, operation if block_given?
238
+ return response
239
+ end
240
+ rescue GRPC::BadStatus => e
241
+ raise Google::Cloud::Error.from_error(e)
242
+ end
243
+
244
+ ##
245
+ # Deletes a long-running operation. This method indicates that the client is
246
+ # no longer interested in the operation result. It does not cancel the
247
+ # operation. If the server doesn't support this method, it returns
248
+ # `google.rpc.Code.UNIMPLEMENTED`.
249
+ #
250
+ # @overload delete_operation(request, options = nil)
251
+ # @param request [Google::Longrunning::DeleteOperationRequest | Hash]
252
+ # Deletes a long-running operation. This method indicates that the client is
253
+ # no longer interested in the operation result. It does not cancel the
254
+ # operation. If the server doesn't support this method, it returns
255
+ # `google.rpc.Code.UNIMPLEMENTED`.
256
+ # @param options [Gapic::CallOptions, Hash]
257
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
258
+ #
259
+ # @overload delete_operation(name: nil)
260
+ # @param name [String]
261
+ # The name of the operation resource to be deleted.
262
+ #
263
+ #
264
+ # @yield [response, operation] Access the result along with the RPC operation
265
+ # @yieldparam response [Google::Protobuf::Empty]
266
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
267
+ #
268
+ # @return [Google::Protobuf::Empty]
269
+ #
270
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
271
+ #
272
+ def delete_operation request, options = nil
273
+ raise ArgumentError, "request must be provided" if request.nil?
274
+
275
+ request = Gapic::Protobuf.coerce request, to: Google::Longrunning::DeleteOperationRequest
276
+
277
+ # Converts hash and nil to an options object
278
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
279
+
280
+ # Customize the options with defaults
281
+ metadata = @config.rpcs.delete_operation.metadata.to_h
282
+
283
+ # Set x-goog-api-client and x-goog-user-project headers
284
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
285
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
286
+ gapic_version: ::Google::Cloud::Dialogflow::V2::VERSION
287
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
288
+
289
+ header_params = {
290
+ "name" => request.name
291
+ }
292
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
293
+ metadata[:"x-goog-request-params"] ||= request_params_header
294
+
295
+ options.apply_defaults timeout: @config.rpcs.delete_operation.timeout,
296
+ metadata: metadata,
297
+ retry_policy: @config.rpcs.delete_operation.retry_policy
298
+ options.apply_defaults metadata: @config.metadata,
299
+ retry_policy: @config.retry_policy
300
+
301
+ @operations_stub.call_rpc :delete_operation, request, options: options do |response, operation|
302
+ yield response, operation if block_given?
303
+ return response
304
+ end
305
+ rescue GRPC::BadStatus => e
306
+ raise Google::Cloud::Error.from_error(e)
307
+ end
308
+
309
+ ##
310
+ # Starts asynchronous cancellation on a long-running operation. The server
311
+ # makes a best effort to cancel the operation, but success is not
312
+ # guaranteed. If the server doesn't support this method, it returns
313
+ # `google.rpc.Code.UNIMPLEMENTED`. Clients can use
314
+ # Operations.GetOperation or
315
+ # other methods to check whether the cancellation succeeded or whether the
316
+ # operation completed despite cancellation. On successful cancellation,
317
+ # the operation is not deleted; instead, it becomes an operation with
318
+ # an {Google::Longrunning::Operation#error Operation.error} value with a {Google::Rpc::Status#code google.rpc.Status.code} of 1,
319
+ # corresponding to `Code.CANCELLED`.
320
+ #
321
+ # @overload cancel_operation(request, options = nil)
322
+ # @param request [Google::Longrunning::CancelOperationRequest | Hash]
323
+ # Starts asynchronous cancellation on a long-running operation. The server
324
+ # makes a best effort to cancel the operation, but success is not
325
+ # guaranteed. If the server doesn't support this method, it returns
326
+ # `google.rpc.Code.UNIMPLEMENTED`. Clients can use
327
+ # Operations.GetOperation or
328
+ # other methods to check whether the cancellation succeeded or whether the
329
+ # operation completed despite cancellation. On successful cancellation,
330
+ # the operation is not deleted; instead, it becomes an operation with
331
+ # an {Google::Longrunning::Operation#error Operation.error} value with a {Google::Rpc::Status#code google.rpc.Status.code} of 1,
332
+ # corresponding to `Code.CANCELLED`.
333
+ # @param options [Gapic::CallOptions, Hash]
334
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
335
+ #
336
+ # @overload cancel_operation(name: nil)
337
+ # @param name [String]
338
+ # The name of the operation resource to be cancelled.
339
+ #
340
+ #
341
+ # @yield [response, operation] Access the result along with the RPC operation
342
+ # @yieldparam response [Google::Protobuf::Empty]
343
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
344
+ #
345
+ # @return [Google::Protobuf::Empty]
346
+ #
347
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
348
+ #
349
+ def cancel_operation request, options = nil
350
+ raise ArgumentError, "request must be provided" if request.nil?
351
+
352
+ request = Gapic::Protobuf.coerce request, to: Google::Longrunning::CancelOperationRequest
353
+
354
+ # Converts hash and nil to an options object
355
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
356
+
357
+ # Customize the options with defaults
358
+ metadata = @config.rpcs.cancel_operation.metadata.to_h
359
+
360
+ # Set x-goog-api-client and x-goog-user-project headers
361
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
362
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
363
+ gapic_version: ::Google::Cloud::Dialogflow::V2::VERSION
364
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
365
+
366
+ header_params = {
367
+ "name" => request.name
368
+ }
369
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
370
+ metadata[:"x-goog-request-params"] ||= request_params_header
371
+
372
+ options.apply_defaults timeout: @config.rpcs.cancel_operation.timeout,
373
+ metadata: metadata,
374
+ retry_policy: @config.rpcs.cancel_operation.retry_policy
375
+ options.apply_defaults metadata: @config.metadata,
376
+ retry_policy: @config.retry_policy
377
+
378
+ @operations_stub.call_rpc :cancel_operation, request, options: options do |response, operation|
379
+ yield response, operation if block_given?
380
+ return response
381
+ end
382
+ rescue GRPC::BadStatus => e
383
+ raise Google::Cloud::Error.from_error(e)
384
+ end
385
+
386
+ ##
387
+ # Configuration class for the Operations API.
388
+ #
389
+ # This class represents the configuration for Operations,
390
+ # providing control over timeouts, retry behavior, logging, transport
391
+ # parameters, and other low-level controls. Certain parameters can also be
392
+ # applied individually to specific RPCs. See
393
+ # {Google::Longrunning::Operations::Client::Configuration::Rpcs}
394
+ # for a list of RPCs that can be configured independently.
395
+ #
396
+ # Configuration can be applied globally to all clients, or to a single client
397
+ # on construction.
398
+ #
399
+ # # Examples
400
+ #
401
+ # To modify the global config, setting the timeout for list_operations
402
+ # to 20 seconds, and all remaining timeouts to 10 seconds:
403
+ #
404
+ # Google::Longrunning::Operations::Client.configure do |config|
405
+ # config.timeout = 10_000
406
+ # config.rpcs.list_operations.timeout = 20_000
407
+ # end
408
+ #
409
+ # To apply the above configuration only to a new client:
410
+ #
411
+ # client = Google::Longrunning::Operations::Client.new do |config|
412
+ # config.timeout = 10_000
413
+ # config.rpcs.list_operations.timeout = 20_000
414
+ # end
415
+ #
416
+ # @!attribute [rw] endpoint
417
+ # The hostname or hostname:port of the service endpoint.
418
+ # Defaults to `"localhost"`.
419
+ # @return [String]
420
+ # @!attribute [rw] credentials
421
+ # Credentials to send with calls. You may provide any of the following types:
422
+ # * (`String`) The path to a service account key file in JSON format
423
+ # * (`Hash`) A service account key as a Hash
424
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
425
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
426
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
427
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
428
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
429
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
430
+ # * (`nil`) indicating no credentials
431
+ # @return [Object]
432
+ # @!attribute [rw] scope
433
+ # The OAuth scopes
434
+ # @return [Array<String>]
435
+ # @!attribute [rw] lib_name
436
+ # The library name as recorded in instrumentation and logging
437
+ # @return [String]
438
+ # @!attribute [rw] lib_version
439
+ # The library version as recorded in instrumentation and logging
440
+ # @return [String]
441
+ # @!attribute [rw] channel_args
442
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
443
+ # `GRPC::Core::Channel` object is provided as the credential.
444
+ # @return [Hash]
445
+ # @!attribute [rw] interceptors
446
+ # An array of interceptors that are run before calls are executed.
447
+ # @return [Array<GRPC::ClientInterceptor>]
448
+ # @!attribute [rw] timeout
449
+ # The call timeout in milliseconds.
450
+ # @return [Numeric]
451
+ # @!attribute [rw] metadata
452
+ # Additional gRPC headers to be sent with the call.
453
+ # @return [Hash{Symbol=>String}]
454
+ # @!attribute [rw] retry_policy
455
+ # The retry policy. The value is a hash with the following keys:
456
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
457
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
458
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
459
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
460
+ # trigger a retry.
461
+ # @return [Hash]
462
+ #
463
+ class Configuration
464
+ extend Gapic::Config
465
+
466
+ config_attr :endpoint, "localhost", String
467
+ config_attr :credentials, nil do |value|
468
+ allowed = [::String, ::Hash, ::Proc, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
469
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
470
+ allowed.any? { |klass| klass === value }
471
+ end
472
+ config_attr :scope, nil, String, Array, nil
473
+ config_attr :lib_name, nil, String, nil
474
+ config_attr :lib_version, nil, String, nil
475
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, Hash, nil)
476
+ config_attr :interceptors, nil, Array, nil
477
+ config_attr :timeout, nil, Numeric, nil
478
+ config_attr :metadata, nil, Hash, nil
479
+ config_attr :retry_policy, nil, Hash, Proc, nil
480
+
481
+ # @private
482
+ def initialize parent_config = nil
483
+ @parent_config = parent_config unless parent_config.nil?
484
+
485
+ yield self if block_given?
486
+ end
487
+
488
+ ##
489
+ # Configurations for individual RPCs
490
+ # @return [Rpcs]
491
+ #
492
+ def rpcs
493
+ @rpcs ||= begin
494
+ parent_rpcs = nil
495
+ parent_rpcs = @parent_config.rpcs if @parent_config&.respond_to? :rpcs
496
+ Rpcs.new parent_rpcs
497
+ end
498
+ end
499
+
500
+ ##
501
+ # Configuration RPC class for the Operations API.
502
+ #
503
+ # Includes fields providing the configuration for each RPC in this service.
504
+ # Each configuration object is of type `Gapic::Config::Method` and includes
505
+ # the following configuration fields:
506
+ #
507
+ # * `timeout` (*type:* `Numeric`) - The call timeout in milliseconds
508
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
509
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
510
+ # include the following keys:
511
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
512
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
513
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
514
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
515
+ # trigger a retry.
516
+ #
517
+ class Rpcs
518
+ ##
519
+ # RPC-specific configuration for `list_operations`
520
+ # @return [Gapic::Config::Method]
521
+ #
522
+ attr_reader :list_operations
523
+ ##
524
+ # RPC-specific configuration for `get_operation`
525
+ # @return [Gapic::Config::Method]
526
+ #
527
+ attr_reader :get_operation
528
+ ##
529
+ # RPC-specific configuration for `delete_operation`
530
+ # @return [Gapic::Config::Method]
531
+ #
532
+ attr_reader :delete_operation
533
+ ##
534
+ # RPC-specific configuration for `cancel_operation`
535
+ # @return [Gapic::Config::Method]
536
+ #
537
+ attr_reader :cancel_operation
538
+
539
+ # @private
540
+ def initialize parent_rpcs = nil
541
+ list_operations_config = parent_rpcs&.list_operations if parent_rpcs&.respond_to? :list_operations
542
+ @list_operations = Gapic::Config::Method.new list_operations_config
543
+ get_operation_config = parent_rpcs&.get_operation if parent_rpcs&.respond_to? :get_operation
544
+ @get_operation = Gapic::Config::Method.new get_operation_config
545
+ delete_operation_config = parent_rpcs&.delete_operation if parent_rpcs&.respond_to? :delete_operation
546
+ @delete_operation = Gapic::Config::Method.new delete_operation_config
547
+ cancel_operation_config = parent_rpcs&.cancel_operation if parent_rpcs&.respond_to? :cancel_operation
548
+ @cancel_operation = Gapic::Config::Method.new cancel_operation_config
549
+
550
+ yield self if block_given?
551
+ end
552
+ end
553
+ end
554
+ end
555
+ end
556
+ end
557
+ end
558
+ end
559
+ end