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.
- google/developer_knowledge/__init__.py +49 -0
- google/developer_knowledge/gapic_version.py +16 -0
- google/developer_knowledge/py.typed +2 -0
- google/developer_knowledge_v1/__init__.py +135 -0
- google/developer_knowledge_v1/gapic_metadata.json +73 -0
- google/developer_knowledge_v1/gapic_version.py +16 -0
- google/developer_knowledge_v1/py.typed +2 -0
- google/developer_knowledge_v1/services/__init__.py +15 -0
- google/developer_knowledge_v1/services/developer_knowledge/__init__.py +22 -0
- google/developer_knowledge_v1/services/developer_knowledge/async_client.py +642 -0
- google/developer_knowledge_v1/services/developer_knowledge/client.py +1067 -0
- google/developer_knowledge_v1/services/developer_knowledge/pagers.py +201 -0
- google/developer_knowledge_v1/services/developer_knowledge/transports/__init__.py +36 -0
- google/developer_knowledge_v1/services/developer_knowledge/transports/base.py +227 -0
- google/developer_knowledge_v1/services/developer_knowledge/transports/grpc.py +449 -0
- google/developer_knowledge_v1/services/developer_knowledge/transports/grpc_asyncio.py +502 -0
- google/developer_knowledge_v1/services/developer_knowledge/transports/rest.py +855 -0
- google/developer_knowledge_v1/services/developer_knowledge/transports/rest_base.py +236 -0
- google/developer_knowledge_v1/types/__init__.py +36 -0
- google/developer_knowledge_v1/types/developerknowledge.py +413 -0
- google_developer_knowledge-0.1.0.dist-info/METADATA +240 -0
- google_developer_knowledge-0.1.0.dist-info/RECORD +25 -0
- google_developer_knowledge-0.1.0.dist-info/WHEEL +5 -0
- google_developer_knowledge-0.1.0.dist-info/licenses/LICENSE +202 -0
- google_developer_knowledge-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,236 @@
|
|
|
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 json # type: ignore
|
|
17
|
+
import re
|
|
18
|
+
from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union
|
|
19
|
+
|
|
20
|
+
from google.api_core import gapic_v1, path_template
|
|
21
|
+
from google.protobuf import json_format
|
|
22
|
+
|
|
23
|
+
from google.developer_knowledge_v1.types import developerknowledge
|
|
24
|
+
|
|
25
|
+
from .base import DEFAULT_CLIENT_INFO, DeveloperKnowledgeTransport
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class _BaseDeveloperKnowledgeRestTransport(DeveloperKnowledgeTransport):
|
|
29
|
+
"""Base REST backend transport for DeveloperKnowledge.
|
|
30
|
+
|
|
31
|
+
Note: This class is not meant to be used directly. Use its sync and
|
|
32
|
+
async sub-classes instead.
|
|
33
|
+
|
|
34
|
+
This class defines the same methods as the primary client, so the
|
|
35
|
+
primary client can load the underlying transport implementation
|
|
36
|
+
and call it.
|
|
37
|
+
|
|
38
|
+
It sends JSON representations of protocol buffers over HTTP/1.1
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
def __init__(
|
|
42
|
+
self,
|
|
43
|
+
*,
|
|
44
|
+
host: str = "developerknowledge.googleapis.com",
|
|
45
|
+
credentials: Optional[Any] = None,
|
|
46
|
+
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
|
|
47
|
+
always_use_jwt_access: Optional[bool] = False,
|
|
48
|
+
url_scheme: str = "https",
|
|
49
|
+
api_audience: Optional[str] = None,
|
|
50
|
+
) -> None:
|
|
51
|
+
"""Instantiate the transport.
|
|
52
|
+
Args:
|
|
53
|
+
host (Optional[str]):
|
|
54
|
+
The hostname to connect to (default: 'developerknowledge.googleapis.com').
|
|
55
|
+
credentials (Optional[Any]): The
|
|
56
|
+
authorization credentials to attach to requests. These
|
|
57
|
+
credentials identify the application to the service; if none
|
|
58
|
+
are specified, the client will attempt to ascertain the
|
|
59
|
+
credentials from the environment.
|
|
60
|
+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
|
|
61
|
+
The client info used to send a user-agent string along with
|
|
62
|
+
API requests. If ``None``, then default info will be used.
|
|
63
|
+
Generally, you only need to set this if you are developing
|
|
64
|
+
your own client library.
|
|
65
|
+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
|
|
66
|
+
be used for service account credentials.
|
|
67
|
+
url_scheme: the protocol scheme for the API endpoint. Normally
|
|
68
|
+
"https", but for testing or local servers,
|
|
69
|
+
"http" can be specified.
|
|
70
|
+
"""
|
|
71
|
+
# Run the base constructor
|
|
72
|
+
maybe_url_match = re.match("^(?P<scheme>http(?:s)?://)?(?P<host>.*)$", host)
|
|
73
|
+
if maybe_url_match is None:
|
|
74
|
+
raise ValueError(
|
|
75
|
+
f"Unexpected hostname structure: {host}"
|
|
76
|
+
) # pragma: NO COVER
|
|
77
|
+
|
|
78
|
+
url_match_items = maybe_url_match.groupdict()
|
|
79
|
+
|
|
80
|
+
host = f"{url_scheme}://{host}" if not url_match_items["scheme"] else host
|
|
81
|
+
|
|
82
|
+
super().__init__(
|
|
83
|
+
host=host,
|
|
84
|
+
credentials=credentials,
|
|
85
|
+
client_info=client_info,
|
|
86
|
+
always_use_jwt_access=always_use_jwt_access,
|
|
87
|
+
api_audience=api_audience,
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
class _BaseBatchGetDocuments:
|
|
91
|
+
def __hash__(self): # pragma: NO COVER
|
|
92
|
+
return NotImplementedError("__hash__ must be implemented.")
|
|
93
|
+
|
|
94
|
+
__REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {
|
|
95
|
+
"names": "",
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
@classmethod
|
|
99
|
+
def _get_unset_required_fields(cls, message_dict):
|
|
100
|
+
return {
|
|
101
|
+
k: v
|
|
102
|
+
for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items()
|
|
103
|
+
if k not in message_dict
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
@staticmethod
|
|
107
|
+
def _get_http_options():
|
|
108
|
+
http_options: List[Dict[str, str]] = [
|
|
109
|
+
{
|
|
110
|
+
"method": "get",
|
|
111
|
+
"uri": "/v1/documents:batchGet",
|
|
112
|
+
},
|
|
113
|
+
]
|
|
114
|
+
return http_options
|
|
115
|
+
|
|
116
|
+
@staticmethod
|
|
117
|
+
def _get_transcoded_request(http_options, request):
|
|
118
|
+
pb_request = developerknowledge.BatchGetDocumentsRequest.pb(request)
|
|
119
|
+
transcoded_request = path_template.transcode(http_options, pb_request)
|
|
120
|
+
return transcoded_request
|
|
121
|
+
|
|
122
|
+
@staticmethod
|
|
123
|
+
def _get_query_params_json(transcoded_request):
|
|
124
|
+
query_params = json.loads(
|
|
125
|
+
json_format.MessageToJson(
|
|
126
|
+
transcoded_request["query_params"],
|
|
127
|
+
use_integers_for_enums=True,
|
|
128
|
+
)
|
|
129
|
+
)
|
|
130
|
+
query_params.update(
|
|
131
|
+
_BaseDeveloperKnowledgeRestTransport._BaseBatchGetDocuments._get_unset_required_fields(
|
|
132
|
+
query_params
|
|
133
|
+
)
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
query_params["$alt"] = "json;enum-encoding=int"
|
|
137
|
+
return query_params
|
|
138
|
+
|
|
139
|
+
class _BaseGetDocument:
|
|
140
|
+
def __hash__(self): # pragma: NO COVER
|
|
141
|
+
return NotImplementedError("__hash__ must be implemented.")
|
|
142
|
+
|
|
143
|
+
__REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {}
|
|
144
|
+
|
|
145
|
+
@classmethod
|
|
146
|
+
def _get_unset_required_fields(cls, message_dict):
|
|
147
|
+
return {
|
|
148
|
+
k: v
|
|
149
|
+
for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items()
|
|
150
|
+
if k not in message_dict
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
@staticmethod
|
|
154
|
+
def _get_http_options():
|
|
155
|
+
http_options: List[Dict[str, str]] = [
|
|
156
|
+
{
|
|
157
|
+
"method": "get",
|
|
158
|
+
"uri": "/v1/{name=documents/**}",
|
|
159
|
+
},
|
|
160
|
+
]
|
|
161
|
+
return http_options
|
|
162
|
+
|
|
163
|
+
@staticmethod
|
|
164
|
+
def _get_transcoded_request(http_options, request):
|
|
165
|
+
pb_request = developerknowledge.GetDocumentRequest.pb(request)
|
|
166
|
+
transcoded_request = path_template.transcode(http_options, pb_request)
|
|
167
|
+
return transcoded_request
|
|
168
|
+
|
|
169
|
+
@staticmethod
|
|
170
|
+
def _get_query_params_json(transcoded_request):
|
|
171
|
+
query_params = json.loads(
|
|
172
|
+
json_format.MessageToJson(
|
|
173
|
+
transcoded_request["query_params"],
|
|
174
|
+
use_integers_for_enums=True,
|
|
175
|
+
)
|
|
176
|
+
)
|
|
177
|
+
query_params.update(
|
|
178
|
+
_BaseDeveloperKnowledgeRestTransport._BaseGetDocument._get_unset_required_fields(
|
|
179
|
+
query_params
|
|
180
|
+
)
|
|
181
|
+
)
|
|
182
|
+
|
|
183
|
+
query_params["$alt"] = "json;enum-encoding=int"
|
|
184
|
+
return query_params
|
|
185
|
+
|
|
186
|
+
class _BaseSearchDocumentChunks:
|
|
187
|
+
def __hash__(self): # pragma: NO COVER
|
|
188
|
+
return NotImplementedError("__hash__ must be implemented.")
|
|
189
|
+
|
|
190
|
+
__REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {
|
|
191
|
+
"query": "",
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
@classmethod
|
|
195
|
+
def _get_unset_required_fields(cls, message_dict):
|
|
196
|
+
return {
|
|
197
|
+
k: v
|
|
198
|
+
for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items()
|
|
199
|
+
if k not in message_dict
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
@staticmethod
|
|
203
|
+
def _get_http_options():
|
|
204
|
+
http_options: List[Dict[str, str]] = [
|
|
205
|
+
{
|
|
206
|
+
"method": "get",
|
|
207
|
+
"uri": "/v1/documents:searchDocumentChunks",
|
|
208
|
+
},
|
|
209
|
+
]
|
|
210
|
+
return http_options
|
|
211
|
+
|
|
212
|
+
@staticmethod
|
|
213
|
+
def _get_transcoded_request(http_options, request):
|
|
214
|
+
pb_request = developerknowledge.SearchDocumentChunksRequest.pb(request)
|
|
215
|
+
transcoded_request = path_template.transcode(http_options, pb_request)
|
|
216
|
+
return transcoded_request
|
|
217
|
+
|
|
218
|
+
@staticmethod
|
|
219
|
+
def _get_query_params_json(transcoded_request):
|
|
220
|
+
query_params = json.loads(
|
|
221
|
+
json_format.MessageToJson(
|
|
222
|
+
transcoded_request["query_params"],
|
|
223
|
+
use_integers_for_enums=True,
|
|
224
|
+
)
|
|
225
|
+
)
|
|
226
|
+
query_params.update(
|
|
227
|
+
_BaseDeveloperKnowledgeRestTransport._BaseSearchDocumentChunks._get_unset_required_fields(
|
|
228
|
+
query_params
|
|
229
|
+
)
|
|
230
|
+
)
|
|
231
|
+
|
|
232
|
+
query_params["$alt"] = "json;enum-encoding=int"
|
|
233
|
+
return query_params
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
__all__ = ("_BaseDeveloperKnowledgeRestTransport",)
|
|
@@ -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 .developerknowledge import (
|
|
17
|
+
BatchGetDocumentsRequest,
|
|
18
|
+
BatchGetDocumentsResponse,
|
|
19
|
+
Document,
|
|
20
|
+
DocumentChunk,
|
|
21
|
+
DocumentView,
|
|
22
|
+
GetDocumentRequest,
|
|
23
|
+
SearchDocumentChunksRequest,
|
|
24
|
+
SearchDocumentChunksResponse,
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
__all__ = (
|
|
28
|
+
"BatchGetDocumentsRequest",
|
|
29
|
+
"BatchGetDocumentsResponse",
|
|
30
|
+
"Document",
|
|
31
|
+
"DocumentChunk",
|
|
32
|
+
"GetDocumentRequest",
|
|
33
|
+
"SearchDocumentChunksRequest",
|
|
34
|
+
"SearchDocumentChunksResponse",
|
|
35
|
+
"DocumentView",
|
|
36
|
+
)
|
|
@@ -0,0 +1,413 @@
|
|
|
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 __future__ import annotations
|
|
17
|
+
|
|
18
|
+
from typing import MutableMapping, MutableSequence
|
|
19
|
+
|
|
20
|
+
import google.protobuf.timestamp_pb2 as timestamp_pb2 # type: ignore
|
|
21
|
+
import proto # type: ignore
|
|
22
|
+
|
|
23
|
+
__protobuf__ = proto.module(
|
|
24
|
+
package="google.developers.knowledge.v1",
|
|
25
|
+
manifest={
|
|
26
|
+
"DocumentView",
|
|
27
|
+
"Document",
|
|
28
|
+
"SearchDocumentChunksRequest",
|
|
29
|
+
"SearchDocumentChunksResponse",
|
|
30
|
+
"GetDocumentRequest",
|
|
31
|
+
"BatchGetDocumentsRequest",
|
|
32
|
+
"BatchGetDocumentsResponse",
|
|
33
|
+
"DocumentChunk",
|
|
34
|
+
},
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class DocumentView(proto.Enum):
|
|
39
|
+
r"""Specifies which fields of the
|
|
40
|
+
[Document][google.developers.knowledge.v1.Document] are included.
|
|
41
|
+
|
|
42
|
+
Values:
|
|
43
|
+
DOCUMENT_VIEW_UNSPECIFIED (0):
|
|
44
|
+
The default / unset value. See each API method for its
|
|
45
|
+
default value if
|
|
46
|
+
[DocumentView][google.developers.knowledge.v1.DocumentView]
|
|
47
|
+
is not specified.
|
|
48
|
+
DOCUMENT_VIEW_BASIC (1):
|
|
49
|
+
Includes only the basic metadata fields:
|
|
50
|
+
|
|
51
|
+
- ``name``
|
|
52
|
+
- ``uri``
|
|
53
|
+
- ``data_source``
|
|
54
|
+
- ``title``
|
|
55
|
+
- ``description``
|
|
56
|
+
- ``update_time``
|
|
57
|
+
- ``view``
|
|
58
|
+
|
|
59
|
+
This is the default of view for
|
|
60
|
+
[DeveloperKnowledge.SearchDocumentChunks][google.developers.knowledge.v1.DeveloperKnowledge.SearchDocumentChunks].
|
|
61
|
+
DOCUMENT_VIEW_FULL (2):
|
|
62
|
+
Includes all
|
|
63
|
+
[Document][google.developers.knowledge.v1.Document] fields.
|
|
64
|
+
DOCUMENT_VIEW_CONTENT (3):
|
|
65
|
+
Includes the ``DOCUMENT_VIEW_BASIC`` fields and the
|
|
66
|
+
``content`` field.
|
|
67
|
+
|
|
68
|
+
This is the default of view for
|
|
69
|
+
[DeveloperKnowledge.GetDocument][google.developers.knowledge.v1.DeveloperKnowledge.GetDocument]
|
|
70
|
+
and
|
|
71
|
+
[DeveloperKnowledge.BatchGetDocuments][google.developers.knowledge.v1.DeveloperKnowledge.BatchGetDocuments].
|
|
72
|
+
"""
|
|
73
|
+
|
|
74
|
+
DOCUMENT_VIEW_UNSPECIFIED = 0
|
|
75
|
+
DOCUMENT_VIEW_BASIC = 1
|
|
76
|
+
DOCUMENT_VIEW_FULL = 2
|
|
77
|
+
DOCUMENT_VIEW_CONTENT = 3
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
class Document(proto.Message):
|
|
81
|
+
r"""A Document represents a piece of content from the Developer
|
|
82
|
+
Knowledge corpus.
|
|
83
|
+
|
|
84
|
+
Attributes:
|
|
85
|
+
name (str):
|
|
86
|
+
Identifier. Contains the resource name of the document.
|
|
87
|
+
Format: ``documents/{uri_without_scheme}`` Example:
|
|
88
|
+
``documents/docs.cloud.google.com/storage/docs/creating-buckets``
|
|
89
|
+
uri (str):
|
|
90
|
+
Output only. Provides the URI of the content, such as
|
|
91
|
+
``docs.cloud.google.com/storage/docs/creating-buckets``.
|
|
92
|
+
content (str):
|
|
93
|
+
Output only. Contains the full content of the
|
|
94
|
+
document in Markdown format.
|
|
95
|
+
description (str):
|
|
96
|
+
Output only. Provides a description of the
|
|
97
|
+
document.
|
|
98
|
+
data_source (str):
|
|
99
|
+
Output only. Specifies the data source of the document.
|
|
100
|
+
Example data source: ``firebase.google.com``
|
|
101
|
+
title (str):
|
|
102
|
+
Output only. Provides the title of the
|
|
103
|
+
document.
|
|
104
|
+
update_time (google.protobuf.timestamp_pb2.Timestamp):
|
|
105
|
+
Output only. Represents the timestamp when
|
|
106
|
+
the content or metadata of the document was last
|
|
107
|
+
updated.
|
|
108
|
+
view (google.developer_knowledge_v1.types.DocumentView):
|
|
109
|
+
Output only. Specifies the
|
|
110
|
+
[DocumentView][google.developers.knowledge.v1.DocumentView]
|
|
111
|
+
of the document.
|
|
112
|
+
"""
|
|
113
|
+
|
|
114
|
+
name: str = proto.Field(
|
|
115
|
+
proto.STRING,
|
|
116
|
+
number=1,
|
|
117
|
+
)
|
|
118
|
+
uri: str = proto.Field(
|
|
119
|
+
proto.STRING,
|
|
120
|
+
number=2,
|
|
121
|
+
)
|
|
122
|
+
content: str = proto.Field(
|
|
123
|
+
proto.STRING,
|
|
124
|
+
number=3,
|
|
125
|
+
)
|
|
126
|
+
description: str = proto.Field(
|
|
127
|
+
proto.STRING,
|
|
128
|
+
number=4,
|
|
129
|
+
)
|
|
130
|
+
data_source: str = proto.Field(
|
|
131
|
+
proto.STRING,
|
|
132
|
+
number=5,
|
|
133
|
+
)
|
|
134
|
+
title: str = proto.Field(
|
|
135
|
+
proto.STRING,
|
|
136
|
+
number=6,
|
|
137
|
+
)
|
|
138
|
+
update_time: timestamp_pb2.Timestamp = proto.Field(
|
|
139
|
+
proto.MESSAGE,
|
|
140
|
+
number=7,
|
|
141
|
+
message=timestamp_pb2.Timestamp,
|
|
142
|
+
)
|
|
143
|
+
view: "DocumentView" = proto.Field(
|
|
144
|
+
proto.ENUM,
|
|
145
|
+
number=8,
|
|
146
|
+
enum="DocumentView",
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
class SearchDocumentChunksRequest(proto.Message):
|
|
151
|
+
r"""Request message for
|
|
152
|
+
[DeveloperKnowledge.SearchDocumentChunks][google.developers.knowledge.v1.DeveloperKnowledge.SearchDocumentChunks].
|
|
153
|
+
|
|
154
|
+
Attributes:
|
|
155
|
+
query (str):
|
|
156
|
+
Required. Provides the raw query string
|
|
157
|
+
provided by the user, such as "How to create a
|
|
158
|
+
Cloud Storage bucket?".
|
|
159
|
+
page_size (int):
|
|
160
|
+
Optional. Specifies the maximum number of results to return.
|
|
161
|
+
The service may return fewer than this value.
|
|
162
|
+
|
|
163
|
+
If unspecified, at most 5 results will be returned.
|
|
164
|
+
|
|
165
|
+
The maximum value is 20; values above 20 will result in an
|
|
166
|
+
INVALID_ARGUMENT error.
|
|
167
|
+
page_token (str):
|
|
168
|
+
Optional. Contains a page token, received from a previous
|
|
169
|
+
``SearchDocumentChunks`` call. Provide this to retrieve the
|
|
170
|
+
subsequent page.
|
|
171
|
+
filter (str):
|
|
172
|
+
Optional. Applies a strict filter to the search results. The
|
|
173
|
+
expression supports a subset of the syntax described at
|
|
174
|
+
https://google.aip.dev/160.
|
|
175
|
+
|
|
176
|
+
While ``SearchDocumentChunks`` returns
|
|
177
|
+
[DocumentChunk][google.developers.knowledge.v1.DocumentChunk]s,
|
|
178
|
+
the filter is applied to ``DocumentChunk.document`` fields.
|
|
179
|
+
|
|
180
|
+
Supported fields for filtering:
|
|
181
|
+
|
|
182
|
+
- ``data_source`` (STRING): The source of the document, e.g.
|
|
183
|
+
``docs.cloud.google.com``. See
|
|
184
|
+
https://developers.google.com/knowledge/reference/corpus-reference
|
|
185
|
+
for the complete list of data sources in the corpus.
|
|
186
|
+
- ``update_time`` (TIMESTAMP): The timestamp of when the
|
|
187
|
+
document was last meaningfully updated. A meaningful
|
|
188
|
+
update is one that changes document's markdown content or
|
|
189
|
+
metadata.
|
|
190
|
+
- ``uri`` (STRING): The document URI, e.g.
|
|
191
|
+
``https://docs.cloud.google.com/bigquery/docs/tables``.
|
|
192
|
+
|
|
193
|
+
STRING fields support ``=`` (equals) and ``!=`` (not equals)
|
|
194
|
+
operators for **exact match** on the whole string. Partial
|
|
195
|
+
match, prefix match, and regexp match are not supported.
|
|
196
|
+
|
|
197
|
+
TIMESTAMP fields support ``=``, ``<``, ``<=``, ``>``, and
|
|
198
|
+
``>=`` operators. Timestamps must be in RFC-3339 format,
|
|
199
|
+
e.g., ``"2025-01-01T00:00:00Z"``.
|
|
200
|
+
|
|
201
|
+
You can combine expressions using ``AND``, ``OR``, and
|
|
202
|
+
``NOT`` (or ``-``) logical operators. ``OR`` has higher
|
|
203
|
+
precedence than ``AND``. Use parentheses for explicit
|
|
204
|
+
precedence grouping.
|
|
205
|
+
|
|
206
|
+
Examples:
|
|
207
|
+
|
|
208
|
+
- ``data_source = "docs.cloud.google.com" OR data_source = "firebase.google.com"``
|
|
209
|
+
- ``data_source != "firebase.google.com"``
|
|
210
|
+
- ``update_time < "2024-01-01T00:00:00Z"``
|
|
211
|
+
- ``update_time >= "2025-01-22T00:00:00Z" AND (data_source = "developer.chrome.com" OR data_source = "web.dev")``
|
|
212
|
+
- ``uri = "https://docs.cloud.google.com/release-notes"``
|
|
213
|
+
|
|
214
|
+
The ``filter`` string must not exceed 500 characters; values
|
|
215
|
+
longer than 500 characters will result in an
|
|
216
|
+
``INVALID_ARGUMENT`` error.
|
|
217
|
+
"""
|
|
218
|
+
|
|
219
|
+
query: str = proto.Field(
|
|
220
|
+
proto.STRING,
|
|
221
|
+
number=1,
|
|
222
|
+
)
|
|
223
|
+
page_size: int = proto.Field(
|
|
224
|
+
proto.INT32,
|
|
225
|
+
number=2,
|
|
226
|
+
)
|
|
227
|
+
page_token: str = proto.Field(
|
|
228
|
+
proto.STRING,
|
|
229
|
+
number=3,
|
|
230
|
+
)
|
|
231
|
+
filter: str = proto.Field(
|
|
232
|
+
proto.STRING,
|
|
233
|
+
number=4,
|
|
234
|
+
)
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
class SearchDocumentChunksResponse(proto.Message):
|
|
238
|
+
r"""Response message for
|
|
239
|
+
[DeveloperKnowledge.SearchDocumentChunks][google.developers.knowledge.v1.DeveloperKnowledge.SearchDocumentChunks].
|
|
240
|
+
|
|
241
|
+
Attributes:
|
|
242
|
+
results (MutableSequence[google.developer_knowledge_v1.types.DocumentChunk]):
|
|
243
|
+
Contains the search results for the given query. Each
|
|
244
|
+
[DocumentChunk][google.developers.knowledge.v1.DocumentChunk]
|
|
245
|
+
in this list contains a snippet of content relevant to the
|
|
246
|
+
search query. Use the
|
|
247
|
+
[DocumentChunk.parent][google.developers.knowledge.v1.DocumentChunk.parent]
|
|
248
|
+
field of each result with
|
|
249
|
+
[DeveloperKnowledge.GetDocument][google.developers.knowledge.v1.DeveloperKnowledge.GetDocument]
|
|
250
|
+
or
|
|
251
|
+
[DeveloperKnowledge.BatchGetDocuments][google.developers.knowledge.v1.DeveloperKnowledge.BatchGetDocuments]
|
|
252
|
+
to retrieve the full document content.
|
|
253
|
+
next_page_token (str):
|
|
254
|
+
Optional. Provides a token that can be sent as
|
|
255
|
+
``page_token`` to retrieve the next page. If this field is
|
|
256
|
+
omitted, there are no subsequent pages.
|
|
257
|
+
"""
|
|
258
|
+
|
|
259
|
+
@property
|
|
260
|
+
def raw_page(self):
|
|
261
|
+
return self
|
|
262
|
+
|
|
263
|
+
results: MutableSequence["DocumentChunk"] = proto.RepeatedField(
|
|
264
|
+
proto.MESSAGE,
|
|
265
|
+
number=1,
|
|
266
|
+
message="DocumentChunk",
|
|
267
|
+
)
|
|
268
|
+
next_page_token: str = proto.Field(
|
|
269
|
+
proto.STRING,
|
|
270
|
+
number=2,
|
|
271
|
+
)
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
class GetDocumentRequest(proto.Message):
|
|
275
|
+
r"""Request message for
|
|
276
|
+
[DeveloperKnowledge.GetDocument][google.developers.knowledge.v1.DeveloperKnowledge.GetDocument].
|
|
277
|
+
|
|
278
|
+
Attributes:
|
|
279
|
+
name (str):
|
|
280
|
+
Required. Specifies the name of the document to retrieve.
|
|
281
|
+
Format: ``documents/{uri_without_scheme}`` Example:
|
|
282
|
+
``documents/docs.cloud.google.com/storage/docs/creating-buckets``
|
|
283
|
+
view (google.developer_knowledge_v1.types.DocumentView):
|
|
284
|
+
Optional. Specifies the
|
|
285
|
+
[DocumentView][google.developers.knowledge.v1.DocumentView]
|
|
286
|
+
of the document. If unspecified,
|
|
287
|
+
[DeveloperKnowledge.GetDocument][google.developers.knowledge.v1.DeveloperKnowledge.GetDocument]
|
|
288
|
+
defaults to ``DOCUMENT_VIEW_CONTENT``.
|
|
289
|
+
"""
|
|
290
|
+
|
|
291
|
+
name: str = proto.Field(
|
|
292
|
+
proto.STRING,
|
|
293
|
+
number=1,
|
|
294
|
+
)
|
|
295
|
+
view: "DocumentView" = proto.Field(
|
|
296
|
+
proto.ENUM,
|
|
297
|
+
number=2,
|
|
298
|
+
enum="DocumentView",
|
|
299
|
+
)
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
class BatchGetDocumentsRequest(proto.Message):
|
|
303
|
+
r"""Request message for
|
|
304
|
+
[DeveloperKnowledge.BatchGetDocuments][google.developers.knowledge.v1.DeveloperKnowledge.BatchGetDocuments].
|
|
305
|
+
|
|
306
|
+
Attributes:
|
|
307
|
+
names (MutableSequence[str]):
|
|
308
|
+
Required. Specifies the names of the documents to retrieve.
|
|
309
|
+
A maximum of 20 documents can be retrieved in a batch. The
|
|
310
|
+
documents are returned in the same order as the ``names`` in
|
|
311
|
+
the request.
|
|
312
|
+
|
|
313
|
+
Format: ``documents/{uri_without_scheme}`` Example:
|
|
314
|
+
``documents/docs.cloud.google.com/storage/docs/creating-buckets``
|
|
315
|
+
view (google.developer_knowledge_v1.types.DocumentView):
|
|
316
|
+
Optional. Specifies the
|
|
317
|
+
[DocumentView][google.developers.knowledge.v1.DocumentView]
|
|
318
|
+
of the document. If unspecified,
|
|
319
|
+
[DeveloperKnowledge.BatchGetDocuments][google.developers.knowledge.v1.DeveloperKnowledge.BatchGetDocuments]
|
|
320
|
+
defaults to ``DOCUMENT_VIEW_CONTENT``.
|
|
321
|
+
"""
|
|
322
|
+
|
|
323
|
+
names: MutableSequence[str] = proto.RepeatedField(
|
|
324
|
+
proto.STRING,
|
|
325
|
+
number=1,
|
|
326
|
+
)
|
|
327
|
+
view: "DocumentView" = proto.Field(
|
|
328
|
+
proto.ENUM,
|
|
329
|
+
number=2,
|
|
330
|
+
enum="DocumentView",
|
|
331
|
+
)
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
class BatchGetDocumentsResponse(proto.Message):
|
|
335
|
+
r"""Response message for
|
|
336
|
+
[DeveloperKnowledge.BatchGetDocuments][google.developers.knowledge.v1.DeveloperKnowledge.BatchGetDocuments].
|
|
337
|
+
|
|
338
|
+
Attributes:
|
|
339
|
+
documents (MutableSequence[google.developer_knowledge_v1.types.Document]):
|
|
340
|
+
Contains the documents requested.
|
|
341
|
+
"""
|
|
342
|
+
|
|
343
|
+
documents: MutableSequence["Document"] = proto.RepeatedField(
|
|
344
|
+
proto.MESSAGE,
|
|
345
|
+
number=1,
|
|
346
|
+
message="Document",
|
|
347
|
+
)
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
class DocumentChunk(proto.Message):
|
|
351
|
+
r"""A DocumentChunk represents a piece of content from a
|
|
352
|
+
[Document][google.developers.knowledge.v1.Document] in the
|
|
353
|
+
DeveloperKnowledge corpus. To fetch the entire document content,
|
|
354
|
+
pass the ``parent`` to
|
|
355
|
+
[DeveloperKnowledge.GetDocument][google.developers.knowledge.v1.DeveloperKnowledge.GetDocument]
|
|
356
|
+
or
|
|
357
|
+
[DeveloperKnowledge.BatchGetDocuments][google.developers.knowledge.v1.DeveloperKnowledge.BatchGetDocuments].
|
|
358
|
+
|
|
359
|
+
Attributes:
|
|
360
|
+
parent (str):
|
|
361
|
+
Output only. Contains the resource name of the document this
|
|
362
|
+
chunk is from. Format: ``documents/{uri_without_scheme}``
|
|
363
|
+
Example:
|
|
364
|
+
``documents/docs.cloud.google.com/storage/docs/creating-buckets``
|
|
365
|
+
id (str):
|
|
366
|
+
Output only. Specifies the ID of this chunk
|
|
367
|
+
within the document. The chunk ID is unique
|
|
368
|
+
within a document, but not globally unique
|
|
369
|
+
across documents. The chunk ID is not stable and
|
|
370
|
+
may change over time.
|
|
371
|
+
content (str):
|
|
372
|
+
Output only. Contains the content of the
|
|
373
|
+
document chunk.
|
|
374
|
+
document (google.developer_knowledge_v1.types.Document):
|
|
375
|
+
Output only. Represents metadata about the
|
|
376
|
+
[Document][google.developers.knowledge.v1.Document] this
|
|
377
|
+
chunk is from. The
|
|
378
|
+
[DocumentView][google.developers.knowledge.v1.DocumentView]
|
|
379
|
+
of this [Document][google.developers.knowledge.v1.Document]
|
|
380
|
+
message will be set to ``DOCUMENT_VIEW_BASIC``. It is
|
|
381
|
+
included here for convenience so that clients do not need to
|
|
382
|
+
call
|
|
383
|
+
[DeveloperKnowledge.GetDocument][google.developers.knowledge.v1.DeveloperKnowledge.GetDocument]
|
|
384
|
+
or
|
|
385
|
+
[DeveloperKnowledge.BatchGetDocuments][google.developers.knowledge.v1.DeveloperKnowledge.BatchGetDocuments]
|
|
386
|
+
if they only need the metadata fields. Otherwise, clients
|
|
387
|
+
should use
|
|
388
|
+
[DeveloperKnowledge.GetDocument][google.developers.knowledge.v1.DeveloperKnowledge.GetDocument]
|
|
389
|
+
or
|
|
390
|
+
[DeveloperKnowledge.BatchGetDocuments][google.developers.knowledge.v1.DeveloperKnowledge.BatchGetDocuments]
|
|
391
|
+
to fetch the full document content.
|
|
392
|
+
"""
|
|
393
|
+
|
|
394
|
+
parent: str = proto.Field(
|
|
395
|
+
proto.STRING,
|
|
396
|
+
number=1,
|
|
397
|
+
)
|
|
398
|
+
id: str = proto.Field(
|
|
399
|
+
proto.STRING,
|
|
400
|
+
number=2,
|
|
401
|
+
)
|
|
402
|
+
content: str = proto.Field(
|
|
403
|
+
proto.STRING,
|
|
404
|
+
number=3,
|
|
405
|
+
)
|
|
406
|
+
document: "Document" = proto.Field(
|
|
407
|
+
proto.MESSAGE,
|
|
408
|
+
number=4,
|
|
409
|
+
message="Document",
|
|
410
|
+
)
|
|
411
|
+
|
|
412
|
+
|
|
413
|
+
__all__ = tuple(sorted(__protobuf__.manifest))
|