云服务器内容精选

  • 响应示例 状态码: 200 OK { "result" : { "id" : "85a0a9d5c6e43bc9c3e443ac01f789e24eeef02b", "title" : "some commit message", "message" : "some commit message", "short_id" : "85a0a9d5", "author_name" : "repo", "author_email" : null, "committer_name" : "repo", "committer_email" : null, "created_at" : "2021-09-26T03:44:51.000Z", "parent_ids" : [ "5c114bb316dff4d4a046e09a5c44c816f2433140" ], "committed_date" : "2021-09-26T03:44:51.000Z", "authored_date" : null, "stats" : { "additions" : 1, "deletions" : 0, "total" : 1 } }, "status" : "success"}
  • 请求示例 POST https://{endpoint}/v2/projects/859341/repository/commits{ "branch" : "master", "commit_message" : "some commit message", "actions" : [ { "action" : "create", "file_path" : "test001.txt", "content" : "some content" } ]}
  • 响应参数 状态码: 200 表5 响应Body参数 参数 参数类型 描述 error Error object 参数解释: 响应错误码 result CreateCommitResponseBody object 参数解释: 响应结果 status String 参数解释: 调用此接口的响应状态。 取值范围: success,表示接口调用成功。 failed,表示接口调用失败。 表6 Error 参数 参数类型 描述 code String 参数解释: 错误码 取值范围: 符合错误码格式字符串,长度[0,100] message String 参数解释: 错误信息 取值范围: 不涉及 表7 CreateCommitResponseBody 参数 参数类型 描述 id String 参数解释: 提交对应的SHA id short_id String 参数解释: 提交对应的短SHA id title String 参数解释: 提交标题 author_name String 参数解释: 作者 author_email String 参数解释: 作者邮箱 committer_name String 参数解释: 提交作者 committer_email String 参数解释: 提交作者邮箱 created_at String 参数解释: 创建时间 message String 参数解释: 提交信息 parent_ids Array of strings 参数解释: 父提交id committed_date String 参数解释: 提交时间 authored_date String 参数解释: 作者提交时间 stats stats object 参数解释: 统计信息 表8 stats 参数 参数类型 描述 additions Integer 参数解释: 变更增加的行数 deletions Integer 参数解释: 变更删除的行数 total Integer 参数解释: 变更的总行数
  • 请求参数 表2 请求Header参数 参数 是否必选 参数类型 描述 X-Auth-Token 是 String 参数解释: 用户Token。通过调用 IAM 服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。 约束限制: 必传。 取值范围: 字符串长度不少于1,不超过10万。 默认取值: 不涉及。 表3 请求Body参数 参数 是否必选 参数类型 描述 branch 是 String 参数解释: 目标分支 约束限制: 必传 取值范围: 最小长度:1 最大长度:200 默认取值: 不涉及 commit_message 是 String 参数解释: 提交信息 约束限制: 必传 取值范围: 最小长度:0 最大长度:2000 默认取值: 不涉及 start_branch 否 String 参数解释: 创建分支时,新的分支名 约束限制: 无 取值范围: 最小长度:1 最大长度:200 默认取值: 不涉及 actions 是 Array of CommitAction objects 参数解释: 提交处理列表 约束限制: 无 取值范围: 最小长度:1 最大长度:100 默认取值: 不涉及 author_email 否 String 参数解释: 提交作者的电子邮件地址 author_name 否 String 参数解释: 提交作者的名称 stats 否 Boolean 参数解释: 是否包括提交统计信息。默认值为true force 否 Boolean 参数解释: 是否覆盖目标分支。当true时,使用基于start_branch的新提交覆盖目标分支 表4 CommitAction 参数 是否必选 参数类型 描述 action 是 String 参数解释: 要执行的操作:create、delete、move、update、chmod 约束限制: 必传 取值范围: create、delete、move、update、chmod 默认取值: 不涉及 file_path 是 String 参数解释: 文件的完整路径。例如lib/class.rb 约束限制: 必传 取值范围: 无 默认取值: 不涉及 previous_path 否 String 参数解释: 要移动的文件的原始完整路径。例如lib/class1.rb。仅在move操作时生效 约束限制: 无 取值范围: 无 默认取值: 不涉及 content 否 String 参数解释: 文件内容,create和update操作时必须。未指定内容的移动操作将保留现有文件内容,内容的任何其他值将覆盖文件内容。 约束限制: 无 取值范围: 无 默认取值: 不涉及 encoding 否 String 参数解释: 文件编码:text、base64。默认为text 约束限制: 无 取值范围: 无 默认取值: 不涉及 last_commit_id 否 String 参数解释: 最后一个已知的提交ID。仅在update、move、delete操作时生效 约束限制: 无 取值范围: 无 默认取值: 不涉及 execute_filemode 否 Boolean 参数解释: 启用或者禁用文件的执行模式。仅在chmod操作时生效 约束限制: 无 取值范围: 无 默认取值: 不涉及