Skip to content

create_space async

create_space(
    name: str,
    domain_id: DomainId,
    data_access_role_arn: Arn,
    *,
    config_overrides: Optional[AsyncCloudWatchOmniClientConfig] = None,
    agent_core_evaluation_role_arn: Optional[Arn] = None,
    encryption_configuration: Optional[EncryptionConfiguration] = None,
    tags: Optional[TagMap] = None,
    client_token: Optional[ClientToken] = None,
) -> CreateSpaceOutput

Creates a space in a domain. Use GetSpace to retrieve the space, ListSpaces to enumerate spaces, UpdateSpace to modify it, and DeleteSpace to remove it.

Parameters:

  • name (str) –

    A name that identifies the space. Must be 3-64 characters: lowercase letters, numbers, and hyphens. It must begin and end with a letter or number and cannot contain consecutive hyphens.

  • domain_id (DomainId) –

    The ID of the domain to create the space in.

  • data_access_role_arn (Arn) –

    The ARN of the IAM role used for data access. The role must be in the caller's account.

  • agent_core_evaluation_role_arn (Optional[Arn], default: None ) –

    The ARN of the IAM role used by AgentCore online evaluation. Must be in the caller's account. Omit if the space does not use AgentCore online evaluation.

  • encryption_configuration (Optional[EncryptionConfiguration], default: None ) –

    How to encrypt the space's data at rest. Omit for service owned encryption, which is equivalent to passing encryptionStrategy AWS_OWNED.

  • tags (Optional[TagMap], default: None ) –

    The tags to associate with the space.

  • client_token (Optional[ClientToken], default: None ) –

    Idempotency token for safe retries. Repeated requests with the same token return the original result instead of creating a duplicate.

Raises:

Examples:

Create a space The following example creates a space in a domain and encrypts its data at rest with a customer managed KMS key. The name must be 3-64 characters of lowercase letters, numbers, and hyphens. Payloads are shown as JSON; on the wire they are CBOR-encoded.

>>> await client.create_space(name='prod-observability', domain_id='d-1a2b3c4d5e', data_access_role_arn='arn:aws:iam::123456789012:role/CloudWatchSpaceDataAccessRole', agent_core_evaluation_role_arn='arn:aws:iam::123456789012:role/CloudWatchAgentCoreEvaluationRole', encryption_configuration={'encryptionStrategy': 'CUSTOMER_MANAGED', 'kmsKeyArn': 'arn:aws:kms:us-east-1:123456789012:key/1a2b3c4d-5e6f-4a3b-8c9d-0e1f2a3b4c5d'}, tags={'Team': 'observability'}, client_token='3f2a9c1e-7b04-4d8a-9e15-6c2b8d0f4a73')
Source code in docs_src/capo_cloudwatchomni/_services/async_cloud_watch_omni.py
async def create_space(
    self,
    name: str,
    domain_id: "capo_cloudwatchomni.types.domain_id.DomainId",
    data_access_role_arn: "capo_cloudwatchomni.types.arn.Arn",
    *,
    config_overrides: Optional[AsyncCloudWatchOmniClientConfig] = None,
    agent_core_evaluation_role_arn: Optional[
        "capo_cloudwatchomni.types.arn.Arn"
    ] = None,
    encryption_configuration: Optional[
        "capo_cloudwatchomni.types.encryption_configuration.EncryptionConfiguration"
    ] = None,
    tags: Optional["capo_cloudwatchomni.types.tag_map.TagMap"] = None,
    client_token: Optional[
        "capo_cloudwatchomni.types.client_token.ClientToken"
    ] = None,
) -> "capo_cloudwatchomni.types.create_space_output.CreateSpaceOutput":
    """Creates a space in a domain. Use GetSpace to retrieve the space, ListSpaces to enumerate spaces, UpdateSpace to modify it, and DeleteSpace to remove it.

    Args:
        name: A name that identifies the space. Must be 3-64 characters: lowercase letters, numbers, and hyphens. It must begin and end with a letter or number and cannot contain consecutive hyphens.
        domain_id: The ID of the domain to create the space in.
        data_access_role_arn: The ARN of the IAM role used for data access. The role must be in the caller's account.
        agent_core_evaluation_role_arn: The ARN of the IAM role used by AgentCore online evaluation. Must be in the caller's account. Omit if the space does not use AgentCore online evaluation.
        encryption_configuration: How to encrypt the space's data at rest. Omit for service owned encryption, which is equivalent to passing `encryptionStrategy` AWS_OWNED.
        tags: The tags to associate with the space.
        client_token: Idempotency token for safe retries. Repeated requests with the same token return the original result instead of creating a duplicate.

    Raises:
        capo_cloudwatchomni.errors.access_denied_exception.AccessDeniedException: The caller is not authorized to perform this action.
        capo_cloudwatchomni.errors.conflict_exception.ConflictException: The operation could not be completed because of a conflict with the current state of the resource.
        capo_cloudwatchomni.errors.internal_server_exception.InternalServerException: An unexpected error occurred while processing the request.
        capo_cloudwatchomni.errors.resource_not_found_exception.ResourceNotFoundException: The specified resource does not exist.
        capo_cloudwatchomni.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: A service quota was exceeded.
        capo_cloudwatchomni.errors.throttling_exception.ThrottlingException: The request was throttled due to exceeding the allowed request rate.
        capo_cloudwatchomni.errors.validation_exception.ValidationException: A parameter is specified incorrectly.
        capo_cloudwatchomni.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        Create a space
        The following example creates a space in a domain and encrypts its data at rest with a customer managed KMS key. The name must be 3-64 characters of lowercase letters, numbers, and hyphens. Payloads are shown as JSON; on the wire they are CBOR-encoded.

        >>> await client.create_space(name='prod-observability', domain_id='d-1a2b3c4d5e', data_access_role_arn='arn:aws:iam::123456789012:role/CloudWatchSpaceDataAccessRole', agent_core_evaluation_role_arn='arn:aws:iam::123456789012:role/CloudWatchAgentCoreEvaluationRole', encryption_configuration={'encryptionStrategy': 'CUSTOMER_MANAGED', 'kmsKeyArn': 'arn:aws:kms:us-east-1:123456789012:key/1a2b3c4d-5e6f-4a3b-8c9d-0e1f2a3b4c5d'}, tags={'Team': 'observability'}, client_token='3f2a9c1e-7b04-4d8a-9e15-6c2b8d0f4a73')
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_cloudwatchomni.types.create_space_input.CreateSpaceInput]",
    ) -> AsyncOperationResponse[
        "capo_cloudwatchomni.types.create_space_output.CreateSpaceOutput"
    ]:
        import capo_cloudwatchomni._operations.cloud_watch_omni_frontend.create_space

        (
            output,
            http_response,
        ) = await capo_cloudwatchomni._operations.cloud_watch_omni_frontend.create_space.async_create_space(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateSpace")
    )
    input_: capo_cloudwatchomni.types.create_space_input.CreateSpaceInput = {
        "name": name,
        "domain_id": domain_id,
        "data_access_role_arn": data_access_role_arn,
    }
    if agent_core_evaluation_role_arn is not None:
        input_["agent_core_evaluation_role_arn"] = agent_core_evaluation_role_arn
    if encryption_configuration is not None:
        input_["encryption_configuration"] = encryption_configuration
    if tags is not None:
        input_["tags"] = tags
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token

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