listSecrets method

Future<ListSecretsResponse> listSecrets({
  1. List<Filter>? filters,
  2. int? maxResults,
  3. String? nextToken,
  4. SortOrderType? sortOrder,
})

Lists all of the secrets that are stored by Secrets Manager in the AWS account. To list the versions currently stored for a specific secret, use ListSecretVersionIds. The encrypted fields SecretString and SecretBinary are not included in the output. To get that information, call the GetSecretValue operation. Minimum permissions

To run this command, you must have the following permissions:

  • secretsmanager:ListSecrets
Related operations

May throw InvalidParameterException. May throw InvalidNextTokenException. May throw InternalServiceError.

Parameter filters : Lists the secret request filters.

Parameter maxResults : (Optional) Limits the number of results you want to include in the response. If you don't include this parameter, it defaults to a value that's specific to the operation. If additional items exist beyond the maximum you specify, the NextToken response element is present and has a value (isn't null). Include that value as the NextToken request parameter in the next call to the operation to get the next part of the results. Note that Secrets Manager might return fewer results than the maximum even when there are more results available. You should check NextToken after every operation to ensure that you receive all of the results.

Parameter nextToken : (Optional) Use this parameter in a request if you receive a NextToken response in a previous request indicating there's more output available. In a subsequent call, set it to the value of the previous call NextToken response to indicate where the output should continue from.

Parameter sortOrder : Lists secrets in the requested order.

Implementation

Future<ListSecretsResponse> listSecrets({
  List<Filter>? filters,
  int? maxResults,
  String? nextToken,
  SortOrderType? sortOrder,
}) async {
  _s.validateNumRange(
    'maxResults',
    maxResults,
    1,
    100,
  );
  _s.validateStringLength(
    'nextToken',
    nextToken,
    1,
    4096,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'secretsmanager.ListSecrets'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      if (filters != null) 'Filters': filters,
      if (maxResults != null) 'MaxResults': maxResults,
      if (nextToken != null) 'NextToken': nextToken,
      if (sortOrder != null) 'SortOrder': sortOrder.toValue(),
    },
  );

  return ListSecretsResponse.fromJson(jsonResponse.body);
}