google-cloud-discovery_engine-v1 1.0.2 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/lib/google/cloud/discovery_engine/v1/completion_service/rest/operations.rb +14 -0
  3. data/lib/google/cloud/discovery_engine/v1/control_service/client.rb +6 -6
  4. data/lib/google/cloud/discovery_engine/v1/control_service/rest/client.rb +6 -6
  5. data/lib/google/cloud/discovery_engine/v1/conversational_search_service/client.rb +15 -12
  6. data/lib/google/cloud/discovery_engine/v1/conversational_search_service/rest/client.rb +15 -12
  7. data/lib/google/cloud/discovery_engine/v1/data_store_service/client.rb +10 -1
  8. data/lib/google/cloud/discovery_engine/v1/data_store_service/rest/client.rb +10 -1
  9. data/lib/google/cloud/discovery_engine/v1/data_store_service/rest/operations.rb +14 -0
  10. data/lib/google/cloud/discovery_engine/v1/document_service/client.rb +109 -1
  11. data/lib/google/cloud/discovery_engine/v1/document_service/paths.rb +25 -0
  12. data/lib/google/cloud/discovery_engine/v1/document_service/rest/client.rb +102 -1
  13. data/lib/google/cloud/discovery_engine/v1/document_service/rest/operations.rb +14 -0
  14. data/lib/google/cloud/discovery_engine/v1/document_service/rest/service_stub.rb +66 -0
  15. data/lib/google/cloud/discovery_engine/v1/engine_service/rest/operations.rb +14 -0
  16. data/lib/google/cloud/discovery_engine/v1/grounded_generation_service/client.rb +219 -3
  17. data/lib/google/cloud/discovery_engine/v1/grounded_generation_service/paths.rb +85 -0
  18. data/lib/google/cloud/discovery_engine/v1/grounded_generation_service/rest/client.rb +126 -3
  19. data/lib/google/cloud/discovery_engine/v1/grounded_generation_service/rest/service_stub.rb +60 -0
  20. data/lib/google/cloud/discovery_engine/v1/project_service/rest/operations.rb +14 -0
  21. data/lib/google/cloud/discovery_engine/v1/rank_service/client.rb +1 -1
  22. data/lib/google/cloud/discovery_engine/v1/rank_service/rest/client.rb +1 -1
  23. data/lib/google/cloud/discovery_engine/v1/recommendation_service/client.rb +2 -1
  24. data/lib/google/cloud/discovery_engine/v1/recommendation_service/rest/client.rb +2 -1
  25. data/lib/google/cloud/discovery_engine/v1/rest.rb +1 -0
  26. data/lib/google/cloud/discovery_engine/v1/schema_service/rest/operations.rb +14 -0
  27. data/lib/google/cloud/discovery_engine/v1/search_service/client.rb +11 -4
  28. data/lib/google/cloud/discovery_engine/v1/search_service/rest/client.rb +11 -4
  29. data/lib/google/cloud/discovery_engine/v1/search_tuning_service/client.rb +571 -0
  30. data/lib/google/cloud/discovery_engine/v1/search_tuning_service/credentials.rb +47 -0
  31. data/lib/google/cloud/discovery_engine/v1/search_tuning_service/operations.rb +809 -0
  32. data/lib/google/cloud/discovery_engine/v1/search_tuning_service/paths.rb +78 -0
  33. data/lib/google/cloud/discovery_engine/v1/search_tuning_service/rest/client.rb +531 -0
  34. data/lib/google/cloud/discovery_engine/v1/search_tuning_service/rest/operations.rb +1128 -0
  35. data/lib/google/cloud/discovery_engine/v1/search_tuning_service/rest/service_stub.rb +188 -0
  36. data/lib/google/cloud/discovery_engine/v1/search_tuning_service/rest.rb +53 -0
  37. data/lib/google/cloud/discovery_engine/v1/search_tuning_service.rb +56 -0
  38. data/lib/google/cloud/discovery_engine/v1/site_search_engine_service/client.rb +5 -1
  39. data/lib/google/cloud/discovery_engine/v1/site_search_engine_service/rest/client.rb +5 -1
  40. data/lib/google/cloud/discovery_engine/v1/site_search_engine_service/rest/operations.rb +14 -0
  41. data/lib/google/cloud/discovery_engine/v1/user_event_service/client.rb +139 -0
  42. data/lib/google/cloud/discovery_engine/v1/user_event_service/rest/client.rb +132 -0
  43. data/lib/google/cloud/discovery_engine/v1/user_event_service/rest/operations.rb +14 -0
  44. data/lib/google/cloud/discovery_engine/v1/user_event_service/rest/service_stub.rb +68 -0
  45. data/lib/google/cloud/discovery_engine/v1/version.rb +1 -1
  46. data/lib/google/cloud/discovery_engine/v1.rb +1 -0
  47. data/lib/google/cloud/discoveryengine/v1/answer_pb.rb +2 -1
  48. data/lib/google/cloud/discoveryengine/v1/common_pb.rb +1 -1
  49. data/lib/google/cloud/discoveryengine/v1/conversational_search_service_pb.rb +2 -1
  50. data/lib/google/cloud/discoveryengine/v1/custom_tuning_model_pb.rb +48 -0
  51. data/lib/google/cloud/discoveryengine/v1/data_store_pb.rb +4 -1
  52. data/lib/google/cloud/discoveryengine/v1/data_store_service_pb.rb +1 -1
  53. data/lib/google/cloud/discoveryengine/v1/document_pb.rb +4 -1
  54. data/lib/google/cloud/discoveryengine/v1/document_service_pb.rb +11 -1
  55. data/lib/google/cloud/discoveryengine/v1/document_service_services_pb.rb +4 -0
  56. data/lib/google/cloud/discoveryengine/v1/engine_pb.rb +1 -1
  57. data/lib/google/cloud/discoveryengine/v1/grounded_generation_service_pb.rb +23 -1
  58. data/lib/google/cloud/discoveryengine/v1/grounded_generation_service_services_pb.rb +4 -0
  59. data/lib/google/cloud/discoveryengine/v1/import_config_pb.rb +1 -1
  60. data/lib/google/cloud/discoveryengine/v1/purge_config_pb.rb +8 -1
  61. data/lib/google/cloud/discoveryengine/v1/search_service_pb.rb +5 -1
  62. data/lib/google/cloud/discoveryengine/v1/search_tuning_service_pb.rb +61 -0
  63. data/lib/google/cloud/discoveryengine/v1/search_tuning_service_services_pb.rb +47 -0
  64. data/lib/google/cloud/discoveryengine/v1/site_search_engine_service_pb.rb +1 -1
  65. data/lib/google/cloud/discoveryengine/v1/user_event_pb.rb +1 -1
  66. data/lib/google/cloud/discoveryengine/v1/user_event_service_pb.rb +2 -1
  67. data/lib/google/cloud/discoveryengine/v1/user_event_service_services_pb.rb +5 -0
  68. data/proto_docs/google/cloud/discoveryengine/v1/answer.rb +62 -7
  69. data/proto_docs/google/cloud/discoveryengine/v1/control.rb +6 -4
  70. data/proto_docs/google/cloud/discoveryengine/v1/control_service.rb +6 -6
  71. data/proto_docs/google/cloud/discoveryengine/v1/conversational_search_service.rb +68 -24
  72. data/proto_docs/google/cloud/discoveryengine/v1/custom_tuning_model.rb +99 -0
  73. data/proto_docs/google/cloud/discoveryengine/v1/data_store.rb +88 -0
  74. data/proto_docs/google/cloud/discoveryengine/v1/data_store_service.rb +10 -0
  75. data/proto_docs/google/cloud/discoveryengine/v1/document.rb +22 -0
  76. data/proto_docs/google/cloud/discoveryengine/v1/document_processing_config.rb +9 -5
  77. data/proto_docs/google/cloud/discoveryengine/v1/document_service.rb +120 -0
  78. data/proto_docs/google/cloud/discoveryengine/v1/engine.rb +5 -1
  79. data/proto_docs/google/cloud/discoveryengine/v1/grounded_generation_service.rb +385 -1
  80. data/proto_docs/google/cloud/discoveryengine/v1/import_config.rb +13 -7
  81. data/proto_docs/google/cloud/discoveryengine/v1/project.rb +1 -1
  82. data/proto_docs/google/cloud/discoveryengine/v1/purge_config.rb +115 -0
  83. data/proto_docs/google/cloud/discoveryengine/v1/rank_service.rb +1 -1
  84. data/proto_docs/google/cloud/discoveryengine/v1/recommendation_service.rb +2 -1
  85. data/proto_docs/google/cloud/discoveryengine/v1/search_service.rb +156 -16
  86. data/proto_docs/google/cloud/discoveryengine/v1/search_tuning_service.rb +172 -0
  87. data/proto_docs/google/cloud/discoveryengine/v1/site_search_engine_service.rb +5 -0
  88. data/proto_docs/google/cloud/discoveryengine/v1/user_event.rb +5 -1
  89. metadata +17 -3
@@ -888,11 +888,18 @@ module Google
888
888
  # @param options [::Gapic::CallOptions, ::Hash]
889
889
  # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
890
890
  #
891
- # @overload purge_documents(parent: nil, filter: nil, force: nil)
891
+ # @overload purge_documents(gcs_source: nil, inline_source: nil, parent: nil, filter: nil, error_config: nil, force: nil)
892
892
  # Pass arguments to `purge_documents` via keyword arguments. Note that at
893
893
  # least one keyword argument is required. To specify no parameters, or to keep all
894
894
  # the default parameter values, pass an empty Hash as a request object (see above).
895
895
  #
896
+ # @param gcs_source [::Google::Cloud::DiscoveryEngine::V1::GcsSource, ::Hash]
897
+ # Cloud Storage location for the input content.
898
+ # Supported `data_schema`:
899
+ # * `document_id`: One valid
900
+ # {::Google::Cloud::DiscoveryEngine::V1::Document#id Document.id} per line.
901
+ # @param inline_source [::Google::Cloud::DiscoveryEngine::V1::PurgeDocumentsRequest::InlineSource, ::Hash]
902
+ # Inline source for the input content for purge.
896
903
  # @param parent [::String]
897
904
  # Required. The parent resource name, such as
898
905
  # `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`.
@@ -900,6 +907,8 @@ module Google
900
907
  # Required. Filter matching documents to purge. Only currently supported
901
908
  # value is
902
909
  # `*` (all items).
910
+ # @param error_config [::Google::Cloud::DiscoveryEngine::V1::PurgeErrorConfig, ::Hash]
911
+ # The desired location of errors incurred during the purge.
903
912
  # @param force [::Boolean]
904
913
  # Actually performs the purge. If `force` is set to false, return the
905
914
  # expected purge count without deleting any documents.
@@ -970,6 +979,91 @@ module Google
970
979
  raise ::Google::Cloud::Error.from_error(e)
971
980
  end
972
981
 
982
+ ##
983
+ # Gets index freshness metadata for
984
+ # {::Google::Cloud::DiscoveryEngine::V1::Document Document}s. Supported for
985
+ # website search only.
986
+ #
987
+ # @overload batch_get_documents_metadata(request, options = nil)
988
+ # Pass arguments to `batch_get_documents_metadata` via a request object, either of type
989
+ # {::Google::Cloud::DiscoveryEngine::V1::BatchGetDocumentsMetadataRequest} or an equivalent Hash.
990
+ #
991
+ # @param request [::Google::Cloud::DiscoveryEngine::V1::BatchGetDocumentsMetadataRequest, ::Hash]
992
+ # A request object representing the call parameters. Required. To specify no
993
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
994
+ # @param options [::Gapic::CallOptions, ::Hash]
995
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
996
+ #
997
+ # @overload batch_get_documents_metadata(parent: nil, matcher: nil)
998
+ # Pass arguments to `batch_get_documents_metadata` via keyword arguments. Note that at
999
+ # least one keyword argument is required. To specify no parameters, or to keep all
1000
+ # the default parameter values, pass an empty Hash as a request object (see above).
1001
+ #
1002
+ # @param parent [::String]
1003
+ # Required. The parent branch resource name, such as
1004
+ # `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`.
1005
+ # @param matcher [::Google::Cloud::DiscoveryEngine::V1::BatchGetDocumentsMetadataRequest::Matcher, ::Hash]
1006
+ # Required. Matcher for the
1007
+ # {::Google::Cloud::DiscoveryEngine::V1::Document Document}s.
1008
+ # @yield [result, operation] Access the result along with the TransportOperation object
1009
+ # @yieldparam result [::Google::Cloud::DiscoveryEngine::V1::BatchGetDocumentsMetadataResponse]
1010
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1011
+ #
1012
+ # @return [::Google::Cloud::DiscoveryEngine::V1::BatchGetDocumentsMetadataResponse]
1013
+ #
1014
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1015
+ #
1016
+ # @example Basic example
1017
+ # require "google/cloud/discovery_engine/v1"
1018
+ #
1019
+ # # Create a client object. The client can be reused for multiple calls.
1020
+ # client = Google::Cloud::DiscoveryEngine::V1::DocumentService::Rest::Client.new
1021
+ #
1022
+ # # Create a request. To set request fields, pass in keyword arguments.
1023
+ # request = Google::Cloud::DiscoveryEngine::V1::BatchGetDocumentsMetadataRequest.new
1024
+ #
1025
+ # # Call the batch_get_documents_metadata method.
1026
+ # result = client.batch_get_documents_metadata request
1027
+ #
1028
+ # # The returned object is of type Google::Cloud::DiscoveryEngine::V1::BatchGetDocumentsMetadataResponse.
1029
+ # p result
1030
+ #
1031
+ def batch_get_documents_metadata request, options = nil
1032
+ raise ::ArgumentError, "request must be provided" if request.nil?
1033
+
1034
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DiscoveryEngine::V1::BatchGetDocumentsMetadataRequest
1035
+
1036
+ # Converts hash and nil to an options object
1037
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1038
+
1039
+ # Customize the options with defaults
1040
+ call_metadata = @config.rpcs.batch_get_documents_metadata.metadata.to_h
1041
+
1042
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
1043
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1044
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1045
+ gapic_version: ::Google::Cloud::DiscoveryEngine::V1::VERSION,
1046
+ transports_version_send: [:rest]
1047
+
1048
+ call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
1049
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1050
+
1051
+ options.apply_defaults timeout: @config.rpcs.batch_get_documents_metadata.timeout,
1052
+ metadata: call_metadata,
1053
+ retry_policy: @config.rpcs.batch_get_documents_metadata.retry_policy
1054
+
1055
+ options.apply_defaults timeout: @config.timeout,
1056
+ metadata: @config.metadata,
1057
+ retry_policy: @config.retry_policy
1058
+
1059
+ @document_service_stub.batch_get_documents_metadata request, options do |result, operation|
1060
+ yield result, operation if block_given?
1061
+ return result
1062
+ end
1063
+ rescue ::Gapic::Rest::Error => e
1064
+ raise ::Google::Cloud::Error.from_error(e)
1065
+ end
1066
+
973
1067
  ##
974
1068
  # Configuration class for the DocumentService REST API.
975
1069
  #
@@ -1138,6 +1232,11 @@ module Google
1138
1232
  # @return [::Gapic::Config::Method]
1139
1233
  #
1140
1234
  attr_reader :purge_documents
1235
+ ##
1236
+ # RPC-specific configuration for `batch_get_documents_metadata`
1237
+ # @return [::Gapic::Config::Method]
1238
+ #
1239
+ attr_reader :batch_get_documents_metadata
1141
1240
 
1142
1241
  # @private
1143
1242
  def initialize parent_rpcs = nil
@@ -1155,6 +1254,8 @@ module Google
1155
1254
  @import_documents = ::Gapic::Config::Method.new import_documents_config
1156
1255
  purge_documents_config = parent_rpcs.purge_documents if parent_rpcs.respond_to? :purge_documents
1157
1256
  @purge_documents = ::Gapic::Config::Method.new purge_documents_config
1257
+ batch_get_documents_metadata_config = parent_rpcs.batch_get_documents_metadata if parent_rpcs.respond_to? :batch_get_documents_metadata
1258
+ @batch_get_documents_metadata = ::Gapic::Config::Method.new batch_get_documents_metadata_config
1158
1259
 
1159
1260
  yield self if block_given?
1160
1261
  end
@@ -911,6 +911,13 @@ module Google
911
911
  ["name", %r{^projects/[^/]+/locations/[^/]+/dataStores/[^/]+/?$}, false]
912
912
  ]
913
913
  )
914
+ .with_bindings(
915
+ uri_method: :get,
916
+ uri_template: "/v1/{name}/operations",
917
+ matches: [
918
+ ["name", %r{^projects/[^/]+/locations/[^/]+/identityMappingStores/[^/]+/?$}, false]
919
+ ]
920
+ )
914
921
  .with_bindings(
915
922
  uri_method: :get,
916
923
  uri_template: "/v1/{name}/operations",
@@ -1030,6 +1037,13 @@ module Google
1030
1037
  ["name", %r{^projects/[^/]+/locations/[^/]+/dataStores/[^/]+/operations/[^/]+/?$}, false]
1031
1038
  ]
1032
1039
  )
1040
+ .with_bindings(
1041
+ uri_method: :get,
1042
+ uri_template: "/v1/{name}",
1043
+ matches: [
1044
+ ["name", %r{^projects/[^/]+/locations/[^/]+/identityMappingStores/[^/]+/operations/[^/]+/?$}, false]
1045
+ ]
1046
+ )
1033
1047
  .with_bindings(
1034
1048
  uri_method: :get,
1035
1049
  uri_template: "/v1/{name}",
@@ -327,6 +327,44 @@ module Google
327
327
  result
328
328
  end
329
329
 
330
+ ##
331
+ # Baseline implementation for the batch_get_documents_metadata REST call
332
+ #
333
+ # @param request_pb [::Google::Cloud::DiscoveryEngine::V1::BatchGetDocumentsMetadataRequest]
334
+ # A request object representing the call parameters. Required.
335
+ # @param options [::Gapic::CallOptions]
336
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
337
+ #
338
+ # @yield [result, operation] Access the result along with the TransportOperation object
339
+ # @yieldparam result [::Google::Cloud::DiscoveryEngine::V1::BatchGetDocumentsMetadataResponse]
340
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
341
+ #
342
+ # @return [::Google::Cloud::DiscoveryEngine::V1::BatchGetDocumentsMetadataResponse]
343
+ # A result object deserialized from the server's reply
344
+ def batch_get_documents_metadata request_pb, options = nil
345
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
346
+
347
+ verb, uri, query_string_params, body = ServiceStub.transcode_batch_get_documents_metadata_request request_pb
348
+ query_string_params = if query_string_params.any?
349
+ query_string_params.to_h { |p| p.split "=", 2 }
350
+ else
351
+ {}
352
+ end
353
+
354
+ response = @client_stub.make_http_request(
355
+ verb,
356
+ uri: uri,
357
+ body: body || "",
358
+ params: query_string_params,
359
+ options: options
360
+ )
361
+ operation = ::Gapic::Rest::TransportOperation.new response
362
+ result = ::Google::Cloud::DiscoveryEngine::V1::BatchGetDocumentsMetadataResponse.decode_json response.body, ignore_unknown_fields: true
363
+
364
+ yield result, operation if block_given?
365
+ result
366
+ end
367
+
330
368
  ##
331
369
  # @private
332
370
  #
@@ -530,6 +568,34 @@ module Google
530
568
  )
531
569
  transcoder.transcode request_pb
532
570
  end
571
+
572
+ ##
573
+ # @private
574
+ #
575
+ # GRPC transcoding helper method for the batch_get_documents_metadata REST call
576
+ #
577
+ # @param request_pb [::Google::Cloud::DiscoveryEngine::V1::BatchGetDocumentsMetadataRequest]
578
+ # A request object representing the call parameters. Required.
579
+ # @return [Array(String, [String, nil], Hash{String => String})]
580
+ # Uri, Body, Query string parameters
581
+ def self.transcode_batch_get_documents_metadata_request request_pb
582
+ transcoder = Gapic::Rest::GrpcTranscoder.new
583
+ .with_bindings(
584
+ uri_method: :get,
585
+ uri_template: "/v1/{parent}/batchGetDocumentsMetadata",
586
+ matches: [
587
+ ["parent", %r{^projects/[^/]+/locations/[^/]+/dataStores/[^/]+/branches/[^/]+/?$}, false]
588
+ ]
589
+ )
590
+ .with_bindings(
591
+ uri_method: :get,
592
+ uri_template: "/v1/{parent}/batchGetDocumentsMetadata",
593
+ matches: [
594
+ ["parent", %r{^projects/[^/]+/locations/[^/]+/collections/[^/]+/dataStores/[^/]+/branches/[^/]+/?$}, false]
595
+ ]
596
+ )
597
+ transcoder.transcode request_pb
598
+ end
533
599
  end
534
600
  end
535
601
  end
@@ -911,6 +911,13 @@ module Google
911
911
  ["name", %r{^projects/[^/]+/locations/[^/]+/dataStores/[^/]+/?$}, false]
912
912
  ]
913
913
  )
914
+ .with_bindings(
915
+ uri_method: :get,
916
+ uri_template: "/v1/{name}/operations",
917
+ matches: [
918
+ ["name", %r{^projects/[^/]+/locations/[^/]+/identityMappingStores/[^/]+/?$}, false]
919
+ ]
920
+ )
914
921
  .with_bindings(
915
922
  uri_method: :get,
916
923
  uri_template: "/v1/{name}/operations",
@@ -1030,6 +1037,13 @@ module Google
1030
1037
  ["name", %r{^projects/[^/]+/locations/[^/]+/dataStores/[^/]+/operations/[^/]+/?$}, false]
1031
1038
  ]
1032
1039
  )
1040
+ .with_bindings(
1041
+ uri_method: :get,
1042
+ uri_template: "/v1/{name}",
1043
+ matches: [
1044
+ ["name", %r{^projects/[^/]+/locations/[^/]+/identityMappingStores/[^/]+/operations/[^/]+/?$}, false]
1045
+ ]
1046
+ )
1033
1047
  .with_bindings(
1034
1048
  uri_method: :get,
1035
1049
  uri_template: "/v1/{name}",
@@ -183,6 +183,208 @@ module Google
183
183
 
184
184
  # Service calls
185
185
 
186
+ ##
187
+ # Generates grounded content in a streaming fashion.
188
+ #
189
+ # @param request [::Gapic::StreamInput, ::Enumerable<::Google::Cloud::DiscoveryEngine::V1::GenerateGroundedContentRequest, ::Hash>]
190
+ # An enumerable of {::Google::Cloud::DiscoveryEngine::V1::GenerateGroundedContentRequest} instances.
191
+ # @param options [::Gapic::CallOptions, ::Hash]
192
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
193
+ #
194
+ # @yield [response, operation] Access the result along with the RPC operation
195
+ # @yieldparam response [::Enumerable<::Google::Cloud::DiscoveryEngine::V1::GenerateGroundedContentResponse>]
196
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
197
+ #
198
+ # @return [::Enumerable<::Google::Cloud::DiscoveryEngine::V1::GenerateGroundedContentResponse>]
199
+ #
200
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
201
+ #
202
+ # @example Basic example
203
+ # require "google/cloud/discovery_engine/v1"
204
+ #
205
+ # # Create a client object. The client can be reused for multiple calls.
206
+ # client = Google::Cloud::DiscoveryEngine::V1::GroundedGenerationService::Client.new
207
+ #
208
+ # # Create an input stream.
209
+ # input = Gapic::StreamInput.new
210
+ #
211
+ # # Call the stream_generate_grounded_content method to start streaming.
212
+ # output = client.stream_generate_grounded_content input
213
+ #
214
+ # # Send requests on the stream. For each request object, set fields by
215
+ # # passing keyword arguments. Be sure to close the stream when done.
216
+ # input << Google::Cloud::DiscoveryEngine::V1::GenerateGroundedContentRequest.new
217
+ # input << Google::Cloud::DiscoveryEngine::V1::GenerateGroundedContentRequest.new
218
+ # input.close
219
+ #
220
+ # # The returned object is a streamed enumerable yielding elements of type
221
+ # # ::Google::Cloud::DiscoveryEngine::V1::GenerateGroundedContentResponse
222
+ # output.each do |current_response|
223
+ # p current_response
224
+ # end
225
+ #
226
+ def stream_generate_grounded_content request, options = nil
227
+ unless request.is_a? ::Enumerable
228
+ raise ::ArgumentError, "request must be an Enumerable" unless request.respond_to? :to_enum
229
+ request = request.to_enum
230
+ end
231
+
232
+ request = request.lazy.map do |req|
233
+ ::Gapic::Protobuf.coerce req, to: ::Google::Cloud::DiscoveryEngine::V1::GenerateGroundedContentRequest
234
+ end
235
+
236
+ # Converts hash and nil to an options object
237
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
238
+
239
+ # Customize the options with defaults
240
+ metadata = @config.rpcs.stream_generate_grounded_content.metadata.to_h
241
+
242
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
243
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
244
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
245
+ gapic_version: ::Google::Cloud::DiscoveryEngine::V1::VERSION
246
+ metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
247
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
248
+
249
+ options.apply_defaults timeout: @config.rpcs.stream_generate_grounded_content.timeout,
250
+ metadata: metadata,
251
+ retry_policy: @config.rpcs.stream_generate_grounded_content.retry_policy
252
+
253
+ options.apply_defaults timeout: @config.timeout,
254
+ metadata: @config.metadata,
255
+ retry_policy: @config.retry_policy
256
+
257
+ @grounded_generation_service_stub.call_rpc :stream_generate_grounded_content, request, options: options do |response, operation|
258
+ yield response, operation if block_given?
259
+ return response
260
+ end
261
+ rescue ::GRPC::BadStatus => e
262
+ raise ::Google::Cloud::Error.from_error(e)
263
+ end
264
+
265
+ ##
266
+ # Generates grounded content.
267
+ #
268
+ # @overload generate_grounded_content(request, options = nil)
269
+ # Pass arguments to `generate_grounded_content` via a request object, either of type
270
+ # {::Google::Cloud::DiscoveryEngine::V1::GenerateGroundedContentRequest} or an equivalent Hash.
271
+ #
272
+ # @param request [::Google::Cloud::DiscoveryEngine::V1::GenerateGroundedContentRequest, ::Hash]
273
+ # A request object representing the call parameters. Required. To specify no
274
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
275
+ # @param options [::Gapic::CallOptions, ::Hash]
276
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
277
+ #
278
+ # @overload generate_grounded_content(location: nil, system_instruction: nil, contents: nil, generation_spec: nil, grounding_spec: nil, user_labels: nil)
279
+ # Pass arguments to `generate_grounded_content` via keyword arguments. Note that at
280
+ # least one keyword argument is required. To specify no parameters, or to keep all
281
+ # the default parameter values, pass an empty Hash as a request object (see above).
282
+ #
283
+ # @param location [::String]
284
+ # Required. Location resource.
285
+ #
286
+ # Format: `projects/{project}/locations/{location}`.
287
+ # @param system_instruction [::Google::Cloud::DiscoveryEngine::V1::GroundedGenerationContent, ::Hash]
288
+ # Content of the system instruction for the current API.
289
+ #
290
+ # These instructions will take priority over any other prompt instructions
291
+ # if the selected model is supporting them.
292
+ # @param contents [::Array<::Google::Cloud::DiscoveryEngine::V1::GroundedGenerationContent, ::Hash>]
293
+ # Content of the current conversation with the model.
294
+ #
295
+ # For single-turn queries, this is a single instance. For multi-turn queries,
296
+ # this is a repeated field that contains conversation history + latest
297
+ # request.
298
+ #
299
+ # Only a single-turn query is supported currently.
300
+ # @param generation_spec [::Google::Cloud::DiscoveryEngine::V1::GenerateGroundedContentRequest::GenerationSpec, ::Hash]
301
+ # Content generation specification.
302
+ # @param grounding_spec [::Google::Cloud::DiscoveryEngine::V1::GenerateGroundedContentRequest::GroundingSpec, ::Hash]
303
+ # Grounding specification.
304
+ # @param user_labels [::Hash{::String => ::String}]
305
+ # The user labels applied to a resource must meet the following requirements:
306
+ #
307
+ # * Each resource can have multiple labels, up to a maximum of 64.
308
+ # * Each label must be a key-value pair.
309
+ # * Keys have a minimum length of 1 character and a maximum length of 63
310
+ # characters and cannot be empty. Values can be empty and have a maximum
311
+ # length of 63 characters.
312
+ # * Keys and values can contain only lowercase letters, numeric characters,
313
+ # underscores, and dashes. All characters must use UTF-8 encoding, and
314
+ # international characters are allowed.
315
+ # * The key portion of a label must be unique. However, you can use the same
316
+ # key with multiple resources.
317
+ # * Keys must start with a lowercase letter or international character.
318
+ #
319
+ # See [Google Cloud
320
+ # Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements)
321
+ # for more details.
322
+ #
323
+ # @yield [response, operation] Access the result along with the RPC operation
324
+ # @yieldparam response [::Google::Cloud::DiscoveryEngine::V1::GenerateGroundedContentResponse]
325
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
326
+ #
327
+ # @return [::Google::Cloud::DiscoveryEngine::V1::GenerateGroundedContentResponse]
328
+ #
329
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
330
+ #
331
+ # @example Basic example
332
+ # require "google/cloud/discovery_engine/v1"
333
+ #
334
+ # # Create a client object. The client can be reused for multiple calls.
335
+ # client = Google::Cloud::DiscoveryEngine::V1::GroundedGenerationService::Client.new
336
+ #
337
+ # # Create a request. To set request fields, pass in keyword arguments.
338
+ # request = Google::Cloud::DiscoveryEngine::V1::GenerateGroundedContentRequest.new
339
+ #
340
+ # # Call the generate_grounded_content method.
341
+ # result = client.generate_grounded_content request
342
+ #
343
+ # # The returned object is of type Google::Cloud::DiscoveryEngine::V1::GenerateGroundedContentResponse.
344
+ # p result
345
+ #
346
+ def generate_grounded_content request, options = nil
347
+ raise ::ArgumentError, "request must be provided" if request.nil?
348
+
349
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DiscoveryEngine::V1::GenerateGroundedContentRequest
350
+
351
+ # Converts hash and nil to an options object
352
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
353
+
354
+ # Customize the options with defaults
355
+ metadata = @config.rpcs.generate_grounded_content.metadata.to_h
356
+
357
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
358
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
359
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
360
+ gapic_version: ::Google::Cloud::DiscoveryEngine::V1::VERSION
361
+ metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
362
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
363
+
364
+ header_params = {}
365
+ if request.location
366
+ header_params["location"] = request.location
367
+ end
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.generate_grounded_content.timeout,
373
+ metadata: metadata,
374
+ retry_policy: @config.rpcs.generate_grounded_content.retry_policy
375
+
376
+ options.apply_defaults timeout: @config.timeout,
377
+ metadata: @config.metadata,
378
+ retry_policy: @config.retry_policy
379
+
380
+ @grounded_generation_service_stub.call_rpc :generate_grounded_content, request, options: options do |response, operation|
381
+ yield response, operation if block_given?
382
+ return response
383
+ end
384
+ rescue ::GRPC::BadStatus => e
385
+ raise ::Google::Cloud::Error.from_error(e)
386
+ end
387
+
186
388
  ##
187
389
  # Performs a grounding check.
188
390
  #
@@ -311,17 +513,17 @@ module Google
311
513
  # @example
312
514
  #
313
515
  # # Modify the global config, setting the timeout for
314
- # # check_grounding to 20 seconds,
516
+ # # stream_generate_grounded_content to 20 seconds,
315
517
  # # and all remaining timeouts to 10 seconds.
316
518
  # ::Google::Cloud::DiscoveryEngine::V1::GroundedGenerationService::Client.configure do |config|
317
519
  # config.timeout = 10.0
318
- # config.rpcs.check_grounding.timeout = 20.0
520
+ # config.rpcs.stream_generate_grounded_content.timeout = 20.0
319
521
  # end
320
522
  #
321
523
  # # Apply the above configuration only to a new client.
322
524
  # client = ::Google::Cloud::DiscoveryEngine::V1::GroundedGenerationService::Client.new do |config|
323
525
  # config.timeout = 10.0
324
- # config.rpcs.check_grounding.timeout = 20.0
526
+ # config.rpcs.stream_generate_grounded_content.timeout = 20.0
325
527
  # end
326
528
  #
327
529
  # @!attribute [rw] endpoint
@@ -448,6 +650,16 @@ module Google
448
650
  # trigger a retry.
449
651
  #
450
652
  class Rpcs
653
+ ##
654
+ # RPC-specific configuration for `stream_generate_grounded_content`
655
+ # @return [::Gapic::Config::Method]
656
+ #
657
+ attr_reader :stream_generate_grounded_content
658
+ ##
659
+ # RPC-specific configuration for `generate_grounded_content`
660
+ # @return [::Gapic::Config::Method]
661
+ #
662
+ attr_reader :generate_grounded_content
451
663
  ##
452
664
  # RPC-specific configuration for `check_grounding`
453
665
  # @return [::Gapic::Config::Method]
@@ -456,6 +668,10 @@ module Google
456
668
 
457
669
  # @private
458
670
  def initialize parent_rpcs = nil
671
+ stream_generate_grounded_content_config = parent_rpcs.stream_generate_grounded_content if parent_rpcs.respond_to? :stream_generate_grounded_content
672
+ @stream_generate_grounded_content = ::Gapic::Config::Method.new stream_generate_grounded_content_config
673
+ generate_grounded_content_config = parent_rpcs.generate_grounded_content if parent_rpcs.respond_to? :generate_grounded_content
674
+ @generate_grounded_content = ::Gapic::Config::Method.new generate_grounded_content_config
459
675
  check_grounding_config = parent_rpcs.check_grounding if parent_rpcs.respond_to? :check_grounding
460
676
  @check_grounding = ::Gapic::Config::Method.new check_grounding_config
461
677
 
@@ -43,6 +43,91 @@ module Google
43
43
  "projects/#{project}/locations/#{location}/groundingConfigs/#{grounding_config}"
44
44
  end
45
45
 
46
+ ##
47
+ # Create a fully-qualified Location resource string.
48
+ #
49
+ # The resource will be in the following format:
50
+ #
51
+ # `projects/{project}/locations/{location}`
52
+ #
53
+ # @param project [String]
54
+ # @param location [String]
55
+ #
56
+ # @return [::String]
57
+ def location_path project:, location:
58
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
59
+
60
+ "projects/#{project}/locations/#{location}"
61
+ end
62
+
63
+ ##
64
+ # Create a fully-qualified ServingConfig resource string.
65
+ #
66
+ # @overload serving_config_path(project:, location:, data_store:, serving_config:)
67
+ # The resource will be in the following format:
68
+ #
69
+ # `projects/{project}/locations/{location}/dataStores/{data_store}/servingConfigs/{serving_config}`
70
+ #
71
+ # @param project [String]
72
+ # @param location [String]
73
+ # @param data_store [String]
74
+ # @param serving_config [String]
75
+ #
76
+ # @overload serving_config_path(project:, location:, collection:, data_store:, serving_config:)
77
+ # The resource will be in the following format:
78
+ #
79
+ # `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/servingConfigs/{serving_config}`
80
+ #
81
+ # @param project [String]
82
+ # @param location [String]
83
+ # @param collection [String]
84
+ # @param data_store [String]
85
+ # @param serving_config [String]
86
+ #
87
+ # @overload serving_config_path(project:, location:, collection:, engine:, serving_config:)
88
+ # The resource will be in the following format:
89
+ #
90
+ # `projects/{project}/locations/{location}/collections/{collection}/engines/{engine}/servingConfigs/{serving_config}`
91
+ #
92
+ # @param project [String]
93
+ # @param location [String]
94
+ # @param collection [String]
95
+ # @param engine [String]
96
+ # @param serving_config [String]
97
+ #
98
+ # @return [::String]
99
+ def serving_config_path **args
100
+ resources = {
101
+ "data_store:location:project:serving_config" => (proc do |project:, location:, data_store:, serving_config:|
102
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
103
+ raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
104
+ raise ::ArgumentError, "data_store cannot contain /" if data_store.to_s.include? "/"
105
+
106
+ "projects/#{project}/locations/#{location}/dataStores/#{data_store}/servingConfigs/#{serving_config}"
107
+ end),
108
+ "collection:data_store:location:project:serving_config" => (proc do |project:, location:, collection:, data_store:, serving_config:|
109
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
110
+ raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
111
+ raise ::ArgumentError, "collection cannot contain /" if collection.to_s.include? "/"
112
+ raise ::ArgumentError, "data_store cannot contain /" if data_store.to_s.include? "/"
113
+
114
+ "projects/#{project}/locations/#{location}/collections/#{collection}/dataStores/#{data_store}/servingConfigs/#{serving_config}"
115
+ end),
116
+ "collection:engine:location:project:serving_config" => (proc do |project:, location:, collection:, engine:, serving_config:|
117
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
118
+ raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
119
+ raise ::ArgumentError, "collection cannot contain /" if collection.to_s.include? "/"
120
+ raise ::ArgumentError, "engine cannot contain /" if engine.to_s.include? "/"
121
+
122
+ "projects/#{project}/locations/#{location}/collections/#{collection}/engines/#{engine}/servingConfigs/#{serving_config}"
123
+ end)
124
+ }
125
+
126
+ resource = resources[args.keys.sort.join(":")]
127
+ raise ::ArgumentError, "no resource found for values #{args.keys}" if resource.nil?
128
+ resource.call(**args)
129
+ end
130
+
46
131
  extend self
47
132
  end
48
133
  end