群组 wikis API
- Tier: 专业版, 旗舰版
- Offering: JihuLab.com, 私有化部署
群组 wiki API 仅在 APIv4 中可用。也可以使用项目 wiki的 API。
列出 wiki 页面
列出给定群组的所有 wiki 页面。
plaintextGET /groups/:id/wikis
| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
| id | integer/string | Yes | 群组的 ID 或URL 编码路径。 |
| with_content | boolean | No | 包含页面内容。 |
shellcurl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/1/wikis?with_content=1"
示例响应:
json1[ 2 { 3 "content" : "Here is an instruction how to deploy this project.", 4 "format" : "markdown", 5 "slug" : "deploy", 6 "title" : "deploy", 7 "encoding": "UTF-8" 8 }, 9 { 10 "content" : "Our development process is described here.", 11 "format" : "markdown", 12 "slug" : "development", 13 "title" : "development", 14 "encoding": "UTF-8" 15 },{ 16 "content" : "* [Deploy](deploy)\n* [Development](development)", 17 "format" : "markdown", 18 "slug" : "home", 19 "title" : "home", 20 "encoding": "UTF-8" 21 } 22]
获取 wiki 页面
获取给定群组的 wiki 页面。
plaintextGET /groups/:id/wikis/:slug
| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
| id | integer/string | Yes | 群组的 ID 或URL 编码路径。 |
| slug | string | Yes | wiki 页面的 URL 编码 slug(唯一字符串),例如 dir%2Fpage_name。 |
| render_html | boolean | No | 返回 wiki 页面的渲染 HTML。 |
| version | string | No | wiki 页面版本 SHA。 |
shellcurl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/1/wikis/home"
示例响应:
json1{ 2 "content" : "home page", 3 "format" : "markdown", 4 "slug" : "home", 5 "title" : "home", 6 "encoding": "UTF-8" 7}
创建新的 wiki 页面
使用给定的标题、slug 和内容为给定的仓库创建新的 wiki 页面。
plaintextPOST /projects/:id/wikis
| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
| id | integer/string | Yes | 群组的 ID 或URL 编码路径。 |
| content | string | Yes | wiki 页面的内容。 |
| title | string | Yes | wiki 页面的标题。 |
| format | string | No | wiki 页面的格式。可用格式包括:markdown(默认)、rdoc、asciidoc 和 org。 |
shellcurl --data "format=rdoc&title=Hello&content=Hello world" \ --header "PRIVATE-TOKEN: <your_access_token>" \ "https://gitlab.example.com/api/v4/groups/1/wikis"
示例响应:
json1{ 2 "content" : "Hello world", 3 "format" : "markdown", 4 "slug" : "Hello", 5 "title" : "Hello", 6 "encoding": "UTF-8" 7}
编辑现有 wiki 页面
更新现有 wiki 页面。至少需要一个参数来更新 wiki 页面。
plaintextPUT /groups/:id/wikis/:slug
| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
| id | integer/string | Yes | 群组的 ID 或URL 编码路径。 |
| content | string | Yes, 如果没有提供 title | wiki 页面的内容。 |
| title | string | Yes, 如果没有提供 content | wiki 页面的标题。 |
| format | string | No | wiki 页面的格式。可用格式包括 markdown(默认)、rdoc、asciidoc 和 org。 |
| slug | string | Yes | wiki 页面的 URL 编码 slug(唯一字符串)。例如:dir%2Fpage_name。 |
shellcurl --request PUT --data "format=rdoc&content=documentation&title=Docs" \ --header "PRIVATE-TOKEN: <your_access_token>" \ "https://gitlab.example.com/api/v4/groups/1/wikis/foo"
示例响应:
json1{ 2 "content" : "documentation", 3 "format" : "markdown", 4 "slug" : "Docs", 5 "title" : "Docs", 6 "encoding": "UTF-8" 7}
删除 wiki 页面
删除具有给定 slug 的 wiki 页面。
plaintextDELETE /groups/:id/wikis/:slug
| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
| id | integer/string | Yes | 群组的 ID 或URL 编码路径。 |
| slug | string | Yes | wiki 页面的 URL 编码 slug(唯一字符串),例如 dir%2Fpage_name。 |
shellcurl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/1/wikis/foo"
如果成功,预计会返回一个带有空体的 204 No Content HTTP 响应。
上传附件到 wiki 仓库
将文件上传到 wiki 仓库内的附件文件夹。附件文件夹是 uploads 文件夹。
plaintextPOST /groups/:id/wikis/attachments
| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
| id | integer/string | Yes | 群组的 ID 或URL 编码路径。 |
| file | string | Yes | 要上传的附件。 |
| branch | string | No | 分支的名称。默认为 wiki 仓库默认分支。 |
要从文件系统上传文件,请使用 --form 参数。这会导致 cURL 使用头 Content-Type: multipart/form-data 发布数据。file= 参数必须指向文件系统上的文件,并以 @ 开头。例如:
shellcurl --request POST --header "PRIVATE-TOKEN: <your_access_token>" \ --form "file=@dk.png" "https://gitlab.example.com/api/v4/groups/1/wikis/attachments"
示例响应:
json1{ 2 "file_name" : "dk.png", 3 "file_path" : "uploads/6a061c4cf9f1c28cb22c384b4b8d4e3c/dk.png", 4 "branch" : "main", 5 "link" : { 6 "url" : "uploads/6a061c4cf9f1c28cb22c384b4b8d4e3c/dk.png", 7 "markdown" : "" 8 } 9}