From 71274080d49fb6f746569a4d16487b947e5ecd90 Mon Sep 17 00:00:00 2001 From: "Joseph T. French" Date: Thu, 2 Apr 2026 18:38:26 -0500 Subject: [PATCH] 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. --- .../api/documents/delete_document.py | 8 +- .../api/documents/get_document.py | 182 +++++++++++++++ .../api/documents/list_documents.py | 8 +- .../api/documents/update_document.py | 204 ++++++++++++++++ .../api/documents/upload_document.py | 8 +- .../api/documents/upload_documents_bulk.py | 8 +- .../extensions/document_client.py | 72 ++++++ robosystems_client/models/__init__.py | 4 + .../models/document_detail_response.py | 219 ++++++++++++++++++ .../models/document_list_item.py | 44 ++-- .../models/document_update_request.py | 145 ++++++++++++ .../models/document_upload_response.py | 8 + 12 files changed, 874 insertions(+), 36 deletions(-) create mode 100644 robosystems_client/api/documents/get_document.py create mode 100644 robosystems_client/api/documents/update_document.py create mode 100644 robosystems_client/models/document_detail_response.py create mode 100644 robosystems_client/models/document_update_request.py diff --git a/robosystems_client/api/documents/delete_document.py b/robosystems_client/api/documents/delete_document.py index 84de85c..9ba26cb 100644 --- a/robosystems_client/api/documents/delete_document.py +++ b/robosystems_client/api/documents/delete_document.py @@ -62,7 +62,7 @@ def sync_detailed( ) -> Response[Any | HTTPValidationError]: """Delete Document - Delete a document and all its sections. + Delete a document from PostgreSQL and OpenSearch. Args: graph_id (str): @@ -96,7 +96,7 @@ def sync( ) -> Any | HTTPValidationError | None: """Delete Document - Delete a document and all its sections. + Delete a document from PostgreSQL and OpenSearch. Args: graph_id (str): @@ -125,7 +125,7 @@ async def asyncio_detailed( ) -> Response[Any | HTTPValidationError]: """Delete Document - Delete a document and all its sections. + Delete a document from PostgreSQL and OpenSearch. Args: graph_id (str): @@ -157,7 +157,7 @@ async def asyncio( ) -> Any | HTTPValidationError | None: """Delete Document - Delete a document and all its sections. + Delete a document from PostgreSQL and OpenSearch. Args: graph_id (str): diff --git a/robosystems_client/api/documents/get_document.py b/robosystems_client/api/documents/get_document.py new file mode 100644 index 0000000..d6c3873 --- /dev/null +++ b/robosystems_client/api/documents/get_document.py @@ -0,0 +1,182 @@ +from http import HTTPStatus +from typing import Any +from urllib.parse import quote + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.document_detail_response import DocumentDetailResponse +from ...models.http_validation_error import HTTPValidationError +from ...types import Response + + +def _get_kwargs( + graph_id: str, + document_id: str, +) -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/v1/graphs/{graph_id}/documents/{document_id}".format( + graph_id=quote(str(graph_id), safe=""), + document_id=quote(str(document_id), safe=""), + ), + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> DocumentDetailResponse | HTTPValidationError | None: + if response.status_code == 200: + response_200 = DocumentDetailResponse.from_dict(response.json()) + + return response_200 + + if response.status_code == 422: + response_422 = HTTPValidationError.from_dict(response.json()) + + return response_422 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[DocumentDetailResponse | HTTPValidationError]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + graph_id: str, + document_id: str, + *, + client: AuthenticatedClient, +) -> Response[DocumentDetailResponse | HTTPValidationError]: + """Get Document + + Get a document with full content from PostgreSQL. + + Args: + graph_id (str): + document_id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[DocumentDetailResponse | HTTPValidationError] + """ + + kwargs = _get_kwargs( + graph_id=graph_id, + document_id=document_id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + graph_id: str, + document_id: str, + *, + client: AuthenticatedClient, +) -> DocumentDetailResponse | HTTPValidationError | None: + """Get Document + + Get a document with full content from PostgreSQL. + + Args: + graph_id (str): + document_id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + DocumentDetailResponse | HTTPValidationError + """ + + return sync_detailed( + graph_id=graph_id, + document_id=document_id, + client=client, + ).parsed + + +async def asyncio_detailed( + graph_id: str, + document_id: str, + *, + client: AuthenticatedClient, +) -> Response[DocumentDetailResponse | HTTPValidationError]: + """Get Document + + Get a document with full content from PostgreSQL. + + Args: + graph_id (str): + document_id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[DocumentDetailResponse | HTTPValidationError] + """ + + kwargs = _get_kwargs( + graph_id=graph_id, + document_id=document_id, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + graph_id: str, + document_id: str, + *, + client: AuthenticatedClient, +) -> DocumentDetailResponse | HTTPValidationError | None: + """Get Document + + Get a document with full content from PostgreSQL. + + Args: + graph_id (str): + document_id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + DocumentDetailResponse | HTTPValidationError + """ + + return ( + await asyncio_detailed( + graph_id=graph_id, + document_id=document_id, + client=client, + ) + ).parsed diff --git a/robosystems_client/api/documents/list_documents.py b/robosystems_client/api/documents/list_documents.py index c762a42..3bef6ab 100644 --- a/robosystems_client/api/documents/list_documents.py +++ b/robosystems_client/api/documents/list_documents.py @@ -76,7 +76,7 @@ def sync_detailed( ) -> Response[DocumentListResponse | HTTPValidationError]: """List Documents - List indexed documents for a graph. + List documents for a graph from PostgreSQL. Args: graph_id (str): @@ -110,7 +110,7 @@ def sync( ) -> DocumentListResponse | HTTPValidationError | None: """List Documents - List indexed documents for a graph. + List documents for a graph from PostgreSQL. Args: graph_id (str): @@ -139,7 +139,7 @@ async def asyncio_detailed( ) -> Response[DocumentListResponse | HTTPValidationError]: """List Documents - List indexed documents for a graph. + List documents for a graph from PostgreSQL. Args: graph_id (str): @@ -171,7 +171,7 @@ async def asyncio( ) -> DocumentListResponse | HTTPValidationError | None: """List Documents - List indexed documents for a graph. + List documents for a graph from PostgreSQL. Args: graph_id (str): diff --git a/robosystems_client/api/documents/update_document.py b/robosystems_client/api/documents/update_document.py new file mode 100644 index 0000000..ec62715 --- /dev/null +++ b/robosystems_client/api/documents/update_document.py @@ -0,0 +1,204 @@ +from http import HTTPStatus +from typing import Any +from urllib.parse import quote + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.document_update_request import DocumentUpdateRequest +from ...models.document_upload_response import DocumentUploadResponse +from ...models.http_validation_error import HTTPValidationError +from ...types import Response + + +def _get_kwargs( + graph_id: str, + document_id: str, + *, + body: DocumentUpdateRequest, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "put", + "url": "/v1/graphs/{graph_id}/documents/{document_id}".format( + graph_id=quote(str(graph_id), safe=""), + document_id=quote(str(document_id), safe=""), + ), + } + + _kwargs["json"] = body.to_dict() + + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> DocumentUploadResponse | HTTPValidationError | None: + if response.status_code == 200: + response_200 = DocumentUploadResponse.from_dict(response.json()) + + return response_200 + + if response.status_code == 422: + response_422 = HTTPValidationError.from_dict(response.json()) + + return response_422 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[DocumentUploadResponse | HTTPValidationError]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + graph_id: str, + document_id: str, + *, + client: AuthenticatedClient, + body: DocumentUpdateRequest, +) -> Response[DocumentUploadResponse | HTTPValidationError]: + """Update Document + + Update a document's content and/or metadata. Re-syncs to OpenSearch. + + Args: + graph_id (str): + document_id (str): + body (DocumentUpdateRequest): Update a document's metadata and/or content. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[DocumentUploadResponse | HTTPValidationError] + """ + + kwargs = _get_kwargs( + graph_id=graph_id, + document_id=document_id, + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + graph_id: str, + document_id: str, + *, + client: AuthenticatedClient, + body: DocumentUpdateRequest, +) -> DocumentUploadResponse | HTTPValidationError | None: + """Update Document + + Update a document's content and/or metadata. Re-syncs to OpenSearch. + + Args: + graph_id (str): + document_id (str): + body (DocumentUpdateRequest): Update a document's metadata and/or content. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + DocumentUploadResponse | HTTPValidationError + """ + + return sync_detailed( + graph_id=graph_id, + document_id=document_id, + client=client, + body=body, + ).parsed + + +async def asyncio_detailed( + graph_id: str, + document_id: str, + *, + client: AuthenticatedClient, + body: DocumentUpdateRequest, +) -> Response[DocumentUploadResponse | HTTPValidationError]: + """Update Document + + Update a document's content and/or metadata. Re-syncs to OpenSearch. + + Args: + graph_id (str): + document_id (str): + body (DocumentUpdateRequest): Update a document's metadata and/or content. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[DocumentUploadResponse | HTTPValidationError] + """ + + kwargs = _get_kwargs( + graph_id=graph_id, + document_id=document_id, + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + graph_id: str, + document_id: str, + *, + client: AuthenticatedClient, + body: DocumentUpdateRequest, +) -> DocumentUploadResponse | HTTPValidationError | None: + """Update Document + + Update a document's content and/or metadata. Re-syncs to OpenSearch. + + Args: + graph_id (str): + document_id (str): + body (DocumentUpdateRequest): Update a document's metadata and/or content. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + DocumentUploadResponse | HTTPValidationError + """ + + return ( + await asyncio_detailed( + graph_id=graph_id, + document_id=document_id, + client=client, + body=body, + ) + ).parsed diff --git a/robosystems_client/api/documents/upload_document.py b/robosystems_client/api/documents/upload_document.py index 54d72d8..b6916f3 100644 --- a/robosystems_client/api/documents/upload_document.py +++ b/robosystems_client/api/documents/upload_document.py @@ -72,7 +72,7 @@ def sync_detailed( ) -> Response[DocumentUploadResponse | HTTPValidationError]: """Upload Document - Upload a markdown document for text indexing. + Upload a markdown document. Stored in PostgreSQL, synced to OpenSearch. Args: graph_id (str): @@ -106,7 +106,7 @@ def sync( ) -> DocumentUploadResponse | HTTPValidationError | None: """Upload Document - Upload a markdown document for text indexing. + Upload a markdown document. Stored in PostgreSQL, synced to OpenSearch. Args: graph_id (str): @@ -135,7 +135,7 @@ async def asyncio_detailed( ) -> Response[DocumentUploadResponse | HTTPValidationError]: """Upload Document - Upload a markdown document for text indexing. + Upload a markdown document. Stored in PostgreSQL, synced to OpenSearch. Args: graph_id (str): @@ -167,7 +167,7 @@ async def asyncio( ) -> DocumentUploadResponse | HTTPValidationError | None: """Upload Document - Upload a markdown document for text indexing. + Upload a markdown document. Stored in PostgreSQL, synced to OpenSearch. Args: graph_id (str): diff --git a/robosystems_client/api/documents/upload_documents_bulk.py b/robosystems_client/api/documents/upload_documents_bulk.py index 9f2f2e7..5d17a16 100644 --- a/robosystems_client/api/documents/upload_documents_bulk.py +++ b/robosystems_client/api/documents/upload_documents_bulk.py @@ -72,7 +72,7 @@ def sync_detailed( ) -> Response[BulkDocumentUploadResponse | HTTPValidationError]: """Upload Documents Bulk - Upload multiple markdown documents for text indexing (max 50). + Upload multiple markdown documents (max 50). Args: graph_id (str): @@ -106,7 +106,7 @@ def sync( ) -> BulkDocumentUploadResponse | HTTPValidationError | None: """Upload Documents Bulk - Upload multiple markdown documents for text indexing (max 50). + Upload multiple markdown documents (max 50). Args: graph_id (str): @@ -135,7 +135,7 @@ async def asyncio_detailed( ) -> Response[BulkDocumentUploadResponse | HTTPValidationError]: """Upload Documents Bulk - Upload multiple markdown documents for text indexing (max 50). + Upload multiple markdown documents (max 50). Args: graph_id (str): @@ -167,7 +167,7 @@ async def asyncio( ) -> BulkDocumentUploadResponse | HTTPValidationError | None: """Upload Documents Bulk - Upload multiple markdown documents for text indexing (max 50). + Upload multiple markdown documents (max 50). Args: graph_id (str): diff --git a/robosystems_client/extensions/document_client.py b/robosystems_client/extensions/document_client.py index e8a2913..51b85e2 100644 --- a/robosystems_client/extensions/document_client.py +++ b/robosystems_client/extensions/document_client.py @@ -10,14 +10,18 @@ from typing import Any, Dict, List, Optional from ..api.documents.delete_document import sync_detailed as delete_document +from ..api.documents.get_document import sync_detailed as get_document from ..api.documents.list_documents import sync_detailed as list_documents +from ..api.documents.update_document import sync_detailed as update_document from ..api.documents.upload_document import sync_detailed as upload_document from ..api.documents.upload_documents_bulk import sync_detailed as upload_documents_bulk from ..api.search.get_document_section import sync_detailed as get_document_section from ..api.search.search_documents import sync_detailed as search_documents from ..client import AuthenticatedClient +from ..models.document_detail_response import DocumentDetailResponse from ..models.document_list_response import DocumentListResponse from ..models.document_section import DocumentSection +from ..models.document_update_request import DocumentUpdateRequest from ..models.bulk_document_upload_request import BulkDocumentUploadRequest from ..models.bulk_document_upload_response import BulkDocumentUploadResponse from ..models.document_upload_request import DocumentUploadRequest @@ -89,6 +93,74 @@ def upload( ) return response.parsed + def get( + self, + graph_id: str, + document_id: str, + ) -> Optional[DocumentDetailResponse]: + """Get a document with full content by ID. + + Returns the raw markdown content and metadata from PostgreSQL. + + Args: + graph_id: Target graph ID. + document_id: Document ID. + + Returns: + DocumentDetailResponse or None if not found. + """ + client = self._get_client() + response = get_document(graph_id=graph_id, document_id=document_id, client=client) + if response.status_code == HTTPStatus.NOT_FOUND: + return None + if response.status_code != HTTPStatus.OK: + raise Exception( + f"Get document failed ({response.status_code}): {response.content.decode()}" + ) + return response.parsed + + def update( + self, + graph_id: str, + document_id: str, + title: Optional[str] = None, + content: Optional[str] = None, + tags: Optional[List[str]] = UNSET, + folder: Optional[str] = UNSET, + ) -> DocumentUploadResponse: + """Update a document's content and/or metadata. + + Only provided fields are updated. Content is re-sectioned, + re-embedded, and re-indexed in OpenSearch. + + Args: + graph_id: Target graph ID. + document_id: Document ID. + title: Updated title. + content: Updated markdown content. + tags: Updated tags (None to clear, UNSET to leave unchanged). + folder: Updated folder (None to clear, UNSET to leave unchanged). + + Returns: + DocumentUploadResponse with updated section counts. + """ + body = DocumentUpdateRequest( + title=title if title is not None else UNSET, + content=content if content is not None else UNSET, + tags=tags, + folder=folder, + ) + + client = self._get_client() + response = update_document( + graph_id=graph_id, document_id=document_id, client=client, body=body + ) + if response.status_code != HTTPStatus.OK: + raise Exception( + f"Update document failed ({response.status_code}): {response.content.decode()}" + ) + return response.parsed + def upload_file( self, graph_id: str, diff --git a/robosystems_client/models/__init__.py b/robosystems_client/models/__init__.py index 5a5e645..f510bfc 100644 --- a/robosystems_client/models/__init__.py +++ b/robosystems_client/models/__init__.py @@ -113,9 +113,11 @@ DetailedTransactionsResponseDateRange, ) from .detailed_transactions_response_summary import DetailedTransactionsResponseSummary +from .document_detail_response import DocumentDetailResponse from .document_list_item import DocumentListItem from .document_list_response import DocumentListResponse from .document_section import DocumentSection +from .document_update_request import DocumentUpdateRequest from .document_upload_request import DocumentUploadRequest from .document_upload_response import DocumentUploadResponse from .download_quota import DownloadQuota @@ -460,9 +462,11 @@ "DetailedTransactionsResponse", "DetailedTransactionsResponseDateRange", "DetailedTransactionsResponseSummary", + "DocumentDetailResponse", "DocumentListItem", "DocumentListResponse", "DocumentSection", + "DocumentUpdateRequest", "DocumentUploadRequest", "DocumentUploadResponse", "DownloadQuota", diff --git a/robosystems_client/models/document_detail_response.py b/robosystems_client/models/document_detail_response.py new file mode 100644 index 0000000..3fbf44f --- /dev/null +++ b/robosystems_client/models/document_detail_response.py @@ -0,0 +1,219 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, cast + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="DocumentDetailResponse") + + +@_attrs_define +class DocumentDetailResponse: + """Full document detail with raw content. + + Attributes: + id (str): + graph_id (str): + user_id (str): + title (str): + content (str): + source_type (str): + sections_indexed (int): + created_at (str): + updated_at (str): + tags (list[str] | None | Unset): + folder (None | str | Unset): + external_id (None | str | Unset): + source_provider (None | str | Unset): + """ + + id: str + graph_id: str + user_id: str + title: str + content: str + source_type: str + sections_indexed: int + created_at: str + updated_at: str + tags: list[str] | None | Unset = UNSET + folder: None | str | Unset = UNSET + external_id: None | str | Unset = UNSET + source_provider: None | str | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + id = self.id + + graph_id = self.graph_id + + user_id = self.user_id + + title = self.title + + content = self.content + + source_type = self.source_type + + sections_indexed = self.sections_indexed + + created_at = self.created_at + + updated_at = self.updated_at + + tags: list[str] | None | Unset + if isinstance(self.tags, Unset): + tags = UNSET + elif isinstance(self.tags, list): + tags = self.tags + + else: + tags = self.tags + + folder: None | str | Unset + if isinstance(self.folder, Unset): + folder = UNSET + else: + folder = self.folder + + external_id: None | str | Unset + if isinstance(self.external_id, Unset): + external_id = UNSET + else: + external_id = self.external_id + + source_provider: None | str | Unset + if isinstance(self.source_provider, Unset): + source_provider = UNSET + else: + source_provider = self.source_provider + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "id": id, + "graph_id": graph_id, + "user_id": user_id, + "title": title, + "content": content, + "source_type": source_type, + "sections_indexed": sections_indexed, + "created_at": created_at, + "updated_at": updated_at, + } + ) + if tags is not UNSET: + field_dict["tags"] = tags + if folder is not UNSET: + field_dict["folder"] = folder + if external_id is not UNSET: + field_dict["external_id"] = external_id + if source_provider is not UNSET: + field_dict["source_provider"] = source_provider + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + id = d.pop("id") + + graph_id = d.pop("graph_id") + + user_id = d.pop("user_id") + + title = d.pop("title") + + content = d.pop("content") + + source_type = d.pop("source_type") + + sections_indexed = d.pop("sections_indexed") + + created_at = d.pop("created_at") + + updated_at = d.pop("updated_at") + + def _parse_tags(data: object) -> list[str] | None | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + tags_type_0 = cast(list[str], data) + + return tags_type_0 + except (TypeError, ValueError, AttributeError, KeyError): + pass + return cast(list[str] | None | Unset, data) + + tags = _parse_tags(d.pop("tags", UNSET)) + + def _parse_folder(data: object) -> None | str | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(None | str | Unset, data) + + folder = _parse_folder(d.pop("folder", UNSET)) + + def _parse_external_id(data: object) -> None | str | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(None | str | Unset, data) + + external_id = _parse_external_id(d.pop("external_id", UNSET)) + + def _parse_source_provider(data: object) -> None | str | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(None | str | Unset, data) + + source_provider = _parse_source_provider(d.pop("source_provider", UNSET)) + + document_detail_response = cls( + id=id, + graph_id=graph_id, + user_id=user_id, + title=title, + content=content, + source_type=source_type, + sections_indexed=sections_indexed, + created_at=created_at, + updated_at=updated_at, + tags=tags, + folder=folder, + external_id=external_id, + source_provider=source_provider, + ) + + document_detail_response.additional_properties = d + return document_detail_response + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/robosystems_client/models/document_list_item.py b/robosystems_client/models/document_list_item.py index 60409d5..1fe7a1b 100644 --- a/robosystems_client/models/document_list_item.py +++ b/robosystems_client/models/document_list_item.py @@ -16,29 +16,39 @@ class DocumentListItem: """A document in the document list. Attributes: + id (str): document_title (str): section_count (int): source_type (str): + created_at (str): + updated_at (str): folder (None | str | Unset): tags (list[str] | None | Unset): - last_indexed (None | str | Unset): """ + id: str document_title: str section_count: int source_type: str + created_at: str + updated_at: str folder: None | str | Unset = UNSET tags: list[str] | None | Unset = UNSET - last_indexed: None | str | Unset = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: + id = self.id + document_title = self.document_title section_count = self.section_count source_type = self.source_type + created_at = self.created_at + + updated_at = self.updated_at + folder: None | str | Unset if isinstance(self.folder, Unset): folder = UNSET @@ -54,39 +64,40 @@ def to_dict(self) -> dict[str, Any]: else: tags = self.tags - last_indexed: None | str | Unset - if isinstance(self.last_indexed, Unset): - last_indexed = UNSET - else: - last_indexed = self.last_indexed - field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( { + "id": id, "document_title": document_title, "section_count": section_count, "source_type": source_type, + "created_at": created_at, + "updated_at": updated_at, } ) if folder is not UNSET: field_dict["folder"] = folder if tags is not UNSET: field_dict["tags"] = tags - if last_indexed is not UNSET: - field_dict["last_indexed"] = last_indexed return field_dict @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: d = dict(src_dict) + id = d.pop("id") + document_title = d.pop("document_title") section_count = d.pop("section_count") source_type = d.pop("source_type") + created_at = d.pop("created_at") + + updated_at = d.pop("updated_at") + def _parse_folder(data: object) -> None | str | Unset: if data is None: return data @@ -113,22 +124,15 @@ def _parse_tags(data: object) -> list[str] | None | Unset: tags = _parse_tags(d.pop("tags", UNSET)) - def _parse_last_indexed(data: object) -> None | str | Unset: - if data is None: - return data - if isinstance(data, Unset): - return data - return cast(None | str | Unset, data) - - last_indexed = _parse_last_indexed(d.pop("last_indexed", UNSET)) - document_list_item = cls( + id=id, document_title=document_title, section_count=section_count, source_type=source_type, + created_at=created_at, + updated_at=updated_at, folder=folder, tags=tags, - last_indexed=last_indexed, ) document_list_item.additional_properties = d diff --git a/robosystems_client/models/document_update_request.py b/robosystems_client/models/document_update_request.py new file mode 100644 index 0000000..abf42f2 --- /dev/null +++ b/robosystems_client/models/document_update_request.py @@ -0,0 +1,145 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, cast + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="DocumentUpdateRequest") + + +@_attrs_define +class DocumentUpdateRequest: + """Update a document's metadata and/or content. + + Attributes: + title (None | str | Unset): + content (None | str | Unset): + tags (list[str] | None | Unset): + folder (None | str | Unset): + """ + + title: None | str | Unset = UNSET + content: None | str | Unset = UNSET + tags: list[str] | None | Unset = UNSET + folder: None | str | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + title: None | str | Unset + if isinstance(self.title, Unset): + title = UNSET + else: + title = self.title + + content: None | str | Unset + if isinstance(self.content, Unset): + content = UNSET + else: + content = self.content + + tags: list[str] | None | Unset + if isinstance(self.tags, Unset): + tags = UNSET + elif isinstance(self.tags, list): + tags = self.tags + + else: + tags = self.tags + + folder: None | str | Unset + if isinstance(self.folder, Unset): + folder = UNSET + else: + folder = self.folder + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if title is not UNSET: + field_dict["title"] = title + if content is not UNSET: + field_dict["content"] = content + if tags is not UNSET: + field_dict["tags"] = tags + if folder is not UNSET: + field_dict["folder"] = folder + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + + def _parse_title(data: object) -> None | str | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(None | str | Unset, data) + + title = _parse_title(d.pop("title", UNSET)) + + def _parse_content(data: object) -> None | str | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(None | str | Unset, data) + + content = _parse_content(d.pop("content", UNSET)) + + def _parse_tags(data: object) -> list[str] | None | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, list): + raise TypeError() + tags_type_0 = cast(list[str], data) + + return tags_type_0 + except (TypeError, ValueError, AttributeError, KeyError): + pass + return cast(list[str] | None | Unset, data) + + tags = _parse_tags(d.pop("tags", UNSET)) + + def _parse_folder(data: object) -> None | str | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(None | str | Unset, data) + + folder = _parse_folder(d.pop("folder", UNSET)) + + document_update_request = cls( + title=title, + content=content, + tags=tags, + folder=folder, + ) + + document_update_request.additional_properties = d + return document_update_request + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/robosystems_client/models/document_upload_response.py b/robosystems_client/models/document_upload_response.py index f22d1ce..89cb565 100644 --- a/robosystems_client/models/document_upload_response.py +++ b/robosystems_client/models/document_upload_response.py @@ -14,12 +14,14 @@ class DocumentUploadResponse: """Response from document upload. Attributes: + id (str): document_id (str): sections_indexed (int): total_content_length (int): section_ids (list[str]): """ + id: str document_id: str sections_indexed: int total_content_length: int @@ -27,6 +29,8 @@ class DocumentUploadResponse: additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: + id = self.id + document_id = self.document_id sections_indexed = self.sections_indexed @@ -39,6 +43,7 @@ def to_dict(self) -> dict[str, Any]: field_dict.update(self.additional_properties) field_dict.update( { + "id": id, "document_id": document_id, "sections_indexed": sections_indexed, "total_content_length": total_content_length, @@ -51,6 +56,8 @@ def to_dict(self) -> dict[str, Any]: @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: d = dict(src_dict) + id = d.pop("id") + document_id = d.pop("document_id") sections_indexed = d.pop("sections_indexed") @@ -60,6 +67,7 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: section_ids = cast(list[str], d.pop("section_ids")) document_upload_response = cls( + id=id, document_id=document_id, sections_indexed=sections_indexed, total_content_length=total_content_length,