tencent cloud

Feedback

DescribeCommands

Last updated: 2023-03-14 16:55:46

1. API Description

Domain name for API request: tat.tencentcloudapi.com.

This API is used to query command details.

A maximum of 20 requests can be initiated per second for this API.

We recommend you to use API Explorer
Try it
API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.

2. Input Parameters

The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.

Parameter Name Required Type Description
Action Yes String Common Params. The value used for this API: DescribeCommands.
Version Yes String Common Params. The value used for this API: 2020-10-28.
Region No String Common Params. This parameter is not required for this API.
CommandIds.N No Array of String List of command IDs. Up to 100 IDs are allowed for each request. CommandIds and Filters cannot be specified at the same time.
Filters.N No Array of Filter Filter conditions.
  • command-id - String - Required: No - (Filter condition) Filter by the command ID.
  • command-name - String - Required: No - (Filter condition) Filter by the command name.
  • command-type - String - Required: No - (Filter condition) Filter by the command type. Valid values: SHELL or POWERSHELL.
  • created-by - String - Required: No - (Filter condition) Filter by the creator. Valid values: TAT (public commands) or USER (custom commands).
  • tag-key - String - Required: No - (Filter condition) Filter by the tag key.
  • tag-value - String - Required: No - (Filter condition) Filter by the tag value.
  • tag:tag-key - String - Required: No - (Filter) Filter by the tag key-value pair. The tag-key should be replaced with a specified tag key. For detailed usage, see sample 4.


  • Up to 10 Filters are allowed in one request. Each filter can have up to 5 Filter.Values. CommandIds and Filters cannot be specified at the same time.
    Limit No Integer Number of returned results. It defaults to 20. The maximum is 100. For more information on Limit, see the relevant section in the API Overview.
    Offset No Integer Offset. The default value is 0. For more information on Offset, see the relevant section in API Introduction.

    3. Output Parameters

    Parameter Name Type Description
    TotalCount Integer Total number of matching commands.
    CommandSet Array of Command List of command details.
    RequestId String The unique request ID, which is returned for each request. RequestId is required for locating a problem.

    4. Example

    Example1 Querying a command with the specified CommandId

    Input Example

    POST / HTTP/1.1
    Host: tat.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: DescribeCommands
    <Common request parameters>
    
    {
        "CommandIds": [
            "cmd-dvstpcyy"
        ],
        "Offset": 0,
        "Limit": 20
    }
    

    Output Example

    {
        "Response": {
            "RequestId": "eb973a12-71e3-4c0c-b1d8-4b863e5f5daf",
            "TotalCount": 1,
            "CommandSet": [
                {
                    "CommandId": "cmd-dvstpcyy",
                    "CommandName": "run-command",
                    "Description": "whoami",
                    "FormattedDescription": "",
                    "CreatedBy": "USER",
                    "Content": "d2hvYW1p",
                    "CommandType": "SHELL",
                    "WorkingDirectory": "/root/",
                    "Timeout": 60,
                    "EnableParameter": false,
                    "DefaultParameters": "",
                    "Username": "root",
                    "Tags": [
                        {
                            "Value": "test-key",
                            "Key": "test-value"
                        }
                    ],
                    "CreatedTime": "2020-11-02T02:48:11+00:00",
                    "UpdatedTime": "2020-11-02T02:48:11+00:00"
                }
            ]
        }
    }
    

    Example2 Querying commands with the command-name filter

    Input Example

    POST / HTTP/1.1
    Host: tat.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: DescribeCommands
    <Common request parameters>
    
    {
        "Offset": 0,
        "Limit": 20,
        "Filters": [
            {
                "Name": "command-name",
                "Values": [
                    "second-command",
                    "first-command"
                ]
            }
        ]
    }
    

    Output Example

    {
        "Response": {
            "RequestId": "6b215093-e1f6-4803-b84a-a230849e88d1",
            "TotalCount": 2,
            "CommandSet": [
                {
                    "CommandId": "cmd-hb2q34lk",
                    "CommandName": "second-command",
                    "Description": "ps",
                    "FormattedDescription": "",
                    "CreatedBy": "USER",
                    "Content": "cHM=",
                    "CommandType": "SHELL",
                    "WorkingDirectory": "/root/",
                    "Timeout": 60,
                    "EnableParameter": false,
                    "DefaultParameters": "",
                    "Username": "root",
                    "Tags": [
                        {
                            "Value": "test-key",
                            "Key": "test-value"
                        }
                    ],
                    "CreatedTime": "2020-10-30T07:19:52+00:00",
                    "UpdatedTime": "2020-10-30T07:19:52+00:00"
                },
                {
                    "CommandId": "cmd-63usjhmq",
                    "CommandName": "first-command",
                    "Description": "hello world!",
                    "FormattedDescription": "",
                    "CreatedBy": "USER",
                    "Content": "cHM=",
                    "CommandType": "SHELL",
                    "WorkingDirectory": "/",
                    "Timeout": 600,
                    "EnableParameter": false,
                    "DefaultParameters": "",
                    "Username": "root",
                    "Tags": [
                        {
                            "Value": "test-key",
                            "Key": "test-value"
                        }
                    ],
                    "CreatedTime": "2020-10-26T11:26:07+00:00",
                    "UpdatedTime": "2020-11-09T08:12:45+00:00"
                }
            ]
        }
    }
    

    Example3 Querying commands with the created-by filter

    Input Example

    POST / HTTP/1.1
    Host: tat.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: DescribeCommands
    <Common request parameters>
    
    {
        "Offset": 0,
        "Limit": 1,
        "Filters": [
            {
                "Name": "created-by",
                "Values": [
                    "USER"
                ]
            }
        ]
    }
    

    Output Example

    {
        "Response": {
            "RequestId": "6b215093-e1f6-4803-b84a-a230849e88d1",
            "TotalCount": 2,
            "CommandSet": [
                {
                    "CommandId": "cmd-hb2q34lk",
                    "CommandName": "second-command",
                    "Description": "ps",
                    "FormattedDescription": "",
                    "CreatedBy": "USER",
                    "Content": "cHM=",
                    "CommandType": "SHELL",
                    "WorkingDirectory": "/root/",
                    "Timeout": 60,
                    "EnableParameter": false,
                    "DefaultParameters": "",
                    "Username": "root",
                    "Tags": [],
                    "CreatedTime": "2020-10-30T07:19:52+00:00",
                    "UpdatedTime": "2020-10-30T07:19:52+00:00"
                }
            ]
        }
    }
    

    Example4 Query commands with the tag:tag-key filter

    Input Example

    POST / HTTP/1.1
    Host: tat.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: DescribeCommands
    <Common request parameters>
    
    {
        "Filters": [
            {
                "Values": [
                    "test-value"
                ],
                "Name": "tag:test-key"
            }
        ]
    }
    

    Output Example

    {
        "Response": {
            "RequestId": "33d3d954-f73a-4a7f-869b-8792bc7a6f13",
            "TotalCount": 1,
            "CommandSet": [
                {
                    "CommandId": "cmd-38ps9q4p",
                    "CommandName": "tag-test-1",
                    "Description": "",
                    "FormattedDescription": "",
                    "CreatedBy": "USER",
                    "Content": "cHMK",
                    "CommandType": "SHELL",
                    "WorkingDirectory": "/root",
                    "Timeout": 60,
                    "EnableParameter": false,
                    "DefaultParameters": "",
                    "Username": "root",
                    "Tags": [
                        {
                            "Key": "test-key",
                            "Value": "test-value"
                        }
                    ],
                    "CreatedTime": "2021-05-12T02:49:04Z",
                    "UpdatedTime": "2021-05-12T02:49:04Z"
                }
            ]
        }
    }
    

    5. Developer Resources

    SDK

    TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

    Command Line Interface

    6. Error Code

    The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.

    Error Code Description
    InternalError Internal error.
    InvalidParameter Invalid parameter.
    InvalidParameter.ConflictParameter Conflicting parameters.
    InvalidParameterValue Invalid parameter value.
    InvalidParameterValue.InvalidCommandId Invalid CommandId.
    InvalidParameterValue.InvalidFilter Invalid filter.
    UnauthorizedOperation.CamAuthFailed CAM authentication failed.
    UnauthorizedOperation.InvalidToken Invalid token.
    UnauthorizedOperation.MFAExpired The Multi-factor authentication (MFA) code expired.
    UnauthorizedOperation.MFANotFound Multi-factor authentication (MFA) does not exist.
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support