From 9b929266cb953f009b34169a986b8a42f89ade8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E6=B0=B8=E5=BC=BA?= <11704063+s-yongqiang@user.noreply.gitee.com> Date: Mon, 2 Sep 2024 14:31:05 +0800 Subject: [PATCH 1/2] Update repo-api-tokens.yaml --- api/repo-api-tokens.yaml | 347 +++++++++++++++++++++++++++++++++++---- 1 file changed, 318 insertions(+), 29 deletions(-) diff --git a/api/repo-api-tokens.yaml b/api/repo-api-tokens.yaml index 87a59e8..99d5b0c 100644 --- a/api/repo-api-tokens.yaml +++ b/api/repo-api-tokens.yaml @@ -44,6 +44,15 @@ components: type: string example: '/Folder/xx.md' + file_p: + name: p + in: query + description: 'Path to the file' + required: true + schema: + type: string + example: '/Folder/xx.md' + dir_path: name: path in: query @@ -161,22 +170,69 @@ components: commit_id: type: string - operation_file: + file_operation_create: + title: 'Create file' type: object properties: operation: type: string - enum: - - rename - - revert - - create - newname: + enum: [create] + + + file_operation_move: + title: 'Move file' + type: object + properties: + operation: + type: string + enum: [move] + dst_dir: + title: dst_dir type: string - example: '2.txt' + example: /folder + + file_operation_revert: + title: 'Revert file' + type: object + properties: + operation: + type: string + enum: [copy] commit_id: + title: dst_dir type: string - required: - - operation + example: 'fb53724f838f92b56559dbe3d86c1c1d3d01f53b' + + file_operation_rename: + title: 'Rename file' + type: object + properties: + operation: + type: string + enum: [rename] + newname: + title: 'newname' + type: string + example: 'test.md' + + file_operation_copy: + title: 'Copy file' + type: object + properties: + operation: + type: string + enum: [copy] + dst_dir: + type: string + example: '/' + + file_operation: + oneOf: + - $ref: '#/components/schemas/file_operation_create' + - $ref: '#/components/schemas/file_operation_revert' + - $ref: '#/components/schemas/file_operation_move' + - $ref: '#/components/schemas/file_operation_rename' + - $ref: '#/components/schemas/file_operation_copy' batch_copy_or_move: type: object @@ -219,6 +275,102 @@ components: success: type: boolean + operation_file_response: + title: create rename move copy + type: object + description: File information + properties: + mtime: + type: string + obj_id: + type: string + obj_name: + type: string + parent_dir: + type: string + repo_id: + type: string + size: + type: integer + type: + type: string + can_preview: + type: boolean + can_edit: + type: boolean + + move: + title: move + type: object + properties: + repo_id: + type: string + parent_dir: + type: string + obj_name: + type: string + + revert: + title: revert + type: object + properties: + success: + type: boolean + + file_lock_operation: + title: 'operation' + type: string + enum: + - lock + - unlock + example: "lock" + + share_links: + type: object + properties: + username: + type: string + repo_id: + type: string + repo_name: + type: string + path: + type: string + obj_name: + type: string + obj_id: + type: string + is_dir: + type: boolean + token: + type: string + link: + type: string + view_cnt: + type: number + ctime: + type: string + expire_date: + type: string + is_expired: + type: boolean + permissions: + type: object + properties: + can_edit: + type: boolean + can_download: + type: boolean + can_upload: + type: boolean + password: + type: string + user_scope: + type: string + can_edit: + type: boolean + + paths: /api/v2.1/repos/{repo_id}/repo-api-tokens/: get: @@ -502,17 +654,62 @@ paths: tags: - Via Repo-Token description: |- - Rename or revert or create a file + Rename or revert or create or move a file *Note: If you want to create a file, simply pass in the path* security: - RepoTokenAuth: [] parameters: - $ref: '#/components/parameters/file_path' + requestBody: + required: true + content: + multipart/form-data: + schema: + $ref: '#/components/schemas/file_operation' + responses: + '200': + description: OK + content: + application/json: + schema: + oneOf: + - $ref: '#/components/schemas/operation_file_response' + - $ref: '#/components/schemas/revert' + examples: + Create or Rename or Move or Copy file: + value: { + "type": "file", + "repo_id": "761f27e6-c198-4c93-8a06-05a3f6e1ac2f", + "parent_dir": "/folder", + "obj_name": "create", + "obj_id": "0000000000000000000000000000000000000000", + "size": 0, + "mtime": "2024-08-28T08:23:59+00:00", + "can_preview": false, + "can_edit": false + } + Revert file: + value: { + "success": true + } + + put: + tags: + - Via Repo-Token + summary: Lock/Unlock file + description: Lock or unlock the file, locked files cannot be modified + security: + - AccountTokenAuth: [] + parameters: + - $ref: '#/components/parameters/file_p' requestBody: content: application/json: schema: - $ref: '#/components/schemas/operation_file' + type: object + properties: + operation: + $ref: '#/components/schemas/file_lock_operation' responses: '200': description: OK @@ -520,36 +717,37 @@ paths: application/json: schema: type: object - description: The file information + description: Return file information properties: - type: + type: type: string - repo_id: + repo_id: type: string - parent_dir: + parent_dir: type: string obj_name: type: string - obj_id: + obj_id: type: string - size: + size: type: integer mtime: type: string can_preview: - type: string + type: boolean can_edit: - type: string + type: boolean example: - 'type': 'file' - 'repo_id': 'b8e06f24-edfe-44a3-b63b-ad9ecc59e1eb' - 'parent_dir': '/' - 'obj_name': '2.txt' - 'obj_id': '0000000000000000000000000000000000000000' - 'size': 0 - 'mtime': '2023-12-26T06:03:06+00:00' - 'can_preview': true - 'can_edit': true + type: "file" + repo_id: "eaa2b714-7993-4abc-93ce-56286d45d3de" + parent_dir: "/folder" + obj_name: "b" + obj_id: "0000000000000000000000000000000000000000" + size: 0 + mtime: "2024-03-04T15:44:56+08:00" + can_preview: true + can_edit: false + delete: summary: Delete file tags: @@ -577,6 +775,45 @@ paths: "commit_id": "d6c213abcaf50ae1f5e775eaf1808b4c80c9ed61" } + /api/v2.1/via-repo-token/move-folder-merge/: + post: + tags: + - Via Repo-Token + summary: Move directory with items merged + description: Move the directory in the current repo. + security: + - AccountTokenAuth: [] + requestBody: + content: + application/json: + schema: + type: object + properties: + src_parent_dir: + type: string + example: '/Folder' + src_dirent_name: + type: string + example: 'folder' + dst_parent_dir: + type: string + example: '/Folder/folder2' + required: + - src_parent_dir + - src_dirent_name + - dst_parent_dir + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + properties: + success: + type: boolean + description: Success state + /api/v2.1/via-repo-token/upload-link/: get: summary: Get upload link @@ -709,4 +946,56 @@ paths: schema: $ref: '#/components/schemas/ResponseSuccess' - \ No newline at end of file + + /api/v2.1/via-repo-token/share-links/: + post: + summary: Create share link + tags: + - Via Repo-Token + description: Create a sharing link for the library/folder. (For a file exists) + security: + - RepoTokenAuth: [] + requestBody: + content: + application/json: + schema: + type: object + properties: + path: + type: string + description: path of folder/file + example: "/folder" + permissions: + type: string + example: '{"can_edit":false,"can_download":false,"can_upload":false}' + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/share_links' + example: + { + "username": "Seafile@example.local", + "repo_id": "761f27e6-c198-4c93-8a06-05a3f6e1ac2f", + "repo_name": "repo", + "path": "/Folder", + "obj_name": "Folder", + "obj_id": "026f15f4643e8a74e5e2312c509908fedba48604", + "is_dir": true, + "token": "35769cb342fc43a3adf5", + "link": "http://cloud.seafile.com/d/35769cb342fc43a3adf5/", + "view_cnt": 0, + "ctime": "2024-08-29T03:48:04+00:00", + "expire_date": "", + "is_expired": false, + "permissions": { + "can_edit": false, + "can_download": false, + "can_upload": false + }, + "password": "", + "user_scope": "all_users", + "can_edit": false + } From 642884caa72d56fe60f779a4dc10911e5411c21e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E6=B0=B8=E5=BC=BA?= <11704063+s-yongqiang@user.noreply.gitee.com> Date: Mon, 9 Sep 2024 10:45:25 +0800 Subject: [PATCH 2/2] Update repo-api-tokens.yaml --- api/repo-api-tokens.yaml | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/api/repo-api-tokens.yaml b/api/repo-api-tokens.yaml index 99d5b0c..d8724fc 100644 --- a/api/repo-api-tokens.yaml +++ b/api/repo-api-tokens.yaml @@ -155,6 +155,10 @@ components: - r - rw + path: + type: string + example: '/Folder' + operation_dir: type: object properties: @@ -268,6 +272,26 @@ components: - parent_dir - dirents + share_link_permission: + type: object + description: Operation permission + properties: + can_edit: + type: boolean + enum: + - false + - true + can_download: + type: boolean + enum: + - true + - false + can_upload: + type: boolean + enum: + - true + - false + # response ResponseSuccess: type: object @@ -701,7 +725,7 @@ paths: security: - AccountTokenAuth: [] parameters: - - $ref: '#/components/parameters/file_p' + - $ref: '#/components/parameters/file_path' requestBody: content: application/json: @@ -775,7 +799,7 @@ paths: "commit_id": "d6c213abcaf50ae1f5e775eaf1808b4c80c9ed61" } - /api/v2.1/via-repo-token/move-folder-merge/: + /api/v2.1/via-repo-token/move-dir/: post: tags: - Via Repo-Token @@ -961,13 +985,10 @@ paths: schema: type: object properties: - path: - type: string - description: path of folder/file - example: "/folder" - permissions: - type: string - example: '{"can_edit":false,"can_download":false,"can_upload":false}' + permissions: + $ref: '#/components/schemas/share_link_permission' + path: + $ref: '#/components/schemas/path' responses: '200': description: OK