google-cloud-dialogflow-v2 0.22.0 → 0.23.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/lib/google/cloud/dialogflow/v2/agents/rest/client.rb +1078 -0
  4. data/lib/google/cloud/dialogflow/v2/agents/rest/operations.rb +813 -0
  5. data/lib/google/cloud/dialogflow/v2/agents/rest/service_stub.rb +652 -0
  6. data/lib/google/cloud/dialogflow/v2/agents/rest.rb +54 -0
  7. data/lib/google/cloud/dialogflow/v2/agents.rb +6 -0
  8. data/lib/google/cloud/dialogflow/v2/answer_records/rest/client.rb +463 -0
  9. data/lib/google/cloud/dialogflow/v2/answer_records/rest/service_stub.rb +182 -0
  10. data/lib/google/cloud/dialogflow/v2/answer_records/rest.rb +54 -0
  11. data/lib/google/cloud/dialogflow/v2/answer_records.rb +6 -0
  12. data/lib/google/cloud/dialogflow/v2/bindings_override.rb +102 -0
  13. data/lib/google/cloud/dialogflow/v2/contexts/rest/client.rb +753 -0
  14. data/lib/google/cloud/dialogflow/v2/contexts/rest/service_stub.rb +536 -0
  15. data/lib/google/cloud/dialogflow/v2/contexts/rest.rb +53 -0
  16. data/lib/google/cloud/dialogflow/v2/contexts.rb +6 -0
  17. data/lib/google/cloud/dialogflow/v2/conversation_datasets/rest/client.rb +714 -0
  18. data/lib/google/cloud/dialogflow/v2/conversation_datasets/rest/operations.rb +813 -0
  19. data/lib/google/cloud/dialogflow/v2/conversation_datasets/rest/service_stub.rb +367 -0
  20. data/lib/google/cloud/dialogflow/v2/conversation_datasets/rest.rb +57 -0
  21. data/lib/google/cloud/dialogflow/v2/conversation_datasets.rb +6 -0
  22. data/lib/google/cloud/dialogflow/v2/conversation_models/rest/client.rb +1010 -0
  23. data/lib/google/cloud/dialogflow/v2/conversation_models/rest/operations.rb +813 -0
  24. data/lib/google/cloud/dialogflow/v2/conversation_models/rest/service_stub.rb +642 -0
  25. data/lib/google/cloud/dialogflow/v2/conversation_models/rest.rb +54 -0
  26. data/lib/google/cloud/dialogflow/v2/conversation_models.rb +6 -0
  27. data/lib/google/cloud/dialogflow/v2/conversation_profiles/rest/client.rb +868 -0
  28. data/lib/google/cloud/dialogflow/v2/conversation_profiles/rest/operations.rb +813 -0
  29. data/lib/google/cloud/dialogflow/v2/conversation_profiles/rest/service_stub.rb +518 -0
  30. data/lib/google/cloud/dialogflow/v2/conversation_profiles/rest.rb +55 -0
  31. data/lib/google/cloud/dialogflow/v2/conversation_profiles.rb +6 -0
  32. data/lib/google/cloud/dialogflow/v2/conversations/rest/client.rb +819 -0
  33. data/lib/google/cloud/dialogflow/v2/conversations/rest/service_stub.rb +450 -0
  34. data/lib/google/cloud/dialogflow/v2/conversations/rest.rb +54 -0
  35. data/lib/google/cloud/dialogflow/v2/conversations.rb +6 -0
  36. data/lib/google/cloud/dialogflow/v2/documents/rest/client.rb +1013 -0
  37. data/lib/google/cloud/dialogflow/v2/documents/rest/operations.rb +813 -0
  38. data/lib/google/cloud/dialogflow/v2/documents/rest/service_stub.rb +631 -0
  39. data/lib/google/cloud/dialogflow/v2/documents/rest.rb +55 -0
  40. data/lib/google/cloud/dialogflow/v2/documents.rb +6 -0
  41. data/lib/google/cloud/dialogflow/v2/entity_types/rest/client.rb +1178 -0
  42. data/lib/google/cloud/dialogflow/v2/entity_types/rest/operations.rb +813 -0
  43. data/lib/google/cloud/dialogflow/v2/entity_types/rest/service_stub.rb +722 -0
  44. data/lib/google/cloud/dialogflow/v2/entity_types/rest.rb +54 -0
  45. data/lib/google/cloud/dialogflow/v2/entity_types.rb +6 -0
  46. data/lib/google/cloud/dialogflow/v2/environments/rest/client.rb +779 -0
  47. data/lib/google/cloud/dialogflow/v2/environments/rest/service_stub.rb +448 -0
  48. data/lib/google/cloud/dialogflow/v2/environments/rest.rb +53 -0
  49. data/lib/google/cloud/dialogflow/v2/environments.rb +6 -0
  50. data/lib/google/cloud/dialogflow/v2/fulfillments/rest/client.rb +444 -0
  51. data/lib/google/cloud/dialogflow/v2/fulfillments/rest/service_stub.rb +182 -0
  52. data/lib/google/cloud/dialogflow/v2/fulfillments/rest.rb +53 -0
  53. data/lib/google/cloud/dialogflow/v2/fulfillments.rb +6 -0
  54. data/lib/google/cloud/dialogflow/v2/intents/rest/client.rb +914 -0
  55. data/lib/google/cloud/dialogflow/v2/intents/rest/operations.rb +813 -0
  56. data/lib/google/cloud/dialogflow/v2/intents/rest/service_stub.rb +532 -0
  57. data/lib/google/cloud/dialogflow/v2/intents/rest.rb +54 -0
  58. data/lib/google/cloud/dialogflow/v2/intents.rb +6 -0
  59. data/lib/google/cloud/dialogflow/v2/knowledge_bases/rest/client.rb +696 -0
  60. data/lib/google/cloud/dialogflow/v2/knowledge_bases/rest/service_stub.rb +419 -0
  61. data/lib/google/cloud/dialogflow/v2/knowledge_bases/rest.rb +54 -0
  62. data/lib/google/cloud/dialogflow/v2/knowledge_bases.rb +6 -0
  63. data/lib/google/cloud/dialogflow/v2/participants/rest/client.rb +955 -0
  64. data/lib/google/cloud/dialogflow/v2/participants/rest/service_stub.rb +588 -0
  65. data/lib/google/cloud/dialogflow/v2/participants/rest.rb +53 -0
  66. data/lib/google/cloud/dialogflow/v2/participants.rb +6 -0
  67. data/lib/google/cloud/dialogflow/v2/rest.rb +54 -0
  68. data/lib/google/cloud/dialogflow/v2/session_entity_types/rest/client.rb +703 -0
  69. data/lib/google/cloud/dialogflow/v2/session_entity_types/rest/service_stub.rb +456 -0
  70. data/lib/google/cloud/dialogflow/v2/session_entity_types/rest.rb +54 -0
  71. data/lib/google/cloud/dialogflow/v2/session_entity_types.rb +6 -0
  72. data/lib/google/cloud/dialogflow/v2/sessions/rest/client.rb +437 -0
  73. data/lib/google/cloud/dialogflow/v2/sessions/rest/service_stub.rb +132 -0
  74. data/lib/google/cloud/dialogflow/v2/sessions/rest.rb +56 -0
  75. data/lib/google/cloud/dialogflow/v2/sessions.rb +6 -0
  76. data/lib/google/cloud/dialogflow/v2/version.rb +1 -1
  77. data/lib/google/cloud/dialogflow/v2/versions/rest/client.rb +686 -0
  78. data/lib/google/cloud/dialogflow/v2/versions/rest/service_stub.rb +382 -0
  79. data/lib/google/cloud/dialogflow/v2/versions/rest.rb +53 -0
  80. data/lib/google/cloud/dialogflow/v2/versions.rb +6 -0
  81. data/lib/google/cloud/dialogflow/v2.rb +5 -0
  82. metadata +66 -5
@@ -0,0 +1,696 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2023 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 "google/cloud/errors"
20
+ require "google/cloud/dialogflow/v2/knowledge_base_pb"
21
+ require "google/cloud/dialogflow/v2/knowledge_bases/rest/service_stub"
22
+ require "google/cloud/location/rest"
23
+
24
+ module Google
25
+ module Cloud
26
+ module Dialogflow
27
+ module V2
28
+ module KnowledgeBases
29
+ module Rest
30
+ ##
31
+ # REST client for the KnowledgeBases service.
32
+ #
33
+ # Service for managing
34
+ # {::Google::Cloud::Dialogflow::V2::KnowledgeBase KnowledgeBases}.
35
+ #
36
+ class Client
37
+ include Paths
38
+
39
+ # @private
40
+ attr_reader :knowledge_bases_stub
41
+
42
+ ##
43
+ # Configure the KnowledgeBases Client class.
44
+ #
45
+ # See {::Google::Cloud::Dialogflow::V2::KnowledgeBases::Rest::Client::Configuration}
46
+ # for a description of the configuration fields.
47
+ #
48
+ # @example
49
+ #
50
+ # # Modify the configuration for all KnowledgeBases clients
51
+ # ::Google::Cloud::Dialogflow::V2::KnowledgeBases::Rest::Client.configure do |config|
52
+ # config.timeout = 10.0
53
+ # end
54
+ #
55
+ # @yield [config] Configure the Client client.
56
+ # @yieldparam config [Client::Configuration]
57
+ #
58
+ # @return [Client::Configuration]
59
+ #
60
+ def self.configure
61
+ @configure ||= begin
62
+ namespace = ["Google", "Cloud", "Dialogflow", "V2"]
63
+ parent_config = while namespace.any?
64
+ parent_name = namespace.join "::"
65
+ parent_const = const_get parent_name
66
+ break parent_const.configure if parent_const.respond_to? :configure
67
+ namespace.pop
68
+ end
69
+ default_config = Client::Configuration.new parent_config
70
+
71
+ default_config.timeout = 60.0
72
+ default_config.retry_policy = {
73
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14]
74
+ }
75
+
76
+ default_config
77
+ end
78
+ yield @configure if block_given?
79
+ @configure
80
+ end
81
+
82
+ ##
83
+ # Configure the KnowledgeBases Client instance.
84
+ #
85
+ # The configuration is set to the derived mode, meaning that values can be changed,
86
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
87
+ # should be made on {Client.configure}.
88
+ #
89
+ # See {::Google::Cloud::Dialogflow::V2::KnowledgeBases::Rest::Client::Configuration}
90
+ # for a description of the configuration fields.
91
+ #
92
+ # @yield [config] Configure the Client client.
93
+ # @yieldparam config [Client::Configuration]
94
+ #
95
+ # @return [Client::Configuration]
96
+ #
97
+ def configure
98
+ yield @config if block_given?
99
+ @config
100
+ end
101
+
102
+ ##
103
+ # Create a new KnowledgeBases REST client object.
104
+ #
105
+ # @example
106
+ #
107
+ # # Create a client using the default configuration
108
+ # client = ::Google::Cloud::Dialogflow::V2::KnowledgeBases::Rest::Client.new
109
+ #
110
+ # # Create a client using a custom configuration
111
+ # client = ::Google::Cloud::Dialogflow::V2::KnowledgeBases::Rest::Client.new do |config|
112
+ # config.timeout = 10.0
113
+ # end
114
+ #
115
+ # @yield [config] Configure the KnowledgeBases client.
116
+ # @yieldparam config [Client::Configuration]
117
+ #
118
+ def initialize
119
+ # Create the configuration object
120
+ @config = Configuration.new Client.configure
121
+
122
+ # Yield the configuration if needed
123
+ yield @config if block_given?
124
+
125
+ # Create credentials
126
+ credentials = @config.credentials
127
+ # Use self-signed JWT if the endpoint is unchanged from default,
128
+ # but only if the default endpoint does not have a region prefix.
129
+ enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
130
+ !@config.endpoint.split(".").first.include?("-")
131
+ credentials ||= Credentials.default scope: @config.scope,
132
+ enable_self_signed_jwt: enable_self_signed_jwt
133
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
134
+ credentials = Credentials.new credentials, scope: @config.scope
135
+ end
136
+
137
+ @quota_project_id = @config.quota_project
138
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
139
+
140
+ @location_client = Google::Cloud::Location::Locations::Rest::Client.new do |config|
141
+ config.credentials = credentials
142
+ config.quota_project = @quota_project_id
143
+ config.endpoint = @config.endpoint
144
+ config.bindings_override = @config.bindings_override
145
+ end
146
+
147
+ @knowledge_bases_stub = ::Google::Cloud::Dialogflow::V2::KnowledgeBases::Rest::ServiceStub.new endpoint: @config.endpoint, credentials: credentials
148
+ end
149
+
150
+ ##
151
+ # Get the associated client for mix-in of the Locations.
152
+ #
153
+ # @return [Google::Cloud::Location::Locations::Rest::Client]
154
+ #
155
+ attr_reader :location_client
156
+
157
+ # Service calls
158
+
159
+ ##
160
+ # Returns the list of all knowledge bases of the specified agent.
161
+ #
162
+ # @overload list_knowledge_bases(request, options = nil)
163
+ # Pass arguments to `list_knowledge_bases` via a request object, either of type
164
+ # {::Google::Cloud::Dialogflow::V2::ListKnowledgeBasesRequest} or an equivalent Hash.
165
+ #
166
+ # @param request [::Google::Cloud::Dialogflow::V2::ListKnowledgeBasesRequest, ::Hash]
167
+ # A request object representing the call parameters. Required. To specify no
168
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
169
+ # @param options [::Gapic::CallOptions, ::Hash]
170
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
171
+ #
172
+ # @overload list_knowledge_bases(parent: nil, page_size: nil, page_token: nil, filter: nil)
173
+ # Pass arguments to `list_knowledge_bases` via keyword arguments. Note that at
174
+ # least one keyword argument is required. To specify no parameters, or to keep all
175
+ # the default parameter values, pass an empty Hash as a request object (see above).
176
+ #
177
+ # @param parent [::String]
178
+ # Required. The project to list of knowledge bases for.
179
+ # Format: `projects/<Project ID>/locations/<Location ID>`.
180
+ # @param page_size [::Integer]
181
+ # The maximum number of items to return in a single page. By
182
+ # default 10 and at most 100.
183
+ # @param page_token [::String]
184
+ # The next_page_token value returned from a previous list request.
185
+ # @param filter [::String]
186
+ # The filter expression used to filter knowledge bases returned by the list
187
+ # method. The expression has the following syntax:
188
+ #
189
+ # <field> <operator> <value> [AND <field> <operator> <value>] ...
190
+ #
191
+ # The following fields and operators are supported:
192
+ #
193
+ # * display_name with has(:) operator
194
+ # * language_code with equals(=) operator
195
+ #
196
+ # Examples:
197
+ #
198
+ # * 'language_code=en-us' matches knowledge bases with en-us language code.
199
+ # * 'display_name:articles' matches knowledge bases whose display name
200
+ # contains "articles".
201
+ # * 'display_name:"Best Articles"' matches knowledge bases whose display
202
+ # name contains "Best Articles".
203
+ # * 'language_code=en-gb AND display_name=articles' matches all knowledge
204
+ # bases whose display name contains "articles" and whose language code is
205
+ # "en-gb".
206
+ #
207
+ # Note: An empty filter string (i.e. "") is a no-op and will result in no
208
+ # filtering.
209
+ #
210
+ # For more information about filtering, see
211
+ # [API Filtering](https://aip.dev/160).
212
+ # @yield [result, operation] Access the result along with the TransportOperation object
213
+ # @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Dialogflow::V2::KnowledgeBase>]
214
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
215
+ #
216
+ # @return [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Dialogflow::V2::KnowledgeBase>]
217
+ #
218
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
219
+ def list_knowledge_bases request, options = nil
220
+ raise ::ArgumentError, "request must be provided" if request.nil?
221
+
222
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Dialogflow::V2::ListKnowledgeBasesRequest
223
+
224
+ # Converts hash and nil to an options object
225
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
226
+
227
+ # Customize the options with defaults
228
+ call_metadata = @config.rpcs.list_knowledge_bases.metadata.to_h
229
+
230
+ # Set x-goog-api-client and x-goog-user-project headers
231
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
232
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
233
+ gapic_version: ::Google::Cloud::Dialogflow::V2::VERSION,
234
+ transports_version_send: [:rest]
235
+
236
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
237
+
238
+ options.apply_defaults timeout: @config.rpcs.list_knowledge_bases.timeout,
239
+ metadata: call_metadata,
240
+ retry_policy: @config.rpcs.list_knowledge_bases.retry_policy
241
+
242
+ options.apply_defaults timeout: @config.timeout,
243
+ metadata: @config.metadata,
244
+ retry_policy: @config.retry_policy
245
+
246
+ @knowledge_bases_stub.list_knowledge_bases request, options do |result, operation|
247
+ result = ::Gapic::Rest::PagedEnumerable.new @knowledge_bases_stub, :list_knowledge_bases, "knowledge_bases", request, result, options
248
+ yield result, operation if block_given?
249
+ return result
250
+ end
251
+ rescue ::Gapic::Rest::Error => e
252
+ raise ::Google::Cloud::Error.from_error(e)
253
+ end
254
+
255
+ ##
256
+ # Retrieves the specified knowledge base.
257
+ #
258
+ # @overload get_knowledge_base(request, options = nil)
259
+ # Pass arguments to `get_knowledge_base` via a request object, either of type
260
+ # {::Google::Cloud::Dialogflow::V2::GetKnowledgeBaseRequest} or an equivalent Hash.
261
+ #
262
+ # @param request [::Google::Cloud::Dialogflow::V2::GetKnowledgeBaseRequest, ::Hash]
263
+ # A request object representing the call parameters. Required. To specify no
264
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
265
+ # @param options [::Gapic::CallOptions, ::Hash]
266
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
267
+ #
268
+ # @overload get_knowledge_base(name: nil)
269
+ # Pass arguments to `get_knowledge_base` via keyword arguments. Note that at
270
+ # least one keyword argument is required. To specify no parameters, or to keep all
271
+ # the default parameter values, pass an empty Hash as a request object (see above).
272
+ #
273
+ # @param name [::String]
274
+ # Required. The name of the knowledge base to retrieve.
275
+ # Format `projects/<Project ID>/locations/<Location
276
+ # ID>/knowledgeBases/<Knowledge Base ID>`.
277
+ # @yield [result, operation] Access the result along with the TransportOperation object
278
+ # @yieldparam result [::Google::Cloud::Dialogflow::V2::KnowledgeBase]
279
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
280
+ #
281
+ # @return [::Google::Cloud::Dialogflow::V2::KnowledgeBase]
282
+ #
283
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
284
+ def get_knowledge_base request, options = nil
285
+ raise ::ArgumentError, "request must be provided" if request.nil?
286
+
287
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Dialogflow::V2::GetKnowledgeBaseRequest
288
+
289
+ # Converts hash and nil to an options object
290
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
291
+
292
+ # Customize the options with defaults
293
+ call_metadata = @config.rpcs.get_knowledge_base.metadata.to_h
294
+
295
+ # Set x-goog-api-client and x-goog-user-project headers
296
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
297
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
298
+ gapic_version: ::Google::Cloud::Dialogflow::V2::VERSION,
299
+ transports_version_send: [:rest]
300
+
301
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
302
+
303
+ options.apply_defaults timeout: @config.rpcs.get_knowledge_base.timeout,
304
+ metadata: call_metadata,
305
+ retry_policy: @config.rpcs.get_knowledge_base.retry_policy
306
+
307
+ options.apply_defaults timeout: @config.timeout,
308
+ metadata: @config.metadata,
309
+ retry_policy: @config.retry_policy
310
+
311
+ @knowledge_bases_stub.get_knowledge_base request, options do |result, operation|
312
+ yield result, operation if block_given?
313
+ return result
314
+ end
315
+ rescue ::Gapic::Rest::Error => e
316
+ raise ::Google::Cloud::Error.from_error(e)
317
+ end
318
+
319
+ ##
320
+ # Creates a knowledge base.
321
+ #
322
+ # @overload create_knowledge_base(request, options = nil)
323
+ # Pass arguments to `create_knowledge_base` via a request object, either of type
324
+ # {::Google::Cloud::Dialogflow::V2::CreateKnowledgeBaseRequest} or an equivalent Hash.
325
+ #
326
+ # @param request [::Google::Cloud::Dialogflow::V2::CreateKnowledgeBaseRequest, ::Hash]
327
+ # A request object representing the call parameters. Required. To specify no
328
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
329
+ # @param options [::Gapic::CallOptions, ::Hash]
330
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
331
+ #
332
+ # @overload create_knowledge_base(parent: nil, knowledge_base: nil)
333
+ # Pass arguments to `create_knowledge_base` via keyword arguments. Note that at
334
+ # least one keyword argument is required. To specify no parameters, or to keep all
335
+ # the default parameter values, pass an empty Hash as a request object (see above).
336
+ #
337
+ # @param parent [::String]
338
+ # Required. The project to create a knowledge base for.
339
+ # Format: `projects/<Project ID>/locations/<Location ID>`.
340
+ # @param knowledge_base [::Google::Cloud::Dialogflow::V2::KnowledgeBase, ::Hash]
341
+ # Required. The knowledge base to create.
342
+ # @yield [result, operation] Access the result along with the TransportOperation object
343
+ # @yieldparam result [::Google::Cloud::Dialogflow::V2::KnowledgeBase]
344
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
345
+ #
346
+ # @return [::Google::Cloud::Dialogflow::V2::KnowledgeBase]
347
+ #
348
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
349
+ def create_knowledge_base request, options = nil
350
+ raise ::ArgumentError, "request must be provided" if request.nil?
351
+
352
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Dialogflow::V2::CreateKnowledgeBaseRequest
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
+ call_metadata = @config.rpcs.create_knowledge_base.metadata.to_h
359
+
360
+ # Set x-goog-api-client and x-goog-user-project headers
361
+ call_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
+ transports_version_send: [:rest]
365
+
366
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
367
+
368
+ options.apply_defaults timeout: @config.rpcs.create_knowledge_base.timeout,
369
+ metadata: call_metadata,
370
+ retry_policy: @config.rpcs.create_knowledge_base.retry_policy
371
+
372
+ options.apply_defaults timeout: @config.timeout,
373
+ metadata: @config.metadata,
374
+ retry_policy: @config.retry_policy
375
+
376
+ @knowledge_bases_stub.create_knowledge_base request, options do |result, operation|
377
+ yield result, operation if block_given?
378
+ return result
379
+ end
380
+ rescue ::Gapic::Rest::Error => e
381
+ raise ::Google::Cloud::Error.from_error(e)
382
+ end
383
+
384
+ ##
385
+ # Deletes the specified knowledge base.
386
+ #
387
+ # @overload delete_knowledge_base(request, options = nil)
388
+ # Pass arguments to `delete_knowledge_base` via a request object, either of type
389
+ # {::Google::Cloud::Dialogflow::V2::DeleteKnowledgeBaseRequest} or an equivalent Hash.
390
+ #
391
+ # @param request [::Google::Cloud::Dialogflow::V2::DeleteKnowledgeBaseRequest, ::Hash]
392
+ # A request object representing the call parameters. Required. To specify no
393
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
394
+ # @param options [::Gapic::CallOptions, ::Hash]
395
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
396
+ #
397
+ # @overload delete_knowledge_base(name: nil, force: nil)
398
+ # Pass arguments to `delete_knowledge_base` via keyword arguments. Note that at
399
+ # least one keyword argument is required. To specify no parameters, or to keep all
400
+ # the default parameter values, pass an empty Hash as a request object (see above).
401
+ #
402
+ # @param name [::String]
403
+ # Required. The name of the knowledge base to delete.
404
+ # Format: `projects/<Project ID>/locations/<Location
405
+ # ID>/knowledgeBases/<Knowledge Base ID>`.
406
+ # @param force [::Boolean]
407
+ # Optional. Force deletes the knowledge base. When set to true, any documents
408
+ # in the knowledge base are also deleted.
409
+ # @yield [result, operation] Access the result along with the TransportOperation object
410
+ # @yieldparam result [::Google::Protobuf::Empty]
411
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
412
+ #
413
+ # @return [::Google::Protobuf::Empty]
414
+ #
415
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
416
+ def delete_knowledge_base request, options = nil
417
+ raise ::ArgumentError, "request must be provided" if request.nil?
418
+
419
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Dialogflow::V2::DeleteKnowledgeBaseRequest
420
+
421
+ # Converts hash and nil to an options object
422
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
423
+
424
+ # Customize the options with defaults
425
+ call_metadata = @config.rpcs.delete_knowledge_base.metadata.to_h
426
+
427
+ # Set x-goog-api-client and x-goog-user-project headers
428
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
429
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
430
+ gapic_version: ::Google::Cloud::Dialogflow::V2::VERSION,
431
+ transports_version_send: [:rest]
432
+
433
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
434
+
435
+ options.apply_defaults timeout: @config.rpcs.delete_knowledge_base.timeout,
436
+ metadata: call_metadata,
437
+ retry_policy: @config.rpcs.delete_knowledge_base.retry_policy
438
+
439
+ options.apply_defaults timeout: @config.timeout,
440
+ metadata: @config.metadata,
441
+ retry_policy: @config.retry_policy
442
+
443
+ @knowledge_bases_stub.delete_knowledge_base request, options do |result, operation|
444
+ yield result, operation if block_given?
445
+ return result
446
+ end
447
+ rescue ::Gapic::Rest::Error => e
448
+ raise ::Google::Cloud::Error.from_error(e)
449
+ end
450
+
451
+ ##
452
+ # Updates the specified knowledge base.
453
+ #
454
+ # @overload update_knowledge_base(request, options = nil)
455
+ # Pass arguments to `update_knowledge_base` via a request object, either of type
456
+ # {::Google::Cloud::Dialogflow::V2::UpdateKnowledgeBaseRequest} or an equivalent Hash.
457
+ #
458
+ # @param request [::Google::Cloud::Dialogflow::V2::UpdateKnowledgeBaseRequest, ::Hash]
459
+ # A request object representing the call parameters. Required. To specify no
460
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
461
+ # @param options [::Gapic::CallOptions, ::Hash]
462
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
463
+ #
464
+ # @overload update_knowledge_base(knowledge_base: nil, update_mask: nil)
465
+ # Pass arguments to `update_knowledge_base` via keyword arguments. Note that at
466
+ # least one keyword argument is required. To specify no parameters, or to keep all
467
+ # the default parameter values, pass an empty Hash as a request object (see above).
468
+ #
469
+ # @param knowledge_base [::Google::Cloud::Dialogflow::V2::KnowledgeBase, ::Hash]
470
+ # Required. The knowledge base to update.
471
+ # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
472
+ # Optional. Not specified means `update all`.
473
+ # Currently, only `display_name` can be updated, an InvalidArgument will be
474
+ # returned for attempting to update other fields.
475
+ # @yield [result, operation] Access the result along with the TransportOperation object
476
+ # @yieldparam result [::Google::Cloud::Dialogflow::V2::KnowledgeBase]
477
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
478
+ #
479
+ # @return [::Google::Cloud::Dialogflow::V2::KnowledgeBase]
480
+ #
481
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
482
+ def update_knowledge_base request, options = nil
483
+ raise ::ArgumentError, "request must be provided" if request.nil?
484
+
485
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Dialogflow::V2::UpdateKnowledgeBaseRequest
486
+
487
+ # Converts hash and nil to an options object
488
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
489
+
490
+ # Customize the options with defaults
491
+ call_metadata = @config.rpcs.update_knowledge_base.metadata.to_h
492
+
493
+ # Set x-goog-api-client and x-goog-user-project headers
494
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
495
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
496
+ gapic_version: ::Google::Cloud::Dialogflow::V2::VERSION,
497
+ transports_version_send: [:rest]
498
+
499
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
500
+
501
+ options.apply_defaults timeout: @config.rpcs.update_knowledge_base.timeout,
502
+ metadata: call_metadata,
503
+ retry_policy: @config.rpcs.update_knowledge_base.retry_policy
504
+
505
+ options.apply_defaults timeout: @config.timeout,
506
+ metadata: @config.metadata,
507
+ retry_policy: @config.retry_policy
508
+
509
+ @knowledge_bases_stub.update_knowledge_base request, options do |result, operation|
510
+ yield result, operation if block_given?
511
+ return result
512
+ end
513
+ rescue ::Gapic::Rest::Error => e
514
+ raise ::Google::Cloud::Error.from_error(e)
515
+ end
516
+
517
+ ##
518
+ # Configuration class for the KnowledgeBases REST API.
519
+ #
520
+ # This class represents the configuration for KnowledgeBases REST,
521
+ # providing control over timeouts, retry behavior, logging, transport
522
+ # parameters, and other low-level controls. Certain parameters can also be
523
+ # applied individually to specific RPCs. See
524
+ # {::Google::Cloud::Dialogflow::V2::KnowledgeBases::Rest::Client::Configuration::Rpcs}
525
+ # for a list of RPCs that can be configured independently.
526
+ #
527
+ # Configuration can be applied globally to all clients, or to a single client
528
+ # on construction.
529
+ #
530
+ # @example
531
+ #
532
+ # # Modify the global config, setting the timeout for
533
+ # # list_knowledge_bases to 20 seconds,
534
+ # # and all remaining timeouts to 10 seconds.
535
+ # ::Google::Cloud::Dialogflow::V2::KnowledgeBases::Rest::Client.configure do |config|
536
+ # config.timeout = 10.0
537
+ # config.rpcs.list_knowledge_bases.timeout = 20.0
538
+ # end
539
+ #
540
+ # # Apply the above configuration only to a new client.
541
+ # client = ::Google::Cloud::Dialogflow::V2::KnowledgeBases::Rest::Client.new do |config|
542
+ # config.timeout = 10.0
543
+ # config.rpcs.list_knowledge_bases.timeout = 20.0
544
+ # end
545
+ #
546
+ # @!attribute [rw] endpoint
547
+ # The hostname or hostname:port of the service endpoint.
548
+ # Defaults to `"dialogflow.googleapis.com"`.
549
+ # @return [::String]
550
+ # @!attribute [rw] credentials
551
+ # Credentials to send with calls. You may provide any of the following types:
552
+ # * (`String`) The path to a service account key file in JSON format
553
+ # * (`Hash`) A service account key as a Hash
554
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
555
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
556
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
557
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
558
+ # * (`nil`) indicating no credentials
559
+ # @return [::Object]
560
+ # @!attribute [rw] scope
561
+ # The OAuth scopes
562
+ # @return [::Array<::String>]
563
+ # @!attribute [rw] lib_name
564
+ # The library name as recorded in instrumentation and logging
565
+ # @return [::String]
566
+ # @!attribute [rw] lib_version
567
+ # The library version as recorded in instrumentation and logging
568
+ # @return [::String]
569
+ # @!attribute [rw] timeout
570
+ # The call timeout in seconds.
571
+ # @return [::Numeric]
572
+ # @!attribute [rw] metadata
573
+ # Additional headers to be sent with the call.
574
+ # @return [::Hash{::Symbol=>::String}]
575
+ # @!attribute [rw] retry_policy
576
+ # The retry policy. The value is a hash with the following keys:
577
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
578
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
579
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
580
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
581
+ # trigger a retry.
582
+ # @return [::Hash]
583
+ # @!attribute [rw] quota_project
584
+ # A separate project against which to charge quota.
585
+ # @return [::String]
586
+ #
587
+ class Configuration
588
+ extend ::Gapic::Config
589
+
590
+ config_attr :endpoint, "dialogflow.googleapis.com", ::String
591
+ config_attr :credentials, nil do |value|
592
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
593
+ allowed.any? { |klass| klass === value }
594
+ end
595
+ config_attr :scope, nil, ::String, ::Array, nil
596
+ config_attr :lib_name, nil, ::String, nil
597
+ config_attr :lib_version, nil, ::String, nil
598
+ config_attr :timeout, nil, ::Numeric, nil
599
+ config_attr :metadata, nil, ::Hash, nil
600
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
601
+ config_attr :quota_project, nil, ::String, nil
602
+
603
+ # @private
604
+ # Overrides for http bindings for the RPCs of this service
605
+ # are only used when this service is used as mixin, and only
606
+ # by the host service.
607
+ # @return [::Hash{::Symbol=>::Array<::Gapic::Rest::GrpcTranscoder::HttpBinding>}]
608
+ config_attr :bindings_override, {}, ::Hash, nil
609
+
610
+ # @private
611
+ def initialize parent_config = nil
612
+ @parent_config = parent_config unless parent_config.nil?
613
+
614
+ yield self if block_given?
615
+ end
616
+
617
+ ##
618
+ # Configurations for individual RPCs
619
+ # @return [Rpcs]
620
+ #
621
+ def rpcs
622
+ @rpcs ||= begin
623
+ parent_rpcs = nil
624
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
625
+ Rpcs.new parent_rpcs
626
+ end
627
+ end
628
+
629
+ ##
630
+ # Configuration RPC class for the KnowledgeBases API.
631
+ #
632
+ # Includes fields providing the configuration for each RPC in this service.
633
+ # Each configuration object is of type `Gapic::Config::Method` and includes
634
+ # the following configuration fields:
635
+ #
636
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
637
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
638
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
639
+ # include the following keys:
640
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
641
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
642
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
643
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
644
+ # trigger a retry.
645
+ #
646
+ class Rpcs
647
+ ##
648
+ # RPC-specific configuration for `list_knowledge_bases`
649
+ # @return [::Gapic::Config::Method]
650
+ #
651
+ attr_reader :list_knowledge_bases
652
+ ##
653
+ # RPC-specific configuration for `get_knowledge_base`
654
+ # @return [::Gapic::Config::Method]
655
+ #
656
+ attr_reader :get_knowledge_base
657
+ ##
658
+ # RPC-specific configuration for `create_knowledge_base`
659
+ # @return [::Gapic::Config::Method]
660
+ #
661
+ attr_reader :create_knowledge_base
662
+ ##
663
+ # RPC-specific configuration for `delete_knowledge_base`
664
+ # @return [::Gapic::Config::Method]
665
+ #
666
+ attr_reader :delete_knowledge_base
667
+ ##
668
+ # RPC-specific configuration for `update_knowledge_base`
669
+ # @return [::Gapic::Config::Method]
670
+ #
671
+ attr_reader :update_knowledge_base
672
+
673
+ # @private
674
+ def initialize parent_rpcs = nil
675
+ list_knowledge_bases_config = parent_rpcs.list_knowledge_bases if parent_rpcs.respond_to? :list_knowledge_bases
676
+ @list_knowledge_bases = ::Gapic::Config::Method.new list_knowledge_bases_config
677
+ get_knowledge_base_config = parent_rpcs.get_knowledge_base if parent_rpcs.respond_to? :get_knowledge_base
678
+ @get_knowledge_base = ::Gapic::Config::Method.new get_knowledge_base_config
679
+ create_knowledge_base_config = parent_rpcs.create_knowledge_base if parent_rpcs.respond_to? :create_knowledge_base
680
+ @create_knowledge_base = ::Gapic::Config::Method.new create_knowledge_base_config
681
+ delete_knowledge_base_config = parent_rpcs.delete_knowledge_base if parent_rpcs.respond_to? :delete_knowledge_base
682
+ @delete_knowledge_base = ::Gapic::Config::Method.new delete_knowledge_base_config
683
+ update_knowledge_base_config = parent_rpcs.update_knowledge_base if parent_rpcs.respond_to? :update_knowledge_base
684
+ @update_knowledge_base = ::Gapic::Config::Method.new update_knowledge_base_config
685
+
686
+ yield self if block_given?
687
+ end
688
+ end
689
+ end
690
+ end
691
+ end
692
+ end
693
+ end
694
+ end
695
+ end
696
+ end