All Products
Search
Document Center

Elastic Compute Service:DescribeCommands

Last Updated:Sep 29, 2024

Queries the Cloud Assistant commands that you created or the common Cloud Assistant commands that Alibaba Cloud provides.

Operation description

Usage notes

  • If you specify only Action and RegionId, all available commands (CommandId) that you created in the specified region are queried by default.

  • You can use one of the following methods to check the responses:

    • Method 1: During a paged query, when you call the DescribeCommands 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 of NextToken is a pagination token, which can be used in the next request to retrieve a new page of results. When you call the DescribeCommands operation to retrieve a new page of results, set NextToken to the NextToken value returned in the previous call and set MaxResults to specify the maximum number of entries to return in this call.
    • Method 2: Use PageSize to specify the number of entries to return on each page and then use PageNumber to specify the number of the page to return. You can use only one of the preceding methods. If you specify MaxResults or NextToken, the PageSize and PageNumber request parameters do not take effect and the TotalCount response parameter is invalid.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer.

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.
OperationAccess levelResource typeCondition keyAssociated operation
ecs:DescribeCommandsget
  • Command
    acs:ecs:{#regionId}:{#accountId}:command/*
  • Command
    acs:ecs:{#regionId}:{#accountId}:command/{#commandId}
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
RegionIdstringYes

The region ID of the command. You can call the DescribeRegions operation to query the most recent region list.

cn-hangzhou
ProviderstringNo

The provider of the common command. Take note of the following items:

  • If you do not specify this parameter, all the commands that you created are queried.

  • If you set this parameter to AlibabaCloud, all the common commands provided by Alibaba Cloud are queried.

  • If you set this parameter to a specific provider, all the common commands provided by the provider are queried. Examples:

    • If you set Provider to AlibabaCloud.ECS.GuestOS, all the common commands provided by AlibabaCloud.ECS.GuestOS are queried.
    • If you set Provider to AlibabaCloud.ECS.GuestOSDiagnose, all the common commands provided by AlibabaCloud.ECS.GuestOSDiagnose are queried.
AlibabaCloud
CommandIdstringNo

The ID of the command.

c-hz01272yr52****
NamestringNo

The name of the command.

If you specify Provider, fuzzy search is supported by default.

If you do not specify Provider, prefix-based fuzzy search is supported. For example, if you specify command*, all commands whose names start with command are queried.

testName
DescriptionstringNo

The description of the command.

If you specify Provider, fuzzy search is supported by default.

If you do not specify Provider, prefix-based fuzzy search is supported. For example, if you specify test*, all commands whose descriptions start with test are queried.

testDescription
TypestringNo

The type of the command. Valid values:

  • RunBatScript: batch command, applicable to Windows instances
  • RunPowerShellScript: PowerShell command, applicable to Windows instances
  • RunShellScript: shell command, applicable to Linux instances
RunShellScript
ContentEncodingstringNo

The encoding mode of the CommandContent and Output values in the response. Valid values:

  • PlainText: returns the original command content and command output.
  • Base64: returns the Base64-encoded command content and command output.

Default value: Base64.

PlainText
PageNumberlongNo

The page number.

Pages start from page 1.

Default value: 1.

1
PageSizelongNo

The number of entries per page.

Valid values: 1 to 50.

Default value: 10.

10
MaxResultsintegerNo

The maximum number of entries per page.

Valid values: 1 to 50.

Default value: 10.

10
NextTokenstringNo

The pagination token that is used in the next request to retrieve a new page of results. You do not need to specify this parameter for the first request. You must specify the token that is obtained from the previous query as the value of NextToken.

AAAAAdDWBF2
LatestbooleanNo

Specifies whether to query only the latest version of common commands when common commands are queried. This parameter does not affect the query for private commands.

  • true: queries only the latest version of common commands.
  • false: queries all versions of common commands.

Default value: false.

true
ResourceGroupIdstringNo

The ID of the resource group to which the command belongs.

rg-123******
Tagarray<object>No

The list of tags.

objectNo

The list of tags.

KeystringNo

The key of tag N of the command. Valid values of N: 1 to 20. 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, call the ListTagResources operation.

The tag key can be up to 64 characters in length and cannot start with acs: or aliyun. It cannot contain http:// or https://.

TestKey
ValuestringNo

The value of tag N of the command. Valid values of N: 1 to 20. The tag value can be an empty string.

It can be up to 128 characters in length and cannot contain http:// or https://.

TestValue

Response parameters

ParameterTypeDescriptionExample
object
PageSizelong

The number of entries per page.

10
RequestIdstring

The ID of the request.

473469C7-AA6F-4DC5-B3DB-A3DC0DE3****
PageNumberlong

The page number.

1
TotalCountlong

The total number of commands.

5
NextTokenstring

A pagination token. It can be used in the next request to retrieve a new page of results.

AAAAAdDWBF2
Commandsarray<object>

The queried commands.

Commandobject

The queried commands.

CreationTimestring

The time when the command was created.

2020-11-17T06:52Z
Typestring

The type of the command.

RunShellScript
Timeoutlong

The timeout period. Unit: seconds.

3600
InvokeTimesinteger

The number of tasks created by using the command.

2
CommandIdstring

The command ID.

c-hz01272yr52****
WorkingDirstring

The execution path of the command.

/home/
Descriptionstring

The description of the command.

testDescription
Versioninteger

The version of the common command. If multiple common commands from the same provider (Provider) belong to the same category and have the same name, these commands are different versions of the same command. This parameter is not returned for the Cloud Assistant commands that you created.

1
Providerstring

The provider of the common command.

AlibabaCloud.ECS.GuestOS
CommandContentstring

The content of the command, which is Base64-encoded.

  • If ContentEncoding is set to PlainText in the request, the original command content is returned.
  • If ContentEncoding is set to Base64 in the request, the Base64-encoded command content is returned.
Y2QgL3Jvb3Q=
Categorystring

The category of the common command.

“”
Latestboolean

Indicates whether the common command is of the latest version. If multiple common commands from the same provider (Provider) belong to the same category and have the same name, these commands are different versions of the same command. This parameter is not returned for the Cloud Assistant commands that you created.

true
Namestring

The name of the command.

testName
EnableParameterboolean

Indicates whether the custom parameter feature is enabled for the command.

true
ResourceGroupIdstring

The ID of the resource group to which the command belongs.

rg-123******
ParameterNamesarray

The custom parameter names that are parsed from the command content specified when the command was created. If the custom parameter feature is disabled, an empty list is returned.

ParameterNamestring

The list of custom parameter names that are parsed from the command content specified when the command was created. If the custom parameter feature is disabled, an empty list is returned.

['parameter1','parameter2']
ParameterDefinitionsarray<object>

The custom parameters.

ParameterDefinitionobject

The custom parameters.

Requiredboolean

Indicates whether the custom parameter is required. Valid values:

  • true
  • false

Default value: false.

true
Descriptionstring

The description of the custom parameter.

Download path of the Cloud Assistant Agent installation package.
DefaultValuestring

The default value of the custom parameter.

https://aliyun-client-assist.oss-accelerate.aliyuncs.com/linux/aliyun_assist_latest.rpm
ParameterNamestring

The name of the custom parameter.

DownloadUrl
PossibleValuesarray

The valid values of the custom parameter of the enumeration type.

PossibleValuestring

The valid values of the custom parameter of the enumeration type.

"Linux","Windows"
Tagsarray<object>

The tags of the command.

Tagobject

The tags of the command.

TagKeystring

The tag key of the command.

owner
TagValuestring

The tag value of the command.

zhangsan

Examples

Sample success responses

JSONformat

{
  "PageSize": 10,
  "RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3****",
  "PageNumber": 1,
  "TotalCount": 5,
  "NextToken": "AAAAAdDWBF2",
  "Commands": {
    "Command": [
      {
        "CreationTime": "2020-11-17T06:52Z",
        "Type": "RunShellScript",
        "Timeout": 3600,
        "InvokeTimes": 2,
        "CommandId": "c-hz01272yr52****",
        "WorkingDir": "/home/",
        "Description": "testDescription",
        "Version": 1,
        "Provider": "AlibabaCloud.ECS.GuestOS",
        "CommandContent": "Y2QgL3Jvb3Q=",
        "Category": "“”",
        "Latest": true,
        "Name": "testName",
        "EnableParameter": true,
        "ResourceGroupId": "rg-123******",
        "ParameterNames": {
          "ParameterName": [
            "['parameter1','parameter2']"
          ]
        },
        "ParameterDefinitions": {
          "ParameterDefinition": [
            {
              "Required": true,
              "Description": "Download path of the Cloud Assistant Agent installation package.",
              "DefaultValue": "https://aliyun-client-assist.oss-accelerate.aliyuncs.com/linux/aliyun_assist_latest.rpm",
              "ParameterName": "DownloadUrl",
              "PossibleValues": {
                "PossibleValue": [
                  "\"Linux\",\"Windows\""
                ]
              }
            }
          ]
        },
        "Tags": {
          "Tag": [
            {
              "TagKey": "owner",
              "TagValue": "zhangsan"
            }
          ]
        }
      }
    ]
  }
}

Error codes

HTTP status codeError codeError messageDescription
400RegionId.ApiNotSupportedThe 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.
400NumberExceed.TagsThe Tags parameter number is exceed.The number of tags exceeds the maximum limit.
400Duplicate.TagKeyThe Tag.N.Key contain duplicate key.The specified tag key already exists. Tag keys must be unique.
400InvalidTagKey.MalformedThe specified Tag.n.Key is not valid.The specified Tag.N.Key parameter is invalid.
400InvalidTagValue.MalformedThe specified Tag.n.Value is not valid.The specified tag value is invalid.
400MissingParameter.TagKeyYou must specify Tag.N.Key.The tag key is not specified.
400InvalidParam.PageNumberThe specified parameter is invalid.The specified PageNumber parameter is invalid.
400InvalidParam.PageSizeThe specified parameter is invalid.The specified PageSize parameter is invalid.
400InvalidParameter.NextTokenThe specified parameter NextToken is not valid.The specified parameter NextToken is illegal.
400InvalidParameter.MaxResultsThe specified parameter MaxResults is not valid.The specified parameter MaxResults is illegal.
403Operation.ForbiddenThe operation is not permitted.The operation is not supported.
404InvalidRegionId.NotFoundThe RegionId provided does not exist in our records.The RegionId provided does not exist
500InternalError.DispatchAn error occurred when you dispatched the request.An error occurred while the request is being sent. Try again later.
500ServiceUnavailableThe request has failed due to a temporary failure of the server.-
500InternalErrorThe request processing has failed due to some unknown error.An internal error has occurred. Try again later.

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2023-12-21The Error code has changed. The request parameters of the API has changed. The response structure of the API has changedView Change Details
2023-10-24The Error code has changed. The request parameters of the API has changed. The response structure of the API has changedView Change Details
2023-05-12The Error code has changedView Change Details
2022-02-25The Error code has changedView Change Details