Creating a Commit (Deprecated)
Function
This API is used to commit multiple files in different directories at a time. If the directory does not exist, the system automatically creates a directory. The forcible overwrite option is supported. When the forcible overwrite flag is set to true, the conflict is ignored and the configuration is forcibly committed.
URI
POST /v2/projects/{repo_id}/repository/commits
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
repo_id |
Yes |
Integer |
Explanation Repository short ID. Constraints Mandatory Range 0–2147483647 Default value None |
Request Parameters
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
X-Auth-Token |
Yes |
String |
Explanation User token. It can be obtained by calling the IAM API used to obtain a user token. The value of X-Subject-Token in the response header is the user token. Constraints Mandatory Range 1–100,000 characters. Default value None. |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
branch |
Yes |
String |
Explanation Target branch. Constraints Mandatory Range Minimum length: 1 Maximum length: 200 Default value None |
|
commit_message |
Yes |
String |
Explanation Commit message. Constraints Mandatory Range Minimum length: 0 characters Maximum length: 2,000 characters Default value None |
|
start_branch |
No |
String |
Explanation Name of the new branch. Constraints None. Range Minimum length: 1 Maximum length: 200 Default value None |
|
actions |
Yes |
Array of CommitAction objects |
Explanation Commit processing list. Constraints None. Range Minimum length: 1 Maximum length: 100 characters Default value None |
|
author_email |
No |
String |
Explanation Committer email address. |
|
author_name |
No |
String |
Explanation Committer name |
|
stats |
No |
Boolean |
Explanation Whether to include commit statistics. The default value is true. |
|
force |
No |
Boolean |
Explanation Whether to overwrite the target branch. When the value is true, overwrite the target branch with a new commit based on start_branch. |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
action |
Yes |
String |
Explanation Operations to be performed: create, delete, move, update, and chmod. Constraints Mandatory Range create, delete, move, update, chmod Default value None |
|
file_path |
Yes |
String |
Explanation Complete path of the file. For example, lib/class.rb. Constraints Mandatory Range None. Default value None |
|
previous_path |
No |
String |
Explanation Original full path of the file to be moved. For example, lib/class1.rb. This parameter is valid only when the move operation is performed. Constraints None. Range None. Default value None |
|
content |
No |
String |
Explanation File content. This parameter is mandatory for the create and update operations. A move operation that does not specify content retains the existing file content, and any other value of the content overwrites the file content. Constraints None. Range None. Default value None |
|
encoding |
No |
String |
Explanation File encoding: text and base64. The default value is text. Constraints None. Range None. Default value None |
|
last_commit_id |
No |
String |
Explanation Last known commit ID. This parameter is valid only when the update, move, or delete operation is performed. Constraints None. Range None. Default value None |
|
execute_filemode |
No |
Boolean |
Explanation Enable or disable the execution mode of a file. This parameter is valid only when the chmod operation is executed. Constraints None. Range None. Default value None |
Response Parameters
Status code: 200
|
Parameter |
Type |
Description |
|---|---|---|
|
error |
Error object |
Explanation Response error code. |
|
result |
CreateCommitResponseBody object |
Explanation Response result. |
|
status |
String |
Explanation Response status of the API. Range
|
|
Parameter |
Type |
Description |
|---|---|---|
|
code |
String |
Explanation Error code. Range Max. 100 characters in the error code format. |
|
message |
String |
Explanation Error message. Range None |
|
Parameter |
Type |
Description |
|---|---|---|
|
id |
String |
Explanation SHA ID of a commit. |
|
short_id |
String |
Explanation Short SHA ID of a commit. |
|
title |
String |
Explanation Commit title. |
|
author_name |
String |
Explanation Author. |
|
author_email |
String |
Explanation Author email. |
|
committer_name |
String |
Explanation Committer. |
|
committer_email |
String |
Explanation Committer email. |
|
created_at |
String |
Explanation Creation time. |
|
message |
String |
Explanation Commit message. |
|
parent_ids |
Array of strings |
Explanation Parent commit ID. |
|
committed_date |
String |
Explanation Commit time. |
|
authored_date |
String |
Explanation Author commit time. |
|
stats |
stats object |
Explanation Statistics. |
Example Requests
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"
} ]
}
Example Responses
Status code: 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"
}
Status Code
|
Status Code |
Description |
|---|---|
|
200 |
OK |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot
