google-developers-developer_knowledge-v1 0.a → 0.1.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 +122 -0
- data/README.md +153 -8
- data/lib/google/developers/developer_knowledge/v1/developer_knowledge/client.rb +758 -0
- data/lib/google/developers/developer_knowledge/v1/developer_knowledge/credentials.rb +47 -0
- data/lib/google/developers/developer_knowledge/v1/developer_knowledge/paths.rb +47 -0
- data/lib/google/developers/developer_knowledge/v1/developer_knowledge/rest/client.rb +710 -0
- data/lib/google/developers/developer_knowledge/v1/developer_knowledge/rest/service_stub.rb +260 -0
- data/lib/google/developers/developer_knowledge/v1/developer_knowledge/rest.rb +67 -0
- data/lib/google/developers/developer_knowledge/v1/developer_knowledge.rb +70 -0
- data/lib/google/developers/developer_knowledge/v1/rest.rb +37 -0
- data/lib/google/developers/developer_knowledge/v1/version.rb +7 -2
- data/lib/google/developers/developer_knowledge/v1.rb +45 -0
- data/lib/google/developers/knowledge/v1/developerknowledge_pb.rb +34 -0
- data/lib/google/developers/knowledge/v1/developerknowledge_services_pb.rb +75 -0
- data/lib/google-developers-developer_knowledge-v1.rb +21 -0
- data/proto_docs/README.md +4 -0
- data/proto_docs/google/api/client.rb +593 -0
- data/proto_docs/google/api/field_behavior.rb +85 -0
- data/proto_docs/google/api/launch_stage.rb +71 -0
- data/proto_docs/google/api/resource.rb +227 -0
- data/proto_docs/google/developers/knowledge/v1/developerknowledge.rb +277 -0
- data/proto_docs/google/protobuf/duration.rb +98 -0
- data/proto_docs/google/protobuf/timestamp.rb +127 -0
- metadata +58 -9
|
@@ -0,0 +1,710 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Copyright 2026 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/developers/knowledge/v1/developerknowledge_pb"
|
|
21
|
+
require "google/developers/developer_knowledge/v1/developer_knowledge/rest/service_stub"
|
|
22
|
+
|
|
23
|
+
module Google
|
|
24
|
+
module Developers
|
|
25
|
+
module DeveloperKnowledge
|
|
26
|
+
module V1
|
|
27
|
+
module DeveloperKnowledge
|
|
28
|
+
module Rest
|
|
29
|
+
##
|
|
30
|
+
# REST client for the DeveloperKnowledge service.
|
|
31
|
+
#
|
|
32
|
+
# The Developer Knowledge API provides programmatic access to Google's public
|
|
33
|
+
# developer documentation, enabling you to integrate this knowledge base into
|
|
34
|
+
# your own applications and workflows.
|
|
35
|
+
#
|
|
36
|
+
# The API is designed to be the canonical source for machine-readable access to
|
|
37
|
+
# Google's developer documentation.
|
|
38
|
+
#
|
|
39
|
+
# A typical use case is to first use
|
|
40
|
+
# {::Google::Developers::DeveloperKnowledge::V1::DeveloperKnowledge::Rest::Client#search_document_chunks DeveloperKnowledge.SearchDocumentChunks}
|
|
41
|
+
# to find relevant page URIs based on a query, and then use
|
|
42
|
+
# {::Google::Developers::DeveloperKnowledge::V1::DeveloperKnowledge::Rest::Client#get_document DeveloperKnowledge.GetDocument}
|
|
43
|
+
# or
|
|
44
|
+
# {::Google::Developers::DeveloperKnowledge::V1::DeveloperKnowledge::Rest::Client#batch_get_documents DeveloperKnowledge.BatchGetDocuments}
|
|
45
|
+
# to fetch the full content of the top results.
|
|
46
|
+
#
|
|
47
|
+
# All document content is provided in Markdown format.
|
|
48
|
+
#
|
|
49
|
+
class Client
|
|
50
|
+
# @private
|
|
51
|
+
API_VERSION = ""
|
|
52
|
+
|
|
53
|
+
# @private
|
|
54
|
+
DEFAULT_ENDPOINT_TEMPLATE = "developerknowledge.$UNIVERSE_DOMAIN$"
|
|
55
|
+
|
|
56
|
+
include Paths
|
|
57
|
+
|
|
58
|
+
# @private
|
|
59
|
+
attr_reader :developer_knowledge_stub
|
|
60
|
+
|
|
61
|
+
##
|
|
62
|
+
# Configure the DeveloperKnowledge Client class.
|
|
63
|
+
#
|
|
64
|
+
# See {::Google::Developers::DeveloperKnowledge::V1::DeveloperKnowledge::Rest::Client::Configuration}
|
|
65
|
+
# for a description of the configuration fields.
|
|
66
|
+
#
|
|
67
|
+
# @example
|
|
68
|
+
#
|
|
69
|
+
# # Modify the configuration for all DeveloperKnowledge clients
|
|
70
|
+
# ::Google::Developers::DeveloperKnowledge::V1::DeveloperKnowledge::Rest::Client.configure do |config|
|
|
71
|
+
# config.timeout = 10.0
|
|
72
|
+
# end
|
|
73
|
+
#
|
|
74
|
+
# @yield [config] Configure the Client client.
|
|
75
|
+
# @yieldparam config [Client::Configuration]
|
|
76
|
+
#
|
|
77
|
+
# @return [Client::Configuration]
|
|
78
|
+
#
|
|
79
|
+
def self.configure
|
|
80
|
+
@configure ||= begin
|
|
81
|
+
namespace = ["Google", "Developers", "DeveloperKnowledge", "V1"]
|
|
82
|
+
parent_config = while namespace.any?
|
|
83
|
+
parent_name = namespace.join "::"
|
|
84
|
+
parent_const = const_get parent_name
|
|
85
|
+
break parent_const.configure if parent_const.respond_to? :configure
|
|
86
|
+
namespace.pop
|
|
87
|
+
end
|
|
88
|
+
default_config = Client::Configuration.new parent_config
|
|
89
|
+
|
|
90
|
+
default_config.rpcs.get_document.timeout = 60.0
|
|
91
|
+
default_config.rpcs.get_document.retry_policy = {
|
|
92
|
+
initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
default_config.rpcs.batch_get_documents.timeout = 60.0
|
|
96
|
+
default_config.rpcs.batch_get_documents.retry_policy = {
|
|
97
|
+
initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
default_config
|
|
101
|
+
end
|
|
102
|
+
yield @configure if block_given?
|
|
103
|
+
@configure
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
##
|
|
107
|
+
# Configure the DeveloperKnowledge Client instance.
|
|
108
|
+
#
|
|
109
|
+
# The configuration is set to the derived mode, meaning that values can be changed,
|
|
110
|
+
# but structural changes (adding new fields, etc.) are not allowed. Structural changes
|
|
111
|
+
# should be made on {Client.configure}.
|
|
112
|
+
#
|
|
113
|
+
# See {::Google::Developers::DeveloperKnowledge::V1::DeveloperKnowledge::Rest::Client::Configuration}
|
|
114
|
+
# for a description of the configuration fields.
|
|
115
|
+
#
|
|
116
|
+
# @yield [config] Configure the Client client.
|
|
117
|
+
# @yieldparam config [Client::Configuration]
|
|
118
|
+
#
|
|
119
|
+
# @return [Client::Configuration]
|
|
120
|
+
#
|
|
121
|
+
def configure
|
|
122
|
+
yield @config if block_given?
|
|
123
|
+
@config
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
##
|
|
127
|
+
# The effective universe domain
|
|
128
|
+
#
|
|
129
|
+
# @return [String]
|
|
130
|
+
#
|
|
131
|
+
def universe_domain
|
|
132
|
+
@developer_knowledge_stub.universe_domain
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
##
|
|
136
|
+
# Create a new DeveloperKnowledge REST client object.
|
|
137
|
+
#
|
|
138
|
+
# @example
|
|
139
|
+
#
|
|
140
|
+
# # Create a client using the default configuration
|
|
141
|
+
# client = ::Google::Developers::DeveloperKnowledge::V1::DeveloperKnowledge::Rest::Client.new
|
|
142
|
+
#
|
|
143
|
+
# # Create a client using a custom configuration
|
|
144
|
+
# client = ::Google::Developers::DeveloperKnowledge::V1::DeveloperKnowledge::Rest::Client.new do |config|
|
|
145
|
+
# config.timeout = 10.0
|
|
146
|
+
# end
|
|
147
|
+
#
|
|
148
|
+
# @yield [config] Configure the DeveloperKnowledge client.
|
|
149
|
+
# @yieldparam config [Client::Configuration]
|
|
150
|
+
#
|
|
151
|
+
def initialize
|
|
152
|
+
# Create the configuration object
|
|
153
|
+
@config = Configuration.new Client.configure
|
|
154
|
+
|
|
155
|
+
# Yield the configuration if needed
|
|
156
|
+
yield @config if block_given?
|
|
157
|
+
|
|
158
|
+
# Create credentials
|
|
159
|
+
credentials = @config.credentials
|
|
160
|
+
# Use self-signed JWT if the endpoint is unchanged from default,
|
|
161
|
+
# but only if the default endpoint does not have a region prefix.
|
|
162
|
+
enable_self_signed_jwt = @config.endpoint.nil? ||
|
|
163
|
+
(@config.endpoint == Configuration::DEFAULT_ENDPOINT &&
|
|
164
|
+
!@config.endpoint.split(".").first.include?("-"))
|
|
165
|
+
credentials ||= Credentials.default scope: @config.scope,
|
|
166
|
+
enable_self_signed_jwt: enable_self_signed_jwt
|
|
167
|
+
if credentials.is_a?(::String) || credentials.is_a?(::Hash)
|
|
168
|
+
credentials = Credentials.new credentials, scope: @config.scope
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
@quota_project_id = @config.quota_project
|
|
172
|
+
@quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
|
|
173
|
+
|
|
174
|
+
@developer_knowledge_stub = ::Google::Developers::DeveloperKnowledge::V1::DeveloperKnowledge::Rest::ServiceStub.new(
|
|
175
|
+
endpoint: @config.endpoint,
|
|
176
|
+
endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
|
|
177
|
+
universe_domain: @config.universe_domain,
|
|
178
|
+
credentials: credentials,
|
|
179
|
+
logger: @config.logger
|
|
180
|
+
)
|
|
181
|
+
|
|
182
|
+
@developer_knowledge_stub.logger(stub: true)&.info do |entry|
|
|
183
|
+
entry.set_system_name
|
|
184
|
+
entry.set_service
|
|
185
|
+
entry.message = "Created client for #{entry.service}"
|
|
186
|
+
entry.set_credentials_fields credentials
|
|
187
|
+
entry.set "customEndpoint", @config.endpoint if @config.endpoint
|
|
188
|
+
entry.set "defaultTimeout", @config.timeout if @config.timeout
|
|
189
|
+
entry.set "quotaProject", @quota_project_id if @quota_project_id
|
|
190
|
+
end
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
##
|
|
194
|
+
# The logger used for request/response debug logging.
|
|
195
|
+
#
|
|
196
|
+
# @return [Logger]
|
|
197
|
+
#
|
|
198
|
+
def logger
|
|
199
|
+
@developer_knowledge_stub.logger
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
# Service calls
|
|
203
|
+
|
|
204
|
+
##
|
|
205
|
+
# Searches for developer knowledge across Google's developer documentation.
|
|
206
|
+
# Returns {::Google::Developers::DeveloperKnowledge::V1::DocumentChunk DocumentChunk}s
|
|
207
|
+
# based on the user's query. There may be many chunks from the same
|
|
208
|
+
# {::Google::Developers::DeveloperKnowledge::V1::Document Document}. To retrieve full
|
|
209
|
+
# documents, use
|
|
210
|
+
# {::Google::Developers::DeveloperKnowledge::V1::DeveloperKnowledge::Rest::Client#get_document DeveloperKnowledge.GetDocument}
|
|
211
|
+
# or
|
|
212
|
+
# {::Google::Developers::DeveloperKnowledge::V1::DeveloperKnowledge::Rest::Client#batch_get_documents DeveloperKnowledge.BatchGetDocuments}
|
|
213
|
+
# with the
|
|
214
|
+
# {::Google::Developers::DeveloperKnowledge::V1::DocumentChunk#parent DocumentChunk.parent}
|
|
215
|
+
# returned in the
|
|
216
|
+
# {::Google::Developers::DeveloperKnowledge::V1::SearchDocumentChunksResponse#results SearchDocumentChunksResponse.results}.
|
|
217
|
+
#
|
|
218
|
+
# @overload search_document_chunks(request, options = nil)
|
|
219
|
+
# Pass arguments to `search_document_chunks` via a request object, either of type
|
|
220
|
+
# {::Google::Developers::DeveloperKnowledge::V1::SearchDocumentChunksRequest} or an equivalent Hash.
|
|
221
|
+
#
|
|
222
|
+
# @param request [::Google::Developers::DeveloperKnowledge::V1::SearchDocumentChunksRequest, ::Hash]
|
|
223
|
+
# A request object representing the call parameters. Required. To specify no
|
|
224
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
|
225
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
|
226
|
+
# Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
|
|
227
|
+
#
|
|
228
|
+
# @overload search_document_chunks(query: nil, page_size: nil, page_token: nil, filter: nil)
|
|
229
|
+
# Pass arguments to `search_document_chunks` via keyword arguments. Note that at
|
|
230
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
|
231
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
|
232
|
+
#
|
|
233
|
+
# @param query [::String]
|
|
234
|
+
# Required. Provides the raw query string provided by the user, such as "How
|
|
235
|
+
# to create a Cloud Storage bucket?".
|
|
236
|
+
# @param page_size [::Integer]
|
|
237
|
+
# Optional. Specifies the maximum number of results to return. The service
|
|
238
|
+
# may return fewer than this value.
|
|
239
|
+
#
|
|
240
|
+
# If unspecified, at most 5 results will be returned.
|
|
241
|
+
#
|
|
242
|
+
# The maximum value is 20; values above 20 will result in an INVALID_ARGUMENT
|
|
243
|
+
# error.
|
|
244
|
+
# @param page_token [::String]
|
|
245
|
+
# Optional. Contains a page token, received from a previous
|
|
246
|
+
# `SearchDocumentChunks` call. Provide this to retrieve the subsequent page.
|
|
247
|
+
# @param filter [::String]
|
|
248
|
+
# Optional. Applies a strict filter to the search results. The expression
|
|
249
|
+
# supports a subset of the syntax described at https://google.aip.dev/160.
|
|
250
|
+
#
|
|
251
|
+
# While `SearchDocumentChunks` returns
|
|
252
|
+
# {::Google::Developers::DeveloperKnowledge::V1::DocumentChunk DocumentChunk}s, the filter
|
|
253
|
+
# is applied to `DocumentChunk.document` fields.
|
|
254
|
+
#
|
|
255
|
+
# Supported fields for filtering:
|
|
256
|
+
#
|
|
257
|
+
# * `data_source` (STRING): The source of the document, e.g.
|
|
258
|
+
# `docs.cloud.google.com`. See
|
|
259
|
+
# https://developers.google.com/knowledge/reference/corpus-reference for
|
|
260
|
+
# the complete list of data sources in the corpus.
|
|
261
|
+
# * `update_time` (TIMESTAMP): The timestamp of when the document was last
|
|
262
|
+
# meaningfully updated. A meaningful update is one that changes document's
|
|
263
|
+
# markdown content or metadata.
|
|
264
|
+
# * `uri` (STRING): The document URI, e.g.
|
|
265
|
+
# `https://docs.cloud.google.com/bigquery/docs/tables`.
|
|
266
|
+
#
|
|
267
|
+
# STRING fields support `=` (equals) and `!=` (not equals) operators for
|
|
268
|
+
# **exact match** on the whole string. Partial match, prefix match, and
|
|
269
|
+
# regexp match are not supported.
|
|
270
|
+
#
|
|
271
|
+
# TIMESTAMP fields support `=`, `<`, `<=`, `>`, and `>=` operators.
|
|
272
|
+
# Timestamps must be in RFC-3339 format, e.g., `"2025-01-01T00:00:00Z"`.
|
|
273
|
+
#
|
|
274
|
+
# You can combine expressions using `AND`, `OR`, and `NOT` (or `-`) logical
|
|
275
|
+
# operators. `OR` has higher precedence than `AND`. Use parentheses for
|
|
276
|
+
# explicit precedence grouping.
|
|
277
|
+
#
|
|
278
|
+
# Examples:
|
|
279
|
+
#
|
|
280
|
+
# * `data_source = "docs.cloud.google.com" OR data_source =
|
|
281
|
+
# "firebase.google.com"`
|
|
282
|
+
# * `data_source != "firebase.google.com"`
|
|
283
|
+
# * `update_time < "2024-01-01T00:00:00Z"`
|
|
284
|
+
# * `update_time >= "2025-01-22T00:00:00Z" AND (data_source =
|
|
285
|
+
# "developer.chrome.com" OR data_source = "web.dev")`
|
|
286
|
+
# * `uri = "https://docs.cloud.google.com/release-notes"`
|
|
287
|
+
#
|
|
288
|
+
# The `filter` string must not exceed 500 characters; values longer than 500
|
|
289
|
+
# characters will result in an `INVALID_ARGUMENT` error.
|
|
290
|
+
# @yield [result, operation] Access the result along with the TransportOperation object
|
|
291
|
+
# @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Developers::DeveloperKnowledge::V1::DocumentChunk>]
|
|
292
|
+
# @yieldparam operation [::Gapic::Rest::TransportOperation]
|
|
293
|
+
#
|
|
294
|
+
# @return [::Gapic::Rest::PagedEnumerable<::Google::Developers::DeveloperKnowledge::V1::DocumentChunk>]
|
|
295
|
+
#
|
|
296
|
+
# @raise [::Google::Cloud::Error] if the REST call is aborted.
|
|
297
|
+
#
|
|
298
|
+
# @example Basic example
|
|
299
|
+
# require "google/developers/developer_knowledge/v1"
|
|
300
|
+
#
|
|
301
|
+
# # Create a client object. The client can be reused for multiple calls.
|
|
302
|
+
# client = Google::Developers::DeveloperKnowledge::V1::DeveloperKnowledge::Rest::Client.new
|
|
303
|
+
#
|
|
304
|
+
# # Create a request. To set request fields, pass in keyword arguments.
|
|
305
|
+
# request = Google::Developers::DeveloperKnowledge::V1::SearchDocumentChunksRequest.new
|
|
306
|
+
#
|
|
307
|
+
# # Call the search_document_chunks method.
|
|
308
|
+
# result = client.search_document_chunks request
|
|
309
|
+
#
|
|
310
|
+
# # The returned object is of type Gapic::PagedEnumerable. You can iterate
|
|
311
|
+
# # over elements, and API calls will be issued to fetch pages as needed.
|
|
312
|
+
# result.each do |item|
|
|
313
|
+
# # Each element is of type ::Google::Developers::DeveloperKnowledge::V1::DocumentChunk.
|
|
314
|
+
# p item
|
|
315
|
+
# end
|
|
316
|
+
#
|
|
317
|
+
def search_document_chunks request, options = nil
|
|
318
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
|
319
|
+
|
|
320
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Developers::DeveloperKnowledge::V1::SearchDocumentChunksRequest
|
|
321
|
+
|
|
322
|
+
# Converts hash and nil to an options object
|
|
323
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
|
324
|
+
|
|
325
|
+
# Customize the options with defaults
|
|
326
|
+
call_metadata = @config.rpcs.search_document_chunks.metadata.to_h
|
|
327
|
+
|
|
328
|
+
# Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
|
|
329
|
+
call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
|
330
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
|
331
|
+
gapic_version: ::Google::Developers::DeveloperKnowledge::V1::VERSION,
|
|
332
|
+
transports_version_send: [:rest]
|
|
333
|
+
|
|
334
|
+
call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
|
|
335
|
+
call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
|
336
|
+
|
|
337
|
+
options.apply_defaults timeout: @config.rpcs.search_document_chunks.timeout,
|
|
338
|
+
metadata: call_metadata,
|
|
339
|
+
retry_policy: @config.rpcs.search_document_chunks.retry_policy
|
|
340
|
+
|
|
341
|
+
options.apply_defaults timeout: @config.timeout,
|
|
342
|
+
metadata: @config.metadata,
|
|
343
|
+
retry_policy: @config.retry_policy
|
|
344
|
+
|
|
345
|
+
@developer_knowledge_stub.search_document_chunks request, options do |result, operation|
|
|
346
|
+
result = ::Gapic::Rest::PagedEnumerable.new @developer_knowledge_stub, :search_document_chunks, "results", request, result, options
|
|
347
|
+
yield result, operation if block_given?
|
|
348
|
+
throw :response, result
|
|
349
|
+
end
|
|
350
|
+
rescue ::Gapic::Rest::Error => e
|
|
351
|
+
raise ::Google::Cloud::Error.from_error(e)
|
|
352
|
+
end
|
|
353
|
+
|
|
354
|
+
##
|
|
355
|
+
# Retrieves a single document with its full Markdown content.
|
|
356
|
+
#
|
|
357
|
+
# @overload get_document(request, options = nil)
|
|
358
|
+
# Pass arguments to `get_document` via a request object, either of type
|
|
359
|
+
# {::Google::Developers::DeveloperKnowledge::V1::GetDocumentRequest} or an equivalent Hash.
|
|
360
|
+
#
|
|
361
|
+
# @param request [::Google::Developers::DeveloperKnowledge::V1::GetDocumentRequest, ::Hash]
|
|
362
|
+
# A request object representing the call parameters. Required. To specify no
|
|
363
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
|
364
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
|
365
|
+
# Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
|
|
366
|
+
#
|
|
367
|
+
# @overload get_document(name: nil, view: nil)
|
|
368
|
+
# Pass arguments to `get_document` via keyword arguments. Note that at
|
|
369
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
|
370
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
|
371
|
+
#
|
|
372
|
+
# @param name [::String]
|
|
373
|
+
# Required. Specifies the name of the document to retrieve.
|
|
374
|
+
# Format: `documents/{uri_without_scheme}`
|
|
375
|
+
# Example: `documents/docs.cloud.google.com/storage/docs/creating-buckets`
|
|
376
|
+
# @param view [::Google::Developers::DeveloperKnowledge::V1::DocumentView]
|
|
377
|
+
# Optional. Specifies the
|
|
378
|
+
# {::Google::Developers::DeveloperKnowledge::V1::DocumentView DocumentView} of the
|
|
379
|
+
# document. If unspecified,
|
|
380
|
+
# {::Google::Developers::DeveloperKnowledge::V1::DeveloperKnowledge::Rest::Client#get_document DeveloperKnowledge.GetDocument}
|
|
381
|
+
# defaults to `DOCUMENT_VIEW_CONTENT`.
|
|
382
|
+
# @yield [result, operation] Access the result along with the TransportOperation object
|
|
383
|
+
# @yieldparam result [::Google::Developers::DeveloperKnowledge::V1::Document]
|
|
384
|
+
# @yieldparam operation [::Gapic::Rest::TransportOperation]
|
|
385
|
+
#
|
|
386
|
+
# @return [::Google::Developers::DeveloperKnowledge::V1::Document]
|
|
387
|
+
#
|
|
388
|
+
# @raise [::Google::Cloud::Error] if the REST call is aborted.
|
|
389
|
+
#
|
|
390
|
+
# @example Basic example
|
|
391
|
+
# require "google/developers/developer_knowledge/v1"
|
|
392
|
+
#
|
|
393
|
+
# # Create a client object. The client can be reused for multiple calls.
|
|
394
|
+
# client = Google::Developers::DeveloperKnowledge::V1::DeveloperKnowledge::Rest::Client.new
|
|
395
|
+
#
|
|
396
|
+
# # Create a request. To set request fields, pass in keyword arguments.
|
|
397
|
+
# request = Google::Developers::DeveloperKnowledge::V1::GetDocumentRequest.new
|
|
398
|
+
#
|
|
399
|
+
# # Call the get_document method.
|
|
400
|
+
# result = client.get_document request
|
|
401
|
+
#
|
|
402
|
+
# # The returned object is of type Google::Developers::DeveloperKnowledge::V1::Document.
|
|
403
|
+
# p result
|
|
404
|
+
#
|
|
405
|
+
def get_document request, options = nil
|
|
406
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
|
407
|
+
|
|
408
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Developers::DeveloperKnowledge::V1::GetDocumentRequest
|
|
409
|
+
|
|
410
|
+
# Converts hash and nil to an options object
|
|
411
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
|
412
|
+
|
|
413
|
+
# Customize the options with defaults
|
|
414
|
+
call_metadata = @config.rpcs.get_document.metadata.to_h
|
|
415
|
+
|
|
416
|
+
# Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
|
|
417
|
+
call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
|
418
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
|
419
|
+
gapic_version: ::Google::Developers::DeveloperKnowledge::V1::VERSION,
|
|
420
|
+
transports_version_send: [:rest]
|
|
421
|
+
|
|
422
|
+
call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
|
|
423
|
+
call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
|
424
|
+
|
|
425
|
+
options.apply_defaults timeout: @config.rpcs.get_document.timeout,
|
|
426
|
+
metadata: call_metadata,
|
|
427
|
+
retry_policy: @config.rpcs.get_document.retry_policy
|
|
428
|
+
|
|
429
|
+
options.apply_defaults timeout: @config.timeout,
|
|
430
|
+
metadata: @config.metadata,
|
|
431
|
+
retry_policy: @config.retry_policy
|
|
432
|
+
|
|
433
|
+
@developer_knowledge_stub.get_document request, options do |result, operation|
|
|
434
|
+
yield result, operation if block_given?
|
|
435
|
+
end
|
|
436
|
+
rescue ::Gapic::Rest::Error => e
|
|
437
|
+
raise ::Google::Cloud::Error.from_error(e)
|
|
438
|
+
end
|
|
439
|
+
|
|
440
|
+
##
|
|
441
|
+
# Retrieves multiple documents, each with its full Markdown content.
|
|
442
|
+
#
|
|
443
|
+
# @overload batch_get_documents(request, options = nil)
|
|
444
|
+
# Pass arguments to `batch_get_documents` via a request object, either of type
|
|
445
|
+
# {::Google::Developers::DeveloperKnowledge::V1::BatchGetDocumentsRequest} or an equivalent Hash.
|
|
446
|
+
#
|
|
447
|
+
# @param request [::Google::Developers::DeveloperKnowledge::V1::BatchGetDocumentsRequest, ::Hash]
|
|
448
|
+
# A request object representing the call parameters. Required. To specify no
|
|
449
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
|
450
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
|
451
|
+
# Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
|
|
452
|
+
#
|
|
453
|
+
# @overload batch_get_documents(names: nil, view: nil)
|
|
454
|
+
# Pass arguments to `batch_get_documents` via keyword arguments. Note that at
|
|
455
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
|
456
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
|
457
|
+
#
|
|
458
|
+
# @param names [::Array<::String>]
|
|
459
|
+
# Required. Specifies the names of the documents to retrieve. A maximum of 20
|
|
460
|
+
# documents can be retrieved in a batch. The documents are returned in the
|
|
461
|
+
# same order as the `names` in the request.
|
|
462
|
+
#
|
|
463
|
+
# Format: `documents/{uri_without_scheme}`
|
|
464
|
+
# Example: `documents/docs.cloud.google.com/storage/docs/creating-buckets`
|
|
465
|
+
# @param view [::Google::Developers::DeveloperKnowledge::V1::DocumentView]
|
|
466
|
+
# Optional. Specifies the
|
|
467
|
+
# {::Google::Developers::DeveloperKnowledge::V1::DocumentView DocumentView} of the
|
|
468
|
+
# document. If unspecified,
|
|
469
|
+
# {::Google::Developers::DeveloperKnowledge::V1::DeveloperKnowledge::Rest::Client#batch_get_documents DeveloperKnowledge.BatchGetDocuments}
|
|
470
|
+
# defaults to `DOCUMENT_VIEW_CONTENT`.
|
|
471
|
+
# @yield [result, operation] Access the result along with the TransportOperation object
|
|
472
|
+
# @yieldparam result [::Google::Developers::DeveloperKnowledge::V1::BatchGetDocumentsResponse]
|
|
473
|
+
# @yieldparam operation [::Gapic::Rest::TransportOperation]
|
|
474
|
+
#
|
|
475
|
+
# @return [::Google::Developers::DeveloperKnowledge::V1::BatchGetDocumentsResponse]
|
|
476
|
+
#
|
|
477
|
+
# @raise [::Google::Cloud::Error] if the REST call is aborted.
|
|
478
|
+
#
|
|
479
|
+
# @example Basic example
|
|
480
|
+
# require "google/developers/developer_knowledge/v1"
|
|
481
|
+
#
|
|
482
|
+
# # Create a client object. The client can be reused for multiple calls.
|
|
483
|
+
# client = Google::Developers::DeveloperKnowledge::V1::DeveloperKnowledge::Rest::Client.new
|
|
484
|
+
#
|
|
485
|
+
# # Create a request. To set request fields, pass in keyword arguments.
|
|
486
|
+
# request = Google::Developers::DeveloperKnowledge::V1::BatchGetDocumentsRequest.new
|
|
487
|
+
#
|
|
488
|
+
# # Call the batch_get_documents method.
|
|
489
|
+
# result = client.batch_get_documents request
|
|
490
|
+
#
|
|
491
|
+
# # The returned object is of type Google::Developers::DeveloperKnowledge::V1::BatchGetDocumentsResponse.
|
|
492
|
+
# p result
|
|
493
|
+
#
|
|
494
|
+
def batch_get_documents request, options = nil
|
|
495
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
|
496
|
+
|
|
497
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Developers::DeveloperKnowledge::V1::BatchGetDocumentsRequest
|
|
498
|
+
|
|
499
|
+
# Converts hash and nil to an options object
|
|
500
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
|
501
|
+
|
|
502
|
+
# Customize the options with defaults
|
|
503
|
+
call_metadata = @config.rpcs.batch_get_documents.metadata.to_h
|
|
504
|
+
|
|
505
|
+
# Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
|
|
506
|
+
call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
|
507
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
|
508
|
+
gapic_version: ::Google::Developers::DeveloperKnowledge::V1::VERSION,
|
|
509
|
+
transports_version_send: [:rest]
|
|
510
|
+
|
|
511
|
+
call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
|
|
512
|
+
call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
|
513
|
+
|
|
514
|
+
options.apply_defaults timeout: @config.rpcs.batch_get_documents.timeout,
|
|
515
|
+
metadata: call_metadata,
|
|
516
|
+
retry_policy: @config.rpcs.batch_get_documents.retry_policy
|
|
517
|
+
|
|
518
|
+
options.apply_defaults timeout: @config.timeout,
|
|
519
|
+
metadata: @config.metadata,
|
|
520
|
+
retry_policy: @config.retry_policy
|
|
521
|
+
|
|
522
|
+
@developer_knowledge_stub.batch_get_documents request, options do |result, operation|
|
|
523
|
+
yield result, operation if block_given?
|
|
524
|
+
end
|
|
525
|
+
rescue ::Gapic::Rest::Error => e
|
|
526
|
+
raise ::Google::Cloud::Error.from_error(e)
|
|
527
|
+
end
|
|
528
|
+
|
|
529
|
+
##
|
|
530
|
+
# Configuration class for the DeveloperKnowledge REST API.
|
|
531
|
+
#
|
|
532
|
+
# This class represents the configuration for DeveloperKnowledge REST,
|
|
533
|
+
# providing control over timeouts, retry behavior, logging, transport
|
|
534
|
+
# parameters, and other low-level controls. Certain parameters can also be
|
|
535
|
+
# applied individually to specific RPCs. See
|
|
536
|
+
# {::Google::Developers::DeveloperKnowledge::V1::DeveloperKnowledge::Rest::Client::Configuration::Rpcs}
|
|
537
|
+
# for a list of RPCs that can be configured independently.
|
|
538
|
+
#
|
|
539
|
+
# Configuration can be applied globally to all clients, or to a single client
|
|
540
|
+
# on construction.
|
|
541
|
+
#
|
|
542
|
+
# @example
|
|
543
|
+
#
|
|
544
|
+
# # Modify the global config, setting the timeout for
|
|
545
|
+
# # search_document_chunks to 20 seconds,
|
|
546
|
+
# # and all remaining timeouts to 10 seconds.
|
|
547
|
+
# ::Google::Developers::DeveloperKnowledge::V1::DeveloperKnowledge::Rest::Client.configure do |config|
|
|
548
|
+
# config.timeout = 10.0
|
|
549
|
+
# config.rpcs.search_document_chunks.timeout = 20.0
|
|
550
|
+
# end
|
|
551
|
+
#
|
|
552
|
+
# # Apply the above configuration only to a new client.
|
|
553
|
+
# client = ::Google::Developers::DeveloperKnowledge::V1::DeveloperKnowledge::Rest::Client.new do |config|
|
|
554
|
+
# config.timeout = 10.0
|
|
555
|
+
# config.rpcs.search_document_chunks.timeout = 20.0
|
|
556
|
+
# end
|
|
557
|
+
#
|
|
558
|
+
# @!attribute [rw] endpoint
|
|
559
|
+
# A custom service endpoint, as a hostname or hostname:port. The default is
|
|
560
|
+
# nil, indicating to use the default endpoint in the current universe domain.
|
|
561
|
+
# @return [::String,nil]
|
|
562
|
+
# @!attribute [rw] credentials
|
|
563
|
+
# Credentials to send with calls. You may provide any of the following types:
|
|
564
|
+
# * (`String`) The path to a service account key file in JSON format
|
|
565
|
+
# * (`Hash`) A service account key as a Hash
|
|
566
|
+
# * (`Google::Auth::Credentials`) A googleauth credentials object
|
|
567
|
+
# (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
|
|
568
|
+
# * (`Signet::OAuth2::Client`) A signet oauth2 client object
|
|
569
|
+
# (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
|
|
570
|
+
# * (`nil`) indicating no credentials
|
|
571
|
+
#
|
|
572
|
+
# Warning: If you accept a credential configuration (JSON file or Hash) from an
|
|
573
|
+
# external source for authentication to Google Cloud, you must validate it before
|
|
574
|
+
# providing it to a Google API client library. Providing an unvalidated credential
|
|
575
|
+
# configuration to Google APIs can compromise the security of your systems and data.
|
|
576
|
+
# For more information, refer to [Validate credential configurations from external
|
|
577
|
+
# sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
|
|
578
|
+
# @return [::Object]
|
|
579
|
+
# @!attribute [rw] scope
|
|
580
|
+
# The OAuth scopes
|
|
581
|
+
# @return [::Array<::String>]
|
|
582
|
+
# @!attribute [rw] lib_name
|
|
583
|
+
# The library name as recorded in instrumentation and logging
|
|
584
|
+
# @return [::String]
|
|
585
|
+
# @!attribute [rw] lib_version
|
|
586
|
+
# The library version as recorded in instrumentation and logging
|
|
587
|
+
# @return [::String]
|
|
588
|
+
# @!attribute [rw] timeout
|
|
589
|
+
# The call timeout in seconds.
|
|
590
|
+
# @return [::Numeric]
|
|
591
|
+
# @!attribute [rw] metadata
|
|
592
|
+
# Additional headers to be sent with the call.
|
|
593
|
+
# @return [::Hash{::Symbol=>::String}]
|
|
594
|
+
# @!attribute [rw] retry_policy
|
|
595
|
+
# The retry policy. The value is a hash with the following keys:
|
|
596
|
+
# * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
|
|
597
|
+
# * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
|
|
598
|
+
# * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
|
|
599
|
+
# * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
|
|
600
|
+
# trigger a retry.
|
|
601
|
+
# @return [::Hash]
|
|
602
|
+
# @!attribute [rw] quota_project
|
|
603
|
+
# A separate project against which to charge quota.
|
|
604
|
+
# @return [::String]
|
|
605
|
+
# @!attribute [rw] universe_domain
|
|
606
|
+
# The universe domain within which to make requests. This determines the
|
|
607
|
+
# default endpoint URL. The default value of nil uses the environment
|
|
608
|
+
# universe (usually the default "googleapis.com" universe).
|
|
609
|
+
# @return [::String,nil]
|
|
610
|
+
# @!attribute [rw] logger
|
|
611
|
+
# A custom logger to use for request/response debug logging, or the value
|
|
612
|
+
# `:default` (the default) to construct a default logger, or `nil` to
|
|
613
|
+
# explicitly disable logging.
|
|
614
|
+
# @return [::Logger,:default,nil]
|
|
615
|
+
#
|
|
616
|
+
class Configuration
|
|
617
|
+
extend ::Gapic::Config
|
|
618
|
+
|
|
619
|
+
# @private
|
|
620
|
+
# The endpoint specific to the default "googleapis.com" universe. Deprecated.
|
|
621
|
+
DEFAULT_ENDPOINT = "developerknowledge.googleapis.com"
|
|
622
|
+
|
|
623
|
+
config_attr :endpoint, nil, ::String, nil
|
|
624
|
+
config_attr :credentials, nil do |value|
|
|
625
|
+
allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Google::Auth::BaseClient, ::Signet::OAuth2::Client, nil]
|
|
626
|
+
allowed.any? { |klass| klass === value }
|
|
627
|
+
end
|
|
628
|
+
config_attr :scope, nil, ::String, ::Array, nil
|
|
629
|
+
config_attr :lib_name, nil, ::String, nil
|
|
630
|
+
config_attr :lib_version, nil, ::String, nil
|
|
631
|
+
config_attr :timeout, nil, ::Numeric, nil
|
|
632
|
+
config_attr :metadata, nil, ::Hash, nil
|
|
633
|
+
config_attr :retry_policy, nil, ::Hash, ::Proc, nil
|
|
634
|
+
config_attr :quota_project, nil, ::String, nil
|
|
635
|
+
config_attr :universe_domain, nil, ::String, nil
|
|
636
|
+
config_attr :logger, :default, ::Logger, nil, :default
|
|
637
|
+
|
|
638
|
+
# @private
|
|
639
|
+
def initialize parent_config = nil
|
|
640
|
+
@parent_config = parent_config unless parent_config.nil?
|
|
641
|
+
|
|
642
|
+
yield self if block_given?
|
|
643
|
+
end
|
|
644
|
+
|
|
645
|
+
##
|
|
646
|
+
# Configurations for individual RPCs
|
|
647
|
+
# @return [Rpcs]
|
|
648
|
+
#
|
|
649
|
+
def rpcs
|
|
650
|
+
@rpcs ||= begin
|
|
651
|
+
parent_rpcs = nil
|
|
652
|
+
parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
|
|
653
|
+
Rpcs.new parent_rpcs
|
|
654
|
+
end
|
|
655
|
+
end
|
|
656
|
+
|
|
657
|
+
##
|
|
658
|
+
# Configuration RPC class for the DeveloperKnowledge API.
|
|
659
|
+
#
|
|
660
|
+
# Includes fields providing the configuration for each RPC in this service.
|
|
661
|
+
# Each configuration object is of type `Gapic::Config::Method` and includes
|
|
662
|
+
# the following configuration fields:
|
|
663
|
+
#
|
|
664
|
+
# * `timeout` (*type:* `Numeric`) - The call timeout in seconds
|
|
665
|
+
# * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
|
|
666
|
+
# * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
|
|
667
|
+
# include the following keys:
|
|
668
|
+
# * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
|
|
669
|
+
# * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
|
|
670
|
+
# * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
|
|
671
|
+
# * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
|
|
672
|
+
# trigger a retry.
|
|
673
|
+
#
|
|
674
|
+
class Rpcs
|
|
675
|
+
##
|
|
676
|
+
# RPC-specific configuration for `search_document_chunks`
|
|
677
|
+
# @return [::Gapic::Config::Method]
|
|
678
|
+
#
|
|
679
|
+
attr_reader :search_document_chunks
|
|
680
|
+
##
|
|
681
|
+
# RPC-specific configuration for `get_document`
|
|
682
|
+
# @return [::Gapic::Config::Method]
|
|
683
|
+
#
|
|
684
|
+
attr_reader :get_document
|
|
685
|
+
##
|
|
686
|
+
# RPC-specific configuration for `batch_get_documents`
|
|
687
|
+
# @return [::Gapic::Config::Method]
|
|
688
|
+
#
|
|
689
|
+
attr_reader :batch_get_documents
|
|
690
|
+
|
|
691
|
+
# @private
|
|
692
|
+
def initialize parent_rpcs = nil
|
|
693
|
+
search_document_chunks_config = parent_rpcs.search_document_chunks if parent_rpcs.respond_to? :search_document_chunks
|
|
694
|
+
@search_document_chunks = ::Gapic::Config::Method.new search_document_chunks_config
|
|
695
|
+
get_document_config = parent_rpcs.get_document if parent_rpcs.respond_to? :get_document
|
|
696
|
+
@get_document = ::Gapic::Config::Method.new get_document_config
|
|
697
|
+
batch_get_documents_config = parent_rpcs.batch_get_documents if parent_rpcs.respond_to? :batch_get_documents
|
|
698
|
+
@batch_get_documents = ::Gapic::Config::Method.new batch_get_documents_config
|
|
699
|
+
|
|
700
|
+
yield self if block_given?
|
|
701
|
+
end
|
|
702
|
+
end
|
|
703
|
+
end
|
|
704
|
+
end
|
|
705
|
+
end
|
|
706
|
+
end
|
|
707
|
+
end
|
|
708
|
+
end
|
|
709
|
+
end
|
|
710
|
+
end
|