google-cloud-discovery_engine-v1 0.a → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.yardopts +12 -0
- data/AUTHENTICATION.md +149 -0
- data/README.md +144 -8
- data/lib/google/cloud/discovery_engine/v1/completion_service/client.rb +451 -0
- data/lib/google/cloud/discovery_engine/v1/completion_service/credentials.rb +47 -0
- data/lib/google/cloud/discovery_engine/v1/completion_service/paths.rb +78 -0
- data/lib/google/cloud/discovery_engine/v1/completion_service/rest/client.rb +408 -0
- data/lib/google/cloud/discovery_engine/v1/completion_service/rest/service_stub.rb +114 -0
- data/lib/google/cloud/discovery_engine/v1/completion_service/rest.rb +52 -0
- data/lib/google/cloud/discovery_engine/v1/completion_service.rb +55 -0
- data/lib/google/cloud/discovery_engine/v1/conversational_search_service/client.rb +959 -0
- data/lib/google/cloud/discovery_engine/v1/conversational_search_service/credentials.rb +47 -0
- data/lib/google/cloud/discovery_engine/v1/conversational_search_service/paths.rb +176 -0
- data/lib/google/cloud/discovery_engine/v1/conversational_search_service/rest/client.rb +797 -0
- data/lib/google/cloud/discovery_engine/v1/conversational_search_service/rest/service_stub.rb +450 -0
- data/lib/google/cloud/discovery_engine/v1/conversational_search_service/rest.rb +52 -0
- data/lib/google/cloud/discovery_engine/v1/conversational_search_service.rb +55 -0
- data/lib/google/cloud/discovery_engine/v1/document_service/client.rb +1170 -0
- data/lib/google/cloud/discovery_engine/v1/document_service/credentials.rb +47 -0
- data/lib/google/cloud/discovery_engine/v1/document_service/operations.rb +770 -0
- data/lib/google/cloud/discovery_engine/v1/document_service/paths.rb +135 -0
- data/lib/google/cloud/discovery_engine/v1/document_service/rest/client.rb +971 -0
- data/lib/google/cloud/discovery_engine/v1/document_service/rest/operations.rb +977 -0
- data/lib/google/cloud/discovery_engine/v1/document_service/rest/service_stub.rb +518 -0
- data/lib/google/cloud/discovery_engine/v1/document_service/rest.rb +54 -0
- data/lib/google/cloud/discovery_engine/v1/document_service.rb +57 -0
- data/lib/google/cloud/discovery_engine/v1/rest.rb +42 -0
- data/lib/google/cloud/discovery_engine/v1/schema_service/client.rb +853 -0
- data/lib/google/cloud/discovery_engine/v1/schema_service/credentials.rb +47 -0
- data/lib/google/cloud/discovery_engine/v1/schema_service/operations.rb +770 -0
- data/lib/google/cloud/discovery_engine/v1/schema_service/paths.rb +127 -0
- data/lib/google/cloud/discovery_engine/v1/schema_service/rest/client.rb +693 -0
- data/lib/google/cloud/discovery_engine/v1/schema_service/rest/operations.rb +977 -0
- data/lib/google/cloud/discovery_engine/v1/schema_service/rest/service_stub.rb +382 -0
- data/lib/google/cloud/discovery_engine/v1/schema_service/rest.rb +53 -0
- data/lib/google/cloud/discovery_engine/v1/schema_service.rb +56 -0
- data/lib/google/cloud/discovery_engine/v1/search_service/client.rb +529 -0
- data/lib/google/cloud/discovery_engine/v1/search_service/credentials.rb +47 -0
- data/lib/google/cloud/discovery_engine/v1/search_service/paths.rb +131 -0
- data/lib/google/cloud/discovery_engine/v1/search_service/rest/client.rb +481 -0
- data/lib/google/cloud/discovery_engine/v1/search_service/rest/service_stub.rb +116 -0
- data/lib/google/cloud/discovery_engine/v1/search_service/rest.rb +52 -0
- data/lib/google/cloud/discovery_engine/v1/search_service.rb +55 -0
- data/lib/google/cloud/discovery_engine/v1/user_event_service/client.rb +654 -0
- data/lib/google/cloud/discovery_engine/v1/user_event_service/credentials.rb +47 -0
- data/lib/google/cloud/discovery_engine/v1/user_event_service/operations.rb +770 -0
- data/lib/google/cloud/discovery_engine/v1/user_event_service/paths.rb +131 -0
- data/lib/google/cloud/discovery_engine/v1/user_event_service/rest/client.rb +558 -0
- data/lib/google/cloud/discovery_engine/v1/user_event_service/rest/operations.rb +977 -0
- data/lib/google/cloud/discovery_engine/v1/user_event_service/rest/service_stub.rb +250 -0
- data/lib/google/cloud/discovery_engine/v1/user_event_service/rest.rb +53 -0
- data/lib/google/cloud/discovery_engine/v1/user_event_service.rb +56 -0
- data/lib/google/cloud/discovery_engine/v1/version.rb +7 -2
- data/lib/google/cloud/discovery_engine/v1.rb +50 -0
- data/lib/google/cloud/discoveryengine/v1/common_pb.rb +46 -0
- data/lib/google/cloud/discoveryengine/v1/completion_service_pb.rb +49 -0
- data/lib/google/cloud/discoveryengine/v1/completion_service_services_pb.rb +45 -0
- data/lib/google/cloud/discoveryengine/v1/conversation_pb.rb +54 -0
- data/lib/google/cloud/discoveryengine/v1/conversational_search_service_pb.rb +61 -0
- data/lib/google/cloud/discoveryengine/v1/conversational_search_service_services_pb.rb +67 -0
- data/lib/google/cloud/discoveryengine/v1/document_pb.rb +48 -0
- data/lib/google/cloud/discoveryengine/v1/document_service_pb.rb +58 -0
- data/lib/google/cloud/discoveryengine/v1/document_service_services_pb.rb +79 -0
- data/lib/google/cloud/discoveryengine/v1/import_config_pb.rb +66 -0
- data/lib/google/cloud/discoveryengine/v1/purge_config_pb.rb +49 -0
- data/lib/google/cloud/discoveryengine/v1/schema_pb.rb +47 -0
- data/lib/google/cloud/discoveryengine/v1/schema_service_pb.rb +61 -0
- data/lib/google/cloud/discoveryengine/v1/schema_service_services_pb.rb +53 -0
- data/lib/google/cloud/discoveryengine/v1/search_service_pb.rb +73 -0
- data/lib/google/cloud/discoveryengine/v1/search_service_services_pb.rb +45 -0
- data/lib/google/cloud/discoveryengine/v1/user_event_pb.rb +58 -0
- data/lib/google/cloud/discoveryengine/v1/user_event_service_pb.rb +53 -0
- data/lib/google/cloud/discoveryengine/v1/user_event_service_services_pb.rb +59 -0
- data/lib/google-cloud-discovery_engine-v1.rb +21 -0
- data/proto_docs/README.md +4 -0
- data/proto_docs/google/api/client.rb +381 -0
- data/proto_docs/google/api/field_behavior.rb +85 -0
- data/proto_docs/google/api/httpbody.rb +80 -0
- data/proto_docs/google/api/launch_stage.rb +71 -0
- data/proto_docs/google/api/resource.rb +222 -0
- data/proto_docs/google/cloud/discoveryengine/v1/common.rb +106 -0
- data/proto_docs/google/cloud/discoveryengine/v1/completion_service.rb +111 -0
- data/proto_docs/google/cloud/discoveryengine/v1/conversation.rb +113 -0
- data/proto_docs/google/cloud/discoveryengine/v1/conversational_search_service.rb +206 -0
- data/proto_docs/google/cloud/discoveryengine/v1/document.rb +108 -0
- data/proto_docs/google/cloud/discoveryengine/v1/document_service.rb +181 -0
- data/proto_docs/google/cloud/discoveryengine/v1/import_config.rb +340 -0
- data/proto_docs/google/cloud/discoveryengine/v1/purge_config.rb +84 -0
- data/proto_docs/google/cloud/discoveryengine/v1/schema.rb +45 -0
- data/proto_docs/google/cloud/discoveryengine/v1/schema_service.rb +177 -0
- data/proto_docs/google/cloud/discoveryengine/v1/search_service.rb +730 -0
- data/proto_docs/google/cloud/discoveryengine/v1/user_event.rb +478 -0
- data/proto_docs/google/cloud/discoveryengine/v1/user_event_service.rb +64 -0
- data/proto_docs/google/longrunning/operations.rb +164 -0
- data/proto_docs/google/protobuf/any.rb +144 -0
- data/proto_docs/google/protobuf/duration.rb +98 -0
- data/proto_docs/google/protobuf/empty.rb +34 -0
- data/proto_docs/google/protobuf/field_mask.rb +229 -0
- data/proto_docs/google/protobuf/struct.rb +96 -0
- data/proto_docs/google/protobuf/timestamp.rb +127 -0
- data/proto_docs/google/rpc/status.rb +48 -0
- data/proto_docs/google/type/date.rb +53 -0
- metadata +277 -13
|
@@ -0,0 +1,451 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Copyright 2023 Google LLC
|
|
4
|
+
#
|
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
# you may not use this file except in compliance with the License.
|
|
7
|
+
# You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
|
|
17
|
+
# Auto-generated by gapic-generator-ruby. DO NOT EDIT!
|
|
18
|
+
|
|
19
|
+
require "google/cloud/errors"
|
|
20
|
+
require "google/cloud/discoveryengine/v1/completion_service_pb"
|
|
21
|
+
require "google/cloud/location"
|
|
22
|
+
|
|
23
|
+
module Google
|
|
24
|
+
module Cloud
|
|
25
|
+
module DiscoveryEngine
|
|
26
|
+
module V1
|
|
27
|
+
module CompletionService
|
|
28
|
+
##
|
|
29
|
+
# Client for the CompletionService service.
|
|
30
|
+
#
|
|
31
|
+
# Service for Auto-Completion.
|
|
32
|
+
#
|
|
33
|
+
class Client
|
|
34
|
+
include Paths
|
|
35
|
+
|
|
36
|
+
# @private
|
|
37
|
+
attr_reader :completion_service_stub
|
|
38
|
+
|
|
39
|
+
##
|
|
40
|
+
# Configure the CompletionService Client class.
|
|
41
|
+
#
|
|
42
|
+
# See {::Google::Cloud::DiscoveryEngine::V1::CompletionService::Client::Configuration}
|
|
43
|
+
# for a description of the configuration fields.
|
|
44
|
+
#
|
|
45
|
+
# @example
|
|
46
|
+
#
|
|
47
|
+
# # Modify the configuration for all CompletionService clients
|
|
48
|
+
# ::Google::Cloud::DiscoveryEngine::V1::CompletionService::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", "DiscoveryEngine", "V1"]
|
|
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 = 5.0
|
|
69
|
+
default_config.retry_policy = {
|
|
70
|
+
initial_delay: 0.1, max_delay: 5.0, multiplier: 1.3, retry_codes: [14]
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
default_config
|
|
74
|
+
end
|
|
75
|
+
yield @configure if block_given?
|
|
76
|
+
@configure
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
##
|
|
80
|
+
# Configure the CompletionService Client instance.
|
|
81
|
+
#
|
|
82
|
+
# The configuration is set to the derived mode, meaning that values can be changed,
|
|
83
|
+
# but structural changes (adding new fields, etc.) are not allowed. Structural changes
|
|
84
|
+
# should be made on {Client.configure}.
|
|
85
|
+
#
|
|
86
|
+
# See {::Google::Cloud::DiscoveryEngine::V1::CompletionService::Client::Configuration}
|
|
87
|
+
# for a description of the configuration fields.
|
|
88
|
+
#
|
|
89
|
+
# @yield [config] Configure the Client client.
|
|
90
|
+
# @yieldparam config [Client::Configuration]
|
|
91
|
+
#
|
|
92
|
+
# @return [Client::Configuration]
|
|
93
|
+
#
|
|
94
|
+
def configure
|
|
95
|
+
yield @config if block_given?
|
|
96
|
+
@config
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
##
|
|
100
|
+
# Create a new CompletionService client object.
|
|
101
|
+
#
|
|
102
|
+
# @example
|
|
103
|
+
#
|
|
104
|
+
# # Create a client using the default configuration
|
|
105
|
+
# client = ::Google::Cloud::DiscoveryEngine::V1::CompletionService::Client.new
|
|
106
|
+
#
|
|
107
|
+
# # Create a client using a custom configuration
|
|
108
|
+
# client = ::Google::Cloud::DiscoveryEngine::V1::CompletionService::Client.new do |config|
|
|
109
|
+
# config.timeout = 10.0
|
|
110
|
+
# end
|
|
111
|
+
#
|
|
112
|
+
# @yield [config] Configure the CompletionService client.
|
|
113
|
+
# @yieldparam config [Client::Configuration]
|
|
114
|
+
#
|
|
115
|
+
def initialize
|
|
116
|
+
# These require statements are intentionally placed here to initialize
|
|
117
|
+
# the gRPC module only when it's required.
|
|
118
|
+
# See https://github.com/googleapis/toolkit/issues/446
|
|
119
|
+
require "gapic/grpc"
|
|
120
|
+
require "google/cloud/discoveryengine/v1/completion_service_services_pb"
|
|
121
|
+
|
|
122
|
+
# Create the configuration object
|
|
123
|
+
@config = Configuration.new Client.configure
|
|
124
|
+
|
|
125
|
+
# Yield the configuration if needed
|
|
126
|
+
yield @config if block_given?
|
|
127
|
+
|
|
128
|
+
# Create credentials
|
|
129
|
+
credentials = @config.credentials
|
|
130
|
+
# Use self-signed JWT if the endpoint is unchanged from default,
|
|
131
|
+
# but only if the default endpoint does not have a region prefix.
|
|
132
|
+
enable_self_signed_jwt = @config.endpoint == Configuration::DEFAULT_ENDPOINT &&
|
|
133
|
+
!@config.endpoint.split(".").first.include?("-")
|
|
134
|
+
credentials ||= Credentials.default scope: @config.scope,
|
|
135
|
+
enable_self_signed_jwt: enable_self_signed_jwt
|
|
136
|
+
if credentials.is_a?(::String) || credentials.is_a?(::Hash)
|
|
137
|
+
credentials = Credentials.new credentials, scope: @config.scope
|
|
138
|
+
end
|
|
139
|
+
@quota_project_id = @config.quota_project
|
|
140
|
+
@quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
|
|
141
|
+
|
|
142
|
+
@location_client = Google::Cloud::Location::Locations::Client.new do |config|
|
|
143
|
+
config.credentials = credentials
|
|
144
|
+
config.quota_project = @quota_project_id
|
|
145
|
+
config.endpoint = @config.endpoint
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
@completion_service_stub = ::Gapic::ServiceStub.new(
|
|
149
|
+
::Google::Cloud::DiscoveryEngine::V1::CompletionService::Stub,
|
|
150
|
+
credentials: credentials,
|
|
151
|
+
endpoint: @config.endpoint,
|
|
152
|
+
channel_args: @config.channel_args,
|
|
153
|
+
interceptors: @config.interceptors
|
|
154
|
+
)
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
##
|
|
158
|
+
# Get the associated client for mix-in of the Locations.
|
|
159
|
+
#
|
|
160
|
+
# @return [Google::Cloud::Location::Locations::Client]
|
|
161
|
+
#
|
|
162
|
+
attr_reader :location_client
|
|
163
|
+
|
|
164
|
+
# Service calls
|
|
165
|
+
|
|
166
|
+
##
|
|
167
|
+
# Completes the specified user input with keyword suggestions.
|
|
168
|
+
#
|
|
169
|
+
# @overload complete_query(request, options = nil)
|
|
170
|
+
# Pass arguments to `complete_query` via a request object, either of type
|
|
171
|
+
# {::Google::Cloud::DiscoveryEngine::V1::CompleteQueryRequest} or an equivalent Hash.
|
|
172
|
+
#
|
|
173
|
+
# @param request [::Google::Cloud::DiscoveryEngine::V1::CompleteQueryRequest, ::Hash]
|
|
174
|
+
# A request object representing the call parameters. Required. To specify no
|
|
175
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
|
176
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
|
177
|
+
# Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
|
|
178
|
+
#
|
|
179
|
+
# @overload complete_query(data_store: nil, query: nil, query_model: nil, user_pseudo_id: nil, include_tail_suggestions: nil)
|
|
180
|
+
# Pass arguments to `complete_query` via keyword arguments. Note that at
|
|
181
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
|
182
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
|
183
|
+
#
|
|
184
|
+
# @param data_store [::String]
|
|
185
|
+
# Required. The parent data store resource name for which the completion is
|
|
186
|
+
# performed, such as
|
|
187
|
+
# `projects/*/locations/global/collections/default_collection/dataStores/default_data_store`.
|
|
188
|
+
# @param query [::String]
|
|
189
|
+
# Required. The typeahead input used to fetch suggestions. Maximum length is
|
|
190
|
+
# 128 characters.
|
|
191
|
+
# @param query_model [::String]
|
|
192
|
+
# Selects data model of query suggestions for serving. Currently supported
|
|
193
|
+
# values:
|
|
194
|
+
#
|
|
195
|
+
# * `document` - Using suggestions generated from user-imported documents.
|
|
196
|
+
# * `search-history` - Using suggestions generated from the past history of
|
|
197
|
+
# {::Google::Cloud::DiscoveryEngine::V1::SearchService::Client#search SearchService.Search}
|
|
198
|
+
# API calls. Do not use it when there is no traffic for Search API.
|
|
199
|
+
# * `user-event` - Using suggestions generated from user-imported search
|
|
200
|
+
# events.
|
|
201
|
+
# * `document-completable` - Using suggestions taken directly from
|
|
202
|
+
# user-imported document fields marked as completable.
|
|
203
|
+
#
|
|
204
|
+
# Default values:
|
|
205
|
+
#
|
|
206
|
+
# * `document` is the default model for regular dataStores.
|
|
207
|
+
# * `search-history` is the default model for
|
|
208
|
+
# [IndustryVertical.SITE_SEARCH][] dataStores.
|
|
209
|
+
# @param user_pseudo_id [::String]
|
|
210
|
+
# A unique identifier for tracking visitors. For example, this could be
|
|
211
|
+
# implemented with an HTTP cookie, which should be able to uniquely identify
|
|
212
|
+
# a visitor on a single device. This unique identifier should not change if
|
|
213
|
+
# the visitor logs in or out of the website.
|
|
214
|
+
#
|
|
215
|
+
# This field should NOT have a fixed value such as `unknown_visitor`.
|
|
216
|
+
#
|
|
217
|
+
# This should be the same identifier as
|
|
218
|
+
# {::Google::Cloud::DiscoveryEngine::V1::UserEvent#user_pseudo_id UserEvent.user_pseudo_id}
|
|
219
|
+
# and
|
|
220
|
+
# {::Google::Cloud::DiscoveryEngine::V1::SearchRequest#user_pseudo_id SearchRequest.user_pseudo_id}.
|
|
221
|
+
#
|
|
222
|
+
# The field must be a UTF-8 encoded string with a length limit of 128
|
|
223
|
+
# characters. Otherwise, an `INVALID_ARGUMENT` error is returned.
|
|
224
|
+
# @param include_tail_suggestions [::Boolean]
|
|
225
|
+
# Indicates if tail suggestions should be returned if there are no
|
|
226
|
+
# suggestions that match the full query. Even if set to true, if there are
|
|
227
|
+
# suggestions that match the full query, those are returned and no
|
|
228
|
+
# tail suggestions are returned.
|
|
229
|
+
#
|
|
230
|
+
# @yield [response, operation] Access the result along with the RPC operation
|
|
231
|
+
# @yieldparam response [::Google::Cloud::DiscoveryEngine::V1::CompleteQueryResponse]
|
|
232
|
+
# @yieldparam operation [::GRPC::ActiveCall::Operation]
|
|
233
|
+
#
|
|
234
|
+
# @return [::Google::Cloud::DiscoveryEngine::V1::CompleteQueryResponse]
|
|
235
|
+
#
|
|
236
|
+
# @raise [::Google::Cloud::Error] if the RPC is aborted.
|
|
237
|
+
#
|
|
238
|
+
# @example Basic example
|
|
239
|
+
# require "google/cloud/discovery_engine/v1"
|
|
240
|
+
#
|
|
241
|
+
# # Create a client object. The client can be reused for multiple calls.
|
|
242
|
+
# client = Google::Cloud::DiscoveryEngine::V1::CompletionService::Client.new
|
|
243
|
+
#
|
|
244
|
+
# # Create a request. To set request fields, pass in keyword arguments.
|
|
245
|
+
# request = Google::Cloud::DiscoveryEngine::V1::CompleteQueryRequest.new
|
|
246
|
+
#
|
|
247
|
+
# # Call the complete_query method.
|
|
248
|
+
# result = client.complete_query request
|
|
249
|
+
#
|
|
250
|
+
# # The returned object is of type Google::Cloud::DiscoveryEngine::V1::CompleteQueryResponse.
|
|
251
|
+
# p result
|
|
252
|
+
#
|
|
253
|
+
def complete_query request, options = nil
|
|
254
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
|
255
|
+
|
|
256
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::DiscoveryEngine::V1::CompleteQueryRequest
|
|
257
|
+
|
|
258
|
+
# Converts hash and nil to an options object
|
|
259
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
|
260
|
+
|
|
261
|
+
# Customize the options with defaults
|
|
262
|
+
metadata = @config.rpcs.complete_query.metadata.to_h
|
|
263
|
+
|
|
264
|
+
# Set x-goog-api-client and x-goog-user-project headers
|
|
265
|
+
metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
|
266
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
|
267
|
+
gapic_version: ::Google::Cloud::DiscoveryEngine::V1::VERSION
|
|
268
|
+
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
|
269
|
+
|
|
270
|
+
header_params = {}
|
|
271
|
+
if request.data_store
|
|
272
|
+
header_params["data_store"] = request.data_store
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
|
|
276
|
+
metadata[:"x-goog-request-params"] ||= request_params_header
|
|
277
|
+
|
|
278
|
+
options.apply_defaults timeout: @config.rpcs.complete_query.timeout,
|
|
279
|
+
metadata: metadata,
|
|
280
|
+
retry_policy: @config.rpcs.complete_query.retry_policy
|
|
281
|
+
|
|
282
|
+
options.apply_defaults timeout: @config.timeout,
|
|
283
|
+
metadata: @config.metadata,
|
|
284
|
+
retry_policy: @config.retry_policy
|
|
285
|
+
|
|
286
|
+
@completion_service_stub.call_rpc :complete_query, request, options: options do |response, operation|
|
|
287
|
+
yield response, operation if block_given?
|
|
288
|
+
return response
|
|
289
|
+
end
|
|
290
|
+
rescue ::GRPC::BadStatus => e
|
|
291
|
+
raise ::Google::Cloud::Error.from_error(e)
|
|
292
|
+
end
|
|
293
|
+
|
|
294
|
+
##
|
|
295
|
+
# Configuration class for the CompletionService API.
|
|
296
|
+
#
|
|
297
|
+
# This class represents the configuration for CompletionService,
|
|
298
|
+
# providing control over timeouts, retry behavior, logging, transport
|
|
299
|
+
# parameters, and other low-level controls. Certain parameters can also be
|
|
300
|
+
# applied individually to specific RPCs. See
|
|
301
|
+
# {::Google::Cloud::DiscoveryEngine::V1::CompletionService::Client::Configuration::Rpcs}
|
|
302
|
+
# for a list of RPCs that can be configured independently.
|
|
303
|
+
#
|
|
304
|
+
# Configuration can be applied globally to all clients, or to a single client
|
|
305
|
+
# on construction.
|
|
306
|
+
#
|
|
307
|
+
# @example
|
|
308
|
+
#
|
|
309
|
+
# # Modify the global config, setting the timeout for
|
|
310
|
+
# # complete_query to 20 seconds,
|
|
311
|
+
# # and all remaining timeouts to 10 seconds.
|
|
312
|
+
# ::Google::Cloud::DiscoveryEngine::V1::CompletionService::Client.configure do |config|
|
|
313
|
+
# config.timeout = 10.0
|
|
314
|
+
# config.rpcs.complete_query.timeout = 20.0
|
|
315
|
+
# end
|
|
316
|
+
#
|
|
317
|
+
# # Apply the above configuration only to a new client.
|
|
318
|
+
# client = ::Google::Cloud::DiscoveryEngine::V1::CompletionService::Client.new do |config|
|
|
319
|
+
# config.timeout = 10.0
|
|
320
|
+
# config.rpcs.complete_query.timeout = 20.0
|
|
321
|
+
# end
|
|
322
|
+
#
|
|
323
|
+
# @!attribute [rw] endpoint
|
|
324
|
+
# The hostname or hostname:port of the service endpoint.
|
|
325
|
+
# Defaults to `"discoveryengine.googleapis.com"`.
|
|
326
|
+
# @return [::String]
|
|
327
|
+
# @!attribute [rw] credentials
|
|
328
|
+
# Credentials to send with calls. You may provide any of the following types:
|
|
329
|
+
# * (`String`) The path to a service account key file in JSON format
|
|
330
|
+
# * (`Hash`) A service account key as a Hash
|
|
331
|
+
# * (`Google::Auth::Credentials`) A googleauth credentials object
|
|
332
|
+
# (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
|
|
333
|
+
# * (`Signet::OAuth2::Client`) A signet oauth2 client object
|
|
334
|
+
# (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
|
|
335
|
+
# * (`GRPC::Core::Channel`) a gRPC channel with included credentials
|
|
336
|
+
# * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
|
|
337
|
+
# * (`nil`) indicating no credentials
|
|
338
|
+
# @return [::Object]
|
|
339
|
+
# @!attribute [rw] scope
|
|
340
|
+
# The OAuth scopes
|
|
341
|
+
# @return [::Array<::String>]
|
|
342
|
+
# @!attribute [rw] lib_name
|
|
343
|
+
# The library name as recorded in instrumentation and logging
|
|
344
|
+
# @return [::String]
|
|
345
|
+
# @!attribute [rw] lib_version
|
|
346
|
+
# The library version as recorded in instrumentation and logging
|
|
347
|
+
# @return [::String]
|
|
348
|
+
# @!attribute [rw] channel_args
|
|
349
|
+
# Extra parameters passed to the gRPC channel. Note: this is ignored if a
|
|
350
|
+
# `GRPC::Core::Channel` object is provided as the credential.
|
|
351
|
+
# @return [::Hash]
|
|
352
|
+
# @!attribute [rw] interceptors
|
|
353
|
+
# An array of interceptors that are run before calls are executed.
|
|
354
|
+
# @return [::Array<::GRPC::ClientInterceptor>]
|
|
355
|
+
# @!attribute [rw] timeout
|
|
356
|
+
# The call timeout in seconds.
|
|
357
|
+
# @return [::Numeric]
|
|
358
|
+
# @!attribute [rw] metadata
|
|
359
|
+
# Additional gRPC headers to be sent with the call.
|
|
360
|
+
# @return [::Hash{::Symbol=>::String}]
|
|
361
|
+
# @!attribute [rw] retry_policy
|
|
362
|
+
# The retry policy. The value is a hash with the following keys:
|
|
363
|
+
# * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
|
|
364
|
+
# * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
|
|
365
|
+
# * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
|
|
366
|
+
# * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
|
|
367
|
+
# trigger a retry.
|
|
368
|
+
# @return [::Hash]
|
|
369
|
+
# @!attribute [rw] quota_project
|
|
370
|
+
# A separate project against which to charge quota.
|
|
371
|
+
# @return [::String]
|
|
372
|
+
#
|
|
373
|
+
class Configuration
|
|
374
|
+
extend ::Gapic::Config
|
|
375
|
+
|
|
376
|
+
DEFAULT_ENDPOINT = "discoveryengine.googleapis.com"
|
|
377
|
+
|
|
378
|
+
config_attr :endpoint, DEFAULT_ENDPOINT, ::String
|
|
379
|
+
config_attr :credentials, nil do |value|
|
|
380
|
+
allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
|
|
381
|
+
allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
|
|
382
|
+
allowed.any? { |klass| klass === value }
|
|
383
|
+
end
|
|
384
|
+
config_attr :scope, nil, ::String, ::Array, nil
|
|
385
|
+
config_attr :lib_name, nil, ::String, nil
|
|
386
|
+
config_attr :lib_version, nil, ::String, nil
|
|
387
|
+
config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
|
|
388
|
+
config_attr :interceptors, nil, ::Array, nil
|
|
389
|
+
config_attr :timeout, nil, ::Numeric, nil
|
|
390
|
+
config_attr :metadata, nil, ::Hash, nil
|
|
391
|
+
config_attr :retry_policy, nil, ::Hash, ::Proc, nil
|
|
392
|
+
config_attr :quota_project, nil, ::String, nil
|
|
393
|
+
|
|
394
|
+
# @private
|
|
395
|
+
def initialize parent_config = nil
|
|
396
|
+
@parent_config = parent_config unless parent_config.nil?
|
|
397
|
+
|
|
398
|
+
yield self if block_given?
|
|
399
|
+
end
|
|
400
|
+
|
|
401
|
+
##
|
|
402
|
+
# Configurations for individual RPCs
|
|
403
|
+
# @return [Rpcs]
|
|
404
|
+
#
|
|
405
|
+
def rpcs
|
|
406
|
+
@rpcs ||= begin
|
|
407
|
+
parent_rpcs = nil
|
|
408
|
+
parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
|
|
409
|
+
Rpcs.new parent_rpcs
|
|
410
|
+
end
|
|
411
|
+
end
|
|
412
|
+
|
|
413
|
+
##
|
|
414
|
+
# Configuration RPC class for the CompletionService API.
|
|
415
|
+
#
|
|
416
|
+
# Includes fields providing the configuration for each RPC in this service.
|
|
417
|
+
# Each configuration object is of type `Gapic::Config::Method` and includes
|
|
418
|
+
# the following configuration fields:
|
|
419
|
+
#
|
|
420
|
+
# * `timeout` (*type:* `Numeric`) - The call timeout in seconds
|
|
421
|
+
# * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
|
|
422
|
+
# * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
|
|
423
|
+
# include the following keys:
|
|
424
|
+
# * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
|
|
425
|
+
# * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
|
|
426
|
+
# * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
|
|
427
|
+
# * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
|
|
428
|
+
# trigger a retry.
|
|
429
|
+
#
|
|
430
|
+
class Rpcs
|
|
431
|
+
##
|
|
432
|
+
# RPC-specific configuration for `complete_query`
|
|
433
|
+
# @return [::Gapic::Config::Method]
|
|
434
|
+
#
|
|
435
|
+
attr_reader :complete_query
|
|
436
|
+
|
|
437
|
+
# @private
|
|
438
|
+
def initialize parent_rpcs = nil
|
|
439
|
+
complete_query_config = parent_rpcs.complete_query if parent_rpcs.respond_to? :complete_query
|
|
440
|
+
@complete_query = ::Gapic::Config::Method.new complete_query_config
|
|
441
|
+
|
|
442
|
+
yield self if block_given?
|
|
443
|
+
end
|
|
444
|
+
end
|
|
445
|
+
end
|
|
446
|
+
end
|
|
447
|
+
end
|
|
448
|
+
end
|
|
449
|
+
end
|
|
450
|
+
end
|
|
451
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Copyright 2023 Google LLC
|
|
4
|
+
#
|
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
# you may not use this file except in compliance with the License.
|
|
7
|
+
# You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
|
|
17
|
+
# Auto-generated by gapic-generator-ruby. DO NOT EDIT!
|
|
18
|
+
|
|
19
|
+
require "googleauth"
|
|
20
|
+
|
|
21
|
+
module Google
|
|
22
|
+
module Cloud
|
|
23
|
+
module DiscoveryEngine
|
|
24
|
+
module V1
|
|
25
|
+
module CompletionService
|
|
26
|
+
# Credentials for the CompletionService API.
|
|
27
|
+
class Credentials < ::Google::Auth::Credentials
|
|
28
|
+
self.scope = [
|
|
29
|
+
"https://www.googleapis.com/auth/cloud-platform"
|
|
30
|
+
]
|
|
31
|
+
self.env_vars = [
|
|
32
|
+
"GOOGLE_CLOUD_CREDENTIALS",
|
|
33
|
+
"GOOGLE_CLOUD_KEYFILE",
|
|
34
|
+
"GCLOUD_KEYFILE",
|
|
35
|
+
"GOOGLE_CLOUD_CREDENTIALS_JSON",
|
|
36
|
+
"GOOGLE_CLOUD_KEYFILE_JSON",
|
|
37
|
+
"GCLOUD_KEYFILE_JSON"
|
|
38
|
+
]
|
|
39
|
+
self.paths = [
|
|
40
|
+
"~/.config/google_cloud/application_default_credentials.json"
|
|
41
|
+
]
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Copyright 2023 Google LLC
|
|
4
|
+
#
|
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
# you may not use this file except in compliance with the License.
|
|
7
|
+
# You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
|
|
17
|
+
# Auto-generated by gapic-generator-ruby. DO NOT EDIT!
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
module Google
|
|
21
|
+
module Cloud
|
|
22
|
+
module DiscoveryEngine
|
|
23
|
+
module V1
|
|
24
|
+
module CompletionService
|
|
25
|
+
# Path helper methods for the CompletionService API.
|
|
26
|
+
module Paths
|
|
27
|
+
##
|
|
28
|
+
# Create a fully-qualified DataStore resource string.
|
|
29
|
+
#
|
|
30
|
+
# @overload data_store_path(project:, location:, data_store:)
|
|
31
|
+
# The resource will be in the following format:
|
|
32
|
+
#
|
|
33
|
+
# `projects/{project}/locations/{location}/dataStores/{data_store}`
|
|
34
|
+
#
|
|
35
|
+
# @param project [String]
|
|
36
|
+
# @param location [String]
|
|
37
|
+
# @param data_store [String]
|
|
38
|
+
#
|
|
39
|
+
# @overload data_store_path(project:, location:, collection:, data_store:)
|
|
40
|
+
# The resource will be in the following format:
|
|
41
|
+
#
|
|
42
|
+
# `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`
|
|
43
|
+
#
|
|
44
|
+
# @param project [String]
|
|
45
|
+
# @param location [String]
|
|
46
|
+
# @param collection [String]
|
|
47
|
+
# @param data_store [String]
|
|
48
|
+
#
|
|
49
|
+
# @return [::String]
|
|
50
|
+
def data_store_path **args
|
|
51
|
+
resources = {
|
|
52
|
+
"data_store:location:project" => (proc do |project:, location:, data_store:|
|
|
53
|
+
raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
|
|
54
|
+
raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
|
|
55
|
+
|
|
56
|
+
"projects/#{project}/locations/#{location}/dataStores/#{data_store}"
|
|
57
|
+
end),
|
|
58
|
+
"collection:data_store:location:project" => (proc do |project:, location:, collection:, data_store:|
|
|
59
|
+
raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
|
|
60
|
+
raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
|
|
61
|
+
raise ::ArgumentError, "collection cannot contain /" if collection.to_s.include? "/"
|
|
62
|
+
|
|
63
|
+
"projects/#{project}/locations/#{location}/collections/#{collection}/dataStores/#{data_store}"
|
|
64
|
+
end)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
resource = resources[args.keys.sort.join(":")]
|
|
68
|
+
raise ::ArgumentError, "no resource found for values #{args.keys}" if resource.nil?
|
|
69
|
+
resource.call(**args)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
extend self
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|