Refine knownledge compilation REST APIs (#17624)

This commit is contained in:
Wang Qi
2026-07-31 17:05:57 +08:00
committed by GitHub
parent 03b7b04e2c
commit 9db2e2314a
8 changed files with 76 additions and 93 deletions

View File

@@ -6955,7 +6955,7 @@ curl --request POST \
"data": [
{
"id": "b330ec2e91ec11efbc510242ac120004",
"name": "test1.txt",
"name": "test1.txt",
"size": 17966,
"type": "doc",
"parent_id": "527fa74891e811ef9c650242ac120006",
@@ -7168,7 +7168,7 @@ curl --request POST \
Success:
```json
{
{
"code": 0,
"data": {
"id": "b330ec2e91ec11efbc510242ac120004",
@@ -7709,17 +7709,16 @@ or
##### Request example
```bash
curl --request POST \
curl --request POST \
--url http://{address}/api/v1/workspaces/{workspace_id}/commits \
--header 'Content-Type: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <YOUR_API_KEY>' \
--header 'Authorization: Bearer <YOUR_API_KEY>' \
--data '{
"message": "update config files",
"files": [
{"file_id": "file_uuid", "file_name": "config.json", "operation": "modify", "content": "{\"key\": \"value\"}"},
{"file_id": "file_uuid", "file_name": "readme.md", "operation": "add", "content": "# New README"}
{"file_id": "file_uuid", "file_name": "readme.md", "operation": "add", "content": "# New README"}
]
}'
```
@@ -7732,7 +7731,7 @@ This endpoint also supports:
Each file change object supports the following fields:
| Field | Type | Required | Description |
|-------|------|----------|-------------|
|-------|------|----------|-------------|
| `file_id` | `string` | Yes | The file ID |
| `file_name` | `string` | Only for add/rename | The file name |
| `operation` | `string` | Yes | `"add"`, `"modify"`, `"delete"`, or `"rename"` |
@@ -7797,17 +7796,16 @@ Failure:
##### Request example
```bash
curl --request GET \
--url 'http://{address}/api/v1/workspaces/{workspace_id}/commits?page=1&page_size=15' \
--header 'Authorization: Bearer <YOUR_API_KEY>'
--header 'Authorization: Bearer <YOUR_API_KEY>'
```
##### Request parameters
- `"page"`: (*Query parameter*), `int`, *Optional*
Page number. Defaults to 1.
Page number. Defaults to 1.
- `"page_size"`: (*Query parameter*), `int`, *Optional*
Number of items per page. Defaults to 15.
- `"order_by"`: (*Query parameter*), `string`, *Optional*
@@ -7820,7 +7818,7 @@ Also available at:
Success:
```json
{
{
"code": 0,
"data": {
"total": 2,
@@ -7865,17 +7863,16 @@ Success:
--url http://{address}/api/v1/workspaces/{workspace_id}/commits/{commit_id} \
--header 'Authorization: Bearer <YOUR_API_KEY>'
```
```
##### Request parameters
- `"folder_id"`: (*Path parameter*), `string`, *Required*
- `"folder_id"`: (*Path parameter*), `string`, *Required*
The folder ID.
- `"commit_id"`: (*Path parameter*), `string`, *Required*
The commit ID.
#### Response
Success:
```json
@@ -7883,7 +7880,7 @@ Also available at:
"code": 0,
"data": {
"id": "commit_uuid",
"folder_id": "folder_uuid",
"folder_id": "folder_uuid",
"parent_id": null,
"message": "added config files",
"author_id": "user_uuid",
@@ -7936,17 +7933,16 @@ Failure:
--url http://{address}/api/v1/workspaces/{workspace_id}/commits/{commit_id}/files \
--header 'Authorization: Bearer <YOUR_API_KEY>'
```
```
#### Response
Success:
Success:
```json
{
"code": 0,
"data": [
{
{
"id": "item_uuid",
"file_id": "file_uuid",
"operation": "add",
@@ -7954,7 +7950,7 @@ Also available at:
"new_hash": "abcd1234",
"old_location": null,
"new_location": ".objects/abcd1234",
"old_name": null,
"old_name": null,
"new_name": null
}
]
@@ -7985,17 +7981,16 @@ Success:
##### Request example
```bash
curl --request GET \
--url 'http://{address}/api/v1/workspaces/{workspace_id}/commits/diff?from=from_commit_id&to=to_commit_id' \
--header 'Authorization: Bearer <YOUR_API_KEY>'
--header 'Authorization: Bearer <YOUR_API_KEY>'
```
##### Request parameters
- `"from"`: (*Query parameter*), `string`, *Required*
The source commit ID.
The source commit ID.
- `"to"`: (*Query parameter*), `string`, *Required*
The target commit ID.
@@ -8008,7 +8003,7 @@ Also available at:
"code": 0,
"data": [
{
"file_id": "file_uuid",
"file_id": "file_uuid",
"file_name": "config.json",
"operation": "modify",
"old_hash": "abc123",
@@ -8053,17 +8048,16 @@ Failure:
--url http://{address}/api/v1/workspaces/{workspace_id}/changes \
--header 'Authorization: Bearer <YOUR_API_KEY>'
```
```
#### Response
Success:
Success:
```json
{
"code": 0,
"data": [
{
{
"file_id": "file_uuid",
"file_name": "new.txt",
"operation": "add"
@@ -8071,7 +8065,7 @@ Also available at:
{
"file_id": "file_uuid",
"file_name": "config.json",
"operation": "modify"
"operation": "modify"
},
{
"file_id": "file_uuid",
@@ -8106,17 +8100,16 @@ Success:
--url http://{address}/api/v1/workspaces/{workspace_id}/commits/{commit_id}/tree \
--header 'Authorization: Bearer <YOUR_API_KEY>'
```
```
#### Response
Success:
Success:
```json
{
"code": 0,
"data": {
"id": "folder_uuid",
"id": "folder_uuid",
"name": "workspace_name",
"type": "folder",
"children": [
@@ -8124,7 +8117,7 @@ Also available at:
"id": "file_uuid",
"name": "config.json",
"type": "file",
"hash": "abcd1234",
"hash": "abcd1234",
"size": 1024,
"status": "1",
"location": ".objects/abcd1234"
@@ -8174,17 +8167,16 @@ Success:
--url http://{address}/api/v1/workspaces/{workspace_id}/commits/{commit_id}/files/{file_id}/content \
--header 'Authorization: Bearer <YOUR_API_KEY>'
```
```
#### Response
Success:
Success:
```json
{
"code": 0,
"data": {
"content": "file content as it existed in that commit"
"content": "file content as it existed in that commit"
}
}
```
@@ -8192,7 +8184,7 @@ Also available at:
Failure:
```json
{
{
"code": 102,
"message": "File not found in this commit"
}
@@ -8220,16 +8212,16 @@ Failure:
--url http://{address}/api/v1/workspace-files/{file_id}/versions \
--header 'Authorization: Bearer <YOUR_API_KEY>'
```
#### Response
Success:
```json
{
"code": 0,
"data": [
{
{
"commit_id": "commit_uuid",
"operation": "modify",
"hash": "def456",
@@ -8237,7 +8229,7 @@ Returns the version history for a specific file across all commits.
"message": "updated file"
},
{
"commit_id": "commit_uuid",
"commit_id": "commit_uuid",
"operation": "add",
"hash": "abc123",
"create_time": 1718100000000,