google-developer-knowledge 0.1.0__py3-none-any.whl

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 (25) hide show
  1. google/developer_knowledge/__init__.py +49 -0
  2. google/developer_knowledge/gapic_version.py +16 -0
  3. google/developer_knowledge/py.typed +2 -0
  4. google/developer_knowledge_v1/__init__.py +135 -0
  5. google/developer_knowledge_v1/gapic_metadata.json +73 -0
  6. google/developer_knowledge_v1/gapic_version.py +16 -0
  7. google/developer_knowledge_v1/py.typed +2 -0
  8. google/developer_knowledge_v1/services/__init__.py +15 -0
  9. google/developer_knowledge_v1/services/developer_knowledge/__init__.py +22 -0
  10. google/developer_knowledge_v1/services/developer_knowledge/async_client.py +642 -0
  11. google/developer_knowledge_v1/services/developer_knowledge/client.py +1067 -0
  12. google/developer_knowledge_v1/services/developer_knowledge/pagers.py +201 -0
  13. google/developer_knowledge_v1/services/developer_knowledge/transports/__init__.py +36 -0
  14. google/developer_knowledge_v1/services/developer_knowledge/transports/base.py +227 -0
  15. google/developer_knowledge_v1/services/developer_knowledge/transports/grpc.py +449 -0
  16. google/developer_knowledge_v1/services/developer_knowledge/transports/grpc_asyncio.py +502 -0
  17. google/developer_knowledge_v1/services/developer_knowledge/transports/rest.py +855 -0
  18. google/developer_knowledge_v1/services/developer_knowledge/transports/rest_base.py +236 -0
  19. google/developer_knowledge_v1/types/__init__.py +36 -0
  20. google/developer_knowledge_v1/types/developerknowledge.py +413 -0
  21. google_developer_knowledge-0.1.0.dist-info/METADATA +240 -0
  22. google_developer_knowledge-0.1.0.dist-info/RECORD +25 -0
  23. google_developer_knowledge-0.1.0.dist-info/WHEEL +5 -0
  24. google_developer_knowledge-0.1.0.dist-info/licenses/LICENSE +202 -0
  25. google_developer_knowledge-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,642 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright 2026 Google LLC
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ import logging as std_logging
17
+ import re
18
+ from collections import OrderedDict
19
+ from typing import (
20
+ Callable,
21
+ Dict,
22
+ Mapping,
23
+ MutableMapping,
24
+ MutableSequence,
25
+ Optional,
26
+ Sequence,
27
+ Tuple,
28
+ Type,
29
+ Union,
30
+ )
31
+
32
+ import google.protobuf
33
+ from google.api_core import exceptions as core_exceptions
34
+ from google.api_core import gapic_v1
35
+ from google.api_core import retry_async as retries
36
+ from google.api_core.client_options import ClientOptions
37
+ from google.auth import credentials as ga_credentials # type: ignore
38
+ from google.oauth2 import service_account # type: ignore
39
+
40
+ from google.developer_knowledge_v1 import gapic_version as package_version
41
+
42
+ try:
43
+ OptionalRetry = Union[retries.AsyncRetry, gapic_v1.method._MethodDefault, None]
44
+ except AttributeError: # pragma: NO COVER
45
+ OptionalRetry = Union[retries.AsyncRetry, object, None] # type: ignore
46
+
47
+ import google.protobuf.timestamp_pb2 as timestamp_pb2 # type: ignore
48
+
49
+ from google.developer_knowledge_v1.services.developer_knowledge import pagers
50
+ from google.developer_knowledge_v1.types import developerknowledge
51
+
52
+ from .client import DeveloperKnowledgeClient
53
+ from .transports.base import DEFAULT_CLIENT_INFO, DeveloperKnowledgeTransport
54
+ from .transports.grpc_asyncio import DeveloperKnowledgeGrpcAsyncIOTransport
55
+
56
+ try:
57
+ from google.api_core import client_logging # type: ignore
58
+
59
+ CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
60
+ except ImportError: # pragma: NO COVER
61
+ CLIENT_LOGGING_SUPPORTED = False
62
+
63
+ _LOGGER = std_logging.getLogger(__name__)
64
+
65
+
66
+ class DeveloperKnowledgeAsyncClient:
67
+ """The Developer Knowledge API provides programmatic access to Google's
68
+ public developer documentation, enabling you to integrate this
69
+ knowledge base into your own applications and workflows.
70
+
71
+ The API is designed to be the canonical source for machine-readable
72
+ access to Google's developer documentation.
73
+
74
+ A typical use case is to first use
75
+ [DeveloperKnowledge.SearchDocumentChunks][google.developers.knowledge.v1.DeveloperKnowledge.SearchDocumentChunks]
76
+ to find relevant page URIs based on a query, and then use
77
+ [DeveloperKnowledge.GetDocument][google.developers.knowledge.v1.DeveloperKnowledge.GetDocument]
78
+ or
79
+ [DeveloperKnowledge.BatchGetDocuments][google.developers.knowledge.v1.DeveloperKnowledge.BatchGetDocuments]
80
+ to fetch the full content of the top results.
81
+
82
+ All document content is provided in Markdown format.
83
+ """
84
+
85
+ _client: DeveloperKnowledgeClient
86
+
87
+ # Copy defaults from the synchronous client for use here.
88
+ # Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead.
89
+ DEFAULT_ENDPOINT = DeveloperKnowledgeClient.DEFAULT_ENDPOINT
90
+ DEFAULT_MTLS_ENDPOINT = DeveloperKnowledgeClient.DEFAULT_MTLS_ENDPOINT
91
+ _DEFAULT_ENDPOINT_TEMPLATE = DeveloperKnowledgeClient._DEFAULT_ENDPOINT_TEMPLATE
92
+ _DEFAULT_UNIVERSE = DeveloperKnowledgeClient._DEFAULT_UNIVERSE
93
+
94
+ document_path = staticmethod(DeveloperKnowledgeClient.document_path)
95
+ parse_document_path = staticmethod(DeveloperKnowledgeClient.parse_document_path)
96
+ common_billing_account_path = staticmethod(
97
+ DeveloperKnowledgeClient.common_billing_account_path
98
+ )
99
+ parse_common_billing_account_path = staticmethod(
100
+ DeveloperKnowledgeClient.parse_common_billing_account_path
101
+ )
102
+ common_folder_path = staticmethod(DeveloperKnowledgeClient.common_folder_path)
103
+ parse_common_folder_path = staticmethod(
104
+ DeveloperKnowledgeClient.parse_common_folder_path
105
+ )
106
+ common_organization_path = staticmethod(
107
+ DeveloperKnowledgeClient.common_organization_path
108
+ )
109
+ parse_common_organization_path = staticmethod(
110
+ DeveloperKnowledgeClient.parse_common_organization_path
111
+ )
112
+ common_project_path = staticmethod(DeveloperKnowledgeClient.common_project_path)
113
+ parse_common_project_path = staticmethod(
114
+ DeveloperKnowledgeClient.parse_common_project_path
115
+ )
116
+ common_location_path = staticmethod(DeveloperKnowledgeClient.common_location_path)
117
+ parse_common_location_path = staticmethod(
118
+ DeveloperKnowledgeClient.parse_common_location_path
119
+ )
120
+
121
+ @classmethod
122
+ def from_service_account_info(cls, info: dict, *args, **kwargs):
123
+ """Creates an instance of this client using the provided credentials
124
+ info.
125
+
126
+ Args:
127
+ info (dict): The service account private key info.
128
+ args: Additional arguments to pass to the constructor.
129
+ kwargs: Additional arguments to pass to the constructor.
130
+
131
+ Returns:
132
+ DeveloperKnowledgeAsyncClient: The constructed client.
133
+ """
134
+ sa_info_func = (
135
+ DeveloperKnowledgeClient.from_service_account_info.__func__ # type: ignore
136
+ )
137
+ return sa_info_func(DeveloperKnowledgeAsyncClient, info, *args, **kwargs)
138
+
139
+ @classmethod
140
+ def from_service_account_file(cls, filename: str, *args, **kwargs):
141
+ """Creates an instance of this client using the provided credentials
142
+ file.
143
+
144
+ Args:
145
+ filename (str): The path to the service account private key json
146
+ file.
147
+ args: Additional arguments to pass to the constructor.
148
+ kwargs: Additional arguments to pass to the constructor.
149
+
150
+ Returns:
151
+ DeveloperKnowledgeAsyncClient: The constructed client.
152
+ """
153
+ sa_file_func = (
154
+ DeveloperKnowledgeClient.from_service_account_file.__func__ # type: ignore
155
+ )
156
+ return sa_file_func(DeveloperKnowledgeAsyncClient, filename, *args, **kwargs)
157
+
158
+ from_service_account_json = from_service_account_file
159
+
160
+ @classmethod
161
+ def get_mtls_endpoint_and_cert_source(
162
+ cls, client_options: Optional[ClientOptions] = None
163
+ ):
164
+ """Return the API endpoint and client cert source for mutual TLS.
165
+
166
+ The client cert source is determined in the following order:
167
+ (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the
168
+ client cert source is None.
169
+ (2) if `client_options.client_cert_source` is provided, use the provided one; if the
170
+ default client cert source exists, use the default one; otherwise the client cert
171
+ source is None.
172
+
173
+ The API endpoint is determined in the following order:
174
+ (1) if `client_options.api_endpoint` if provided, use the provided one.
175
+ (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the
176
+ default mTLS endpoint; if the environment variable is "never", use the default API
177
+ endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise
178
+ use the default API endpoint.
179
+
180
+ More details can be found at https://google.aip.dev/auth/4114.
181
+
182
+ Args:
183
+ client_options (google.api_core.client_options.ClientOptions): Custom options for the
184
+ client. Only the `api_endpoint` and `client_cert_source` properties may be used
185
+ in this method.
186
+
187
+ Returns:
188
+ Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the
189
+ client cert source to use.
190
+
191
+ Raises:
192
+ google.auth.exceptions.MutualTLSChannelError: If any errors happen.
193
+ """
194
+ return DeveloperKnowledgeClient.get_mtls_endpoint_and_cert_source(
195
+ client_options
196
+ ) # type: ignore
197
+
198
+ @property
199
+ def transport(self) -> DeveloperKnowledgeTransport:
200
+ """Returns the transport used by the client instance.
201
+
202
+ Returns:
203
+ DeveloperKnowledgeTransport: The transport used by the client instance.
204
+ """
205
+ return self._client.transport
206
+
207
+ @property
208
+ def api_endpoint(self) -> str:
209
+ """Return the API endpoint used by the client instance.
210
+
211
+ Returns:
212
+ str: The API endpoint used by the client instance.
213
+ """
214
+ return self._client._api_endpoint
215
+
216
+ @property
217
+ def universe_domain(self) -> str:
218
+ """Return the universe domain used by the client instance.
219
+
220
+ Returns:
221
+ str: The universe domain used
222
+ by the client instance.
223
+ """
224
+ return self._client._universe_domain
225
+
226
+ get_transport_class = DeveloperKnowledgeClient.get_transport_class
227
+
228
+ def __init__(
229
+ self,
230
+ *,
231
+ credentials: Optional[ga_credentials.Credentials] = None,
232
+ transport: Optional[
233
+ Union[
234
+ str,
235
+ DeveloperKnowledgeTransport,
236
+ Callable[..., DeveloperKnowledgeTransport],
237
+ ]
238
+ ] = "grpc_asyncio",
239
+ client_options: Optional[ClientOptions] = None,
240
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
241
+ ) -> None:
242
+ """Instantiates the developer knowledge async client.
243
+
244
+ Args:
245
+ credentials (Optional[google.auth.credentials.Credentials]): The
246
+ authorization credentials to attach to requests. These
247
+ credentials identify the application to the service; if none
248
+ are specified, the client will attempt to ascertain the
249
+ credentials from the environment.
250
+ transport (Optional[Union[str,DeveloperKnowledgeTransport,Callable[..., DeveloperKnowledgeTransport]]]):
251
+ The transport to use, or a Callable that constructs and returns a new transport to use.
252
+ If a Callable is given, it will be called with the same set of initialization
253
+ arguments as used in the DeveloperKnowledgeTransport constructor.
254
+ If set to None, a transport is chosen automatically.
255
+ client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]):
256
+ Custom options for the client.
257
+
258
+ 1. The ``api_endpoint`` property can be used to override the
259
+ default endpoint provided by the client when ``transport`` is
260
+ not explicitly provided. Only if this property is not set and
261
+ ``transport`` was not explicitly provided, the endpoint is
262
+ determined by the GOOGLE_API_USE_MTLS_ENDPOINT environment
263
+ variable, which have one of the following values:
264
+ "always" (always use the default mTLS endpoint), "never" (always
265
+ use the default regular endpoint) and "auto" (auto-switch to the
266
+ default mTLS endpoint if client certificate is present; this is
267
+ the default value).
268
+
269
+ 2. If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
270
+ is "true", then the ``client_cert_source`` property can be used
271
+ to provide a client certificate for mTLS transport. If
272
+ not provided, the default SSL client certificate will be used if
273
+ present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
274
+ set, no client certificate will be used.
275
+
276
+ 3. The ``universe_domain`` property can be used to override the
277
+ default "googleapis.com" universe. Note that ``api_endpoint``
278
+ property still takes precedence; and ``universe_domain`` is
279
+ currently not supported for mTLS.
280
+
281
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
282
+ The client info used to send a user-agent string along with
283
+ API requests. If ``None``, then default info will be used.
284
+ Generally, you only need to set this if you're developing
285
+ your own client library.
286
+
287
+ Raises:
288
+ google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
289
+ creation failed for any reason.
290
+ """
291
+ self._client = DeveloperKnowledgeClient(
292
+ credentials=credentials,
293
+ transport=transport,
294
+ client_options=client_options,
295
+ client_info=client_info,
296
+ )
297
+
298
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
299
+ std_logging.DEBUG
300
+ ): # pragma: NO COVER
301
+ _LOGGER.debug(
302
+ "Created client `google.developers.knowledge_v1.DeveloperKnowledgeAsyncClient`.",
303
+ extra={
304
+ "serviceName": "google.developers.knowledge.v1.DeveloperKnowledge",
305
+ "universeDomain": getattr(
306
+ self._client._transport._credentials, "universe_domain", ""
307
+ ),
308
+ "credentialsType": f"{type(self._client._transport._credentials).__module__}.{type(self._client._transport._credentials).__qualname__}",
309
+ "credentialsInfo": getattr(
310
+ self.transport._credentials, "get_cred_info", lambda: None
311
+ )(),
312
+ }
313
+ if hasattr(self._client._transport, "_credentials")
314
+ else {
315
+ "serviceName": "google.developers.knowledge.v1.DeveloperKnowledge",
316
+ "credentialsType": None,
317
+ },
318
+ )
319
+
320
+ async def search_document_chunks(
321
+ self,
322
+ request: Optional[
323
+ Union[developerknowledge.SearchDocumentChunksRequest, dict]
324
+ ] = None,
325
+ *,
326
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
327
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
328
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
329
+ ) -> pagers.SearchDocumentChunksAsyncPager:
330
+ r"""Searches for developer knowledge across Google's developer
331
+ documentation. Returns
332
+ [DocumentChunk][google.developers.knowledge.v1.DocumentChunk]s
333
+ based on the user's query. There may be many chunks from the
334
+ same [Document][google.developers.knowledge.v1.Document]. To
335
+ retrieve full documents, use
336
+ [DeveloperKnowledge.GetDocument][google.developers.knowledge.v1.DeveloperKnowledge.GetDocument]
337
+ or
338
+ [DeveloperKnowledge.BatchGetDocuments][google.developers.knowledge.v1.DeveloperKnowledge.BatchGetDocuments]
339
+ with the
340
+ [DocumentChunk.parent][google.developers.knowledge.v1.DocumentChunk.parent]
341
+ returned in the
342
+ [SearchDocumentChunksResponse.results][google.developers.knowledge.v1.SearchDocumentChunksResponse.results].
343
+
344
+ .. code-block:: python
345
+
346
+ # This snippet has been automatically generated and should be regarded as a
347
+ # code template only.
348
+ # It will require modifications to work:
349
+ # - It may require correct/in-range values for request initialization.
350
+ # - It may require specifying regional endpoints when creating the service
351
+ # client as shown in:
352
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
353
+ from google import developer_knowledge_v1
354
+
355
+ async def sample_search_document_chunks():
356
+ # Create a client
357
+ client = developer_knowledge_v1.DeveloperKnowledgeAsyncClient()
358
+
359
+ # Initialize request argument(s)
360
+ request = developer_knowledge_v1.SearchDocumentChunksRequest(
361
+ query="query_value",
362
+ )
363
+
364
+ # Make the request
365
+ page_result = client.search_document_chunks(request=request)
366
+
367
+ # Handle the response
368
+ async for response in page_result:
369
+ print(response)
370
+
371
+ Args:
372
+ request (Optional[Union[google.developer_knowledge_v1.types.SearchDocumentChunksRequest, dict]]):
373
+ The request object. Request message for
374
+ [DeveloperKnowledge.SearchDocumentChunks][google.developers.knowledge.v1.DeveloperKnowledge.SearchDocumentChunks].
375
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
376
+ should be retried.
377
+ timeout (float): The timeout for this request.
378
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
379
+ sent along with the request as metadata. Normally, each value must be of type `str`,
380
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
381
+ be of type `bytes`.
382
+
383
+ Returns:
384
+ google.developer_knowledge_v1.services.developer_knowledge.pagers.SearchDocumentChunksAsyncPager:
385
+ Response message for
386
+ [DeveloperKnowledge.SearchDocumentChunks][google.developers.knowledge.v1.DeveloperKnowledge.SearchDocumentChunks].
387
+
388
+ Iterating over this object will yield results and
389
+ resolve additional pages automatically.
390
+
391
+ """
392
+ # Create or coerce a protobuf request object.
393
+ # - Use the request object if provided (there's no risk of modifying the input as
394
+ # there are no flattened fields), or create one.
395
+ if not isinstance(request, developerknowledge.SearchDocumentChunksRequest):
396
+ request = developerknowledge.SearchDocumentChunksRequest(request)
397
+
398
+ # Wrap the RPC method; this adds retry and timeout information,
399
+ # and friendly error handling.
400
+ rpc = self._client._transport._wrapped_methods[
401
+ self._client._transport.search_document_chunks
402
+ ]
403
+
404
+ # Validate the universe domain.
405
+ self._client._validate_universe_domain()
406
+
407
+ # Send the request.
408
+ response = await rpc(
409
+ request,
410
+ retry=retry,
411
+ timeout=timeout,
412
+ metadata=metadata,
413
+ )
414
+
415
+ # This method is paged; wrap the response in a pager, which provides
416
+ # an `__aiter__` convenience method.
417
+ response = pagers.SearchDocumentChunksAsyncPager(
418
+ method=rpc,
419
+ request=request,
420
+ response=response,
421
+ retry=retry,
422
+ timeout=timeout,
423
+ metadata=metadata,
424
+ )
425
+
426
+ # Done; return the response.
427
+ return response
428
+
429
+ async def get_document(
430
+ self,
431
+ request: Optional[Union[developerknowledge.GetDocumentRequest, dict]] = None,
432
+ *,
433
+ name: Optional[str] = None,
434
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
435
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
436
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
437
+ ) -> developerknowledge.Document:
438
+ r"""Retrieves a single document with its full Markdown
439
+ content.
440
+
441
+ .. code-block:: python
442
+
443
+ # This snippet has been automatically generated and should be regarded as a
444
+ # code template only.
445
+ # It will require modifications to work:
446
+ # - It may require correct/in-range values for request initialization.
447
+ # - It may require specifying regional endpoints when creating the service
448
+ # client as shown in:
449
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
450
+ from google import developer_knowledge_v1
451
+
452
+ async def sample_get_document():
453
+ # Create a client
454
+ client = developer_knowledge_v1.DeveloperKnowledgeAsyncClient()
455
+
456
+ # Initialize request argument(s)
457
+ request = developer_knowledge_v1.GetDocumentRequest(
458
+ name="name_value",
459
+ )
460
+
461
+ # Make the request
462
+ response = await client.get_document(request=request)
463
+
464
+ # Handle the response
465
+ print(response)
466
+
467
+ Args:
468
+ request (Optional[Union[google.developer_knowledge_v1.types.GetDocumentRequest, dict]]):
469
+ The request object. Request message for
470
+ [DeveloperKnowledge.GetDocument][google.developers.knowledge.v1.DeveloperKnowledge.GetDocument].
471
+ name (:class:`str`):
472
+ Required. Specifies the name of the document to
473
+ retrieve. Format: ``documents/{uri_without_scheme}``
474
+ Example:
475
+ ``documents/docs.cloud.google.com/storage/docs/creating-buckets``
476
+
477
+ This corresponds to the ``name`` field
478
+ on the ``request`` instance; if ``request`` is provided, this
479
+ should not be set.
480
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
481
+ should be retried.
482
+ timeout (float): The timeout for this request.
483
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
484
+ sent along with the request as metadata. Normally, each value must be of type `str`,
485
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
486
+ be of type `bytes`.
487
+
488
+ Returns:
489
+ google.developer_knowledge_v1.types.Document:
490
+ A Document represents a piece of
491
+ content from the Developer Knowledge
492
+ corpus.
493
+
494
+ """
495
+ # Create or coerce a protobuf request object.
496
+ # - Quick check: If we got a request object, we should *not* have
497
+ # gotten any keyword arguments that map to the request.
498
+ flattened_params = [name]
499
+ has_flattened_params = (
500
+ len([param for param in flattened_params if param is not None]) > 0
501
+ )
502
+ if request is not None and has_flattened_params:
503
+ raise ValueError(
504
+ "If the `request` argument is set, then none of "
505
+ "the individual field arguments should be set."
506
+ )
507
+
508
+ # - Use the request object if provided (there's no risk of modifying the input as
509
+ # there are no flattened fields), or create one.
510
+ if not isinstance(request, developerknowledge.GetDocumentRequest):
511
+ request = developerknowledge.GetDocumentRequest(request)
512
+
513
+ # If we have keyword arguments corresponding to fields on the
514
+ # request, apply these.
515
+ if name is not None:
516
+ request.name = name
517
+
518
+ # Wrap the RPC method; this adds retry and timeout information,
519
+ # and friendly error handling.
520
+ rpc = self._client._transport._wrapped_methods[
521
+ self._client._transport.get_document
522
+ ]
523
+
524
+ # Certain fields should be provided within the metadata header;
525
+ # add these here.
526
+ metadata = tuple(metadata) + (
527
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
528
+ )
529
+
530
+ # Validate the universe domain.
531
+ self._client._validate_universe_domain()
532
+
533
+ # Send the request.
534
+ response = await rpc(
535
+ request,
536
+ retry=retry,
537
+ timeout=timeout,
538
+ metadata=metadata,
539
+ )
540
+
541
+ # Done; return the response.
542
+ return response
543
+
544
+ async def batch_get_documents(
545
+ self,
546
+ request: Optional[
547
+ Union[developerknowledge.BatchGetDocumentsRequest, dict]
548
+ ] = None,
549
+ *,
550
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
551
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
552
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
553
+ ) -> developerknowledge.BatchGetDocumentsResponse:
554
+ r"""Retrieves multiple documents, each with its full
555
+ Markdown content.
556
+
557
+ .. code-block:: python
558
+
559
+ # This snippet has been automatically generated and should be regarded as a
560
+ # code template only.
561
+ # It will require modifications to work:
562
+ # - It may require correct/in-range values for request initialization.
563
+ # - It may require specifying regional endpoints when creating the service
564
+ # client as shown in:
565
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
566
+ from google import developer_knowledge_v1
567
+
568
+ async def sample_batch_get_documents():
569
+ # Create a client
570
+ client = developer_knowledge_v1.DeveloperKnowledgeAsyncClient()
571
+
572
+ # Initialize request argument(s)
573
+ request = developer_knowledge_v1.BatchGetDocumentsRequest(
574
+ names=['names_value1', 'names_value2'],
575
+ )
576
+
577
+ # Make the request
578
+ response = await client.batch_get_documents(request=request)
579
+
580
+ # Handle the response
581
+ print(response)
582
+
583
+ Args:
584
+ request (Optional[Union[google.developer_knowledge_v1.types.BatchGetDocumentsRequest, dict]]):
585
+ The request object. Request message for
586
+ [DeveloperKnowledge.BatchGetDocuments][google.developers.knowledge.v1.DeveloperKnowledge.BatchGetDocuments].
587
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
588
+ should be retried.
589
+ timeout (float): The timeout for this request.
590
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
591
+ sent along with the request as metadata. Normally, each value must be of type `str`,
592
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
593
+ be of type `bytes`.
594
+
595
+ Returns:
596
+ google.developer_knowledge_v1.types.BatchGetDocumentsResponse:
597
+ Response message for
598
+ [DeveloperKnowledge.BatchGetDocuments][google.developers.knowledge.v1.DeveloperKnowledge.BatchGetDocuments].
599
+
600
+ """
601
+ # Create or coerce a protobuf request object.
602
+ # - Use the request object if provided (there's no risk of modifying the input as
603
+ # there are no flattened fields), or create one.
604
+ if not isinstance(request, developerknowledge.BatchGetDocumentsRequest):
605
+ request = developerknowledge.BatchGetDocumentsRequest(request)
606
+
607
+ # Wrap the RPC method; this adds retry and timeout information,
608
+ # and friendly error handling.
609
+ rpc = self._client._transport._wrapped_methods[
610
+ self._client._transport.batch_get_documents
611
+ ]
612
+
613
+ # Validate the universe domain.
614
+ self._client._validate_universe_domain()
615
+
616
+ # Send the request.
617
+ response = await rpc(
618
+ request,
619
+ retry=retry,
620
+ timeout=timeout,
621
+ metadata=metadata,
622
+ )
623
+
624
+ # Done; return the response.
625
+ return response
626
+
627
+ async def __aenter__(self) -> "DeveloperKnowledgeAsyncClient":
628
+ return self
629
+
630
+ async def __aexit__(self, exc_type, exc, tb):
631
+ await self.transport.close()
632
+
633
+
634
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
635
+ gapic_version=package_version.__version__
636
+ )
637
+
638
+ if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER
639
+ DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__
640
+
641
+
642
+ __all__ = ("DeveloperKnowledgeAsyncClient",)