Skip to content

delete_memory

delete_memory(
    space_id: SpaceId,
    memory_id: MemoryId,
    *,
    config_overrides: Optional[OpenSearchMemoryClientConfig] = None,
    actor_id: Optional[ActorId] = None,
    strategy_name: Optional[StrategyName] = None,
) -> DeleteMemoryOutput

Deletes a memory, including its content and embedding. Deletion can't be undone. Searches stop returning the memory shortly after you delete it.

Deleting a memory that no longer exists returns ResourceNotFoundException, so the operation is not idempotent. If you retry deletes, treat that error as success.

A memory past its expiry (set from the space's memoryExpiryDays when the memory is written) reads as not found: the operation returns ResourceNotFoundException, as for a memory that was already deleted.

If the space uses a customer managed AWS KMS key, the call can also fail because of the key. It fails with AccessDeniedException if you aren't allowed to use the key, and with ThrottlingException if AWS KMS throttles the request. It fails with ValidationException if the key is disabled, pending deletion, or deleted.

Parameters:

  • space_id (SpaceId) –

    The ID of the space that owns the memory.

  • memory_id (MemoryId) –

    The ID of the memory to delete.

  • actor_id (Optional[ActorId], default: None ) –

    The ID of the actor that the memory must belong to. Omit it to skip this check. If it doesn't match the stored memory, the call fails with ResourceNotFoundException, as if the memory did not exist.

  • strategy_name (Optional[StrategyName], default: None ) –

    The name of the strategy that the memory must belong to. Omit it to skip this check. If it doesn't match the stored memory, the call fails with ResourceNotFoundException, as if the memory did not exist.

Raises:

  • AccessDeniedException –

    You don't have sufficient access to perform this operation. To use this operation, you must have AWS Identity and Access Management (IAM) permissions for the operation, and on the resource it acts on. If the space uses a customer managed AWS Key Management Service (AWS KMS) key, you must also have permission to use the key.

  • InternalServerException –

    The service couldn't process the request because of an internal error. Retry the request.

  • ResourceNotFoundException –

    The specified resource doesn't exist. Check the IDs in the request.

  • ThrottlingException –

    The service throttled the request. Retry the request with exponential backoff.

  • ValidationException –

    The request isn't valid. The reason, message, and fieldList members describe the problem. Fix the request, and then try again.

  • UnknownServiceError –

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

Source code in docs_src/capo_opensearchmemory/_services/open_search_memory.py
def delete_memory(
    self,
    space_id: "capo_opensearchmemory.types.space_id.SpaceId",
    memory_id: "capo_opensearchmemory.types.memory_id.MemoryId",
    *,
    config_overrides: Optional[OpenSearchMemoryClientConfig] = None,
    actor_id: Optional["capo_opensearchmemory.types.actor_id.ActorId"] = None,
    strategy_name: Optional[
        "capo_opensearchmemory.types.strategy_name.StrategyName"
    ] = None,
) -> "capo_opensearchmemory.types.delete_memory_output.DeleteMemoryOutput":
    """<p>Deletes a memory, including its content and embedding. Deletion can't be undone. Searches stop returning the memory shortly after you delete it.</p> <p>Deleting a memory that no longer exists returns <code>ResourceNotFoundException</code>, so the operation is not idempotent. If you retry deletes, treat that error as success.</p> <p>A memory past its expiry (set from the space's <code>memoryExpiryDays</code> when the memory is written) reads as not found: the operation returns <code>ResourceNotFoundException</code>, as for a memory that was already deleted.</p> <p>If the space uses a customer managed AWS KMS key, the call can also fail because of the key. It fails with <code>AccessDeniedException</code> if you aren't allowed to use the key, and with <code>ThrottlingException</code> if AWS KMS throttles the request. It fails with <code>ValidationException</code> if the key is disabled, pending deletion, or deleted.</p>

    Args:
        space_id: <p>The ID of the space that owns the memory.</p>
        memory_id: <p>The ID of the memory to delete.</p>
        actor_id: <p>The ID of the actor that the memory must belong to. Omit it to skip this check. If it doesn't match the stored memory, the call fails with <code>ResourceNotFoundException</code>, as if the memory did not exist.</p>
        strategy_name: <p>The name of the strategy that the memory must belong to. Omit it to skip this check. If it doesn't match the stored memory, the call fails with <code>ResourceNotFoundException</code>, as if the memory did not exist.</p>

    Raises:
        capo_opensearchmemory.errors.access_denied_exception.AccessDeniedException: <p>You don't have sufficient access to perform this operation. To use this operation, you must have AWS Identity and Access Management (IAM) permissions for the operation, and on the resource it acts on. If the space uses a customer managed AWS Key Management Service (AWS KMS) key, you must also have permission to use the key.</p>
        capo_opensearchmemory.errors.internal_server_exception.InternalServerException: <p>The service couldn't process the request because of an internal error. Retry the request.</p>
        capo_opensearchmemory.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified resource doesn't exist. Check the IDs in the request.</p>
        capo_opensearchmemory.errors.throttling_exception.ThrottlingException: <p>The service throttled the request. Retry the request with exponential backoff.</p>
        capo_opensearchmemory.errors.validation_exception.ValidationException: <p>The request isn't valid. The <code>reason</code>, <code>message</code>, and <code>fieldList</code> members describe the problem. Fix the request, and then try again.</p>
        capo_opensearchmemory.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_opensearchmemory.types.delete_memory_input.DeleteMemoryInput]",
    ) -> OperationResponse[
        "capo_opensearchmemory.types.delete_memory_output.DeleteMemoryOutput"
    ]:
        import capo_opensearchmemory._operations.open_search_memory.delete_memory

        output, http_response = (
            capo_opensearchmemory._operations.open_search_memory.delete_memory.delete_memory(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("DeleteMemory")
    )
    input_: capo_opensearchmemory.types.delete_memory_input.DeleteMemoryInput = {
        "space_id": space_id,
        "memory_id": memory_id,
    }
    if actor_id is not None:
        input_["actor_id"] = actor_id
    if strategy_name is not None:
        input_["strategy_name"] = strategy_name

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