google-cloud-dialogflow-v2 0.6.2 → 0.8.1

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