Skip to content

list_secret_version_ids async

list_secret_version_ids(
    secret_id: SecretIdType,
    *,
    config_overrides: Optional[AsyncSecretsManagerClientConfig] = None,
    max_results: Optional[MaxResultsType] = None,
    next_token: Optional[NextTokenType] = None,
    include_deprecated: Optional[BooleanType] = None,
) -> ListSecretVersionIdsResponse

Lists the versions of a secret. Secrets Manager uses staging labels to indicate the different versions of a secret. For more information, see Secrets Manager concepts: Versions.

To list the secrets in the account, use ListSecrets.

Secrets Manager generates a CloudTrail log entry when you call this action. Do not include sensitive information in request parameters because it might be logged. For more information, see Logging Secrets Manager events with CloudTrail.

Required permissions: secretsmanager:ListSecretVersionIds. For more information, see IAM policy actions for Secrets Manager and Authentication and access control in Secrets Manager.

Parameters:

  • secret_id (SecretIdType) –

    The ARN or name of the secret whose versions you want to list.

    For an ARN, we recommend that you specify a complete ARN rather than a partial ARN. See Finding a secret from a partial ARN.

  • max_results (Optional[MaxResultsType], default: None ) –

    The number of results to include in the response.

    If there are more results available, in the response, Secrets Manager includes NextToken. To get the next results, call ListSecretVersionIds again with the value from NextToken.

  • next_token (Optional[NextTokenType], default: None ) –

    A token that indicates where the output should continue from, if a previous call did not show all results. To get the next results, call ListSecretVersionIds again with this value.

  • include_deprecated (Optional[BooleanType], default: None ) –

    Specifies whether to include versions of secrets that don't have any staging labels attached to them. Versions without staging labels are considered deprecated and are subject to deletion by Secrets Manager. By default, versions without staging labels aren't included.

Raises:

Examples:

To list all of the secret versions associated with a secret The following example shows how to retrieve a list of all of the versions of a secret, including those without any staging labels.

>>> await client.list_secret_version_ids(secret_id='MyTestDatabaseSecret', include_deprecated=True)
Source code in docs_src/capo_secrets_manager/_services/async_secrets_manager.py
async def list_secret_version_ids(
    self,
    secret_id: "capo_secrets_manager.types.secret_id_type.SecretIdType",
    *,
    config_overrides: Optional[AsyncSecretsManagerClientConfig] = None,
    max_results: Optional[
        "capo_secrets_manager.types.max_results_type.MaxResultsType"
    ] = None,
    next_token: Optional[
        "capo_secrets_manager.types.next_token_type.NextTokenType"
    ] = None,
    include_deprecated: Optional[
        "capo_secrets_manager.types.boolean_type.BooleanType"
    ] = None,
) -> "capo_secrets_manager.types.list_secret_version_ids_response.ListSecretVersionIdsResponse":
    """<p>Lists the versions of a secret. Secrets Manager uses staging labels to indicate the different versions of a secret. For more information, see <a href="https://docs.aws.amazon.com/secretsmanager/latest/userguide/getting-started.html#term_version"> Secrets Manager concepts: Versions</a>.</p> <p>To list the secrets in the account, use <a>ListSecrets</a>.</p> <p>Secrets Manager generates a CloudTrail log entry when you call this action. Do not include sensitive information in request parameters because it might be logged. For more information, see <a href="https://docs.aws.amazon.com/secretsmanager/latest/userguide/retrieve-ct-entries.html">Logging Secrets Manager events with CloudTrail</a>.</p> <p> <b>Required permissions: </b> <code>secretsmanager:ListSecretVersionIds</code>. For more information, see <a href="https://docs.aws.amazon.com/secretsmanager/latest/userguide/reference_iam-permissions.html#reference_iam-permissions_actions"> IAM policy actions for Secrets Manager</a> and <a href="https://docs.aws.amazon.com/secretsmanager/latest/userguide/auth-and-access.html">Authentication and access control in Secrets Manager</a>. </p>

    Args:
        secret_id: <p>The ARN or name of the secret whose versions you want to list.</p> <p>For an ARN, we recommend that you specify a complete ARN rather than a partial ARN. See <a href="https://docs.aws.amazon.com/secretsmanager/latest/userguide/troubleshoot.html#ARN_secretnamehyphen">Finding a secret from a partial ARN</a>.</p>
        max_results: <p>The number of results to include in the response.</p> <p>If there are more results available, in the response, Secrets Manager includes <code>NextToken</code>. To get the next results, call <code>ListSecretVersionIds</code> again with the value from <code>NextToken</code>. </p>
        next_token: <p>A token that indicates where the output should continue from, if a previous call did not show all results. To get the next results, call <code>ListSecretVersionIds</code> again with this value.</p>
        include_deprecated: <p>Specifies whether to include versions of secrets that don't have any staging labels attached to them. Versions without staging labels are considered deprecated and are subject to deletion by Secrets Manager. By default, versions without staging labels aren't included.</p>

    Raises:
        capo_secrets_manager.errors.internal_service_error.InternalServiceError: <p>An error occurred on the server side.</p>
        capo_secrets_manager.errors.invalid_next_token_exception.InvalidNextTokenException: <p>The <code>NextToken</code> value is invalid.</p>
        capo_secrets_manager.errors.invalid_parameter_exception.InvalidParameterException: <p>The parameter name or value is invalid.</p>
        capo_secrets_manager.errors.resource_not_found_exception.ResourceNotFoundException: <p>Secrets Manager can't find the resource that you asked for.</p>
        capo_secrets_manager.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To list all of the secret versions associated with a secret
        The following example shows how to retrieve a list of all of the versions of a secret, including those without any staging labels.

        >>> await client.list_secret_version_ids(secret_id='MyTestDatabaseSecret', include_deprecated=True)
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_secrets_manager.types.list_secret_version_ids_request.ListSecretVersionIdsRequest]",
    ) -> AsyncOperationResponse[
        "capo_secrets_manager.types.list_secret_version_ids_response.ListSecretVersionIdsResponse"
    ]:
        import capo_secrets_manager._operations.secretsmanager.list_secret_version_ids

        (
            output,
            http_response,
        ) = await capo_secrets_manager._operations.secretsmanager.list_secret_version_ids.async_list_secret_version_ids(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("ListSecretVersionIds")
    )
    input_: capo_secrets_manager.types.list_secret_version_ids_request.ListSecretVersionIdsRequest = {
        "secret_id": secret_id
    }
    if max_results is not None:
        input_["max_results"] = max_results
    if next_token is not None:
        input_["next_token"] = next_token
    if include_deprecated is not None:
        input_["include_deprecated"] = include_deprecated

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output