Skip to content

list_vectors async

list_vectors(
    *,
    config_overrides: Optional[AsyncS3VectorsClientConfig] = None,
    vector_bucket_name: Optional[VectorBucketName] = None,
    index_name: Optional[IndexName] = None,
    index_arn: Optional[IndexArn] = None,
    max_results: Optional[ListVectorsMaxResults] = None,
    next_token: Optional[ListVectorsNextToken] = None,
    segment_count: Optional[ListVectorsSegmentCount] = None,
    segment_index: Optional[ListVectorsSegmentIndex] = None,
    return_data: Optional[bool] = None,
    return_metadata: Optional[bool] = None,
) -> ListVectorsOutput

List vectors in the specified vector index. To specify the vector index, you can either use both the vector bucket name and the vector index name, or use the vector index Amazon Resource Name (ARN).

ListVectors operations proceed sequentially; however, for faster performance on a large number of vectors in a vector index, applications can request a parallel ListVectors operation by providing the segmentCount and segmentIndex parameters.

Permissions

You must have the s3vectors:ListVectors permission to use this operation. Additional permissions are required based on the request parameters you specify:

  • With only s3vectors:ListVectors permission, you can list vector keys when returnData and returnMetadata are both set to false or not specified..

  • If you set returnData or returnMetadata to true, you must have both s3vectors:ListVectors and s3vectors:GetVectors permissions. The request fails with a 403 Forbidden error if you request vector data or metadata without the s3vectors:GetVectors permission.

Parameters:

  • vector_bucket_name (Optional[VectorBucketName], default: None ) –

    The name of the vector bucket.

  • index_name (Optional[IndexName], default: None ) –

    The name of the vector index.

  • index_arn (Optional[IndexArn], default: None ) –

    The Amazon resource Name (ARN) of the vector index.

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

    The maximum number of vectors to return on a page.

    If you don't specify maxResults, the ListVectors operation uses a default value of 500.

    If the processed dataset size exceeds 1 MB before reaching the maxResults value, the operation stops and returns the vectors that are retrieved up to that point, along with a nextToken that you can use in a subsequent request to retrieve the next set of results.

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

    Pagination token from a previous request. The value of this field is empty for an initial request.

  • segment_count (Optional[ListVectorsSegmentCount], default: None ) –

    For a parallel ListVectors request, segmentCount represents the total number of vector segments into which the ListVectors operation will be divided. The value of segmentCount corresponds to the number of application workers that will perform the parallel ListVectors operation. For example, if you want to use four application threads to list vectors in a vector index, specify a segmentCount value of 4.

    If you specify a segmentCount value of 1, the ListVectors operation will be sequential rather than parallel.

    If you specify segmentCount, you must also specify segmentIndex.

  • segment_index (Optional[ListVectorsSegmentIndex], default: None ) –

    For a parallel ListVectors request, segmentIndex is the index of the segment from which to list vectors in the current request. It identifies an individual segment to be listed by an application worker.

    Segment IDs are zero-based, so the first segment is always 0. For example, if you want to use four application threads to list vectors in a vector index, then the first thread specifies a segmentIndex value of 0, the second thread specifies 1, and so on.

    The value of segmentIndex must be less than the value provided for segmentCount.

    If you provide segmentIndex, you must also provide segmentCount.

  • return_data (Optional[bool], default: None ) –

    If true, the vector data of each vector will be included in the response. The default value is false.

  • return_metadata (Optional[bool], default: None ) –

    If true, the metadata associated with each vector will be included in the response. The default value is false.

Raises:

Source code in docs_src/capo_s3vectors/_services/async_s3_vectors.py
async def list_vectors(
    self,
    *,
    config_overrides: Optional[AsyncS3VectorsClientConfig] = None,
    vector_bucket_name: Optional[
        "capo_s3vectors.types.vector_bucket_name.VectorBucketName"
    ] = None,
    index_name: Optional["capo_s3vectors.types.index_name.IndexName"] = None,
    index_arn: Optional["capo_s3vectors.types.index_arn.IndexArn"] = None,
    max_results: Optional[
        "capo_s3vectors.types.list_vectors_max_results.ListVectorsMaxResults"
    ] = None,
    next_token: Optional[
        "capo_s3vectors.types.list_vectors_next_token.ListVectorsNextToken"
    ] = None,
    segment_count: Optional[
        "capo_s3vectors.types.list_vectors_segment_count.ListVectorsSegmentCount"
    ] = None,
    segment_index: Optional[
        "capo_s3vectors.types.list_vectors_segment_index.ListVectorsSegmentIndex"
    ] = None,
    return_data: Optional[bool] = None,
    return_metadata: Optional[bool] = None,
) -> "capo_s3vectors.types.list_vectors_output.ListVectorsOutput":
    """<p>List vectors in the specified vector index. To specify the vector index, you can either use both the vector bucket name and the vector index name, or use the vector index Amazon Resource Name (ARN). </p> <p> <code>ListVectors</code> operations proceed sequentially; however, for faster performance on a large number of vectors in a vector index, applications can request a parallel <code>ListVectors</code> operation by providing the <code>segmentCount</code> and <code>segmentIndex</code> parameters.</p> <dl> <dt>Permissions</dt> <dd> <p>You must have the <code>s3vectors:ListVectors</code> permission to use this operation. Additional permissions are required based on the request parameters you specify:</p> <ul> <li> <p>With only <code>s3vectors:ListVectors</code> permission, you can list vector keys when <code>returnData</code> and <code>returnMetadata</code> are both set to false or not specified..</p> </li> <li> <p>If you set <code>returnData</code> or <code>returnMetadata</code> to true, you must have both <code>s3vectors:ListVectors</code> and <code>s3vectors:GetVectors</code> permissions. The request fails with a <code>403 Forbidden</code> error if you request vector data or metadata without the <code>s3vectors:GetVectors</code> permission.</p> </li> </ul> </dd> </dl>

    Args:
        vector_bucket_name: <p>The name of the vector bucket. </p>
        index_name: <p>The name of the vector index.</p>
        index_arn: <p>The Amazon resource Name (ARN) of the vector index.</p>
        max_results: <p>The maximum number of vectors to return on a page.</p> <p>If you don't specify <code>maxResults</code>, the <code>ListVectors</code> operation uses a default value of 500.</p> <p>If the processed dataset size exceeds 1 MB before reaching the <code>maxResults</code> value, the operation stops and returns the vectors that are retrieved up to that point, along with a <code>nextToken</code> that you can use in a subsequent request to retrieve the next set of results.</p>
        next_token: <p>Pagination token from a previous request. The value of this field is empty for an initial request.</p>
        segment_count: <p>For a parallel <code>ListVectors</code> request, <code>segmentCount</code> represents the total number of vector segments into which the <code>ListVectors</code> operation will be divided. The value of <code>segmentCount</code> corresponds to the number of application workers that will perform the parallel <code>ListVectors</code> operation. For example, if you want to use four application threads to list vectors in a vector index, specify a <code>segmentCount</code> value of 4. </p> <p>If you specify a <code>segmentCount</code> value of 1, the <code>ListVectors</code> operation will be sequential rather than parallel.</p> <p>If you specify <code>segmentCount</code>, you must also specify <code>segmentIndex</code>.</p>
        segment_index: <p>For a parallel <code>ListVectors</code> request, <code>segmentIndex</code> is the index of the segment from which to list vectors in the current request. It identifies an individual segment to be listed by an application worker. </p> <p>Segment IDs are zero-based, so the first segment is always 0. For example, if you want to use four application threads to list vectors in a vector index, then the first thread specifies a <code>segmentIndex</code> value of 0, the second thread specifies 1, and so on. </p> <p>The value of <code>segmentIndex</code> must be less than the value provided for <code>segmentCount</code>. </p> <p>If you provide <code>segmentIndex</code>, you must also provide <code>segmentCount</code>.</p>
        return_data: <p>If true, the vector data of each vector will be included in the response. The default value is <code>false</code>.</p>
        return_metadata: <p>If true, the metadata associated with each vector will be included in the response. The default value is <code>false</code>.</p>

    Raises:
        capo_s3vectors.errors.access_denied_exception.AccessDeniedException: <p>Access denied.</p>
        capo_s3vectors.errors.internal_server_exception.InternalServerException: <p>The request failed due to an internal server error.</p>
        capo_s3vectors.errors.request_timeout_exception.RequestTimeoutException: <p>The request timed out. Retry your request.</p>
        capo_s3vectors.errors.too_many_requests_exception.TooManyRequestsException: <p>The request was denied due to request throttling.</p>
        capo_s3vectors.errors.validation_exception.ValidationException: <p>The requested action isn't valid.</p>
        capo_s3vectors.errors.not_found_exception.NotFoundException: <p>The request was rejected because the specified resource can't be found.</p>
        capo_s3vectors.errors.service_unavailable_exception.ServiceUnavailableException: <p>The service is unavailable. Wait briefly and retry your request. If it continues to fail, increase your waiting time between retries.</p>
        capo_s3vectors.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_s3vectors.types.list_vectors_input.ListVectorsInput]",
    ) -> AsyncOperationResponse[
        "capo_s3vectors.types.list_vectors_output.ListVectorsOutput"
    ]:
        import capo_s3vectors._operations.s3_vectors.list_vectors

        (
            output,
            http_response,
        ) = await capo_s3vectors._operations.s3_vectors.list_vectors.async_list_vectors(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("ListVectors")
    )
    input_: capo_s3vectors.types.list_vectors_input.ListVectorsInput = {}
    if vector_bucket_name is not None:
        input_["vector_bucket_name"] = vector_bucket_name
    if index_name is not None:
        input_["index_name"] = index_name
    if index_arn is not None:
        input_["index_arn"] = index_arn
    if max_results is not None:
        input_["max_results"] = max_results
    if next_token is not None:
        input_["next_token"] = next_token
    if segment_count is not None:
        input_["segment_count"] = segment_count
    if segment_index is not None:
        input_["segment_index"] = segment_index
    if return_data is not None:
        input_["return_data"] = return_data
    if return_metadata is not None:
        input_["return_metadata"] = return_metadata

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