You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
educoder/README.md

1222 lines
27 KiB

5 years ago
# API文档
---
## 基本介绍
开发API服务地址
https://testgitea.trustie.net/
5 years ago
响应状态说明:
|字段|类型|说明|
-|-|-
|status |int |响应状态码0:请求成功,-1: 请求失败|
|message |string |响应说明 |
### API接口
---
#### 用户注册(通过其他平台)
5 years ago
```
POST accounts/remote_register
5 years ago
```
*示例*
5 years ago
```
curl -X POST \
-d "email=2456233122@qq.com" \
-d "password=djs_D_00001" \
-d "username=16895620" \
-d "platform=forge" \
http://localhost:3000/api/accounts/remote_register | jq
5 years ago
```
*请求参数说明:*
|参数名|必选|类型|说明|
-|-|-|-
|email |是|string |邮箱 |
|username |是|string |登录名 |
|password |是|string |秘密 |
|platform |否|string |用户来源的相关平台,取值范围['educoder', 'trustie', 'forge'], 默认值为forge |
*返回参数说明:*
|参数名|类型|说明|
-|-|-
|user|json object |返回数据|
|-- id |int |用户id |
|-- token |string|用户token|
5 years ago
返回值
5 years ago
```
{
"status": 0,
"message": "success",
"user": {
"id": 36400,
"token": "8c87a80d9cfacc92fcb2451845104f35119eda96"
}
}
5 years ago
```
---
5 years ago
#### 获取项目类别列表(可根据名称搜素)
5 years ago
```
GET api/project_categories
```
*示例*
```
curl -X GET \
-d "name=大数据" \
http://localhost:3000/api/project_categories/ | jq
```
*请求参数说明:*
|参数名|必选|类型|说明|
-|-|-|-
|name |否|string |类别名称 |
*返回参数说明:*
|参数名|类型|说明|
-|-|-
|project_categories|array |返回数据|
|-- id |int |类别id |
|-- name |string|类别名称|
返回值
```
{
"project_categories": [
{
"id": 1,
"name": "大数据"
}
]
}
5 years ago
```
---
#### 获取项目语言列表(可根据名称搜素)
5 years ago
```
GET api/project_languages
5 years ago
```
*示例*
```
curl -X GET \
-d "name=Ruby" \
http://localhost:3000/api/project_languages/ | jq
5 years ago
```
*请求参数说明:*
5 years ago
|参数名|必选|类型|说明|
-|-|-|-
|name |否|string |类别名称 |
5 years ago
*返回参数说明:*
5 years ago
|参数名|类型|说明|
-|-|-
|project_languages|array |返回数据|
|-- id |int |语言id |
|-- name |string|语言名称|
5 years ago
返回值
```
{
"project_languages": [
{
"id": 1,
"name": "Ruby"
}
]
}
```
---
#### 获取.gitignore模板列表(可根据名称搜素)
```
GET api/ignores
```
*示例*
```
curl -X GET \
-d "name=Ada" \
http://localhost:3000/api/ignores/ | jq
```
*请求参数说明:*
5 years ago
|参数名|必选|类型|说明|
-|-|-|-
|name |否|string |gitignore名称 |
5 years ago
*返回参数说明:*
5 years ago
|参数名|类型|说明|
-|-|-
|ignores|array |返回数据|
|-- id |int |id |
|-- name |string|gitignore名称|
5 years ago
返回值
```
{
"ignores": [
{
"id": 1,
"name": "Ada"
}
]
}
```
---
#### 获取开源许可证列表(可根据名称搜素)
```
GET api/licenses
```
*示例*
```
curl -X GET \
-d "name=AFL" \
http://localhost:3000/api/licenses/ | jq
```
*请求参数说明:*
|参数名|必选|类型|说明|
-|-|-|-
|name |否|string |开源许可证名称 |
*返回参数说明:*
|参数名|类型|说明|
-|-|-
|licenses|array |返回数据|
|-- id |int |id |
|-- name |string|开源许可证名称|
返回值
```
{
"licenses": [
{
"id": 57,
"name": "AFL-1.2"
},
{
"id": 76,
"name": "AFL-3.0"
},
{
"id": 214,
"name": "AFL-1.1"
},
{
"id": 326,
"name": "AFL-2.1"
},
{
"id": 350,
"name": "AFL-2.0"
}
]
5 years ago
}
```
---
5 years ago
#### 创建项目
```
POST api/projects
```
*示例*
```
curl -X POST \
-d "user_id=36401" \
-d "name=hnfl_demo" \
5 years ago
-d "description=my first project" \
-d "repository_name=hnfl_demo" \
5 years ago
-d "project_category_id=1" \
-d "project_language_id=2" \
-d "ignore_id=2" \
5 years ago
-d "license_id=1" \
5 years ago
http://localhost:3000/api/projects/ | jq
```
*请求参数说明:*
|参数名|必选|类型|说明|
-|-|-|-
|user_id |是|int |用户id或者组织id |
|name |是|string |项目名称 |
|description |是|string |项目描述 |
|repository_name |是|string |仓库名称, 只含有数字、字母、下划线不能以下划线开头和结尾,且唯一 |
|project_category_id|是|int |项目类别id |
|project_language_id|是|int |项目语言id |
|ignore_id |否|int |gitignore相关id |
|license_id |否|int |开源许可证id |
|private |否|boolean|项目是否私有, true为私有false: 公开,默认为公开 |
5 years ago
*返回参数说明:*
|参数名|类型|说明|
-|-|-
|id |int |id |
|name |string|项目名称|
5 years ago
5 years ago
返回值
```
{
"id": 3240,
"name": "好项目"
}
```
---
#### 新建镜像项目
```
POST api/projects/migrate
```
*示例*
```
curl -X POST \
-d "user_id=36401" \
5 years ago
-d "clone_addr=https://gitee.com/openeuler/A-Tune.git" \
-d "name=A-Tune" \
5 years ago
-d "description=my first project" \
-d "repository_name=mirror_demo" \
5 years ago
-d "project_category_id=1" \
-d "project_language_id=2" \
http://localhost:3000/api/projects/migrate | jq
5 years ago
```
*请求参数说明:*
|参数名|必选|类型|说明|
-|-|-|-
|user_id |是|int |用户id或者组织id |
|name |是|string |项目名称 |
|clone_addr |是|string |镜像项目clone地址 |
|description |否|string |项目描述 |
|repository_name |是|string |仓库名称, 只含有数字、字母、下划线不能以下划线开头和结尾,且唯一 |
|project_category_id|是|int |项目类别id |
|project_language_id|是|int |项目语言id |
|private |否|boolean|项目是否私有, true为私有false: 非私有,默认为公开 |
5 years ago
*返回参数说明:*
|参数名|类型|说明|
-|-|-
|id |int |id |
|name |string|项目名称|
5 years ago
返回值
```
{
"id": 3263,
"name": "ni项目"
}
```
---
#### 获取代码目录列表
```
POST api/:login/:repo_identifier/entries
```
*示例*
```
curl -X GET \
-d "ref=develop" \
http://localhost:3000/api/18816895620/mirror_demo/entries | jq
```
*请求参数说明:*
|参数名|必选|类型|说明|
-|-|-|-
|login |是|string |用户标识(login) |
|repo_identifier |是|string |仓库标识(identifier) |
|ref |否|string |分支名称、tag名称或是提交记录id默认为master分支 |
*返回参数说明:*
|参数名|类型|说明|
-|-|-
|id |int |id |
|name |string|文件夹或文件名称|
|path |string|文件夹或文件相对路径|
|type |string|文件类型, file:文件dir文件目录|
|size |int|文件夹或文件大小 单位KB|
|content |string|文件内容,|
|target |string|标签|
返回值
```
[
5 years ago
{
"name": "Manual",
"path": "Manual",
"sha": "c2f18765235076b4c835b3e31262b3ee65176a75",
"type": "file",
"size": 12579,
"content": null,
"target": null,
"commit": null
},
{
"name": "README",
"path": "README",
"sha": "91a29176828eba5c5598f5d4a95458e861f271ec",
"type": "file",
"size": 1767,
"content": null,
"target": null,
"commit": null
},
{
"name": "base",
"path": "base",
"sha": "7adbe5698e02dba062216333d5e1d16b36ae1cbd",
"type": "dir",
"size": 0,
"content": null,
"target": null,
"commit": null
}
]
```
---
#### 获取子目录代码列表
```
POST api/:login/:repo_identifier/sub_entries
```
*示例*
```
curl -X GET \
-d "ref=develop" \
-d "filepath=lib/slew.rc" \
http://localhost:3000/api/18816895620/mirror_demo/sub_entries | jq
```
*请求参数说明:*
|参数名|必选|类型|说明|
-|-|-|-
|login |是|string |用户标识(login) |
|repo_identifier |是|string |仓库标识(identifier) |
|filepath |是|string |文件夹、文件路径 |
|ref |否|string |分支名称、tag名称或是提交记录id默认为master分支 |
*返回参数说明:*
|参数名|类型|说明|
-|-|-
|id |int |id |
|name |string|文件夹或文件名称|
|path |string|文件夹或文件相对路径|
|type |string|文件类型, file:文件dir文件目录|
|size |int|文件夹或文件大小 单位KB|
|content |string|文件内容,|
|target |string|标签|
|url |string|文件访问链接,带分支|
|html_url |string|文件访问链接,未标识分支|
|git_url |string|文件夹或文件的git仓库访问链接|
|download_url |string|文件下载、文件内容访问链接|
返回值
```
[
{
"name": "build.rc",
"path": "lib/build.rc",
"type": "",
"size": 1268,
"content": null,
"target": null,
"url": "http://localhost:3003/api/v1/repos/18816895620/mirror_demo/contents/lib/build.rc?ref=master",
"html_url": "http://localhost:3003/18816895620/mirror_demo/src/branch/master/lib/build.rc",
"git_url": "http://localhost:3003/api/v1/repos/18816895620/mirror_demo/git/blobs/191fcf1a63b3777e2977fcede7dd5309efdd70fe",
"download_url": null
},
{
"name": "cfg.rc",
"path": "lib/cfg.rc",
"type": "file",
"size": 107,
"content": null,
"target": null,
"url": "http://localhost:3003/api/v1/repos/18816895620/mirror_demo/contents/lib/cfg.rc?ref=master",
"html_url": "http://localhost:3003/18816895620/mirror_demo/src/branch/master/lib/cfg.rc",
"git_url": "http://localhost:3003/api/v1/repos/18816895620/mirror_demo/git/blobs/0b91ba0ed1c00e130c77bb9058af3787fea986a0",
"download_url": "http://localhost:3003/18816895620/mirror_demo/raw/branch/master/lib/cfg.rc"
},
{
"name": "fn",
"path": "lib/fn",
"type": "dir",
"size": 0,
"content": null,
"target": null,
"url": "http://localhost:3003/api/v1/repos/18816895620/mirror_demo/contents/lib/fn?ref=master",
"html_url": "http://localhost:3003/18816895620/mirror_demo/src/branch/master/lib/fn",
"git_url": "http://localhost:3003/api/v1/repos/18816895620/mirror_demo/git/blobs/e33bd45949ef8f804471d0b6b2c59728eb445989",
"download_url": null
}
]
```
---
5 years ago
#### 项目类别列表(用于项目列表左侧导航中的项目类别列表)
```
GET api/project_categories/group_list
```
*示例*
```
curl -X GET http://localhost:3000/api/project_categories/group_list | jq
```
*返回参数说明:*
|参数名|类型|说明|
-|-|-
|id |int |项目分类id |
|name |string|项目分类名称|
|projects_count |int |项目数量|
返回值
```
[
{
"id": 1,
"name": "大数据",
"projects_count": 30
},
{
"id": 2,
"name": "机器学习",
"projects_count": 1
},
{
"id": 3,
"name": "深度学习",
"projects_count": 1
}
]
```
---
#### 项目类型列表(用于项目列表左侧导航上方中的项目类型列表)
```
GET api/projects/group_type_list
```
*示例*
```
curl -X GET http://localhost:3000/api/projects/group_type_list | jq
```
*返回参数说明:*
|参数名|类型|说明|
-|-|-
|project_type |string|项目类型 |
|name |string|项目类型名称|
|projects_count |int |项目数量|
返回值
```
[
{
"project_type": "common",
"name": "开源托管项目",
"projects_count": 2106
},
{
"project_type": "mirror",
"name": "开源镜像项目",
"projects_count": 1
}
]
```
---
#### 项目列表
```
GET api/projects
```
*示例*
```
5 years ago
curl -X GET \
-d "page=1" \
-d "limit=5" \
http://localhost:3000/api/projects | jq
```
*请求参数说明:*
|参数名|必选|类型|说明|
-|-|-|-
5 years ago
|page |否|string |页数,第几页 |
|limit |否|string |每页多少条数据默认15条 |
5 years ago
|sort_by |否|string |排序类型, 取值updated_on \| created_on \| forked_count \| praises_count, updated_on: 更新时间排序created_on: 创建时间排序forked_count: fork数据排序praises_count: 点赞数量排序默认为updated_on更新时间排序 |
5 years ago
|sort_direction|否|string |排序方式,取值为: desc \| asc; desc: 降序排序, asc: 升序排序, 默认为desc |
|search |否|string |按照项目名称搜索 |
5 years ago
|category_id |否|int |项目类别id |
|language_id |否|int |项目语言id |
|project_type |否|string |项目类型, 取值为common \| mirror; common:开源托管项目, mirror:开源镜像项目 |
*返回参数说明:*
|参数名|类型|说明|
-|-|-
|total_count |int |项目总条数 |
|id |string |项目标识 |
|name |string|项目名称|
|description |string|项目简介|
|visits |int|流量数|
|forked_count |int|被fork的数量|
|praises_count |int|star数量|
|is_public |boolean|是否公开, true:公开false:未公开|
|mirror_url |string|镜像url|
|last_update_time|int|最后更新时间为UNIX格式的时间戳|
|author |object|项目创建者|
|-- name |string|用户名,也是用户标识|
|category |object|项目类别|
5 years ago
|-- id |int|项目类型id|
|-- name |string|项目类型名称|
|language |object|项目语言|
5 years ago
|-- id |int|项目语言id|
|-- name |string|项目语言名称|
5 years ago
返回值
```
{
"total_count": 3096,
"projects": [
{
"id": "hnfl_demo1",
"name": "hnfl_demo1",
"description": "my first project",
"visits": 0,
"praises_count": 0,
"forked_count": 0,
"is_public": true,
"mirror_url": null,
"last_update_time": 1577697461,
"author": {
"name": "18816895620",
"image_url": "avatars/User/b"
},
"category": {
"id": 1,
"name": "大数据"
},
"language": {
"id": 2,
"name": "C"
}
5 years ago
},
{
"id": "hnfl_demo",
"name": "hnfl_demo",
"description": "my first project",
"visits": 0,
"praises_count": 0,
"forked_count": 0,
"is_public": true,
"mirror_url": null,
"last_update_time": 1577697403,
"author": {
"name": "18816895620",
"image_url": "avatars/User/b"
},
"category": {
"id": 1,
"name": "大数据"
},
"language": {
"id": 2,
"name": "C"
}
5 years ago
},
{
"id": "tongjj",
"name": "统计局",
"description": "my first project",
"visits": 0,
"praises_count": 0,
"forked_count": 0,
"is_public": true,
"mirror_url": null,
"last_update_time": 1577415173,
"author": {
"name": "18816895620",
"image_url": "avatars/User/b"
},
"category": {
"id": 1,
"name": "大数据"
},
"language": {
"id": 2,
"name": "C"
}
5 years ago
},
{
"id": null,
"name": "开源同名",
"description": "my first project",
"visits": 0,
"praises_count": 0,
"forked_count": 0,
"is_public": false,
"mirror_url": "https://gitea.com/CasperVector/slew.git",
"last_update_time": 1577346228,
"author": {
"name": "18816895620",
"image_url": "avatars/User/b"
},
"category": {
"id": 1,
"name": "大数据"
},
"language": {
"id": 2,
"name": "C"
}
5 years ago
},
{
"id": "mvp_demo",
"name": "开源支持",
"description": "my first project",
"visits": 0,
"praises_count": 0,
"forked_count": 0,
"is_public": true,
"mirror_url": null,
"last_update_time": 1577341572,
"author": {
"name": "18816895620",
"image_url": "avatars/User/b"
},
"category": {
"id": 1,
"name": "大数据"
},
"language": {
"id": 2,
"name": "C"
}
5 years ago
}
]
}
5 years ago
```
---
### 获取分支列表
```
GET /api/projects/:identifier/branches
```
*示例*
```
curl -X GET http://localhost:3000/api/projects/mirror_demo/branches | jq
```
*请求参数说明:*
|参数名|必选|类型|说明|
-|-|-|-
|identifier |是|string |项目标识 |
*返回参数说明:*
|参数名|类型|说明|
-|-|-
|name |string|分支名称|
|user_can_push |boolean|用户是否可push|
|user_can_merge |boolean|用户是否客merge|
|protected |boolean|是否为保护分支|
5 years ago
|http_url |boolean|http链接|
|zip_url |boolean|zip包下载链接|
|tar_url |boolean|tar.gz下载链接|
|last_commit |object|最后提交记录|
|-- id |string|提交记录id|
|-- message |string|提交的说明信息|
|-- timestamp |int|提交时间为UNIX时间戳|
|-- time_from_now|string|转换后的时间|
|author |object|提交用户|
|-- login |string|用户名称|
|-- image_url |string|用户头像|
5 years ago
返回值
```
[
{
"name": "develop",
"user_can_push": true,
"user_can_merge": true,
"protected": false,
5 years ago
"http_url": "http://localhost:3003/18816895620/mirror_demo.git",
"zip_url": "http://localhost:3003/18816895620/mirror_demo/develop.zip",
"tar_url": "http://localhost:3003/18816895620/mirror_demo/develop.tar.gz",
"last_commit": {
"id": "735674d6696bddbafa993db9c67b40c41246c77f",
"message": "FIX test branch content\n",
"timestamp": 1577694074,
"time_from_now": "1天前"
},
"author": {
"login": "18816895620",
"image_url": "avatars/User/b"
}
5 years ago
},
{
"name": "master",
"user_can_push": true,
"user_can_merge": true,
"protected": false,
5 years ago
"http_url": "http://localhost:3003/18816895620/mirror_demo.git",
"zip_url": "http://localhost:3003/18816895620/mirror_demo/master.zip",
"tar_url": "http://localhost:3003/18816895620/mirror_demo/master.tar.gz",
"last_commit": {
"id": "19ac3bc45f62cc87a94b8ecce61101d8fd2dafd2",
"message": "合并pull request测试\n\n该功能很不错感谢你的建议\n",
"timestamp": 1577244567,
"time_from_now": "6天前"
},
"author": {
"login": "18816895620",
"image_url": "avatars/User/b"
}
5 years ago
}
]
```
---
5 years ago
### 获取版本列表
```
GET /api/:login/:repo_identifier/tags
```
*示例*
```
curl -X GET http://localhost:3000/api/18816895620/mirror_demo/tags | jq
```
*请求参数说明:*
|参数名|必选|类型|说明|
-|-|-|-
|identifier |是|string |项目标识 |
*返回参数说明:*
|参数名|类型|说明|
-|-|-
|name |string|分支名称|
|user_can_push |boolean|用户是否可push|
|user_can_merge |boolean|用户是否客merge|
|protected |boolean|是否为保护分支|
|http_url |boolean|http链接|
|zip_url |boolean|zip包下载链接|
|tar_url |boolean|tar.gz下载链接|
|last_commit |object|最后提交记录|
|-- id |string|提交记录id|
|-- message |string|提交的说明信息|
|-- timestamp |int|提交时间为UNIX时间戳|
|-- time_from_now|string|转换后的时间|
|author |object|提交用户|
|-- login |string|用户名称|
|-- image_url |string|用户头像|
返回值
```
[
{
"name": "develop",
"user_can_push": true,
"user_can_merge": true,
"protected": false,
"http_url": "http://localhost:3003/18816895620/mirror_demo.git",
"zip_url": "http://localhost:3003/18816895620/mirror_demo/develop.zip",
"tar_url": "http://localhost:3003/18816895620/mirror_demo/develop.tar.gz",
"last_commit": {
"id": "735674d6696bddbafa993db9c67b40c41246c77f",
"message": "FIX test branch content\n",
"timestamp": 1577694074,
"time_from_now": "1天前"
},
"author": {
"login": "18816895620",
"image_url": "avatars/User/b"
}
},
{
"name": "master",
"user_can_push": true,
"user_can_merge": true,
"protected": false,
"http_url": "http://localhost:3003/18816895620/mirror_demo.git",
"zip_url": "http://localhost:3003/18816895620/mirror_demo/master.zip",
"tar_url": "http://localhost:3003/18816895620/mirror_demo/master.tar.gz",
"last_commit": {
"id": "19ac3bc45f62cc87a94b8ecce61101d8fd2dafd2",
"message": "合并pull request测试\n\n该功能很不错感谢你的建议\n",
"timestamp": 1577244567,
"time_from_now": "6天前"
},
"author": {
"login": "18816895620",
"image_url": "avatars/User/b"
}
}
]
```
---
## 仓库详情
```
GET /api/:login/:repo_identifier/
```
*示例*
```
curl -X GET \
http://localhost:3000/api/18816895620/mirror_demo | jq
```
*请求参数说明:*
|参数名|必选|类型|说明|
-|-|-|-
|login |是|string |用户标识 |
|repo_identifier |是|string |仓库标识 |
*返回参数说明:*
|参数名|类型|说明|
-|-|-
|identifier |string|仓库标识|
|praises_count |int|点赞数量|
|forked_count |int|fork数量|
|watchers_count |int|关注数量|
|author |object|提交用户|
|-- login |string|用户名称|
|-- image_url |string|用户头像|
返回值
```
{
"identifier": "mirror_demo",
"praises_count": 0,
"forked_count": 0,
"watchers_count": 0,
"author": {
"name": "18816895620",
"image_url": "avatars/User/b"
}
}
```
---
## 获取提交记录列表
```
GET /api/:login/:repo_identifier/commits
```
*示例*
```
curl -X GET \
-d "sha=develop" \
-d "page=1" \
http://localhost:3000/api/18816895620/mirror_demo/commits | jq
```
*请求参数说明:*
|参数名|必选|类型|说明|
-|-|-|-
|login |是|string |用户标识 |
|repo_identifier |是|string |仓库标识 |
|sha |否|string |分支名称、提交记录的sha标识默认为master分支 |
|page |否|int |页数, 默认为1 |
*返回参数说明:*
|参数名|类型|说明|
-|-|-
|total_count|int|总记录条数|
|commits |array|提交记录的数组|
|-- sha |string|提交记录sha标识|
|-- message |string|提交的备注说明|
|-- timestamp |int|提交UNIX时间戳|
|-- time_from_now|string|提交距离当前的时间|
|author |object|提交用户|
|-- login |string|用户名称|
|-- image_url |string|用户头像|
返回值
```
{
"total_count": 63,
"commits": [
{
"sha": "19ac3bc45f62cc87a94b8ecce61101d8fd2dafd2",
"message": "合并pull request测试",
"timestamp": 1577244567,
"time_from_now": "7天前",
"author": {
"name": "18816895620",
"image_url": "avatars/User/b"
}
},
{
"sha": "2b33c5f55214db41879936312ee43611406c4dbd",
"message": "FIX .",
"timestamp": 1577244474,
"time_from_now": "7天前",
"author": {
"name": "18816895620",
"image_url": "avatars/User/b"
}
}
]
}
```
---
5 years ago
### 点赞
```
POST /api/praise_tread/like
```
*示例*
```
curl -X POST \
-d 'object_id=1' \
-d 'object_type=project' \
http://localhost:3000/api/praise_tread/like | jq
```
*请求参数说明:*
|参数名|必选|类型|说明|
-|-|-|-
|object_id |是 |int |项目id |
|object_type |否 |string | 点赞类型默认为project|
*返回参数说明:*
|参数名|类型|说明|
-|-|-
|status |int|0:点赞成功,-1:操作失败2:表示已经点过赞了|
返回值
```
{
5 years ago
"status": 0,
"message": "响应成功"
}
```
---
### 取消点赞
```
DELETE /api/praise_tread/unlike
```
*示例*
```
curl -X DELETE \
-d 'object_id=1' \
-d 'object_type=project' \
http://localhost:3000/api/praise_tread/unlike | jq
```
*请求参数说明:*
|参数名|必选|类型|说明|
-|-|-|-
|object_id |是 |string |点赞对象的唯一标识如项目的identifier字段 |
|object_type |是 |string | 点赞类型默认为project|
*返回参数说明:*
|参数名|类型|说明|
-|-|-
|status |int|0:点赞成功,-1:操作失败2:表示还未点赞|
5 years ago
返回值
```
{
"status": 0,
"message": "响应成功"
}
```
---
### 仓库新建文件
```
DELETE /api/:login/:repo_identifier/contents
```
*示例*
```
5 years ago
curl -X POST \
5 years ago
-d 'filepath=test1_create_file1.rb' \
-d 'branch=develop' \
5 years ago
-d 'content=ZnNmc2FkZg==' \
5 years ago
-d 'message=test commit ' \
http://localhost:3000/api/18816895620/mirror_demo/contents.json | jq
5 years ago
```
*请求参数说明:*
|参数名|必选|类型|说明|
-|-|-|-
|login |是|string |用户标识 |
|repo_identifier|是|string |仓库标识 |
|filepath |是|string |文件相对于仓库的路径 |
|content |否|string |内容 |
|message |否|string |提交说明 |
|branch |否|string |分支名称, branch和new_branch必须存在一个 |
|new_branch |否|string |新的分支名称 |
*返回参数说明:*
|参数名|类型|说明|
-|-|-
5 years ago
|name |string|文件名|
|sha |string|提交文件的sha值|
|size |int|文件大小, 单位B|
|content |string|base64编码后的文件内容|
|encoding |string|编码方式|
|commit |object||
|-- message |string|提交备注说明信息|
|-- committer|object||
|---- name |string|用户名|
|---- email |string|用户邮箱|
|---- date |string|文件创建时间|
5 years ago
返回值
```
{
5 years ago
"name": "test1_create_file12.rb",
"sha": "7b70509105b587e71f5692b9e8ab70851e321f64",
"size": 12,
"content": "Wm5ObWMyRmtaZz09",
"encoding": "base64",
"commit": {
"message": "good luck\n",
"author": {
"name": "18816895620",
"email": "2456233122@qq.com",
"date": "2020-01-07T03:31:20Z"
},
"committer": {
"name": "18816895620",
"email": "2456233122@qq.com",
"date": "2020-01-07T03:31:20Z"
}
}
5 years ago
}
```
---
### 更新仓库中的文件
```
DELETE /api/:login/:repo_identifier/contents/files/update
```
*示例*
```
curl -X DELETE \
-d 'filepath=1' \
-d 'object_type=project' \
http://localhost:3000/api/118816895620/mirror_demo/contents | jq
```
*请求参数说明:*
|参数名|必选|类型|说明|
-|-|-|-
|login |是|string |用户标识 |
|repo_identifier|是|string |仓库标识 |
|filepath |是|string |文件相对于仓库的路径 |
|content |否|string |内容 |
|message |否|string |提交说明 |
|branch |否|string |分支名称, branch和new_branch必须存在一个 |
|new_branch |否|string |新的分支名称 |
*返回参数说明:*
|参数名|类型|说明|
-|-|-
|status |int|0:点赞成功,-1:操作失败2:表示还未点赞|
返回值
```
{
"status": 0,
"message": "响应成功"
}
```
---
### 删除仓库中的文件
```
DELETE /api/:login/:repo_identifier/contents/files/delete
```
*示例*
```
curl -X DELETE \
-d 'filepath=1' \
-d 'object_type=project' \
http://localhost:3000/api/118816895620/mirror_demo/contents | jq
```
*请求参数说明:*
|参数名|必选|类型|说明|
-|-|-|-
|login |是|string |用户标识 |
|repo_identifier|是|string |仓库标识 |
|filepath |是|string |文件相对于仓库的路径 |
|content |否|string |内容 |
|message |否|string |提交说明 |
|branch |否|string |分支名称, branch和new_branch必须存在一个 |
|new_branch |否|string |新的分支名称 |
*返回参数说明:*
|参数名|类型|说明|
-|-|-
|status |int|0:点赞成功,-1:操作失败2:表示还未点赞|
5 years ago
返回值
```
{
"status": 0,
"message": "响应成功"
5 years ago
}
```
---