Skip to content

Commit 7127408

Browse files
committed
Enhance document management API with new endpoints and model updates
- Updated the delete document functionality to specify deletion from PostgreSQL and OpenSearch. - Introduced new `get_document` and `update_document` endpoints for retrieving and updating document details, respectively. - Enhanced the `list_documents` endpoint to clarify that it lists documents from PostgreSQL. - Added new models: `DocumentDetailResponse` and `DocumentUpdateRequest` for handling document details and update requests. - Updated existing models to include new fields for better data representation. These changes improve the document management capabilities and provide a more comprehensive API for users.
1 parent 34d859d commit 7127408

12 files changed

Lines changed: 874 additions & 36 deletions

‎robosystems_client/api/documents/delete_document.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def sync_detailed(
6262
) -> Response[Any | HTTPValidationError]:
6363
"""Delete Document
6464
65-
Delete a document and all its sections.
65+
Delete a document from PostgreSQL and OpenSearch.
6666
6767
Args:
6868
graph_id (str):
@@ -96,7 +96,7 @@ def sync(
9696
) -> Any | HTTPValidationError | None:
9797
"""Delete Document
9898
99-
Delete a document and all its sections.
99+
Delete a document from PostgreSQL and OpenSearch.
100100
101101
Args:
102102
graph_id (str):
@@ -125,7 +125,7 @@ async def asyncio_detailed(
125125
) -> Response[Any | HTTPValidationError]:
126126
"""Delete Document
127127
128-
Delete a document and all its sections.
128+
Delete a document from PostgreSQL and OpenSearch.
129129
130130
Args:
131131
graph_id (str):
@@ -157,7 +157,7 @@ async def asyncio(
157157
) -> Any | HTTPValidationError | None:
158158
"""Delete Document
159159
160-
Delete a document and all its sections.
160+
Delete a document from PostgreSQL and OpenSearch.
161161
162162
Args:
163163
graph_id (str):
Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
from http import HTTPStatus
2+
from typing import Any
3+
from urllib.parse import quote
4+
5+
import httpx
6+
7+
from ... import errors
8+
from ...client import AuthenticatedClient, Client
9+
from ...models.document_detail_response import DocumentDetailResponse
10+
from ...models.http_validation_error import HTTPValidationError
11+
from ...types import Response
12+
13+
14+
def _get_kwargs(
15+
graph_id: str,
16+
document_id: str,
17+
) -> dict[str, Any]:
18+
_kwargs: dict[str, Any] = {
19+
"method": "get",
20+
"url": "/v1/graphs/{graph_id}/documents/{document_id}".format(
21+
graph_id=quote(str(graph_id), safe=""),
22+
document_id=quote(str(document_id), safe=""),
23+
),
24+
}
25+
26+
return _kwargs
27+
28+
29+
def _parse_response(
30+
*, client: AuthenticatedClient | Client, response: httpx.Response
31+
) -> DocumentDetailResponse | HTTPValidationError | None:
32+
if response.status_code == 200:
33+
response_200 = DocumentDetailResponse.from_dict(response.json())
34+
35+
return response_200
36+
37+
if response.status_code == 422:
38+
response_422 = HTTPValidationError.from_dict(response.json())
39+
40+
return response_422
41+
42+
if client.raise_on_unexpected_status:
43+
raise errors.UnexpectedStatus(response.status_code, response.content)
44+
else:
45+
return None
46+
47+
48+
def _build_response(
49+
*, client: AuthenticatedClient | Client, response: httpx.Response
50+
) -> Response[DocumentDetailResponse | HTTPValidationError]:
51+
return Response(
52+
status_code=HTTPStatus(response.status_code),
53+
content=response.content,
54+
headers=response.headers,
55+
parsed=_parse_response(client=client, response=response),
56+
)
57+
58+
59+
def sync_detailed(
60+
graph_id: str,
61+
document_id: str,
62+
*,
63+
client: AuthenticatedClient,
64+
) -> Response[DocumentDetailResponse | HTTPValidationError]:
65+
"""Get Document
66+
67+
Get a document with full content from PostgreSQL.
68+
69+
Args:
70+
graph_id (str):
71+
document_id (str):
72+
73+
Raises:
74+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
75+
httpx.TimeoutException: If the request takes longer than Client.timeout.
76+
77+
Returns:
78+
Response[DocumentDetailResponse | HTTPValidationError]
79+
"""
80+
81+
kwargs = _get_kwargs(
82+
graph_id=graph_id,
83+
document_id=document_id,
84+
)
85+
86+
response = client.get_httpx_client().request(
87+
**kwargs,
88+
)
89+
90+
return _build_response(client=client, response=response)
91+
92+
93+
def sync(
94+
graph_id: str,
95+
document_id: str,
96+
*,
97+
client: AuthenticatedClient,
98+
) -> DocumentDetailResponse | HTTPValidationError | None:
99+
"""Get Document
100+
101+
Get a document with full content from PostgreSQL.
102+
103+
Args:
104+
graph_id (str):
105+
document_id (str):
106+
107+
Raises:
108+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
109+
httpx.TimeoutException: If the request takes longer than Client.timeout.
110+
111+
Returns:
112+
DocumentDetailResponse | HTTPValidationError
113+
"""
114+
115+
return sync_detailed(
116+
graph_id=graph_id,
117+
document_id=document_id,
118+
client=client,
119+
).parsed
120+
121+
122+
async def asyncio_detailed(
123+
graph_id: str,
124+
document_id: str,
125+
*,
126+
client: AuthenticatedClient,
127+
) -> Response[DocumentDetailResponse | HTTPValidationError]:
128+
"""Get Document
129+
130+
Get a document with full content from PostgreSQL.
131+
132+
Args:
133+
graph_id (str):
134+
document_id (str):
135+
136+
Raises:
137+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
138+
httpx.TimeoutException: If the request takes longer than Client.timeout.
139+
140+
Returns:
141+
Response[DocumentDetailResponse | HTTPValidationError]
142+
"""
143+
144+
kwargs = _get_kwargs(
145+
graph_id=graph_id,
146+
document_id=document_id,
147+
)
148+
149+
response = await client.get_async_httpx_client().request(**kwargs)
150+
151+
return _build_response(client=client, response=response)
152+
153+
154+
async def asyncio(
155+
graph_id: str,
156+
document_id: str,
157+
*,
158+
client: AuthenticatedClient,
159+
) -> DocumentDetailResponse | HTTPValidationError | None:
160+
"""Get Document
161+
162+
Get a document with full content from PostgreSQL.
163+
164+
Args:
165+
graph_id (str):
166+
document_id (str):
167+
168+
Raises:
169+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
170+
httpx.TimeoutException: If the request takes longer than Client.timeout.
171+
172+
Returns:
173+
DocumentDetailResponse | HTTPValidationError
174+
"""
175+
176+
return (
177+
await asyncio_detailed(
178+
graph_id=graph_id,
179+
document_id=document_id,
180+
client=client,
181+
)
182+
).parsed

‎robosystems_client/api/documents/list_documents.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def sync_detailed(
7676
) -> Response[DocumentListResponse | HTTPValidationError]:
7777
"""List Documents
7878
79-
List indexed documents for a graph.
79+
List documents for a graph from PostgreSQL.
8080
8181
Args:
8282
graph_id (str):
@@ -110,7 +110,7 @@ def sync(
110110
) -> DocumentListResponse | HTTPValidationError | None:
111111
"""List Documents
112112
113-
List indexed documents for a graph.
113+
List documents for a graph from PostgreSQL.
114114
115115
Args:
116116
graph_id (str):
@@ -139,7 +139,7 @@ async def asyncio_detailed(
139139
) -> Response[DocumentListResponse | HTTPValidationError]:
140140
"""List Documents
141141
142-
List indexed documents for a graph.
142+
List documents for a graph from PostgreSQL.
143143
144144
Args:
145145
graph_id (str):
@@ -171,7 +171,7 @@ async def asyncio(
171171
) -> DocumentListResponse | HTTPValidationError | None:
172172
"""List Documents
173173
174-
List indexed documents for a graph.
174+
List documents for a graph from PostgreSQL.
175175
176176
Args:
177177
graph_id (str):

0 commit comments

Comments
 (0)