google-cloud-discovery_engine-v1beta 0.9.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/lib/google/cloud/discovery_engine/v1beta/conversational_search_service/client.rb +747 -1
  3. data/lib/google/cloud/discovery_engine/v1beta/conversational_search_service/paths.rb +199 -0
  4. data/lib/google/cloud/discovery_engine/v1beta/conversational_search_service/rest/client.rb +698 -1
  5. data/lib/google/cloud/discovery_engine/v1beta/conversational_search_service/rest/service_stub.rb +520 -0
  6. data/lib/google/cloud/discovery_engine/v1beta/data_store_service/paths.rb +94 -0
  7. data/lib/google/cloud/discovery_engine/v1beta/document_service/client.rb +48 -23
  8. data/lib/google/cloud/discovery_engine/v1beta/document_service/paths.rb +21 -0
  9. data/lib/google/cloud/discovery_engine/v1beta/document_service/rest/client.rb +48 -23
  10. data/lib/google/cloud/discovery_engine/v1beta/engine_service/client.rb +296 -0
  11. data/lib/google/cloud/discovery_engine/v1beta/engine_service/rest/client.rb +275 -0
  12. data/lib/google/cloud/discovery_engine/v1beta/engine_service/rest/service_stub.rb +180 -0
  13. data/lib/google/cloud/discovery_engine/v1beta/grounded_generation_service/client.rb +449 -0
  14. data/lib/google/cloud/discovery_engine/v1beta/grounded_generation_service/credentials.rb +47 -0
  15. data/lib/google/cloud/discovery_engine/v1beta/grounded_generation_service/paths.rb +52 -0
  16. data/lib/google/cloud/discovery_engine/v1beta/grounded_generation_service/rest/client.rb +416 -0
  17. data/lib/google/cloud/discovery_engine/v1beta/grounded_generation_service/rest/service_stub.rb +129 -0
  18. data/lib/google/cloud/discovery_engine/v1beta/grounded_generation_service/rest.rb +52 -0
  19. data/lib/google/cloud/discovery_engine/v1beta/grounded_generation_service.rb +55 -0
  20. data/lib/google/cloud/discovery_engine/v1beta/rank_service/client.rb +459 -0
  21. data/lib/google/cloud/discovery_engine/v1beta/rank_service/credentials.rb +47 -0
  22. data/lib/google/cloud/discovery_engine/v1beta/rank_service/paths.rb +52 -0
  23. data/lib/google/cloud/discovery_engine/v1beta/rank_service/rest/client.rb +426 -0
  24. data/lib/google/cloud/discovery_engine/v1beta/rank_service/rest/service_stub.rb +129 -0
  25. data/lib/google/cloud/discovery_engine/v1beta/rank_service/rest.rb +52 -0
  26. data/lib/google/cloud/discovery_engine/v1beta/rank_service.rb +55 -0
  27. data/lib/google/cloud/discovery_engine/v1beta/rest.rb +3 -0
  28. data/lib/google/cloud/discovery_engine/v1beta/search_service/client.rb +14 -7
  29. data/lib/google/cloud/discovery_engine/v1beta/search_service/paths.rb +45 -0
  30. data/lib/google/cloud/discovery_engine/v1beta/search_service/rest/client.rb +14 -7
  31. data/lib/google/cloud/discovery_engine/v1beta/search_tuning_service/client.rb +469 -0
  32. data/lib/google/cloud/discovery_engine/v1beta/search_tuning_service/credentials.rb +47 -0
  33. data/lib/google/cloud/discovery_engine/v1beta/search_tuning_service/operations.rb +801 -0
  34. data/lib/google/cloud/discovery_engine/v1beta/search_tuning_service/paths.rb +78 -0
  35. data/lib/google/cloud/discovery_engine/v1beta/search_tuning_service/rest/client.rb +436 -0
  36. data/lib/google/cloud/discovery_engine/v1beta/search_tuning_service/rest/operations.rb +1077 -0
  37. data/lib/google/cloud/discovery_engine/v1beta/search_tuning_service/rest/service_stub.rb +129 -0
  38. data/lib/google/cloud/discovery_engine/v1beta/search_tuning_service/rest.rb +53 -0
  39. data/lib/google/cloud/discovery_engine/v1beta/search_tuning_service.rb +56 -0
  40. data/lib/google/cloud/discovery_engine/v1beta/serving_config_service/client.rb +5 -4
  41. data/lib/google/cloud/discovery_engine/v1beta/serving_config_service/paths.rb +21 -0
  42. data/lib/google/cloud/discovery_engine/v1beta/serving_config_service/rest/client.rb +5 -4
  43. data/lib/google/cloud/discovery_engine/v1beta/serving_config_service/rest.rb +2 -1
  44. data/lib/google/cloud/discovery_engine/v1beta/serving_config_service.rb +2 -1
  45. data/lib/google/cloud/discovery_engine/v1beta/version.rb +1 -1
  46. data/lib/google/cloud/discovery_engine/v1beta.rb +3 -0
  47. data/lib/google/cloud/discoveryengine/v1beta/answer_pb.rb +67 -0
  48. data/lib/google/cloud/discoveryengine/v1beta/common_pb.rb +1 -1
  49. data/lib/google/cloud/discoveryengine/v1beta/conversational_search_service_pb.rb +32 -1
  50. data/lib/google/cloud/discoveryengine/v1beta/conversational_search_service_services_pb.rb +25 -0
  51. data/lib/google/cloud/discoveryengine/v1beta/data_store_pb.rb +5 -1
  52. data/lib/google/cloud/discoveryengine/v1beta/document_pb.rb +3 -1
  53. data/lib/google/cloud/discoveryengine/v1beta/document_processing_config_pb.rb +48 -0
  54. data/lib/google/cloud/discoveryengine/v1beta/document_service_pb.rb +3 -1
  55. data/lib/google/cloud/discoveryengine/v1beta/engine_service_pb.rb +6 -1
  56. data/lib/google/cloud/discoveryengine/v1beta/engine_service_services_pb.rb +12 -0
  57. data/lib/google/cloud/discoveryengine/v1beta/grounded_generation_service_pb.rb +52 -0
  58. data/lib/google/cloud/discoveryengine/v1beta/grounded_generation_service_services_pb.rb +45 -0
  59. data/lib/google/cloud/discoveryengine/v1beta/grounding_pb.rb +46 -0
  60. data/lib/google/cloud/discoveryengine/v1beta/import_config_pb.rb +13 -1
  61. data/lib/google/cloud/discoveryengine/v1beta/purge_config_pb.rb +1 -1
  62. data/lib/google/cloud/discoveryengine/v1beta/rank_service_pb.rb +49 -0
  63. data/lib/google/cloud/discoveryengine/v1beta/rank_service_services_pb.rb +45 -0
  64. data/lib/google/cloud/discoveryengine/v1beta/search_service_pb.rb +8 -1
  65. data/lib/google/cloud/discoveryengine/v1beta/search_tuning_service_pb.rb +57 -0
  66. data/lib/google/cloud/discoveryengine/v1beta/search_tuning_service_services_pb.rb +45 -0
  67. data/lib/google/cloud/discoveryengine/v1beta/serving_config_service_pb.rb +1 -1
  68. data/lib/google/cloud/discoveryengine/v1beta/serving_config_service_services_pb.rb +2 -1
  69. data/lib/google/cloud/discoveryengine/v1beta/session_pb.rb +50 -0
  70. data/proto_docs/google/api/client.rb +4 -0
  71. data/proto_docs/google/cloud/discoveryengine/v1beta/answer.rb +354 -0
  72. data/proto_docs/google/cloud/discoveryengine/v1beta/common.rb +9 -1
  73. data/proto_docs/google/cloud/discoveryengine/v1beta/conversational_search_service.rb +480 -0
  74. data/proto_docs/google/cloud/discoveryengine/v1beta/data_store.rb +20 -0
  75. data/proto_docs/google/cloud/discoveryengine/v1beta/document.rb +7 -0
  76. data/proto_docs/google/cloud/discoveryengine/v1beta/document_processing_config.rb +101 -0
  77. data/proto_docs/google/cloud/discoveryengine/v1beta/document_service.rb +4 -0
  78. data/proto_docs/google/cloud/discoveryengine/v1beta/engine.rb +2 -2
  79. data/proto_docs/google/cloud/discoveryengine/v1beta/engine_service.rb +51 -0
  80. data/proto_docs/google/cloud/discoveryengine/v1beta/grounded_generation_service.rb +106 -0
  81. data/proto_docs/google/cloud/discoveryengine/v1beta/grounding.rb +76 -0
  82. data/proto_docs/google/cloud/discoveryengine/v1beta/import_config.rb +310 -24
  83. data/proto_docs/google/cloud/discoveryengine/v1beta/purge_config.rb +3 -0
  84. data/proto_docs/google/cloud/discoveryengine/v1beta/rank_service.rb +99 -0
  85. data/proto_docs/google/cloud/discoveryengine/v1beta/search_service.rb +171 -26
  86. data/proto_docs/google/cloud/discoveryengine/v1beta/search_tuning_service.rb +141 -0
  87. data/proto_docs/google/cloud/discoveryengine/v1beta/serving_config.rb +4 -3
  88. data/proto_docs/google/cloud/discoveryengine/v1beta/serving_config_service.rb +3 -3
  89. data/proto_docs/google/cloud/discoveryengine/v1beta/session.rb +85 -0
  90. data/proto_docs/google/cloud/discoveryengine/v1beta/user_event.rb +1 -1
  91. metadata +42 -2
@@ -68,9 +68,9 @@ module Google
68
68
  end
69
69
  default_config = Client::Configuration.new parent_config
70
70
 
71
- default_config.timeout = 5.0
71
+ default_config.timeout = 30.0
72
72
  default_config.retry_policy = {
73
- initial_delay: 0.1, max_delay: 5.0, multiplier: 1.3, retry_codes: [14]
73
+ initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
74
74
  }
75
75
 
76
76
  default_config
@@ -193,7 +193,7 @@ module Google
193
193
  # @param options [::Gapic::CallOptions, ::Hash]
194
194
  # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
195
195
  #
196
- # @overload search(serving_config: nil, branch: nil, query: nil, image_query: nil, page_size: nil, page_token: nil, offset: nil, filter: nil, canonical_filter: nil, order_by: nil, user_info: nil, facet_specs: nil, boost_spec: nil, params: nil, query_expansion_spec: nil, spell_correction_spec: nil, user_pseudo_id: nil, content_search_spec: nil, embedding_spec: nil, ranking_expression: nil, safe_search: nil, user_labels: nil)
196
+ # @overload search(serving_config: nil, branch: nil, query: nil, image_query: nil, page_size: nil, page_token: nil, offset: nil, data_store_specs: nil, filter: nil, canonical_filter: nil, order_by: nil, user_info: nil, facet_specs: nil, boost_spec: nil, params: nil, query_expansion_spec: nil, spell_correction_spec: nil, user_pseudo_id: nil, content_search_spec: nil, embedding_spec: nil, ranking_expression: nil, safe_search: nil, user_labels: nil)
197
197
  # Pass arguments to `search` via keyword arguments. Note that at
198
198
  # least one keyword argument is required. To specify no parameters, or to keep all
199
199
  # the default parameter values, pass an empty Hash as a request object (see above).
@@ -217,10 +217,14 @@ module Google
217
217
  # Raw image query.
218
218
  # @param page_size [::Integer]
219
219
  # Maximum number of {::Google::Cloud::DiscoveryEngine::V1beta::Document Document}s
220
- # to return. If unspecified, defaults to a reasonable value. The maximum
221
- # allowed value is 100. Values above 100 are coerced to 100.
220
+ # to return. The maximum allowed value depends on the data type. Values above
221
+ # the maximum value are coerced to the maximum value.
222
222
  #
223
- # If this field is negative, an `INVALID_ARGUMENT` is returned.
223
+ # * Websites with basic indexing: Default `10`, Maximum `25`.
224
+ # * Websites with advanced indexing: Default `25`, Maximum `50`.
225
+ # * Other: Default `50`, Maximum `100`.
226
+ #
227
+ # If this field is negative, an `INVALID_ARGUMENT` is returned.
224
228
  # @param page_token [::String]
225
229
  # A page token received from a previous
226
230
  # {::Google::Cloud::DiscoveryEngine::V1beta::SearchService::Client#search SearchService.Search}
@@ -239,6 +243,8 @@ module Google
239
243
  # is unset.
240
244
  #
241
245
  # If this field is negative, an `INVALID_ARGUMENT` is returned.
246
+ # @param data_store_specs [::Array<::Google::Cloud::DiscoveryEngine::V1beta::SearchRequest::DataStoreSpec, ::Hash>]
247
+ # A list of data store specs to apply on a search call.
242
248
  # @param filter [::String]
243
249
  # The filter syntax consists of an expression language for constructing a
244
250
  # predicate from one or more fields of the documents being filtered. Filter
@@ -340,7 +346,8 @@ module Google
340
346
  #
341
347
  # If
342
348
  # {::Google::Cloud::DiscoveryEngine::V1beta::SearchRequest::EmbeddingSpec::EmbeddingVector#field_path SearchRequest.EmbeddingSpec.EmbeddingVector.field_path}
343
- # is not provided, it will use [ServingConfig.EmbeddingConfig.field_path][].
349
+ # is not provided, it will use
350
+ # {::Google::Cloud::DiscoveryEngine::V1beta::ServingConfig#embedding_config ServingConfig.EmbeddingConfig.field_path}.
344
351
  # @param ranking_expression [::String]
345
352
  # The ranking expression controls the customized ranking on retrieval
346
353
  # documents. This overrides
@@ -73,6 +73,51 @@ module Google
73
73
  resource.call(**args)
74
74
  end
75
75
 
76
+ ##
77
+ # Create a fully-qualified DataStore resource string.
78
+ #
79
+ # @overload data_store_path(project:, location:, data_store:)
80
+ # The resource will be in the following format:
81
+ #
82
+ # `projects/{project}/locations/{location}/dataStores/{data_store}`
83
+ #
84
+ # @param project [String]
85
+ # @param location [String]
86
+ # @param data_store [String]
87
+ #
88
+ # @overload data_store_path(project:, location:, collection:, data_store:)
89
+ # The resource will be in the following format:
90
+ #
91
+ # `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`
92
+ #
93
+ # @param project [String]
94
+ # @param location [String]
95
+ # @param collection [String]
96
+ # @param data_store [String]
97
+ #
98
+ # @return [::String]
99
+ def data_store_path **args
100
+ resources = {
101
+ "data_store:location:project" => (proc do |project:, location:, data_store:|
102
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
103
+ raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
104
+
105
+ "projects/#{project}/locations/#{location}/dataStores/#{data_store}"
106
+ end),
107
+ "collection:data_store:location:project" => (proc do |project:, location:, collection:, data_store:|
108
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
109
+ raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
110
+ raise ::ArgumentError, "collection cannot contain /" if collection.to_s.include? "/"
111
+
112
+ "projects/#{project}/locations/#{location}/collections/#{collection}/dataStores/#{data_store}"
113
+ end)
114
+ }
115
+
116
+ resource = resources[args.keys.sort.join(":")]
117
+ raise ::ArgumentError, "no resource found for values #{args.keys}" if resource.nil?
118
+ resource.call(**args)
119
+ end
120
+
76
121
  ##
77
122
  # Create a fully-qualified ServingConfig resource string.
78
123
  #
@@ -70,9 +70,9 @@ module Google
70
70
  end
71
71
  default_config = Client::Configuration.new parent_config
72
72
 
73
- default_config.timeout = 5.0
73
+ default_config.timeout = 30.0
74
74
  default_config.retry_policy = {
75
- initial_delay: 0.1, max_delay: 5.0, multiplier: 1.3, retry_codes: [14]
75
+ initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
76
76
  }
77
77
 
78
78
  default_config
@@ -186,7 +186,7 @@ module Google
186
186
  # @param options [::Gapic::CallOptions, ::Hash]
187
187
  # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
188
188
  #
189
- # @overload search(serving_config: nil, branch: nil, query: nil, image_query: nil, page_size: nil, page_token: nil, offset: nil, filter: nil, canonical_filter: nil, order_by: nil, user_info: nil, facet_specs: nil, boost_spec: nil, params: nil, query_expansion_spec: nil, spell_correction_spec: nil, user_pseudo_id: nil, content_search_spec: nil, embedding_spec: nil, ranking_expression: nil, safe_search: nil, user_labels: nil)
189
+ # @overload search(serving_config: nil, branch: nil, query: nil, image_query: nil, page_size: nil, page_token: nil, offset: nil, data_store_specs: nil, filter: nil, canonical_filter: nil, order_by: nil, user_info: nil, facet_specs: nil, boost_spec: nil, params: nil, query_expansion_spec: nil, spell_correction_spec: nil, user_pseudo_id: nil, content_search_spec: nil, embedding_spec: nil, ranking_expression: nil, safe_search: nil, user_labels: nil)
190
190
  # Pass arguments to `search` via keyword arguments. Note that at
191
191
  # least one keyword argument is required. To specify no parameters, or to keep all
192
192
  # the default parameter values, pass an empty Hash as a request object (see above).
@@ -210,10 +210,14 @@ module Google
210
210
  # Raw image query.
211
211
  # @param page_size [::Integer]
212
212
  # Maximum number of {::Google::Cloud::DiscoveryEngine::V1beta::Document Document}s
213
- # to return. If unspecified, defaults to a reasonable value. The maximum
214
- # allowed value is 100. Values above 100 are coerced to 100.
213
+ # to return. The maximum allowed value depends on the data type. Values above
214
+ # the maximum value are coerced to the maximum value.
215
215
  #
216
- # If this field is negative, an `INVALID_ARGUMENT` is returned.
216
+ # * Websites with basic indexing: Default `10`, Maximum `25`.
217
+ # * Websites with advanced indexing: Default `25`, Maximum `50`.
218
+ # * Other: Default `50`, Maximum `100`.
219
+ #
220
+ # If this field is negative, an `INVALID_ARGUMENT` is returned.
217
221
  # @param page_token [::String]
218
222
  # A page token received from a previous
219
223
  # {::Google::Cloud::DiscoveryEngine::V1beta::SearchService::Rest::Client#search SearchService.Search}
@@ -232,6 +236,8 @@ module Google
232
236
  # is unset.
233
237
  #
234
238
  # If this field is negative, an `INVALID_ARGUMENT` is returned.
239
+ # @param data_store_specs [::Array<::Google::Cloud::DiscoveryEngine::V1beta::SearchRequest::DataStoreSpec, ::Hash>]
240
+ # A list of data store specs to apply on a search call.
235
241
  # @param filter [::String]
236
242
  # The filter syntax consists of an expression language for constructing a
237
243
  # predicate from one or more fields of the documents being filtered. Filter
@@ -333,7 +339,8 @@ module Google
333
339
  #
334
340
  # If
335
341
  # {::Google::Cloud::DiscoveryEngine::V1beta::SearchRequest::EmbeddingSpec::EmbeddingVector#field_path SearchRequest.EmbeddingSpec.EmbeddingVector.field_path}
336
- # is not provided, it will use [ServingConfig.EmbeddingConfig.field_path][].
342
+ # is not provided, it will use
343
+ # {::Google::Cloud::DiscoveryEngine::V1beta::ServingConfig#embedding_config ServingConfig.EmbeddingConfig.field_path}.
337
344
  # @param ranking_expression [::String]
338
345
  # The ranking expression controls the customized ranking on retrieval
339
346
  # documents. This overrides
@@ -0,0 +1,469 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2024 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/discoveryengine/v1beta/search_tuning_service_pb"
21
+ require "google/cloud/location"
22
+
23
+ module Google
24
+ module Cloud
25
+ module DiscoveryEngine
26
+ module V1beta
27
+ module SearchTuningService
28
+ ##
29
+ # Client for the SearchTuningService service.
30
+ #
31
+ # Service for search tuning.
32
+ #
33
+ class Client
34
+ # @private
35
+ DEFAULT_ENDPOINT_TEMPLATE = "discoveryengine.$UNIVERSE_DOMAIN$"
36
+
37
+ include Paths
38
+
39
+ # @private
40
+ attr_reader :search_tuning_service_stub
41
+
42
+ ##
43
+ # Configure the SearchTuningService Client class.
44
+ #
45
+ # See {::Google::Cloud::DiscoveryEngine::V1beta::SearchTuningService::Client::Configuration}
46
+ # for a description of the configuration fields.
47
+ #
48
+ # @example
49
+ #
50
+ # # Modify the configuration for all SearchTuningService clients
51
+ # ::Google::Cloud::DiscoveryEngine::V1beta::SearchTuningService::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", "DiscoveryEngine", "V1beta"]
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
72
+ end
73
+ yield @configure if block_given?
74
+ @configure
75
+ end
76
+
77
+ ##
78
+ # Configure the SearchTuningService Client instance.
79
+ #
80
+ # The configuration is set to the derived mode, meaning that values can be changed,
81
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
82
+ # should be made on {Client.configure}.
83
+ #
84
+ # See {::Google::Cloud::DiscoveryEngine::V1beta::SearchTuningService::Client::Configuration}
85
+ # for a description of the configuration fields.
86
+ #
87
+ # @yield [config] Configure the Client client.
88
+ # @yieldparam config [Client::Configuration]
89
+ #
90
+ # @return [Client::Configuration]
91
+ #
92
+ def configure
93
+ yield @config if block_given?
94
+ @config
95
+ end
96
+
97
+ ##
98
+ # The effective universe domain
99
+ #
100
+ # @return [String]
101
+ #
102
+ def universe_domain
103
+ @search_tuning_service_stub.universe_domain
104
+ end
105
+
106
+ ##
107
+ # Create a new SearchTuningService client object.
108
+ #
109
+ # @example
110
+ #
111
+ # # Create a client using the default configuration
112
+ # client = ::Google::Cloud::DiscoveryEngine::V1beta::SearchTuningService::Client.new
113
+ #
114
+ # # Create a client using a custom configuration
115
+ # client = ::Google::Cloud::DiscoveryEngine::V1beta::SearchTuningService::Client.new do |config|
116
+ # config.timeout = 10.0
117
+ # end
118
+ #
119
+ # @yield [config] Configure the SearchTuningService 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/discoveryengine/v1beta/search_tuning_service_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 endpoint is unchanged from default,
138
+ # but only if the default endpoint does not have a region prefix.
139
+ enable_self_signed_jwt = @config.endpoint.nil? ||
140
+ (@config.endpoint == Configuration::DEFAULT_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
+ @operations_client = Operations.new do |config|
151
+ config.credentials = credentials
152
+ config.quota_project = @quota_project_id
153
+ config.endpoint = @config.endpoint
154
+ config.universe_domain = @config.universe_domain
155
+ end
156
+
157
+ @search_tuning_service_stub = ::Gapic::ServiceStub.new(
158
+ ::Google::Cloud::DiscoveryEngine::V1beta::SearchTuningService::Stub,
159
+ credentials: credentials,
160
+ endpoint: @config.endpoint,
161
+ endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
162
+ universe_domain: @config.universe_domain,
163
+ channel_args: @config.channel_args,
164
+ interceptors: @config.interceptors,
165
+ channel_pool_config: @config.channel_pool
166
+ )
167
+
168
+ @location_client = Google::Cloud::Location::Locations::Client.new do |config|
169
+ config.credentials = credentials
170
+ config.quota_project = @quota_project_id
171
+ config.endpoint = @search_tuning_service_stub.endpoint
172
+ config.universe_domain = @search_tuning_service_stub.universe_domain
173
+ end
174
+ end
175
+
176
+ ##
177
+ # Get the associated client for long-running operations.
178
+ #
179
+ # @return [::Google::Cloud::DiscoveryEngine::V1beta::SearchTuningService::Operations]
180
+ #
181
+ attr_reader :operations_client
182
+
183
+ ##
184
+ # Get the associated client for mix-in of the Locations.
185
+ #
186
+ # @return [Google::Cloud::Location::Locations::Client]
187
+ #
188
+ attr_reader :location_client
189
+
190
+ # Service calls
191
+
192
+ ##
193
+ # Trains a custom model.
194
+ #
195
+ # @overload train_custom_model(request, options = nil)
196
+ # Pass arguments to `train_custom_model` via a request object, either of type
197
+ # {::Google::Cloud::DiscoveryEngine::V1beta::TrainCustomModelRequest} or an equivalent Hash.
198
+ #
199
+ # @param request [::Google::Cloud::DiscoveryEngine::V1beta::TrainCustomModelRequest, ::Hash]
200
+ # A request object representing the call parameters. Required. To specify no
201
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
202
+ # @param options [::Gapic::CallOptions, ::Hash]
203
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
204
+ #
205
+ # @overload train_custom_model(gcs_training_input: nil, data_store: nil, model_type: nil, error_config: nil)
206
+ # Pass arguments to `train_custom_model` via keyword arguments. Note that at
207
+ # least one keyword argument is required. To specify no parameters, or to keep all
208
+ # the default parameter values, pass an empty Hash as a request object (see above).
209
+ #
210
+ # @param gcs_training_input [::Google::Cloud::DiscoveryEngine::V1beta::TrainCustomModelRequest::GcsTrainingInput, ::Hash]
211
+ # Cloud Storage training input.
212
+ # @param data_store [::String]
213
+ # Required. The resource name of the Data Store, such as
214
+ # `projects/*/locations/global/collections/default_collection/dataStores/default_data_store`.
215
+ # This field is used to identify the data store where to train the models.
216
+ # @param model_type [::String]
217
+ # Model to be trained. Supported values are:
218
+ #
219
+ # * **search-tuning**: Fine tuning the search system based on data provided.
220
+ # @param error_config [::Google::Cloud::DiscoveryEngine::V1beta::ImportErrorConfig, ::Hash]
221
+ # The desired location of errors incurred during the data ingestion and
222
+ # training.
223
+ #
224
+ # @yield [response, operation] Access the result along with the RPC operation
225
+ # @yieldparam response [::Gapic::Operation]
226
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
227
+ #
228
+ # @return [::Gapic::Operation]
229
+ #
230
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
231
+ #
232
+ # @example Basic example
233
+ # require "google/cloud/discovery_engine/v1beta"
234
+ #
235
+ # # Create a client object. The client can be reused for multiple calls.
236
+ # client = Google::Cloud::DiscoveryEngine::V1beta::SearchTuningService::Client.new
237
+ #
238
+ # # Create a request. To set request fields, pass in keyword arguments.
239
+ # request = Google::Cloud::DiscoveryEngine::V1beta::TrainCustomModelRequest.new
240
+ #
241
+ # # Call the train_custom_model method.
242
+ # result = client.train_custom_model request
243
+ #
244
+ # # The returned object is of type Gapic::Operation. You can use it to
245
+ # # check the status of an operation, cancel it, or wait for results.
246
+ # # Here is how to wait for a response.
247
+ # result.wait_until_done! timeout: 60
248
+ # if result.response?
249
+ # p result.response
250
+ # else
251
+ # puts "No response received."
252
+ # end
253
+ #
254
+ def train_custom_model request, options = nil
255
+ raise ::ArgumentError, "request must be provided" if request.nil?
256
+
257
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DiscoveryEngine::V1beta::TrainCustomModelRequest
258
+
259
+ # Converts hash and nil to an options object
260
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
261
+
262
+ # Customize the options with defaults
263
+ metadata = @config.rpcs.train_custom_model.metadata.to_h
264
+
265
+ # Set x-goog-api-client and x-goog-user-project headers
266
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
267
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
268
+ gapic_version: ::Google::Cloud::DiscoveryEngine::V1beta::VERSION
269
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
270
+
271
+ header_params = {}
272
+ if request.data_store
273
+ header_params["data_store"] = request.data_store
274
+ end
275
+
276
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
277
+ metadata[:"x-goog-request-params"] ||= request_params_header
278
+
279
+ options.apply_defaults timeout: @config.rpcs.train_custom_model.timeout,
280
+ metadata: metadata,
281
+ retry_policy: @config.rpcs.train_custom_model.retry_policy
282
+
283
+ options.apply_defaults timeout: @config.timeout,
284
+ metadata: @config.metadata,
285
+ retry_policy: @config.retry_policy
286
+
287
+ @search_tuning_service_stub.call_rpc :train_custom_model, request, options: options do |response, operation|
288
+ response = ::Gapic::Operation.new response, @operations_client, options: options
289
+ yield response, operation if block_given?
290
+ return response
291
+ end
292
+ rescue ::GRPC::BadStatus => e
293
+ raise ::Google::Cloud::Error.from_error(e)
294
+ end
295
+
296
+ ##
297
+ # Configuration class for the SearchTuningService API.
298
+ #
299
+ # This class represents the configuration for SearchTuningService,
300
+ # providing control over timeouts, retry behavior, logging, transport
301
+ # parameters, and other low-level controls. Certain parameters can also be
302
+ # applied individually to specific RPCs. See
303
+ # {::Google::Cloud::DiscoveryEngine::V1beta::SearchTuningService::Client::Configuration::Rpcs}
304
+ # for a list of RPCs that can be configured independently.
305
+ #
306
+ # Configuration can be applied globally to all clients, or to a single client
307
+ # on construction.
308
+ #
309
+ # @example
310
+ #
311
+ # # Modify the global config, setting the timeout for
312
+ # # train_custom_model to 20 seconds,
313
+ # # and all remaining timeouts to 10 seconds.
314
+ # ::Google::Cloud::DiscoveryEngine::V1beta::SearchTuningService::Client.configure do |config|
315
+ # config.timeout = 10.0
316
+ # config.rpcs.train_custom_model.timeout = 20.0
317
+ # end
318
+ #
319
+ # # Apply the above configuration only to a new client.
320
+ # client = ::Google::Cloud::DiscoveryEngine::V1beta::SearchTuningService::Client.new do |config|
321
+ # config.timeout = 10.0
322
+ # config.rpcs.train_custom_model.timeout = 20.0
323
+ # end
324
+ #
325
+ # @!attribute [rw] endpoint
326
+ # A custom service endpoint, as a hostname or hostname:port. The default is
327
+ # nil, indicating to use the default endpoint in the current universe domain.
328
+ # @return [::String,nil]
329
+ # @!attribute [rw] credentials
330
+ # Credentials to send with calls. You may provide any of the following types:
331
+ # * (`String`) The path to a service account key file in JSON format
332
+ # * (`Hash`) A service account key as a Hash
333
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
334
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
335
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
336
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
337
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
338
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
339
+ # * (`nil`) indicating no credentials
340
+ # @return [::Object]
341
+ # @!attribute [rw] scope
342
+ # The OAuth scopes
343
+ # @return [::Array<::String>]
344
+ # @!attribute [rw] lib_name
345
+ # The library name as recorded in instrumentation and logging
346
+ # @return [::String]
347
+ # @!attribute [rw] lib_version
348
+ # The library version as recorded in instrumentation and logging
349
+ # @return [::String]
350
+ # @!attribute [rw] channel_args
351
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
352
+ # `GRPC::Core::Channel` object is provided as the credential.
353
+ # @return [::Hash]
354
+ # @!attribute [rw] interceptors
355
+ # An array of interceptors that are run before calls are executed.
356
+ # @return [::Array<::GRPC::ClientInterceptor>]
357
+ # @!attribute [rw] timeout
358
+ # The call timeout in seconds.
359
+ # @return [::Numeric]
360
+ # @!attribute [rw] metadata
361
+ # Additional gRPC headers to be sent with the call.
362
+ # @return [::Hash{::Symbol=>::String}]
363
+ # @!attribute [rw] retry_policy
364
+ # The retry policy. The value is a hash with the following keys:
365
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
366
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
367
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
368
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
369
+ # trigger a retry.
370
+ # @return [::Hash]
371
+ # @!attribute [rw] quota_project
372
+ # A separate project against which to charge quota.
373
+ # @return [::String]
374
+ # @!attribute [rw] universe_domain
375
+ # The universe domain within which to make requests. This determines the
376
+ # default endpoint URL. The default value of nil uses the environment
377
+ # universe (usually the default "googleapis.com" universe).
378
+ # @return [::String,nil]
379
+ #
380
+ class Configuration
381
+ extend ::Gapic::Config
382
+
383
+ # @private
384
+ # The endpoint specific to the default "googleapis.com" universe. Deprecated.
385
+ DEFAULT_ENDPOINT = "discoveryengine.googleapis.com"
386
+
387
+ config_attr :endpoint, nil, ::String, nil
388
+ config_attr :credentials, nil do |value|
389
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
390
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
391
+ allowed.any? { |klass| klass === value }
392
+ end
393
+ config_attr :scope, nil, ::String, ::Array, nil
394
+ config_attr :lib_name, nil, ::String, nil
395
+ config_attr :lib_version, nil, ::String, nil
396
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
397
+ config_attr :interceptors, nil, ::Array, nil
398
+ config_attr :timeout, nil, ::Numeric, nil
399
+ config_attr :metadata, nil, ::Hash, nil
400
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
401
+ config_attr :quota_project, nil, ::String, nil
402
+ config_attr :universe_domain, nil, ::String, nil
403
+
404
+ # @private
405
+ def initialize parent_config = nil
406
+ @parent_config = parent_config unless parent_config.nil?
407
+
408
+ yield self if block_given?
409
+ end
410
+
411
+ ##
412
+ # Configurations for individual RPCs
413
+ # @return [Rpcs]
414
+ #
415
+ def rpcs
416
+ @rpcs ||= begin
417
+ parent_rpcs = nil
418
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
419
+ Rpcs.new parent_rpcs
420
+ end
421
+ end
422
+
423
+ ##
424
+ # Configuration for the channel pool
425
+ # @return [::Gapic::ServiceStub::ChannelPool::Configuration]
426
+ #
427
+ def channel_pool
428
+ @channel_pool ||= ::Gapic::ServiceStub::ChannelPool::Configuration.new
429
+ end
430
+
431
+ ##
432
+ # Configuration RPC class for the SearchTuningService API.
433
+ #
434
+ # Includes fields providing the configuration for each RPC in this service.
435
+ # Each configuration object is of type `Gapic::Config::Method` and includes
436
+ # the following configuration fields:
437
+ #
438
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
439
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
440
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
441
+ # include the following keys:
442
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
443
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
444
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
445
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
446
+ # trigger a retry.
447
+ #
448
+ class Rpcs
449
+ ##
450
+ # RPC-specific configuration for `train_custom_model`
451
+ # @return [::Gapic::Config::Method]
452
+ #
453
+ attr_reader :train_custom_model
454
+
455
+ # @private
456
+ def initialize parent_rpcs = nil
457
+ train_custom_model_config = parent_rpcs.train_custom_model if parent_rpcs.respond_to? :train_custom_model
458
+ @train_custom_model = ::Gapic::Config::Method.new train_custom_model_config
459
+
460
+ yield self if block_given?
461
+ end
462
+ end
463
+ end
464
+ end
465
+ end
466
+ end
467
+ end
468
+ end
469
+ end