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