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,201 @@
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
+ from typing import (
17
+ Any,
18
+ AsyncIterator,
19
+ Awaitable,
20
+ Callable,
21
+ Iterator,
22
+ Optional,
23
+ Sequence,
24
+ Tuple,
25
+ Union,
26
+ )
27
+
28
+ from google.api_core import gapic_v1
29
+ from google.api_core import retry as retries
30
+ from google.api_core import retry_async as retries_async
31
+
32
+ try:
33
+ OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault, None]
34
+ OptionalAsyncRetry = Union[
35
+ retries_async.AsyncRetry, gapic_v1.method._MethodDefault, None
36
+ ]
37
+ except AttributeError: # pragma: NO COVER
38
+ OptionalRetry = Union[retries.Retry, object, None] # type: ignore
39
+ OptionalAsyncRetry = Union[retries_async.AsyncRetry, object, None] # type: ignore
40
+
41
+ from google.developer_knowledge_v1.types import developerknowledge
42
+
43
+
44
+ class SearchDocumentChunksPager:
45
+ """A pager for iterating through ``search_document_chunks`` requests.
46
+
47
+ This class thinly wraps an initial
48
+ :class:`google.developer_knowledge_v1.types.SearchDocumentChunksResponse` object, and
49
+ provides an ``__iter__`` method to iterate through its
50
+ ``results`` field.
51
+
52
+ If there are more pages, the ``__iter__`` method will make additional
53
+ ``SearchDocumentChunks`` requests and continue to iterate
54
+ through the ``results`` field on the
55
+ corresponding responses.
56
+
57
+ All the usual :class:`google.developer_knowledge_v1.types.SearchDocumentChunksResponse`
58
+ attributes are available on the pager. If multiple requests are made, only
59
+ the most recent response is retained, and thus used for attribute lookup.
60
+ """
61
+
62
+ def __init__(
63
+ self,
64
+ method: Callable[..., developerknowledge.SearchDocumentChunksResponse],
65
+ request: developerknowledge.SearchDocumentChunksRequest,
66
+ response: developerknowledge.SearchDocumentChunksResponse,
67
+ *,
68
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
69
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
70
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
71
+ ):
72
+ """Instantiate the pager.
73
+
74
+ Args:
75
+ method (Callable): The method that was originally called, and
76
+ which instantiated this pager.
77
+ request (google.developer_knowledge_v1.types.SearchDocumentChunksRequest):
78
+ The initial request object.
79
+ response (google.developer_knowledge_v1.types.SearchDocumentChunksResponse):
80
+ The initial response object.
81
+ retry (google.api_core.retry.Retry): Designation of what errors,
82
+ if any, should be retried.
83
+ timeout (float): The timeout for this request.
84
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
85
+ sent along with the request as metadata. Normally, each value must be of type `str`,
86
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
87
+ be of type `bytes`.
88
+ """
89
+ self._method = method
90
+ self._request = developerknowledge.SearchDocumentChunksRequest(request)
91
+ self._response = response
92
+ self._retry = retry
93
+ self._timeout = timeout
94
+ self._metadata = metadata
95
+
96
+ def __getattr__(self, name: str) -> Any:
97
+ return getattr(self._response, name)
98
+
99
+ @property
100
+ def pages(self) -> Iterator[developerknowledge.SearchDocumentChunksResponse]:
101
+ yield self._response
102
+ while self._response.next_page_token:
103
+ self._request.page_token = self._response.next_page_token
104
+ self._response = self._method(
105
+ self._request,
106
+ retry=self._retry,
107
+ timeout=self._timeout,
108
+ metadata=self._metadata,
109
+ )
110
+ yield self._response
111
+
112
+ def __iter__(self) -> Iterator[developerknowledge.DocumentChunk]:
113
+ for page in self.pages:
114
+ yield from page.results
115
+
116
+ def __repr__(self) -> str:
117
+ return "{0}<{1!r}>".format(self.__class__.__name__, self._response)
118
+
119
+
120
+ class SearchDocumentChunksAsyncPager:
121
+ """A pager for iterating through ``search_document_chunks`` requests.
122
+
123
+ This class thinly wraps an initial
124
+ :class:`google.developer_knowledge_v1.types.SearchDocumentChunksResponse` object, and
125
+ provides an ``__aiter__`` method to iterate through its
126
+ ``results`` field.
127
+
128
+ If there are more pages, the ``__aiter__`` method will make additional
129
+ ``SearchDocumentChunks`` requests and continue to iterate
130
+ through the ``results`` field on the
131
+ corresponding responses.
132
+
133
+ All the usual :class:`google.developer_knowledge_v1.types.SearchDocumentChunksResponse`
134
+ attributes are available on the pager. If multiple requests are made, only
135
+ the most recent response is retained, and thus used for attribute lookup.
136
+ """
137
+
138
+ def __init__(
139
+ self,
140
+ method: Callable[
141
+ ..., Awaitable[developerknowledge.SearchDocumentChunksResponse]
142
+ ],
143
+ request: developerknowledge.SearchDocumentChunksRequest,
144
+ response: developerknowledge.SearchDocumentChunksResponse,
145
+ *,
146
+ retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT,
147
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
148
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
149
+ ):
150
+ """Instantiates the pager.
151
+
152
+ Args:
153
+ method (Callable): The method that was originally called, and
154
+ which instantiated this pager.
155
+ request (google.developer_knowledge_v1.types.SearchDocumentChunksRequest):
156
+ The initial request object.
157
+ response (google.developer_knowledge_v1.types.SearchDocumentChunksResponse):
158
+ The initial response object.
159
+ retry (google.api_core.retry.AsyncRetry): Designation of what errors,
160
+ if any, should be retried.
161
+ timeout (float): The timeout for this request.
162
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
163
+ sent along with the request as metadata. Normally, each value must be of type `str`,
164
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
165
+ be of type `bytes`.
166
+ """
167
+ self._method = method
168
+ self._request = developerknowledge.SearchDocumentChunksRequest(request)
169
+ self._response = response
170
+ self._retry = retry
171
+ self._timeout = timeout
172
+ self._metadata = metadata
173
+
174
+ def __getattr__(self, name: str) -> Any:
175
+ return getattr(self._response, name)
176
+
177
+ @property
178
+ async def pages(
179
+ self,
180
+ ) -> AsyncIterator[developerknowledge.SearchDocumentChunksResponse]:
181
+ yield self._response
182
+ while self._response.next_page_token:
183
+ self._request.page_token = self._response.next_page_token
184
+ self._response = await self._method(
185
+ self._request,
186
+ retry=self._retry,
187
+ timeout=self._timeout,
188
+ metadata=self._metadata,
189
+ )
190
+ yield self._response
191
+
192
+ def __aiter__(self) -> AsyncIterator[developerknowledge.DocumentChunk]:
193
+ async def async_generator():
194
+ async for page in self.pages:
195
+ for response in page.results:
196
+ yield response
197
+
198
+ return async_generator()
199
+
200
+ def __repr__(self) -> str:
201
+ return "{0}<{1!r}>".format(self.__class__.__name__, self._response)
@@ -0,0 +1,36 @@
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
+ from collections import OrderedDict
17
+ from typing import Dict, Type
18
+
19
+ from .base import DeveloperKnowledgeTransport
20
+ from .grpc import DeveloperKnowledgeGrpcTransport
21
+ from .grpc_asyncio import DeveloperKnowledgeGrpcAsyncIOTransport
22
+ from .rest import DeveloperKnowledgeRestInterceptor, DeveloperKnowledgeRestTransport
23
+
24
+ # Compile a registry of transports.
25
+ _transport_registry = OrderedDict() # type: Dict[str, Type[DeveloperKnowledgeTransport]]
26
+ _transport_registry["grpc"] = DeveloperKnowledgeGrpcTransport
27
+ _transport_registry["grpc_asyncio"] = DeveloperKnowledgeGrpcAsyncIOTransport
28
+ _transport_registry["rest"] = DeveloperKnowledgeRestTransport
29
+
30
+ __all__ = (
31
+ "DeveloperKnowledgeTransport",
32
+ "DeveloperKnowledgeGrpcTransport",
33
+ "DeveloperKnowledgeGrpcAsyncIOTransport",
34
+ "DeveloperKnowledgeRestTransport",
35
+ "DeveloperKnowledgeRestInterceptor",
36
+ )
@@ -0,0 +1,227 @@
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 abc
17
+ from typing import Awaitable, Callable, Dict, Optional, Sequence, Union
18
+
19
+ import google.api_core
20
+ import google.auth # type: ignore
21
+ import google.protobuf
22
+ from google.api_core import exceptions as core_exceptions
23
+ from google.api_core import gapic_v1
24
+ from google.api_core import retry as retries
25
+ from google.auth import credentials as ga_credentials # type: ignore
26
+ from google.oauth2 import service_account # type: ignore
27
+
28
+ from google.developer_knowledge_v1 import gapic_version as package_version
29
+ from google.developer_knowledge_v1.types import developerknowledge
30
+
31
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
32
+ gapic_version=package_version.__version__
33
+ )
34
+
35
+ if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER
36
+ DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__
37
+
38
+
39
+ class DeveloperKnowledgeTransport(abc.ABC):
40
+ """Abstract transport class for DeveloperKnowledge."""
41
+
42
+ AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",)
43
+
44
+ DEFAULT_HOST: str = "developerknowledge.googleapis.com"
45
+
46
+ def __init__(
47
+ self,
48
+ *,
49
+ host: str = DEFAULT_HOST,
50
+ credentials: Optional[ga_credentials.Credentials] = None,
51
+ credentials_file: Optional[str] = None,
52
+ scopes: Optional[Sequence[str]] = None,
53
+ quota_project_id: Optional[str] = None,
54
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
55
+ always_use_jwt_access: Optional[bool] = False,
56
+ api_audience: Optional[str] = None,
57
+ **kwargs,
58
+ ) -> None:
59
+ """Instantiate the transport.
60
+
61
+ Args:
62
+ host (Optional[str]):
63
+ The hostname to connect to (default: 'developerknowledge.googleapis.com').
64
+ credentials (Optional[google.auth.credentials.Credentials]): The
65
+ authorization credentials to attach to requests. These
66
+ credentials identify the application to the service; if none
67
+ are specified, the client will attempt to ascertain the
68
+ credentials from the environment.
69
+ credentials_file (Optional[str]): Deprecated. A file with credentials that can
70
+ be loaded with :func:`google.auth.load_credentials_from_file`.
71
+ This argument is mutually exclusive with credentials. This argument will be
72
+ removed in the next major version of this library.
73
+ scopes (Optional[Sequence[str]]): A list of scopes.
74
+ quota_project_id (Optional[str]): An optional project to use for billing
75
+ and quota.
76
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
77
+ The client info used to send a user-agent string along with
78
+ API requests. If ``None``, then default info will be used.
79
+ Generally, you only need to set this if you're developing
80
+ your own client library.
81
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
82
+ be used for service account credentials.
83
+ api_audience (Optional[str]): The intended audience for the API calls
84
+ to the service that will be set when using certain 3rd party
85
+ authentication flows. Audience is typically a resource identifier.
86
+ If not set, the host value will be used as a default.
87
+ """
88
+
89
+ # Save the scopes.
90
+ self._scopes = scopes
91
+ if not hasattr(self, "_ignore_credentials"):
92
+ self._ignore_credentials: bool = False
93
+
94
+ # If no credentials are provided, then determine the appropriate
95
+ # defaults.
96
+ if credentials and credentials_file:
97
+ raise core_exceptions.DuplicateCredentialArgs(
98
+ "'credentials_file' and 'credentials' are mutually exclusive"
99
+ )
100
+
101
+ if credentials_file is not None:
102
+ credentials, _ = google.auth.load_credentials_from_file(
103
+ credentials_file,
104
+ scopes=scopes,
105
+ quota_project_id=quota_project_id,
106
+ default_scopes=self.AUTH_SCOPES,
107
+ )
108
+ elif credentials is None and not self._ignore_credentials:
109
+ credentials, _ = google.auth.default(
110
+ scopes=scopes,
111
+ quota_project_id=quota_project_id,
112
+ default_scopes=self.AUTH_SCOPES,
113
+ )
114
+ # Don't apply audience if the credentials file passed from user.
115
+ if hasattr(credentials, "with_gdch_audience"):
116
+ credentials = credentials.with_gdch_audience(
117
+ api_audience if api_audience else host
118
+ )
119
+
120
+ # If the credentials are service account credentials, then always try to use self signed JWT.
121
+ if (
122
+ always_use_jwt_access
123
+ and isinstance(credentials, service_account.Credentials)
124
+ and hasattr(service_account.Credentials, "with_always_use_jwt_access")
125
+ ):
126
+ credentials = credentials.with_always_use_jwt_access(True)
127
+
128
+ # Save the credentials.
129
+ self._credentials = credentials
130
+
131
+ # Save the hostname. Default to port 443 (HTTPS) if none is specified.
132
+ if ":" not in host:
133
+ host += ":443"
134
+ self._host = host
135
+
136
+ self._wrapped_methods: Dict[Callable, Callable] = {}
137
+
138
+ @property
139
+ def host(self):
140
+ return self._host
141
+
142
+ def _prep_wrapped_messages(self, client_info):
143
+ # Precompute the wrapped methods.
144
+ self._wrapped_methods = {
145
+ self.search_document_chunks: gapic_v1.method.wrap_method(
146
+ self.search_document_chunks,
147
+ default_timeout=None,
148
+ client_info=client_info,
149
+ ),
150
+ self.get_document: gapic_v1.method.wrap_method(
151
+ self.get_document,
152
+ default_retry=retries.Retry(
153
+ initial=1.0,
154
+ maximum=10.0,
155
+ multiplier=1.3,
156
+ predicate=retries.if_exception_type(
157
+ core_exceptions.ServiceUnavailable,
158
+ ),
159
+ deadline=60.0,
160
+ ),
161
+ default_timeout=60.0,
162
+ client_info=client_info,
163
+ ),
164
+ self.batch_get_documents: gapic_v1.method.wrap_method(
165
+ self.batch_get_documents,
166
+ default_retry=retries.Retry(
167
+ initial=1.0,
168
+ maximum=10.0,
169
+ multiplier=1.3,
170
+ predicate=retries.if_exception_type(
171
+ core_exceptions.ServiceUnavailable,
172
+ ),
173
+ deadline=60.0,
174
+ ),
175
+ default_timeout=60.0,
176
+ client_info=client_info,
177
+ ),
178
+ }
179
+
180
+ def close(self):
181
+ """Closes resources associated with the transport.
182
+
183
+ .. warning::
184
+ Only call this method if the transport is NOT shared
185
+ with other clients - this may cause errors in other clients!
186
+ """
187
+ raise NotImplementedError()
188
+
189
+ @property
190
+ def search_document_chunks(
191
+ self,
192
+ ) -> Callable[
193
+ [developerknowledge.SearchDocumentChunksRequest],
194
+ Union[
195
+ developerknowledge.SearchDocumentChunksResponse,
196
+ Awaitable[developerknowledge.SearchDocumentChunksResponse],
197
+ ],
198
+ ]:
199
+ raise NotImplementedError()
200
+
201
+ @property
202
+ def get_document(
203
+ self,
204
+ ) -> Callable[
205
+ [developerknowledge.GetDocumentRequest],
206
+ Union[developerknowledge.Document, Awaitable[developerknowledge.Document]],
207
+ ]:
208
+ raise NotImplementedError()
209
+
210
+ @property
211
+ def batch_get_documents(
212
+ self,
213
+ ) -> Callable[
214
+ [developerknowledge.BatchGetDocumentsRequest],
215
+ Union[
216
+ developerknowledge.BatchGetDocumentsResponse,
217
+ Awaitable[developerknowledge.BatchGetDocumentsResponse],
218
+ ],
219
+ ]:
220
+ raise NotImplementedError()
221
+
222
+ @property
223
+ def kind(self) -> str:
224
+ raise NotImplementedError()
225
+
226
+
227
+ __all__ = ("DeveloperKnowledgeTransport",)