Skip to content

Commit 1a42f76

Browse files
committed
Release v0.18.0 - Add edit_document API method
1 parent 5e9a79f commit 1a42f76

12 files changed

Lines changed: 516 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## [0.18.0] - 2025-10-29
4+
5+
### Added
6+
7+
- **📝 Edit Document API**: New method to edit document metadata
8+
- `edit_document` - Update document properties
9+
310
## [0.17.0] - 2025-10-24
411

512
### Added

docs-site/docs/api-reference/documents.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,36 @@ print(f"Created: {document.id}")
4343

4444
---
4545

46+
### `edit_document`
47+
48+
```python
49+
edit_document(request: EditDocumentRequest) -> EditDocumentResponse
50+
```
51+
52+
Edit document metadata such as title.
53+
54+
**Parameters:**
55+
- `request` - EditDocumentRequest with document_id and title
56+
57+
**Returns:** `EditDocumentResponse` with updated document
58+
59+
**Example:**
60+
```python
61+
from vaiz.models import EditDocumentRequest
62+
63+
response = client.edit_document(
64+
EditDocumentRequest(
65+
document_id="doc_id",
66+
title="Updated Title"
67+
)
68+
)
69+
70+
edited_doc = response.payload.document
71+
print(f"Updated: {edited_doc.title}")
72+
```
73+
74+
---
75+
4676
### `get_documents`
4777

4878
```python
@@ -96,6 +126,32 @@ class Document:
96126

97127
---
98128

129+
### EditDocument
130+
131+
Model representing an edited document (without internal fields like map).
132+
133+
```python
134+
class EditDocument:
135+
id: str # Document ID
136+
title: str # Document title
137+
space: str # Space ID
138+
size: int # Document size in bytes
139+
contributor_ids: List[str] # List of contributor IDs
140+
archiver: Optional[str] # User who archived (if archived)
141+
followers: Dict[str, str] # Document followers
142+
archived_at: Optional[datetime] # Archive timestamp
143+
kind_id: str # ID of document scope
144+
kind: Kind # Document scope (Space/Member/Project)
145+
creator: str # Creator user ID
146+
created_at: datetime # Creation timestamp
147+
updated_at: datetime # Last update timestamp
148+
bucket: str # Storage bucket ID
149+
content: Optional[str] # Document content (encoded)
150+
content_updated_at: Optional[datetime] # Content update timestamp
151+
```
152+
153+
---
154+
99155
## Request Models
100156

101157
### CreateDocumentRequest
@@ -111,6 +167,16 @@ class CreateDocumentRequest:
111167

112168
---
113169

170+
### EditDocumentRequest
171+
172+
```python
173+
class EditDocumentRequest:
174+
document_id: str # Required - Document ID to edit
175+
title: str # Required - New document title
176+
```
177+
178+
---
179+
114180
## Response Models
115181

116182
### CreateDocumentResponse
@@ -132,6 +198,25 @@ class CreateDocumentPayload:
132198

133199
---
134200

201+
### EditDocumentResponse
202+
203+
```python
204+
class EditDocumentResponse:
205+
payload: EditDocumentPayload # Response payload
206+
type: str # Response type ("EditDocument")
207+
```
208+
209+
---
210+
211+
### EditDocumentPayload
212+
213+
```python
214+
class EditDocumentPayload:
215+
document: EditDocument # Edited document
216+
```
217+
218+
---
219+
135220
### GetDocumentsRequest
136221

137222
```python

docs-site/docs/guides/documents.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,65 @@ root_doc = create_doc_tree(client, project_id)
260260
print(f"\n✅ Created documentation tree with root: {root_doc.id}")
261261
```
262262

263+
## Editing Documents
264+
265+
Update document metadata such as title:
266+
267+
```python
268+
from vaiz.models import EditDocumentRequest
269+
270+
# Edit document title
271+
response = client.edit_document(
272+
EditDocumentRequest(
273+
document_id="document_id",
274+
title="Updated Document Title"
275+
)
276+
)
277+
278+
edited_doc = response.payload.document
279+
print(f"✅ Updated document: {edited_doc.title}")
280+
```
281+
282+
### Complete Edit Workflow
283+
284+
Create, edit, and verify document changes:
285+
286+
```python
287+
from vaiz import CreateDocumentRequest, EditDocumentRequest, GetDocumentsRequest, Kind
288+
289+
# 1. Create document
290+
create_response = client.create_document(
291+
CreateDocumentRequest(
292+
kind=Kind.Project,
293+
kind_id=project_id,
294+
title="Initial Title",
295+
index=0
296+
)
297+
)
298+
299+
doc_id = create_response.payload.document.id
300+
print(f"Created: {create_response.payload.document.title}")
301+
302+
# 2. Edit document title
303+
edit_response = client.edit_document(
304+
EditDocumentRequest(
305+
document_id=doc_id,
306+
title="Updated Title"
307+
)
308+
)
309+
310+
print(f"Updated: {edit_response.payload.document.title}")
311+
312+
# 3. Verify change in document list
313+
docs = client.get_documents(
314+
GetDocumentsRequest(kind=Kind.Project, kind_id=project_id)
315+
)
316+
317+
updated_doc = next((d for d in docs.payload.documents if d.id == doc_id), None)
318+
if updated_doc:
319+
print(f"✅ Verified: {updated_doc.title}")
320+
```
321+
263322
## Working with Document Content
264323

265324
In addition to listing and creating documents, you can work with their content using document API methods.

docs-site/docs/patterns/ready-to-run.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ The SDK includes a collection of ready-to-run examples in the [`/examples`](http
3131
### Basic Operations
3232
- **`get_documents.py`** - List documents by scope (Space/Member/Project)
3333
- **`create_document.py`** - Create new documents
34+
- **`edit_document.py`** - Edit document metadata (e.g., title)
3435
- **`get_document.py`** - Get single document
3536
- **`replace_document.py`** - Replace document content with plain text
3637
- **`replace_json_document.py`** - Replace document content with rich JSON (document structure format)

docs-site/docusaurus.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,8 @@ const config: Config = {
206206
},
207207
items: [
208208
{
209-
label: "v0.17.0",
210-
href: "https://pypi.org/project/vaiz-sdk/0.17.0/",
209+
label: "v0.18.0",
210+
href: "https://pypi.org/project/vaiz-sdk/0.18.0/",
211211
position: "left",
212212
},
213213
{

examples/edit_document.py

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
"""
2+
Edit Document Example
3+
4+
This example demonstrates how to edit a document's title using the editDocument API.
5+
It shows the complete workflow:
6+
1. Creating a new document
7+
2. Editing the document title
8+
3. Verifying the change
9+
"""
10+
11+
from datetime import datetime
12+
from vaiz import VaizClient, CreateDocumentRequest, EditDocumentRequest, GetDocumentsRequest, Kind
13+
from config import API_KEY, SPACE_ID
14+
15+
16+
def main():
17+
# Initialize client
18+
client = VaizClient(api_key=API_KEY, space_id=SPACE_ID, verify_ssl=False)
19+
20+
print("=== Edit Document Example ===\n")
21+
22+
# 1. Create a new document
23+
print("1. Creating a new document...")
24+
original_title = f"Test Document - {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}"
25+
26+
create_request = CreateDocumentRequest(
27+
kind=Kind.Space,
28+
kind_id=SPACE_ID,
29+
title=original_title,
30+
index=0
31+
)
32+
33+
create_response = client.create_document(create_request)
34+
document = create_response.payload.document
35+
36+
print(f"✅ Created document:")
37+
print(f" ID: {document.id}")
38+
print(f" Title: {document.title}")
39+
print(f" Kind: {document.kind}")
40+
print(f" Size: {document.size} bytes\n")
41+
42+
# 2. Edit document title
43+
print("2. Editing document title...")
44+
new_title = f"Updated Document - {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}"
45+
46+
edit_request = EditDocumentRequest(
47+
document_id=document.id,
48+
title=new_title
49+
)
50+
51+
edit_response = client.edit_document(edit_request)
52+
edited_document = edit_response.payload.document
53+
54+
print(f"✅ Edited document:")
55+
print(f" ID: {edited_document.id}")
56+
print(f" Old Title: {original_title}")
57+
print(f" New Title: {edited_document.title}")
58+
print(f" Updated At: {edited_document.updated_at}\n")
59+
60+
# 3. Verify the change
61+
print("3. Verifying title change in document list...")
62+
list_request = GetDocumentsRequest(
63+
kind=Kind.Space,
64+
kind_id=SPACE_ID
65+
)
66+
67+
list_response = client.get_documents(list_request)
68+
69+
# Find our document in the list
70+
found_document = None
71+
for doc in list_response.payload.documents:
72+
if doc.id == document.id:
73+
found_document = doc
74+
break
75+
76+
if found_document:
77+
print(f"✅ Document found in list:")
78+
print(f" ID: {found_document.id}")
79+
print(f" Title: {found_document.title}")
80+
print(f" Title matches: {found_document.title == new_title}")
81+
else:
82+
print("❌ Document not found in list")
83+
84+
print("\n=== Example completed successfully! ===")
85+
86+
87+
if __name__ == "__main__":
88+
main()
89+

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "vaiz-sdk"
3-
version = "0.17.0"
3+
version = "0.18.0"
44
description = "Official SDK for interacting with the Vaiz API"
55
authors = [{ name = "Vaiz", email = "mail@vaiz.com" }]
66
license = "MIT"

0 commit comments

Comments
 (0)