Batch Baselining or Canceling Baseline of Plans
Function
This API is used to baseline or cancel the baseline of project plans in a batch.
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.
URI
PUT /v1/planservice/projects/{project_id}/plans/batch-baseline
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| project_id | Yes | String | Definition 32-character UUID of a project, which uniquely identifies a project. Obtain the value of this parameter from the project_id field in the response body of the API for querying the project list. Constraints A string of 32 characters consisting of letters and digits. Range N/A Default Value N/A |
Request Parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| x-auth-token | Yes | String | Definition User token. Obtain a token by calling the IAM API for obtaining a user token. The value of X-Subject-Token in the response header is the user token. Constraints N/A Range A string of 10 to 32,768 characters Default Value N/A |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| ids | Yes | Array of strings | Definition List of release/sprint IDs. You can obtain the release/sprint ID using the API for querying the release/sprint list. The value of the id field in the response message body is the release/sprint ID. Constraints N/A Range N/A Default Value N/A |
| attribute | Yes | BaseLineVO object | Definition Baseline attribute information, which specifies the baseline or cancels the baseline operation. Constraints N/A |
Response Parameters
Status code: 200
| Parameter | Type | Description |
|---|---|---|
| status | String | Definition Response status. Range |
| message | String | Definition Returned message. Range N/A |
| result | BatchResultVO object | Definition Batch operation result data. |
| Parameter | Type | Description |
|---|---|---|
| success_num | Number | Definition The number of succeeded items in the batch operation task. Range N/A |
| fail_num | Number | Definition The number of failed items in the batch operation task. Range N/A |
| success | Array of BatchOperateInfo objects | Definition List of plans that are successfully operated in batches. |
| failed | Array of BatchOperateInfo objects | Definition List of plans that fail to be operated in batches. |
| Parameter | Type | Description |
|---|---|---|
| id | String | Definition Release/Sprint plan ID. Range The value is a numeric string of 18 to 19 characters. |
| modified_by | String | Definition ID of the last updater. Range N/A |
Status code: 400
| Parameter | Type | Description |
|---|---|---|
| error_msg | String | Definition Error message. Range N/A |
| error_code | String | Definition Error code. Range N/A |
Example Requests
PUT https://{endpoint}/v1/planservice/projects/b54914d464d1498a97d683ef198ec448/plans/batch-baseline
{
"ids" : [ "6614174000", "6614174000" ],
"attribute" : {
"baseline" : "Baseline"
}
} Example Responses
Status code: 200
{
"status" : "success",
"message" : null,
"result" : {
"success_num" : 3,
"fail_num" : 1,
"success" : [ {
"id" : "123e4567e89b12d3a456426614174000",
"modified_by" : "user1"
}, {
"id" : "123e4567e89b12d3a456426614174001",
"modified_by" : "user2"
}, {
"id" : "123e4567e89b12d3a456426614174002",
"modified_by" : "user3"
} ],
"failed" : [ {
"id" : "123e4567e89b12d3a456426614174003",
"modified_by" : "user4"
} ]
}
} Status code: 400
{
"error_msg" : "Invalid project_id or other parameters",
"error_code" : "AS.0001"
} SDK Sample Code
The SDK sample code is as follows.
Java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | package com.huaweicloud.sdk.test; import com.huaweicloud.sdk.core.auth.ICredential; import com.huaweicloud.sdk.core.auth.BasicCredentials; import com.huaweicloud.sdk.core.exception.ConnectionException; import com.huaweicloud.sdk.core.exception.RequestTimeoutException; import com.huaweicloud.sdk.core.exception.ServiceResponseException; import com.huaweicloud.sdk.projectman.v4.region.ProjectManRegion; import com.huaweicloud.sdk.projectman.v4.*; import com.huaweicloud.sdk.projectman.v4.model.*; import java.util.List; import java.util.ArrayList; public class BatchUpdateBaselineSolution { public static void main(String[] args) { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment String ak = System.getenv("CLOUD_SDK_AK"); String sk = System.getenv("CLOUD_SDK_SK"); ICredential auth = new BasicCredentials() .withAk(ak) .withSk(sk); ProjectManClient client = ProjectManClient.newBuilder() .withCredential(auth) .withRegion(ProjectManRegion.valueOf("<YOUR REGION>")) .build(); BatchUpdateBaselineRequest request = new BatchUpdateBaselineRequest(); request.withProjectId("{project_id}"); OperateSprintReqVO body = new OperateSprintReqVO(); BaseLineVO attributebody = new BaseLineVO(); attributebody.withBaseline("Baseline"); List<String> listbodyIds = new ArrayList<>(); listbodyIds.add("6614174000"); listbodyIds.add("6614174000"); body.withAttribute(attributebody); body.withIds(listbodyIds); request.withBody(body); try { BatchUpdateBaselineResponse response = client.batchUpdateBaseline(request); System.out.println(response.toString()); } catch (ConnectionException e) { e.printStackTrace(); } catch (RequestTimeoutException e) { e.printStackTrace(); } catch (ServiceResponseException e) { e.printStackTrace(); System.out.println(e.getHttpStatusCode()); System.out.println(e.getRequestId()); System.out.println(e.getErrorCode()); System.out.println(e.getErrorMsg()); } } } |
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | # coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkprojectman.v4.region.projectman_region import ProjectManRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkprojectman.v4 import * if __name__ == "__main__": # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak = os.environ["CLOUD_SDK_AK"] sk = os.environ["CLOUD_SDK_SK"] credentials = BasicCredentials(ak, sk) client = ProjectManClient.new_builder() \ .with_credentials(credentials) \ .with_region(ProjectManRegion.value_of("<YOUR REGION>")) \ .build() try: request = BatchUpdateBaselineRequest() request.project_id = "{project_id}" attributebody = BaseLineVO( baseline="Baseline" ) listIdsbody = [ "6614174000", "6614174000" ] request.body = OperateSprintReqVO( attribute=attributebody, ids=listIdsbody ) response = client.batch_update_baseline(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg) |
Go
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" projectman "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/projectman/v4" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/projectman/v4/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/projectman/v4/region" ) func main() { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak := os.Getenv("CLOUD_SDK_AK") sk := os.Getenv("CLOUD_SDK_SK") auth, err := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). SafeBuild() if err != nil { fmt.Println(err) return } hcClient, err := projectman.ProjectManClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). SafeBuild() if err != nil { fmt.Println(err) return } client := projectman.NewProjectManClient(hcClient) request := &model.BatchUpdateBaselineRequest{} request.ProjectId = "{project_id}" baselineAttribute:= "Baseline" attributebody := &model.BaseLineVo{ Baseline: &baselineAttribute, } var listIdsbody = []string{ "6614174000", "6614174000", } request.Body = &model.OperateSprintReqVo{ Attribute: attributebody, Ids: listIdsbody, } response, err := client.BatchUpdateBaseline(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } } |
More
For SDK sample code of more programming languages, see the Sample Code tab in API Explorer. SDK sample code can be automatically generated.
Status Codes
| Status Code | Description |
|---|---|
| 200 | Batch baseline creation or cancellation succeeded. |
| 400 | Bad Request |
Error Codes
See Error Codes.
What is your overall rating for this page?
Thank 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