Wikis API

Wikis API

在 GitLab 10.0 中引入 .

仅在 APIv4 中可用.

获取给定项目的所有 Wiki 页面.

  1. curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/wikis?with_content=1"

响应示例:

  1. [ { "content" : "Here is an instruction how to deploy this project.", "format" : "markdown", "slug" : "deploy", "title" : "deploy" }, { "content" : "Our development process is described here.", "format" : "markdown", "slug" : "development", "title" : "development" },{ "content" : "* [Deploy](deploy)\n* [Development](development)", "format" : "markdown", "slug" : "home", "title" : "home" } ]

Get a wiki page

  1. GET /projects/:id/wikis/:slug
Attribute Type Required Description
id integer/string yes 项目的 ID 或URL 编码的路径
slug string yes Wiki 页面的段(唯一字符串)
  1. curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/wikis/home"

响应示例:

使用给定的标题,条目和内容为给定的存储库创建一个新的 Wiki 页面.

    1. curl --data "format=rdoc&title=Hello&content=Hello world" --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/wikis"

    响应示例:

    1. { "content" : "Hello world", "format" : "markdown", "slug" : "Hello", "title" : "Hello" }

    Edit an existing wiki page

    更新现有的 Wiki 页面. 至少需要一个参数才能更新 Wiki 页面.

    1. PUT /projects/:id/wikis/:slug
    Attribute Type Required Description
    id integer/string yes 项目的 ID 或URL 编码的路径
    content string 是,如果未提供title Wiki 页面的内容
    title string 是,如果未提供content 维基页面的标题
    format string no Wiki 页面的格式. 可用格式为: markdown (默认), rdocasciidocorg
    string yes Wiki 页面的段(唯一字符串)
    1. { "content" : "documentation", "format" : "markdown", "slug" : "Docs", "title" : "Docs" }

    删除带有给定子弹的 Wiki 页面.

    1. DELETE /projects/:id/wikis/:slug
    1. curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/wikis/foo"

    成功时,HTTP 状态代码为204并且不需要 JSON 响应.

    Upload an attachment to the wiki repository

    将文件上传到 Wiki 信息库中的附件文件夹. 附件文件夹是uploads文件夹.

    1. POST /projects/:id/wikis/attachments
    Attribute Type Required Description
    id integer/string yes 项目的 ID 或URL 编码的路径
    file string yes 要上传的附件
    branch string no 分支的名称. 默认为 Wiki 存储库默认分支

    要从文件系统上载文件,请使用--form参数. 这将导致 cURL 使用标题Content-Type: multipart/form-data . file=参数必须指向文件系统上的文件,并以开头. 例如:

    1. { "file_name" : "dk.png", "file_path" : "uploads/6a061c4cf9f1c28cb22c384b4b8d4e3c/dk.png", "branch" : "master", "link" : { "url" : "uploads/6a061c4cf9f1c28cb22c384b4b8d4e3c/dk.png", "markdown" : "![dk](uploads/6a061c4cf9f1c28cb22c384b4b8d4e3c/dk.png)" } }