Skip to content

RESTful API For GitLab

Echo edited this page May 4, 2018 · 5 revisions
获取指定产品GitLab项目分支 项目类型(state_project, pillar_project)
Request
GET /saltshaker/api/v1.0/gitlab/branch?product_id=p-b4aaef1e322611e8ab56000c298454d8&project_type=state_project

Response
HTTP/1.1 200 OK
Content-Type: application/json

{
    "data": [
        "dev",
        "master"
    ],
    "status": true,
    "message": ""
}
获取指定产品GitLab项目文件及目录 path为目录结构如: a/b/c , branch为分支名
Request
GET /saltshaker/api/v1.0/gitlab/file?product_id=p-b4aaef1e322611e8ab56000c298454d8&path=vip&branch=master&project_type=state_project

Response
HTTP/1.1 200 OK
Content-Type: application/json

{
    "data": [
        {
            "title": "root/salt_sls",
            "expand": true,
            "children": [
                {
                    "title": "a",
                    "type": "tree",
                    "expand": false,
                    "children": [
                        {
                            "title": "test"
                        }
                    ]
                },
                {
                    "title": "p",
                    "type": "tree",
                    "expand": false,
                    "children": [
                        {
                            "title": "test"
                        }
                    ]
                },
                {
                    "title": "README.md",
                    "type": "blob",
                    "expand": true,
                    "path": "/README.md"
                },
                {
                    "title": "git_test.sls",
                    "type": "blob",
                    "expand": true,
                    "path": "/git_test.sls"
                },
                {
                    "title": "p_test.sls",
                    "type": "blob",
                    "expand": true,
                    "path": "/p_test.sls"
                },
                {
                    "title": "test.sls",
                    "type": "blob",
                    "expand": true,
                    "path": "/test.sls"
                },
                {
                    "title": "top.sls",
                    "type": "blob",
                    "expand": true,
                    "path": "/top.sls"
                }
            ]
        }
    ],
    "status": true,
    "message": ""
}
获取指定产品GitLab项目文件内容 path为文件路径如: a/b/c.py , branch为分支名
Request
GET /saltshaker/api/v1.0/gitlab/content?product_id=p-b4aaef1e322611e8ab56000c298454d8&path=common/views.py&branch=master&project_type=pillar_project

Response
HTTP/1.1 200 OK
Content-Type: application/json

{
    "data": "# -*- coding:utf-8 -*-\nfrom django.shortcuts import render\n",
    "status": true,
    "message": ""
}
修改增加删除指定产品GitLab项目文件 path为文件路径如: a/b/c.py , branch为分支名,action 为操作类型 create, delete, move, update
Request
POST /saltshaker/api/v1.0/gitlab/commit?product_id=p-4bc4a5b83bd011e8aa0e000c298454d8

POST Body
{
	"project_type": "pillar_project",
	"path": "top.sls",
	"branch": "master",
	"action": "update",
	"content":"base:\n  '*':\n    - common\n    - test\n"
}

Response
HTTP/1.1 200 OK
Content-Type: application/json

{
    "status": true,
    "message": ""
}