Skip to content

list_keys

list_keys(
    *,
    config_overrides: Optional[PaymentCryptographyClientConfig] = None,
    key_state: Optional[KeyState] = None,
    next_token: Optional[NextToken] = None,
    max_results: Optional[MaxResults] = None,
) -> ListKeysOutput

Lists the keys in the caller's Amazon Web Services account and Amazon Web Services Region. You can filter the list of keys.

This is a paginated operation, which means that each response might contain only a subset of all the keys. When the response contains only a subset of keys, it includes a NextToken value. Use this value in a subsequent ListKeys request to get more keys. When you receive a response with no NextToken (or an empty or null value), that means there are no more keys to get.

Cross-account use: This operation can't be used across different Amazon Web Services accounts.

Related operations:

Parameters:

  • key_state (Optional[KeyState], default: None ) –

    The key state of the keys you want to list.

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

    Use this parameter in a subsequent request after you receive a response with truncated results. Set it to the value of NextToken from the truncated response you just received.

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

    Use this parameter to specify the maximum number of items to return. When this value is present, Amazon Web Services Payment Cryptography does not return more than the specified number of items, but it might return fewer.

    This value is optional. If you include a value, it must be between 1 and 100, inclusive. If you do not include a value, it defaults to 50.

Raises:

  • AccessDeniedException –

    You do not have sufficient access to perform this action.

    This exception is thrown when the caller lacks the necessary IAM permissions to perform the requested operation. Verify that your IAM policy includes the required permissions for the specific Amazon Web Services Payment Cryptography action you're attempting.

  • InternalServerException –

    The request processing has failed because of an unknown error, exception, or failure.

    This indicates a server-side error within the Amazon Web Services Payment Cryptography service. If this error persists, contact support for assistance.

  • ResourceNotFoundException –

    The request was denied due to resource not found.

    The specified key, alias, or other resource does not exist in your account or region. Verify that the resource identifier is correct and that the resource exists in the expected region.

  • ServiceUnavailableException –

    The service cannot complete the request.

    The Amazon Web Services Payment Cryptography service is temporarily unavailable. This is typically a temporary condition - retry your request after a brief delay.

  • ThrottlingException –

    The request was denied due to request throttling.

    You have exceeded the rate limits for Amazon Web Services Payment Cryptography API calls. Implement exponential backoff and retry logic in your application to handle throttling gracefully.

  • ValidationException –

    The request was denied due to an invalid request error.

    One or more parameters in your request are invalid. Check the parameter values, formats, and constraints specified in the API documentation.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_payment_cryptography/_services/payment_cryptography.py
def list_keys(
    self,
    *,
    config_overrides: Optional[PaymentCryptographyClientConfig] = None,
    key_state: Optional[
        "capo_payment_cryptography.types.key_state.KeyState"
    ] = None,
    next_token: Optional[
        "capo_payment_cryptography.types.next_token.NextToken"
    ] = None,
    max_results: Optional[
        "capo_payment_cryptography.types.max_results.MaxResults"
    ] = None,
) -> "capo_payment_cryptography.types.list_keys_output.ListKeysOutput":
    """<p>Lists the keys in the caller's Amazon Web Services account and Amazon Web Services Region. You can filter the list of keys.</p> <p>This is a paginated operation, which means that each response might contain only a subset of all the keys. When the response contains only a subset of keys, it includes a <code>NextToken</code> value. Use this value in a subsequent <code>ListKeys</code> request to get more keys. When you receive a response with no NextToken (or an empty or null value), that means there are no more keys to get.</p> <p> <b>Cross-account use:</b> This operation can't be used across different Amazon Web Services accounts.</p> <p> <b>Related operations:</b> </p> <ul> <li> <p> <a href="https://docs.aws.amazon.com/payment-cryptography/latest/APIReference/API_CreateKey.html">CreateKey</a> </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/payment-cryptography/latest/APIReference/API_DeleteKey.html">DeleteKey</a> </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/payment-cryptography/latest/APIReference/API_GetKey.html">GetKey</a> </p> </li> </ul>

    Args:
        key_state: <p>The key state of the keys you want to list.</p>
        next_token: <p>Use this parameter in a subsequent request after you receive a response with truncated results. Set it to the value of <code>NextToken</code> from the truncated response you just received.</p>
        max_results: <p>Use this parameter to specify the maximum number of items to return. When this value is present, Amazon Web Services Payment Cryptography does not return more than the specified number of items, but it might return fewer.</p> <p>This value is optional. If you include a value, it must be between 1 and 100, inclusive. If you do not include a value, it defaults to 50.</p>

    Raises:
        capo_payment_cryptography.errors.access_denied_exception.AccessDeniedException: <p>You do not have sufficient access to perform this action.</p> <p>This exception is thrown when the caller lacks the necessary IAM permissions to perform the requested operation. Verify that your IAM policy includes the required permissions for the specific Amazon Web Services Payment Cryptography action you're attempting.</p>
        capo_payment_cryptography.errors.internal_server_exception.InternalServerException: <p>The request processing has failed because of an unknown error, exception, or failure.</p> <p>This indicates a server-side error within the Amazon Web Services Payment Cryptography service. If this error persists, contact support for assistance.</p>
        capo_payment_cryptography.errors.resource_not_found_exception.ResourceNotFoundException: <p>The request was denied due to resource not found.</p> <p>The specified key, alias, or other resource does not exist in your account or region. Verify that the resource identifier is correct and that the resource exists in the expected region.</p>
        capo_payment_cryptography.errors.service_unavailable_exception.ServiceUnavailableException: <p>The service cannot complete the request.</p> <p>The Amazon Web Services Payment Cryptography service is temporarily unavailable. This is typically a temporary condition - retry your request after a brief delay.</p>
        capo_payment_cryptography.errors.throttling_exception.ThrottlingException: <p>The request was denied due to request throttling.</p> <p>You have exceeded the rate limits for Amazon Web Services Payment Cryptography API calls. Implement exponential backoff and retry logic in your application to handle throttling gracefully.</p>
        capo_payment_cryptography.errors.validation_exception.ValidationException: <p>The request was denied due to an invalid request error.</p> <p>One or more parameters in your request are invalid. Check the parameter values, formats, and constraints specified in the API documentation.</p>
        capo_payment_cryptography.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_payment_cryptography.types.list_keys_input.ListKeysInput]",
    ) -> OperationResponse[
        "capo_payment_cryptography.types.list_keys_output.ListKeysOutput"
    ]:
        import capo_payment_cryptography._operations.payment_cryptography_control_plane.list_keys

        output, http_response = (
            capo_payment_cryptography._operations.payment_cryptography_control_plane.list_keys.list_keys(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("ListKeys")
    )
    input_: capo_payment_cryptography.types.list_keys_input.ListKeysInput = {}
    if key_state is not None:
        input_["key_state"] = key_state
    if next_token is not None:
        input_["next_token"] = next_token
    if max_results is not None:
        input_["max_results"] = max_results

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output