Skip to content

list_memories

list_memories(
    space_id: SpaceId,
    *,
    config_overrides: Optional[OpenSearchMemoryClientConfig] = None,
    memory_strategies: Optional[StrategySelectorList] = None,
    actor_ids: Optional[ActorIdList] = None,
    session_ids: Optional[SessionIdList] = None,
    sort_by: Optional[MemorySortField] = None,
    sort_order: Optional[SortOrder] = None,
    max_results: Optional[MaxResults] = None,
    next_token: Optional[PaginationToken] = None,
) -> ListMemoriesOutput

Lists a space's memories without a query, for example the most recent memories or the memories of one strategy. Filter by strategy and optionally by owning actor or session, sort by creation or update time, and page through the results. Results have no relevance score. To query or filter by metadata, use SearchMemories.

If memories are written or deleted while you page, the results can skip a memory or return it twice. You can page through only a limited number of results. A request past that limit fails with ValidationException (reason invalidNextToken), and the message gives the limit.

Memories past their expiry (set from the space's memoryExpiryDays when each memory is written) are left out. Unlike SearchMemories, this operation also returns memories that consolidation has superseded.

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 space whose memories to list.

  • memory_strategies (Optional[StrategySelectorList], default: None ) –

    The strategies to list, as selectors. A selector without memoryStrategyNames lists every strategy of its type, and omitting memoryStrategies lists every strategy in the space. A name that is not a declared strategy of that type fails with ValidationException.

  • actor_ids (Optional[ActorIdList], default: None ) –

    Lists only memories owned by one of these actors. Combined with sessionIds by AND: a memory must match both filters when both are given. Omit for no actor filter. An empty list fails validation. A memory stored without an actor never matches an actor filter.

  • session_ids (Optional[SessionIdList], default: None ) –

    Lists only memories from one of these sessions. Combined with actorIds by AND. Omit for no session filter. An empty list fails validation. A memory stored without a session never matches a session filter.

  • sort_by (Optional[MemorySortField], default: None ) –

    The timestamp to sort by, as returned in systemMetadata: CREATED_AT (the default) or UPDATED_AT.

  • sort_order (Optional[SortOrder], default: None ) –

    The sort order: ASC or DESC. The default is DESC, most recent first.

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

    The maximum number of memories to return, from 1 to 100. The default is 20.

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

    The token for the next set of results. Use the value returned in the previous response in the next request to retrieve the next set of results.

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 list_memories(
    self,
    space_id: "capo_opensearchmemory.types.space_id.SpaceId",
    *,
    config_overrides: Optional[OpenSearchMemoryClientConfig] = None,
    memory_strategies: Optional[
        "capo_opensearchmemory.types.strategy_selector_list.StrategySelectorList"
    ] = None,
    actor_ids: Optional[
        "capo_opensearchmemory.types.actor_id_list.ActorIdList"
    ] = None,
    session_ids: Optional[
        "capo_opensearchmemory.types.session_id_list.SessionIdList"
    ] = None,
    sort_by: Optional[
        "capo_opensearchmemory.types.memory_sort_field.MemorySortField"
    ] = None,
    sort_order: Optional["capo_opensearchmemory.types.sort_order.SortOrder"] = None,
    max_results: Optional[
        "capo_opensearchmemory.types.max_results.MaxResults"
    ] = None,
    next_token: Optional[
        "capo_opensearchmemory.types.pagination_token.PaginationToken"
    ] = None,
) -> "capo_opensearchmemory.types.list_memories_output.ListMemoriesOutput":
    """<p>Lists a space's memories without a query, for example the most recent memories or the memories of one strategy. Filter by strategy and optionally by owning actor or session, sort by creation or update time, and page through the results. Results have no relevance score. To query or filter by metadata, use <code>SearchMemories</code>.</p> <p>If memories are written or deleted while you page, the results can skip a memory or return it twice. You can page through only a limited number of results. A request past that limit fails with <code>ValidationException</code> (reason <code>invalidNextToken</code>), and the message gives the limit.</p> <p>Memories past their expiry (set from the space's <code>memoryExpiryDays</code> when each memory is written) are left out. Unlike <code>SearchMemories</code>, this operation also returns memories that consolidation has superseded.</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 space whose memories to list.</p>
        memory_strategies: <p>The strategies to list, as selectors. A selector without <code>memoryStrategyNames</code> lists every strategy of its type, and omitting <code>memoryStrategies</code> lists every strategy in the space. A name that is not a declared strategy of that type fails with <code>ValidationException</code>.</p>
        actor_ids: <p>Lists only memories owned by one of these actors. Combined with <code>sessionIds</code> by AND: a memory must match both filters when both are given. Omit for no actor filter. An empty list fails validation. A memory stored without an actor never matches an actor filter.</p>
        session_ids: <p>Lists only memories from one of these sessions. Combined with <code>actorIds</code> by AND. Omit for no session filter. An empty list fails validation. A memory stored without a session never matches a session filter.</p>
        sort_by: <p>The timestamp to sort by, as returned in <code>systemMetadata</code>: <code>CREATED_AT</code> (the default) or <code>UPDATED_AT</code>.</p>
        sort_order: <p>The sort order: <code>ASC</code> or <code>DESC</code>. The default is <code>DESC</code>, most recent first.</p>
        max_results: <p>The maximum number of memories to return, from 1 to 100. The default is 20.</p>
        next_token: <p>The token for the next set of results. Use the value returned in the previous response in the next request to retrieve the next set of results.</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.list_memories_input.ListMemoriesInput]",
    ) -> OperationResponse[
        "capo_opensearchmemory.types.list_memories_output.ListMemoriesOutput"
    ]:
        import capo_opensearchmemory._operations.open_search_memory.list_memories

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("ListMemories")
    )
    input_: capo_opensearchmemory.types.list_memories_input.ListMemoriesInput = {
        "space_id": space_id
    }
    if memory_strategies is not None:
        input_["memory_strategies"] = memory_strategies
    if actor_ids is not None:
        input_["actor_ids"] = actor_ids
    if session_ids is not None:
        input_["session_ids"] = session_ids
    if sort_by is not None:
        input_["sort_by"] = sort_by
    if sort_order is not None:
        input_["sort_order"] = sort_order
    if max_results is not None:
        input_["max_results"] = max_results
    if next_token is not None:
        input_["next_token"] = next_token

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