Queries the execution list and states of Cloud Assistant commands.
Operation description
-
After you run a command, the command may fail to run or may return unexpected results. You can call this operation to query the execution results.
-
You can query information about command executions within the last four weeks. Up to 100,000 pieces of execution information can be retained.
-
You can subscribe to Cloud Assistant task status events to obtain command execution results from the events. This helps you reduce the number of times to poll API operations and improve efficiency.
-
During a paged query, when you call the DescribeInvocations operation to retrieve the first page of results, set
MaxResults
to specify the maximum number of entries to return in the call. The return value ofNextToken
is a pagination token that can be used in the next call to retrieve a new page of results. When you call the DescribeInvocations operation to retrieve a new page of results, setNextToken
to theNextToken
value returned in the previous call and setMaxResults
to specify the maximum number of entries to return in this call. -
Differences between the
DescribeInvocations
andDescribeInvocationResults
operations:-
Scenario in which the
RunCommand
orInvokeCommand
operation is called to run a Cloud Assistant command on multiple instances:- The
DescribeInvocations
operation queries the execution status of the command on each instance and the overall execution status of the command on all instances. - The
DescribeInvocationResults
operation queries only the execution status of the command on each instance.
- The
-
Scenario in which the
RunCommand
orInvokeCommand
operation is called to run a Cloud Assistant command on a single instance:- The
DescribeInvocations
operation is equivalent to theDescribeInvocationResults
operation.
- The
-
If you want to query the status of each execution for a scheduled (recurring) task or a task that is automatically executed on instance startup (
RepeatMode is set to Period or EveryReboot
), you can call only theDescribeInvocationResults
operation and must setIncludeHistory
to true. TheDescribeInvocations
operation queries only the most recent execution status of the command. -
If you want to view the command content and parameters, you can call only the
DescribeInvocations
operation and check theCommandContent
value in the response.
-
Debugging
Authorization information
The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action
policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:
- Operation: the value that you can use in the Action element to specify the operation on a resource.
- Access level: the access level of each operation. The levels are read, write, and list.
- Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
- The required resource types are displayed in bold characters.
- If the permissions cannot be granted at the resource level,
All Resources
is used in the Resource type column of the operation.
- Condition Key: the condition key that is defined by the cloud service.
- Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
Operation | Access level | Resource type | Condition key | Associated operation |
---|---|---|---|---|
ecs:DescribeInvocations | get | *Instance acs:ecs:{#regionId}:{#accountId}:instance/{#instanceId} *Command acs:ecs:{#regionId}:{#accountId}:command/{#commandId} |
| none |
Request parameters
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
RegionId | string | Yes | The region ID. You can call the DescribeRegions operation to query the most recent list of regions. | cn-hangzhou |
ResourceGroupId | string | No | The ID of the resource group. After you set this parameter, command execution results in the specified resource group are queried. | rg-bp67acfmxazb4p**** |
InvokeId | string | No | The command task ID. | t-hz0jdfwd9f**** |
CommandId | string | No | The command ID. You can call the DescribeCommands operation to query all available command IDs. | c-hz0jdfwcsr**** |
CommandName | string | No | The command name. If you specify both this parameter and | CommandTestName |
CommandType | string | No | The command type. Valid values:
| RunShellScript |
Timed | boolean | No | Specifies whether the command is to be automatically run. Valid values:
Default value: false. | true |
InvokeStatus | string | No | The overall execution status of the command task. The value of this parameter depends on the execution states of the command task on all involved instances. Valid values:
| Finished |
InstanceId | string | No | The ID of instance N. When you specify this parameter, the system queries all the execution records of all the commands that run on the instance. | i-bp1i7gg30r52z2em**** |
ContentEncoding | string | No | The encoding mode of the
Default value: Base64. | PlainText |
IncludeOutput | boolean | No | Specifies whether to return the command outputs in the response.
Default value: false | false |
PageNumber | long | No | Note
This parameter will be removed in the future. We recommend that you use NextToken and MaxResults for a paged query.
| 1 |
PageSize | long | No | Note
This parameter will be removed in the future. We recommend that you use NextToken and MaxResults for a paged query.
| 10 |
MaxResults | integer | No | The maximum number of entries per page. Valid values: 1 to 50. Default value: 10. | 10 |
NextToken | string | No | The pagination token that is used in the next request to retrieve a new page of results. You must specify the token that is obtained from the previous query as the value of NextToken. | AAAAAdDWBF2 |
RepeatMode | string | No | The execution mode of the command. If you specify both this parameter and
This parameter is empty by default, which indicates that commands run in all modes are queried. | Once |
Tag | array<object> | No | The tags that are added to the command. | |
object | No | The tag that is added to the command. | ||
Key | string | No | The key of tag N of the command. You can specify up to 20 tag keys for the command. The tag key cannot be an empty string. If a single tag is specified to query resources, up to 1,000 resources that have this tag added can be displayed in the response. If multiple tags are specified to query resources, up to 1,000 resources that have all these tags added can be displayed in the response. To query more than 1,000 resources that have specified tags added, call the ListTagResources operation. The tag key can be up to 64 characters in length and cannot contain | TestKey |
Value | string | No | The value of tag N of the command. You can specify up to 20 tag values for the command. The tag value can be an empty string. It can be up to 128 characters in length and cannot contain | TestValue |
Response parameters
Examples
Sample success responses
JSON
format
{
"PageSize": 10,
"RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3****",
"PageNumber": 1,
"TotalCount": 1,
"NextToken": "AAAAAdDWBF2",
"Invocations": {
"Invocation": [
{
"CreationTime": "2020-01-19T09:15:46Z",
"Frequency": "0 */20 * * * *",
"InvocationStatus": "Running",
"RepeatMode": "Once",
"CommandId": "c-hz0jdfwcsr****",
"CommandType": "RunShellScript",
"InvokeStatus": "Finished",
"Parameters": "{}",
"Timed": false,
"CommandContent": "cnBtIC1xYSB8IGdyZXAgdnNm****",
"CommandName": "CommandTestName",
"CommandDescription": "testDescription",
"InvokeId": "t-hz0jdfwd9f****",
"Username": "root",
"WorkingDir": "/home/",
"Timeout": 60,
"ContainerId": "ab141ddfbacfe02d9dbc25966ed971536124527097398d419a6746873fea****",
"ContainerName": "test-container",
"TerminationMode": "ProcessTree",
"Launcher": "python3 -u {{ACS::ScriptFileName|Ext(\".py\")}}",
"InvokeInstances": {
"InvokeInstance": [
{
"CreationTime": "2019-12-20T06:15:54Z",
"UpdateTime": "2020-01-19T09:15:47Z",
"FinishTime": "2019-12-20T06:15:56Z",
"InvocationStatus": "Success",
"Repeats": 0,
"InstanceId": "i-bp1i7gg30r52z2em****",
"Output": "OutPutTestmsg",
"Dropped": 0,
"StopTime": "2020-01-19T09:15:47Z",
"ExitCode": 0,
"StartTime": "2019-12-20T06:15:55Z",
"ErrorInfo": "the specified instance does not exists",
"Timed": false,
"ErrorCode": "InstanceNotExists",
"InstanceInvokeStatus": "Finished"
}
]
},
"Tags": {
"Tag": [
{
"TagKey": "owner",
"TagValue": "zhangsan"
}
]
}
}
]
}
}
Error codes
HTTP status code | Error code | Error message | Description |
---|---|---|---|
400 | RegionId.ApiNotSupported | The api is not supported in this region. | The API operation cannot be called in the specified region. Check whether the specified RegionId parameter is valid. |
400 | NumberExceed.Tags | The Tags parameter number is exceed. | The number of tags exceeds the maximum limit. |
400 | Duplicate.TagKey | The Tag.N.Key contain duplicate key. | The specified tag key already exists. Tag keys must be unique. |
400 | InvalidTagKey.Malformed | The specified Tag.n.Key is not valid. | The specified Tag.N.Key parameter is invalid. |
400 | InvalidTagValue.Malformed | The specified Tag.n.Value is not valid. | The specified tag value is invalid. |
400 | MissingParameter.TagKey | You must specify Tag.N.Key. | The tag key is not specified. |
400 | InvalidParam.PageNumber | The specified parameter is invalid. | The specified PageNumber parameter is invalid. |
400 | InvalidParam.PageSize | The specified parameter is invalid. | The specified PageSize parameter is invalid. |
400 | InvalidParameter.NextToken | The specified parameter NextToken is not valid. | The specified parameter NextToken is illegal. |
400 | InvalidParameter.MaxResults | The specified parameter MaxResults is not valid. | The specified parameter MaxResults is illegal. |
403 | Operation.Forbidden | The operation is not permitted. | The operation is not supported. |
404 | InvalidRegionId.NotFound | The RegionId provided does not exist in our records. | The RegionId provided does not exist |
500 | InternalError.Dispatch | An error occurred when you dispatched the request. | An error occurred while the request is being sent. Try again later. |
For a list of error codes, visit the Service error codes.
Change history
Change time | Summary of changes | Operation |
---|---|---|
2024-12-05 | API Description Update. The Error code has changed | View Change Details |
2024-08-01 | The Error code has changed. The response structure of the API has changed | View Change Details |
2024-05-14 | The Error code has changed. The response structure of the API has changed | View Change Details |
2023-12-21 | The Error code has changed. The request parameters of the API has changed. The response structure of the API has changed | View Change Details |
2023-05-12 | The Error code has changed | View Change Details |
2022-07-07 | The Error code has changed. The response structure of the API has changed | View Change Details |
2022-06-22 | The Error code has changed. The response structure of the API has changed | View Change Details |
2021-05-12 | The Error code has changed | View Change Details |