Querying a Script
Function
This API is used to query a script. You can specify a script name and creator for exact query. Information about the corresponding script will be returned.
Calling Method
For details, see Calling APIs.
URI
POST /v1/{project_id}/cms/script/list
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
project_id |
Yes |
String |
Project ID. |
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 Script objects |
Query result set. |
total_elements |
Integer |
Number of queried results. |
Parameter |
Type |
Description |
---|---|---|
approve_info |
ApproveInfo object |
Review information. |
create_by |
String |
Creator, for example, Tom. |
create_time |
Long |
Creation time. |
description |
String |
Script description, which can contain a maximum of 1000 characters. |
enterprise_project_id |
String |
Enterprise project ID. |
id |
String |
Script ID, which is generated based on UUID.randomUUID. |
name |
String |
Script name, which can contain digits, underscores (_), and letters. |
online_exist_status |
Boolean |
Whether a version has been released. Options: true (a version has been released) and false (no version has been released). |
online_id |
String |
ID of the released version. |
project_id |
String |
Project ID obtained from IAM. Generally, a project ID contains 32 characters. |
rate_control |
RateControl object |
Execution policy. |
script_language |
String |
Script language. Options: SHELL, BAT, PYTHON, and POWER_SHELL. |
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. |
Parameter |
Type |
Description |
---|---|---|
topic_selected |
String |
Selected topic. |
need_approve |
Boolean |
Whether a review is needed. Options: true and false (default). |
smn_urn_list |
String |
Topic URN set. |
Parameter |
Type |
Description |
---|---|---|
have_rate_control |
Boolean |
Whether to implement batch release. Default: false. |
time_delay |
Integer |
Interval. |
max |
Integer |
Maximum number of instances supported for batch release. |
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
Obtain the list of scripts whose name is xxx and sort order is DESC.
https://{endpoint}/v1/{project_id}/cms/script/list { "name" : "xxx", "create_by" : "user1", "enterprise_project_id" : "", "page_num" : 1, "page_size" : 10, "is_default" : "default", "order_by_column" : "create_time", "sort_order" : "DESC", "script_id" : "" }
Example Responses
Status code: 200
OK: The basic script information is returned.
{ "elements" : [ { "approve_info" : { "need_approve" : false }, "create_by" : "chenkaiyuan", "create_time" : 1600076223389, "description" : "fassfa", "enterprise_project_id" : "0", "id" : "xxxxxxxxxxxxxxxxxxx", "name" : "awffawsafws", "online_exist_status" : false, "project_id" : "xxxxxxxxxxxxxxxxxxx", "rate_control" : { "have_rate_control" : false, "max" : 0, "time_delay" : 0 }, "script_language" : "SHELL", "update_by" : "xxxx", "update_time" : 1600076223389 } ], "total_elements" : 1 }
Status code: 400
Bad Request: Invalid request. The client should not repeat the request without modifications.
{ "error_code" : "AOM.31002002", "error_message" : "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
Obtain the list of scripts whose name is xxx and sort order is DESC.
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 |
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 ListAllScriptByNameSolution { 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(); ListAllScriptByNameRequest request = new ListAllScriptByNameRequest(); SearchScriptsRequestBody body = new SearchScriptsRequestBody(); body.withEnterpriseProjectId(""); body.withSortOrder("DESC"); body.withOrderByColumn("create_time"); body.withPageSize(10); body.withPageNum(1); body.withScriptId(""); body.withCreateBy("user1"); body.withIsDefault("default"); body.withName("xxx"); request.withBody(body); try { ListAllScriptByNameResponse response = client.listAllScriptByName(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
Obtain the list of scripts whose name is xxx and sort order is DESC.
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 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 = ListAllScriptByNameRequest() request.body = SearchScriptsRequestBody( enterprise_project_id="", sort_order="DESC", order_by_column="create_time", page_size=10, page_num=1, script_id="", create_by="user1", is_default="default", name="xxx" ) response = client.list_all_script_by_name(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
Obtain the list of scripts whose name is xxx and sort order is DESC.
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 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.ListAllScriptByNameRequest{} enterpriseProjectIdSearchScriptsRequestBody:= "" pageSizeSearchScriptsRequestBody:= int32(10) pageNumSearchScriptsRequestBody:= int32(1) createBySearchScriptsRequestBody:= "user1" isDefaultSearchScriptsRequestBody:= "default" nameSearchScriptsRequestBody:= "xxx" request.Body = &model.SearchScriptsRequestBody{ EnterpriseProjectId: &enterpriseProjectIdSearchScriptsRequestBody, SortOrder: "DESC", OrderByColumn: "create_time", PageSize: &pageSizeSearchScriptsRequestBody, PageNum: &pageNumSearchScriptsRequestBody, ScriptId: "", CreateBy: &createBySearchScriptsRequestBody, IsDefault: &isDefaultSearchScriptsRequestBody, Name: &nameSearchScriptsRequestBody, } response, err := client.ListAllScriptByName(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 basic script information 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