Updated on 2025-10-24 GMT+08:00

Executing Common Scripts

Function

This API is used to execute public scripts.

Script input parameters, timeout interval, execution user, and limited resources are included.

Constraints

  • A maximum of 20 script input parameters are supported.

  • A maximum of 200 hosts can be delivered at a time.

  • A maximum of 10 hosts can be contained in a batch.

  • A maximum of 20 batches are allowed.

Authorization Information

Each account has all the permissions required to call all APIs, but IAM users must be assigned the required permissions.

  • If you are using role/policy-based authorization, see Permissions Policies and Supported Actions for details on the required permissions.
  • If you are using identity policy-based authorization, the following identity policy-based permissions are required.

    Action

    Access Level

    Resource Type (*: required)

    Condition Key

    Alias

    Dependencies

    coc:instance:executeDocument

    Write

    document *

    -

    -

    -

    instance *

    -

URI

POST /v1/job/public-scripts/{script_uuid}

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

script_uuid

Yes

String

Definition:

UUID of the public script.

Constraints:

N/A.

Value range:

N/A.

Default value:

N/A.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Definition:

Tenant token.

Constraints:

Tenant token obtained from IAM.

Value range:

N/A.

Default value:

N/A.

X-Language

No

String

Definition:

Internationalization tag. zh-cn indicates Chinese, and en-us or no value indicates English.

Constraints:

zh-cn indicates Chinese, and en-us or no value indicates English.

Value range:

zh-cn and en-us

Default value:

N/A.

x-project-id

No

String

Definition:

The project ID.

Constraints:

Project ID corresponding to the region.

Value range:

N/A.

Default value:

N/A.

x-user-profile

No

String

Definition:

IAM 5.0 user information.

Constraints:

N/A.

Value range:

N/A.

Default value:

N/A.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

execute_param

Yes

ScriptExecuteParam object

Definition:

Script execution parameter.

Constraints:

N/A.

Value range:

N/A.

Default value:

N/A.

execute_batches

Yes

Array of ExecuteInstancesBatchInfo objects

Definition:

Batch information of the target instance

Constraints:

N/A.

Value range:

N/A.

Default value:

N/A.

Table 4 ScriptExecuteParam

Parameter

Mandatory

Type

Description

resourceful

No

Boolean

Definition:

This parameter has been discarded and does not take effect when it is transferred.

Constraints:

N/A.

Value range:

N/A.

Default value:

N/A.

timeout

Yes

Integer

Definition:

Timeout.

Constraints:

The unit is second. The value range is 5 < timeout < 1800.

Value range:

N/A.

Default value:

N/A.

success_rate

Yes

Double

Definition:

Success rate.

Constraints:

A value with one decimal place is supported.

Value range:

1–100

Default value:

N/A.

execute_user

Yes

String

Definition:

User who executes the script. The script must be executed by user root.

Constraints:

N/A.

Value range:

N/A.

Default value:

N/A.

script_params

No

Array of ScriptExecuteInputParam objects

Definition:

Script input parameters.

Constraints:

N/A.

Value range:

N/A.

Default value:

N/A.

Table 5 ScriptExecuteInputParam

Parameter

Mandatory

Type

Description

param_name

Yes

String

Definition:

Name of a script input parameter. The parameter name must be unique in the same script.

Constraints:

N/A.

Value range:

N/A.

Default value:

N/A.

param_value

Yes

String

Definition:

Value of the script input parameter, which is mandatory by default. This parameter can be left empty when there are referenced parameters (param_refer is not empty).

Constraints:

The parameter value contains 1 to 4096 characters.

The value can contain uppercase letters, lowercase letters, digits, and special characters (_-/.*?:",=+@#[{]}).

Consecutive periods (.) are not allowed.

Value range:

N/A.

Default value:

N/A.

param_order

No

Integer

Definition:

This parameter has been discarded and does not take effect when it is configured.

Constraints:

N/A.

Value range:

N/A.

Default value:

N/A.

param_refer

No

ScriptExecuteParamReference object

Definition:

Parameter reference.

Constraints:

N/A.

Value range:

N/A.

Default value:

N/A.

Table 6 ScriptExecuteParamReference

Parameter

Mandatory

Type

Description

refer_type

Yes

String

Definition:

Parameter reference type: PARAM_STORE

Constraints:

N/A.

Value range:

N/A.

Default value:

N/A.

param_id

Yes

String

Definition:

Unique primary key ID of a referenced parameter.

Constraints:

  • LOW

  • MEDIUM

  • HIGH

Value range:

N/A.

Default value:

N/A.

param_version

No

String

Definition:

Version of the reference parameter.

Constraints:

N/A.

Value range:

N/A.

Default value:

N/A.

Table 7 ExecuteInstancesBatchInfo

Parameter

Mandatory

Type

Description

batch_index

Yes

Integer

Definition:

Batch index, starting from 1.

Constraints:

N/A.

Value range:

N/A.

Default value:

N/A.

target_instances

Yes

Array of ExecuteResourceInstance objects

Definition:

Target nodes.

Constraints:

N/A.

Value range:

N/A.

Default value:

N/A.

rotation_strategy

Yes

String

Definition:

Policy for determining whether to pause or continue an execution

Constraints:

The value can be CONTINUE or

PAUSE.

Value range:

CONTINUE or PAUSE.

Default value:

N/A.

Table 8 ExecuteResourceInstance

Parameter

Mandatory

Type

Description

resource_id

Yes

String

Definition:

ECS ID.

Constraints:

N/A.

Value range:

N/A.

Default value:

N/A.

region_id

Yes

String

Definition:

Region to which the server belongs.

Constraints:

N/A.

Value range:

N/A.

Default value:

N/A.

provider

No

String

Definition:

Resource provider: ECS. If this parameter is not specified, the default value ECS is used. Ensure that the provider of each instance is the same. CCE instances will be supported later.

Constraints:

N/A.

Value range:

N/A.

Default value:

N/A.

type

No

String

Definition:

Resource type of the resource provider. If this parameter is not specified, CLOUDSERVER is used by default.

CLOUDSERVER: Cloud server type.

Constraints:

Cross-type support is not allowed.

Value range:

N/A.

Default value:

N/A.

custom_attributes

No

Array of Customttribute objects

Definition:

Custom attributes in the key_value format. A maximum of five attributes can be customized.

Constraints:

The length of the key is 10.

The length of the value is 20.

The maximum length of the map is 5.

Do not enter sensitive data.

Value range:

N/A.

Default value:

N/A.

agent_sn

No

String

Definition:

This parameter has been discarded and does not take effect when it is configured.

Constraints:

N/A.

Value range:

N/A.

Default value:

N/A.

project_id

No

String

Definition:

This parameter has been discarded and does not take effect when it is configured.

Constraints:

N/A.

Value range:

N/A.

Default value:

N/A.

Table 9 Customttribute

Parameter

Mandatory

Type

Description

key

Yes

String

Definition:

Key of a custom attribute.

Constraints:

N/A.

Value range:

N/A.

Default value:

N/A.

value

Yes

String

Definition:

Value of a custom attribute.

Constraints:

N/A.

Value range:

N/A.

Default value:

N/A.

Response Parameters

Status code: 200

Table 10 Response body parameters

Parameter

Type

Description

data

String

Response parameters for executing a public script: execute_uuid.

Example Requests

Execute a public script.

POST https://{Endpoint}/v1/job/public-scripts/{script_uuid}

{
  "execute_param" : {
    "timeout" : 300,
    "execute_user" : "SYSTEM",
    "success_rate" : "100.0",
    "script_params" : [ {
      "param_name" : "action",
      "param_value" : "start",
      "param_order" : 1
    } ]
  },
  "execute_batches" : [ {
    "batch_index" : 1,
    "rotation_strategy" : "CONTINUE",
    "target_instances" : [ {
      "agent_sn" : "705c526eb7774c51xxxxxxxxxxxxxxxx",
      "resource_id" : "7c118539-15ab-41d3-xxxxxxxxxxxxxxxx",
      "enterprise_project_id" : "0",
      "project_id" : "10a6c23c2a10447797xxxxxxxxxxxxxxxx",
      "region_id" : "xxx",
      "provider" : "ECS",
      "type" : "CLOUDSERVERS",
      "properties" : {
        "host_name" : "ecs-b007-0001",
        "fixed_ip" : "192.168.x.xx",
        "region_id" : "xxx",
        "zone_id" : "xxx",
        "project_id" : "10a6c23c2a10447797xxxxxxxxxxxxxxxx"
      }
    } ]
  } ],
  "ticket_infos" : [ ]
}

Example Responses

Status code: 200

Request result is returned.

For more status codes, see Status Codes.

{
  "data" : "SCT2023083109562xxxxxxxxxx"
}

Status Codes

Status Code

Description

200

Request result is returned.

For more status codes, see Status Codes.

Error Codes

See Error Codes.