Gets a list of all KMS keys in the caller's Amazon Web Services account and Region.
Cross-account use: No. You cannot perform this operation on a KMS key in a different Amazon Web Services account.
Required permissions: kms:ListKeys (IAM policy)
Related operations:
Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency.
Parameters:
-
limit
(Optional[LimitType], default:
None
)
–
Use this parameter to specify the maximum number of items to return. When this value is present, KMS 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 1000, inclusive. If you do not include a value, it defaults to 100.
-
marker
(Optional[MarkerType], default:
None
)
–
Use this parameter in a subsequent request after you receive a response with truncated results. Set it to the value of NextMarker from the truncated response you just received.
Raises:
-
DependencyTimeoutException
–
The system timed out while trying to fulfill the request. You can retry the request.
-
InvalidMarkerException
–
The request was rejected because the marker that specifies where pagination should next begin is not valid.
-
KMSInternalException
–
The request was rejected because an internal exception occurred. The request can be retried.
-
UnknownServiceError
–
The service returned an error code this client does not model.
Examples:
To list KMS keys
The following example lists KMS keys.
Source code in docs_src/capo_kms/_services/kms.py
| def list_keys(
self,
*,
config_overrides: Optional[KMSClientConfig] = None,
limit: Optional["capo_kms.types.limit_type.LimitType"] = None,
marker: Optional["capo_kms.types.marker_type.MarkerType"] = None,
) -> "capo_kms.types.list_keys_response.ListKeysResponse":
"""<p>Gets a list of all KMS keys in the caller's Amazon Web Services account and Region.</p> <p> <b>Cross-account use</b>: No. You cannot perform this operation on a KMS key in a different Amazon Web Services account.</p> <p> <b>Required permissions</b>: <a href="https://docs.aws.amazon.com/kms/latest/developerguide/kms-api-permissions-reference.html">kms:ListKeys</a> (IAM policy)</p> <p> <b>Related operations:</b> </p> <ul> <li> <p> <a>CreateKey</a> </p> </li> <li> <p> <a>DescribeKey</a> </p> </li> <li> <p> <a>ListAliases</a> </p> </li> <li> <p> <a>ListResourceTags</a> </p> </li> </ul> <p> <b>Eventual consistency</b>: The KMS API follows an eventual consistency model. For more information, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/accessing-kms.html#programming-eventual-consistency">KMS eventual consistency</a>.</p>
Args:
limit: <p>Use this parameter to specify the maximum number of items to return. When this value is present, KMS 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 1000, inclusive. If you do not include a value, it defaults to 100.</p>
marker: <p>Use this parameter in a subsequent request after you receive a response with truncated results. Set it to the value of <code>NextMarker</code> from the truncated response you just received.</p>
Raises:
capo_kms.errors.dependency_timeout_exception.DependencyTimeoutException: <p>The system timed out while trying to fulfill the request. You can retry the request.</p>
capo_kms.errors.invalid_marker_exception.InvalidMarkerException: <p>The request was rejected because the marker that specifies where pagination should next begin is not valid.</p>
capo_kms.errors.kms_internal_exception.KMSInternalException: <p>The request was rejected because an internal exception occurred. The request can be retried.</p>
capo_kms.errors.UnknownServiceError: The service returned an error code this client does not model.
Examples:
To list KMS keys
The following example lists KMS keys.
>>> client.list_keys()
"""
def _handler(
req: "OperationRequest[capo_kms.types.list_keys_request.ListKeysRequest]",
) -> OperationResponse["capo_kms.types.list_keys_response.ListKeysResponse"]:
import capo_kms._operations.trent_service.list_keys
output, http_response = (
capo_kms._operations.trent_service.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_kms.types.list_keys_request.ListKeysRequest = {}
if limit is not None:
input_["limit"] = limit
if marker is not None:
input_["marker"] = marker
response = execute_pipeline(
OperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
response.response.close()
return response.output
|