Cloning Tasks Asynchronously in Batches
Function
This API is used to asynchronously clone tasks in batches based on the task ID or template task ID. You can reconfigure parameters such as the project ID, task name, code repository address, and branch name for the tasks to be cloned. The ID and progress of each asynchronous task are returned.
Calling Method
For details, see Calling APIs.
Authorization Information
Each account root user has all the permissions required to call all APIs, but IAM users must be assigned the following required identity policy-based permissions. For details about the required permissions, see Permissions Policies and Supported Actions.
|
Action |
Access Level |
Resource Type (*: required) |
Condition Key |
Alias |
Dependencies |
|---|---|---|---|---|---|
|
codeartscheck:task:create |
Write |
task * |
- |
- |
- |
|
- |
codeartscheck:ProjectId |
URI
POST /v4/tasks/{task_id}/batch/async-copy
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
task_id |
Yes |
String |
Definition : Task ID or template task ID. Constraints: N/A Value range: N/A Default value: N/A |
Request Parameters
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
[items] |
Yes |
Array of CopyAsyncTaskInfo objects |
Definition: Parameters required for creating tasks in batches based on a task template. Constraints: N/A |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
name |
No |
String |
Definition: Task name. Constraints: 1 to 128 characters. The value can contain any letters, digits, periods (.), hyphens (-), and underscores (_). Range: N/A Default value: N/A |
|
taskClassificationId |
No |
String |
Definition: Task group ID. When a task group is created, the system returns a task group ID. Constraints: N/A Value range: N/A Default value: N/A |
|
repoUrl |
No |
String |
Definition: Code repository address. Constraints: N/A Value range: Default value: N/A |
|
projectId |
No |
String |
Definition : You can obtain the 32-character UUID by calling the API used to query the project list. Constraints: N/A Value range: 32-character project ID. Default value: N/A |
|
branchName |
No |
String |
Definition: Name of the code repository branch. Constraints: N/A Range: N/A Default value: N/A |
|
configTemplate |
No |
configTemplate object |
Definition: Configuration template. Constraints: N/A |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
authId |
No |
String |
Definition: The ID of an existing code source endpoint for storing repository information in a project. Constraints: N/A Range: N/A Default value: N/A |
|
authType |
No |
String |
Definition: Authorization type. Constraints: N/A Value range: Default value: N/A |
|
repoType |
No |
String |
Definition: Code repository type. Constraints: N/A Value range: Default value: N/A |
Response Parameters
Status code: 200
|
Parameter |
Type |
Description |
|---|---|---|
|
[items] |
Array of AsyncCopyTaskInfo objects |
Definition: Asynchronous task list. |
|
Parameter |
Type |
Description |
|---|---|---|
|
id |
String |
Definition: Asynchronous job ID. The asynchronous task ID of each task is returned when tasks are created in batches based on the template. Value range: N/A |
|
create_time |
String |
Definition: Task creation time. Value range: N/A |
|
type |
String |
Definition: Asynchronous task type. When tasks are created in batches based on the template, the value is CopyTask. Value range: CopyTask. |
|
status |
String |
Definition: Asynchronous task status. Value range: |
|
user |
AsyncCopyTaskUser object |
Definition: User information of an asynchronous task. |
|
result |
AsyncCopyTaskResult object |
Definition: Result of creating an asynchronous task. |
|
Parameter |
Type |
Description |
|---|---|---|
|
user_id |
String |
Definition: User ID, which is the same as the IAM user ID. Value range: N/A |
|
domain_id |
String |
Definition: Tenant ID, which is the same as the IAM tenant ID. Value range: N/A |
|
region |
String |
Definition: Huawei Cloud region. Value range: N/A |
|
Parameter |
Type |
Description |
|---|---|---|
|
id |
String |
Definition : Task ID, returned by the API for creating a check task. Each code check task, branch task, or incremental task generated through an API has a unique ID. Obtain the ID by calling the API used to . id indicates the task ID. Constraints: N/A Value range: 1 to 32 characters. Default value: N/A |
|
projectId |
String |
Definition : You can obtain the 32-character UUID by calling the API used to query the project list. Value range: 1 to 32 characters. |
Status code: 400
|
Parameter |
Type |
Description |
|---|---|---|
|
error_code |
String |
Definition: Error code. Value range: N/A |
|
error_msg |
String |
Definition: Error message. Value range: N/A |
Status code: 401
|
Parameter |
Type |
Description |
|---|---|---|
|
error_code |
String |
Definition: Error code. Value range: N/A |
|
error_msg |
String |
Definition: Error message. Value range: N/A |
Example Requests
Create two tasks using the task template with the task ID 21ac33fdfaae4132bcb88cf0a6a7a2d3. The repositories of the two tasks are from CodeArts Repo. Their project IDs are 213d2d49dbb2473e9c8d4f117ab1b0dc and bc17c7dd92c84e84be62185b5e383e90, respectively. Their Git URLs are git@codehub.devcloud.example.com:213d2d49dbb2473e9c8d4f117ab1b0dc/phoenix-sample.git and git@codehub.devcloud.example.com:bc17c7dd92c84e84be62185b5e383e90/fortran_test.git, respectively.
POST https://{endpoint}/v4/tasks/21ac33fdfaae4132bcb88cf0a6a7a2d3/batch/async-copy
[ {
"name" : "task_name1",
"taskClassificationId" : "no_grouped",
"repoUrl" : "git@codehub.devcloud.example.com:213d2d49dbb2473e9c8d4f117ab1b0dc/phoenix-sample.git",
"projectId" : "213d2d49dbb2473e9c8d4f117ab1b0dc",
"branchName" : "master",
"configTemplate" : {
"repoType" : "DevCloud"
}
}, {
"name" : "task_name2",
"taskClassificationId" : "no_grouped",
"repoUrl" : "git@codehub.devcloud.example.com:bc17c7dd92c84e84be62185b5e383e90/fortran_test.git",
"projectId" : "bc17c7dd92c84e84be62185b5e383e90",
"branchName" : "master",
"configTemplate" : {
"repoType" : "DevCloud"
}
} ]
Example Responses
Status code: 200
Request succeeded!
[ {
"id" : "24426b3d522f40719e22c4867fb79f3b",
"create_time" : "2025-09-09 11:50:41",
"type" : "CopyTask",
"status" : "RUNNING",
"user" : {
"user_id" : "4050544ea69a40dabf28310fc3d10a09",
"domain_id" : "389efb76b1354e4482eabeed25c895e4",
"region" : "cn-north-7"
}
}, {
"id" : "b7875294d47841d48c4728c7ca17994a",
"create_time" : "2025-09-09 11:50:41",
"type" : "CopyTask",
"status" : "RUNNING",
"user" : {
"user_id" : "4050544ea69a40dabf28310fc3d10a09",
"domain_id" : "389efb76b1354e4482eabeed25c895e4",
"region" : "cn-north-7"
}
} ]
Status code: 400
Bad Request
{
"error_code" : "CC.xxxxxxxx.400",
"error_msg" : "Verify request parameter failed. Check whether the request parameters are correct."
}
Status code: 401
Unauthorized
{
"error_code" : "CC.00000003",
"error_msg" : "Authentication information expired."
}
Status Codes
|
Status Code |
Description |
|---|---|
|
200 |
Request succeeded! |
|
400 |
Bad Request |
|
401 |
Unauthorized |
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