Querying the Script Version
Function
This API is used to query all versions of a script based on the script ID. The versions of the specified script will be returned.
Calling Method
For details, see Calling APIs.
URI
POST /v1/{project_id}/cms/script-version-list
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
project_id |
Yes |
String |
Project ID obtained from IAM. Generally, a project ID contains 32 characters. |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
X-Auth-Token |
Yes |
String |
User token obtained from IAM. |
Content-Type |
Yes |
String |
Content type, which is application/json. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
name |
No |
String |
Parameter input for query. On the version management page, name refers to the script name, which cannot be empty. On the script management page, name refers to the parameter input for fuzzy query. If the value of name is null, all scripts will be queried by default. |
is_default |
No |
String |
Query rule. default: Script management page displayed and fuzzy query supported. no_default: Version management page displayed. |
create_by |
No |
String |
Creator. By default, scripts are searched by creator. |
script_id |
Yes |
String |
ID of the script to be queried during version management. |
page_num |
No |
Integer |
Page number, which is a positive integer. |
page_size |
No |
Integer |
Number of records displayed on each page. Default: 10. |
project_id |
No |
String |
Project ID. |
order_by_column |
Yes |
String |
Field to be sorted. Options: name, create_time, and update_time (default). |
sort_order |
Yes |
String |
Sorting order (default: DESC). Options: ASC (ascending order) and DESC (descending order). |
enterprise_project_id |
No |
String |
Enterprise project ID, based on which you can search for required scripts. |
Response Parameters
Status code: 200
Parameter |
Type |
Description |
---|---|---|
elements |
Array of ScriptVersion objects |
Query result set. |
total_elements |
Integer |
Number of queried results. |
Parameter |
Type |
Description |
---|---|---|
content |
String |
Script content, which cannot be empty. |
create_by |
String |
Creator, for example, Tom. |
create_time |
Long |
Creation time. |
enterprise_project_id |
String |
Enterprise project ID. |
name |
String |
Script name, which can contain digits, underscores (_), and letters. |
project_id |
String |
Project ID obtained from IAM. Generally, a project ID contains 32 characters. |
job_reference_number |
Integer |
Number of times that a script version is referenced by a job. Default: 0. Do not enter a negative number. |
script_id |
String |
Script ID, which is generated based on UUID.randomUUID. |
script_language |
String |
Script language. Options: SHELL, BAT, PYTHON, and POWER_SHELL. |
status_desc |
Integer |
Status. Options: 0 (unreleased), 1 (released); 2 (offline), and 3 (prohibited). |
update_by |
String |
User who makes the modification. |
update_time |
Long |
Time when the entity was last updated. Note: When a creation, modification, or deletion operation is performed, update_time will be updated. |
version_id |
String |
Version ID, which is generated based on UUID.randomUUID. |
version_number |
String |
Script version number. Only digits, underscores (_), letters, and periods (.) are allowed. |
job_reference_name |
Array of ReferenceInfo objects |
Details of a job referenced by a script. |
Status code: 400
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Response code. |
error_msg |
String |
Error message. |
http_code |
Integer |
Returned HTTP code. |
Status code: 401
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Response code. |
error_msg |
String |
Error message. |
http_code |
Integer |
Returned HTTP code. |
Status code: 500
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Response code. |
error_msg |
String |
Error message. |
http_code |
Integer |
Returned HTTP code. |
Example Requests
Query the script version based on a specified script ID.
POST https://{Endpoint}/v1/{project_id}/cms/script-version-list { "script_id" : "xxxxxxxxxx", "page_num" : 1, "page_size" : 10, "order_by_column" : "update_time", "sort_order" : "ASC" }
Example Responses
Status code: 200
OK: The version list of the specified script is returned.
{ "elements" : [ { "content" : "1", "create_by" : "cxxxxx", "create_time" : 1676892212509, "enterprise_project_id" : "0", "job_reference_name" : [ { "job_id" : "012b43a3xxxxx684a30b52xxxx98cbe", "job_name" : "onxx_cxxxxxxxx" } ], "job_reference_number" : 1, "name" : "xxxxx", "project_id" : "2axxxxxcca548xxxxe891bxxxf", "script_id" : "xxxxaef-dbxx-41x9-8xx2-8exxxx4e159d2", "script_language" : "SHELL", "status_desc" : 1, "update_by" : "cxxxxx", "update_time" : 1672294768193, "version_id" : "xxxec4xx0-5x5-4bx0-a2xx-efeexx1c559f", "version_number" : "1" } ], "total_elements" : 1 }
Status code: 400
Bad Request: Invalid request. The client should not repeat the request without modifications.
{ "error_code" : "AOM.31002002", "error_msg" : "Invalid script parameter.", "http_code" : 400 }
Status code: 401
Unauthorized: The authentication information is incorrect or invalid.
{ "error_code" : "AOM.31009011", "error_msg" : "auth failed.", "http_code" : 401 }
Status code: 500
Internal Server Error: The server is able to receive the request but unable to understand the request.
{ "error_code" : "AOM.31002005", "error_msg" : "script internal server error.", "http_code" : 500 }
SDK Sample Code
The SDK sample code is as follows.
Java
Query the script version based on a specified script ID.
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 |
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.aom.v1.region.AomRegion; import com.huaweicloud.sdk.aom.v1.*; import com.huaweicloud.sdk.aom.v1.model.*; public class ListAllVersionByVersionIdSolution { 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"); String projectId = "{project_id}"; ICredential auth = new BasicCredentials() .withProjectId(projectId) .withAk(ak) .withSk(sk); AomClient client = AomClient.newBuilder() .withCredential(auth) .withRegion(AomRegion.valueOf("<YOUR REGION>")) .build(); ListAllVersionByVersionIdRequest request = new ListAllVersionByVersionIdRequest(); SearchScriptsRequestBody body = new SearchScriptsRequestBody(); body.withSortOrder("ASC"); body.withOrderByColumn("update_time"); body.withPageSize(10); body.withPageNum(1); body.withScriptId("xxxxxxxxxx"); request.withBody(body); try { ListAllVersionByVersionIdResponse response = client.listAllVersionByVersionId(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
Query the script version based on a specified script ID.
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 |
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkaom.v1.region.aom_region import AomRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkaom.v1 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"] projectId = "{project_id}" credentials = BasicCredentials(ak, sk, projectId) client = AomClient.new_builder() \ .with_credentials(credentials) \ .with_region(AomRegion.value_of("<YOUR REGION>")) \ .build() try: request = ListAllVersionByVersionIdRequest() request.body = SearchScriptsRequestBody( sort_order="ASC", order_by_column="update_time", page_size=10, page_num=1, script_id="xxxxxxxxxx" ) response = client.list_all_version_by_version_id(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
Query the script version based on a specified script ID.
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 |
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" aom "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/aom/v1" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/aom/v1/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/aom/v1/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") projectId := "{project_id}" auth := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). WithProjectId(projectId). Build() client := aom.NewAomClient( aom.AomClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.ListAllVersionByVersionIdRequest{} pageSizeSearchScriptsRequestBody:= int32(10) pageNumSearchScriptsRequestBody:= int32(1) request.Body = &model.SearchScriptsRequestBody{ SortOrder: "ASC", OrderByColumn: "update_time", PageSize: &pageSizeSearchScriptsRequestBody, PageNum: &pageNumSearchScriptsRequestBody, ScriptId: "xxxxxxxxxx", } response, err := client.ListAllVersionByVersionId(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 |
OK: The version list of the specified script is returned. |
400 |
Bad Request: Invalid request. The client should not repeat the request without modifications. |
401 |
Unauthorized: The authentication information is incorrect or invalid. |
500 |
Internal Server Error: The server is able to receive the request but unable to understand the request. |
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