The CreateKeyspace operation adds a new keyspace to your account. In an Amazon Web Services account, keyspace names must be unique within each Region.
CreateKeyspace is an asynchronous operation. You can monitor the creation status of the new keyspace by using the GetKeyspace operation.
For more information, see Create a keyspace in the Amazon Keyspaces Developer Guide.
Parameters:
-
keyspace_name
(KeyspaceName)
–
The name of the keyspace to be created.
-
tags
(Optional[TagList], default:
None
)
–
-
replication_specification
(Optional[ReplicationSpecification], default:
None
)
–
The replication specification of the keyspace includes:
-
replicationStrategy - the required value is SINGLE_REGION or MULTI_REGION.
-
regionList - if the replicationStrategy is MULTI_REGION, the regionList requires the current Region and at least one additional Amazon Web Services Region where the keyspace is going to be replicated in.
Raises:
-
AccessDeniedException
–
You don't have sufficient access permissions to perform this action.
-
ConflictException
–
Amazon Keyspaces couldn't complete the requested action. This error may occur if you try to perform an action and the same or a different action is already in progress, or if you try to create a resource that already exists.
-
InternalServerException
–
Amazon Keyspaces was unable to fully process this request because of an internal server error.
-
ServiceQuotaExceededException
–
The operation exceeded the service quota for this resource. For more information on service quotas, see Quotas in the Amazon Keyspaces Developer Guide.
-
ValidationException
–
The operation failed due to an invalid or malformed request.
-
UnknownServiceError
–
The service returned an error code this client does not model.
Source code in docs_src/capo_keyspaces/_services/keyspaces.py
| def create_keyspace(
self,
keyspace_name: "capo_keyspaces.types.keyspace_name.KeyspaceName",
*,
config_overrides: Optional[KeyspacesClientConfig] = None,
tags: Optional["capo_keyspaces.types.tag_list.TagList"] = None,
replication_specification: Optional[
"capo_keyspaces.types.replication_specification.ReplicationSpecification"
] = None,
) -> "capo_keyspaces.types.create_keyspace_response.CreateKeyspaceResponse":
"""<p>The <code>CreateKeyspace</code> operation adds a new keyspace to your account. In an Amazon Web Services account, keyspace names must be unique within each Region.</p> <p> <code>CreateKeyspace</code> is an asynchronous operation. You can monitor the creation status of the new keyspace by using the <code>GetKeyspace</code> operation.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/keyspaces/latest/devguide/getting-started.keyspaces.html">Create a keyspace</a> in the <i>Amazon Keyspaces Developer Guide</i>.</p>
Args:
keyspace_name: <p>The name of the keyspace to be created.</p>
tags: <p>A list of key-value pair tags to be attached to the keyspace.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/keyspaces/latest/devguide/tagging-keyspaces.html">Adding tags and labels to Amazon Keyspaces resources</a> in the <i>Amazon Keyspaces Developer Guide</i>.</p>
replication_specification: <p> The replication specification of the keyspace includes:</p> <ul> <li> <p> <code>replicationStrategy</code> - the required value is <code>SINGLE_REGION</code> or <code>MULTI_REGION</code>.</p> </li> <li> <p> <code>regionList</code> - if the <code>replicationStrategy</code> is <code>MULTI_REGION</code>, the <code>regionList</code> requires the current Region and at least one additional Amazon Web Services Region where the keyspace is going to be replicated in.</p> </li> </ul>
Raises:
capo_keyspaces.errors.access_denied_exception.AccessDeniedException: <p>You don't have sufficient access permissions to perform this action. </p>
capo_keyspaces.errors.conflict_exception.ConflictException: <p>Amazon Keyspaces couldn't complete the requested action. This error may occur if you try to perform an action and the same or a different action is already in progress, or if you try to create a resource that already exists. </p>
capo_keyspaces.errors.internal_server_exception.InternalServerException: <p>Amazon Keyspaces was unable to fully process this request because of an internal server error.</p>
capo_keyspaces.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>The operation exceeded the service quota for this resource. For more information on service quotas, see <a href="https://docs.aws.amazon.com/keyspaces/latest/devguide/quotas.html">Quotas</a> in the <i>Amazon Keyspaces Developer Guide</i>.</p>
capo_keyspaces.errors.validation_exception.ValidationException: <p>The operation failed due to an invalid or malformed request.</p>
capo_keyspaces.errors.UnknownServiceError: The service returned an error code this client does not model.
"""
def _handler(
req: "OperationRequest[capo_keyspaces.types.create_keyspace_request.CreateKeyspaceRequest]",
) -> OperationResponse[
"capo_keyspaces.types.create_keyspace_response.CreateKeyspaceResponse"
]:
import capo_keyspaces._operations.keyspaces_service.create_keyspace
output, http_response = (
capo_keyspaces._operations.keyspaces_service.create_keyspace.create_keyspace(
req.options, req.input
)
)
return OperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("CreateKeyspace")
)
input_: capo_keyspaces.types.create_keyspace_request.CreateKeyspaceRequest = {
"keyspace_name": keyspace_name
}
if tags is not None:
input_["tags"] = tags
if replication_specification is not None:
input_["replication_specification"] = replication_specification
response = execute_pipeline(
OperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
response.response.close()
return response.output
|