ListSecrets

更新时间:
复制 MD 格式

Queries all secrets in the current region.

Operation description

  • To call this operation, the RAM user or RAM role must be granted the required policy. For more information, see Resource Access Management.

  • This operation returns only secret metadata, not the secret values.

This example shows how to query secrets created by the current user in the current region. PageNumber is set to 1 and PageSize is set to 2, returning metadata for two secrets.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

No authorization for this operation. If you encounter issues with this operation, contact technical support.

Request parameters

Parameter

Type

Required

Description

Example

FetchTags

string

No

Specifies whether to return resource tags for each secret. Valid values:

  • true: Resource tags are returned.

  • false (default): Resource tags are not returned.

false

PageNumber

integer

No

The page number.
The value must be greater than 0.
Default: 1.

1

PageSize

integer

No

The page size.
The value must be between 1 and 100.
Default: 10.

2

Filters

string

No

Filters secrets based on specified conditions. The value is a list of up to 10 key-value pairs. When you filter by tag, the query returns a maximum of 4,000 resources. If more than 4,000 resources match the filter, call the ListResourceTags operation.

  • Key
    • Description: The filter property.

    • Type: String.

  • Values
    • Description: The filter value.

    • Type: String.

    • You can specify up to 10 items.

Valid values for Key:

  • Set Key to SecretName to filter by secret name.

  • Set Key to Description to filter by secret description.

  • Set Key to TagKey to filter by tag key.

  • Set Key to TagValue to filter by tag value.

  • Set Key to DKMSInstanceId to filter by KMS instance ID.

  • Set Key to SecretType to filter by secret type. Values can be Generic, RDS, Redis, RAMCredentials, ECS, or PolarDB.

  • Set Key to Creator to filter by the creator of the secret.

If you specify multiple values for a key, the filter applies a logical OR. For example, if you enter [ {"Key":"SecretName", "Values":["sec1","sec2"]} ], this means: (SecretName=sec1 OR SecretName=sec2).

[{"Key":"SecretName", "Values":["Val1","Val2"]}]

Response elements

Element

Type

Description

Example

object

PageNumber

integer

The page number.

1

PageSize

integer

The number of entries per page.

2

RequestId

string

The unique identifier generated by Alibaba Cloud for the request. Use it to locate and troubleshoot issues.

6a6287a0-ff34-4780-a790-fdfca900557f

TotalCount

integer

The number of secrets.

55

SecretList

object

Secret

array<object>

The list of secrets.

array<object>

SecretName

string

The name of the secret.

secret001

UpdateTime

string

The time when the secret was last updated.

2024-07-17T07:59:05Z

SecretType

string

The type of the secret. Valid values:

  • Generic: a generic secret.

  • Rds: an RDS secret.

  • Redis: a Redis or Tair secret.

  • RAMCredentials: a RAM secret.

  • ECS: an ECS secret.

  • PolarDB: a PolarDB secret.

Generic

PlannedDeleteTime

string

The scheduled deletion time.

2024-08-17T07:59:05Z

CreateTime

string

The time when the secret was created.

2024-07-17T07:59:05Z

Tags

object

Tag

array<object>

The resource tags for the secret. This parameter is not returned if the FetchTags parameter is set to false or is not specified.

object

A resource tag.

TagValue

string

The tag value.

val1

TagKey

string

The tag key.

key1

OwingService

string

The owner service.

alb

Examples

Success response

JSON format

{
  "PageNumber": 1,
  "PageSize": 2,
  "RequestId": "6a6287a0-ff34-4780-a790-fdfca900557f",
  "TotalCount": 55,
  "SecretList": {
    "Secret": [
      {
        "SecretName": "secret001",
        "UpdateTime": "2024-07-17T07:59:05Z",
        "SecretType": "Generic",
        "PlannedDeleteTime": "2024-08-17T07:59:05Z",
        "CreateTime": "2024-07-17T07:59:05Z",
        "Tags": {
          "Tag": [
            {
              "TagValue": "val1",
              "TagKey": "key1"
            }
          ]
        },
        "OwingService": "alb"
      }
    ]
  }
}

Error codes

HTTP status code

Error code

Error message

Description

400 InvalidParameter some of the specified parameters "\" is not valid
500 InternalFailure Internal Failure
403 Forbidden.NoPermission This operation is forbidden by permission system
404 Forbidden.ResourceNotFound Resource not found
404 InvalidAccessKeyId.NotFound The Access Key ID provided does not exist in our records.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.