Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

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

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID obtained from IAM. Generally, a project ID contains 32 characters.

Request Parameters

Table 2 Request header 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.

Table 3 Request body parameters

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

Table 4 Response body parameters

Parameter

Type

Description

elements

Array of ScriptVersion objects

Query result set.

total_elements

Integer

Number of queried results.

Table 5 ScriptVersion

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.

Table 6 ReferenceInfo

Parameter

Type

Description

job_id

String

Job ID.

job_name

String

Job name.

Status code: 400

Table 7 Response body parameters

Parameter

Type

Description

error_code

String

Response code.

error_msg

String

Error message.

http_code

Integer

Returned HTTP code.

Status code: 401

Table 8 Response body parameters

Parameter

Type

Description

error_code

String

Response code.

error_msg

String

Error message.

http_code

Integer

Returned HTTP code.

Status code: 500

Table 9 Response body parameters

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.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback