This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new d8dfbb4a17e0 CAMEL-28039: camel-aws2-s3-vectors - listVectorBuckets, 
listVectorIndexes and queryVectors can page (#31270)
d8dfbb4a17e0 is described below

commit d8dfbb4a17e01086ff257f4cc740509a5555c122
Author: Andrea Cosentino <[email protected]>
AuthorDate: Wed Dec 2 21:37:12 2026 +0100

    CAMEL-28039: camel-aws2-s3-vectors - listVectorBuckets, listVectorIndexes 
and queryVectors can page (#31270)
    
    The three operations built their request with no token and no page size and 
set the first page as the body, so a
    route could not reach past it. All three answers carry a nextToken 
(verified against s3vectors 2.57.7), which was
    neither followed nor surfaced.
    
    Add CamelAwsS3VectorsNextToken, CamelAwsS3VectorsMaxResults and 
CamelAwsS3VectorsIsTruncated. queryVectors takes
    the token only, as topK is its page size. The producer removes the token 
header on the last page, so a route that
    loops while it is present stops by itself.
    
    Co-Authored-By: Claude Opus 5 <[email protected]>
---
 .../camel/catalog/components/aws2-s3-vectors.json  |   5 +-
 .../catalog/docs/aws2-s3-vectors-component.adoc    |  11 ++
 .../component/aws2/s3vectors/aws2-s3-vectors.json  |   5 +-
 .../src/main/docs/aws2-s3-vectors-component.adoc   |  11 ++
 .../aws2/s3vectors/AWS2S3VectorsConstants.java     |  18 +++
 .../aws2/s3vectors/AWS2S3VectorsProducer.java      |  51 ++++++-
 .../s3vectors/AWS2S3VectorsProducerPagingTest.java | 155 +++++++++++++++++++++
 .../dsl/AWS2S3VectorsEndpointBuilderFactory.java   |  43 ++++++
 8 files changed, 291 insertions(+), 8 deletions(-)

diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-s3-vectors.json
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-s3-vectors.json
index ec58028e5c3e..af9c97bf8aa2 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-s3-vectors.json
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-s3-vectors.json
@@ -76,7 +76,10 @@
     "CamelAwsS3VectorsDistance": { "index": 14, "kind": "header", 
"displayName": "", "group": "consumer", "label": "consumer", "required": false, 
"javaType": "Float", "deprecated": false, "autowired": false, "secret": false, 
"description": "The distance of the consumed vector from the query vector, 
computed with the distance metric of the index: the lower, the closer.", 
"constantName": 
"org.apache.camel.component.aws2.s3vectors.AWS2S3VectorsConstants#DISTANCE" },
     "CamelAwsS3VectorsResultCount": { "index": 15, "kind": "header", 
"displayName": "", "group": "consumer", "label": "consumer", "required": false, 
"javaType": "Integer", "deprecated": false, "autowired": false, "secret": 
false, "description": "The number of vectors that queryVectors returned.", 
"constantName": 
"org.apache.camel.component.aws2.s3vectors.AWS2S3VectorsConstants#RESULT_COUNT" 
},
     "CamelAwsS3VectorsIndexStatus": { "index": 16, "kind": "header", 
"displayName": "", "group": "consumer", "label": "consumer", "required": false, 
"javaType": "String", "deprecated": false, "autowired": false, "secret": false, 
"description": "Never set: the component does not set this header, and an S3 
Vectors index has no status.", "constantName": 
"org.apache.camel.component.aws2.s3vectors.AWS2S3VectorsConstants#INDEX_STATUS" 
},
-    "CamelAwsS3VectorsVectorBucketArn": { "index": 17, "kind": "header", 
"displayName": "", "group": "consumer", "label": "consumer", "required": false, 
"javaType": "String", "deprecated": false, "autowired": false, "secret": false, 
"description": "The ARN of the vector bucket that createVectorBucket created.", 
"constantName": 
"org.apache.camel.component.aws2.s3vectors.AWS2S3VectorsConstants#VECTOR_BUCKET_ARN"
 }
+    "CamelAwsS3VectorsVectorBucketArn": { "index": 17, "kind": "header", 
"displayName": "", "group": "consumer", "label": "consumer", "required": false, 
"javaType": "String", "deprecated": false, "autowired": false, "secret": false, 
"description": "The ARN of the vector bucket that createVectorBucket created.", 
"constantName": 
"org.apache.camel.component.aws2.s3vectors.AWS2S3VectorsConstants#VECTOR_BUCKET_ARN"
 },
+    "CamelAwsS3VectorsNextToken": { "index": 18, "kind": "header", 
"displayName": "", "group": "producer", "label": "producer", "required": false, 
"javaType": "String", "deprecated": false, "autowired": false, "secret": false, 
"description": "The pagination token of listVectorBuckets, listVectorIndexes 
and queryVectors. Set it to the value a previous call returned, to get the next 
page. The producer sets it after the operation to the token of the next page, 
and removes it when the page i [...]
+    "CamelAwsS3VectorsMaxResults": { "index": 19, "kind": "header", 
"displayName": "", "group": "producer", "label": "producer", "required": false, 
"javaType": "Integer", "deprecated": false, "autowired": false, "secret": 
false, "description": "The maximum number of entries that one listVectorBuckets 
or listVectorIndexes call returns. queryVectors uses the topK option or the 
CamelAwsS3VectorsTopK header instead.", "constantName": 
"org.apache.camel.component.aws2.s3vectors.AWS2S3VectorsCo [...]
+    "CamelAwsS3VectorsIsTruncated": { "index": 20, "kind": "header", 
"displayName": "", "group": "producer", "label": "producer", "required": false, 
"javaType": "Boolean", "deprecated": false, "autowired": false, "secret": 
false, "description": "Whether the answer of listVectorBuckets, 
listVectorIndexes or queryVectors was truncated, so that more pages follow. The 
producer sets it after the operation.", "constantName": 
"org.apache.camel.component.aws2.s3vectors.AWS2S3VectorsConstants#IS_ [...]
   },
   "bodyTypes": {
     "consumerOut": { "carriers": [ "pojo" ], "javaType": 
"software.amazon.awssdk.services.s3vectors.model.QueryOutputVector", 
"description": "One message per vector that the similarity search of 
consumerQueryVector finds and that was not sent before, as a QueryOutputVector 
of the AWS SDK with its key, its metadata and its distance, the key also in the 
CamelAwsS3VectorsVectorId header and the distance in the 
CamelAwsS3VectorsDistance header" },
diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/aws2-s3-vectors-component.adoc
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/aws2-s3-vectors-component.adoc
index 7febb8033088..095c8356df61 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/aws2-s3-vectors-component.adoc
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/aws2-s3-vectors-component.adoc
@@ -106,6 +106,17 @@ distance, such as 
`.filter(simple("${header.CamelAwsS3VectorsDistance} < 0.3"))`
 The `dataType` option of `createVectorIndex` is `float32`, the only data type 
of S3 Vectors. The `distanceMetric`
 option is `cosine` (the default) or `euclidean`.
 
+=== Paging listVectorBuckets, listVectorIndexes and queryVectors
+
+S3 Vectors answers these three operations one page at a time. Set 
`CamelAwsS3VectorsMaxResults` to choose how many
+entries `listVectorBuckets` and `listVectorIndexes` return per call; 
`queryVectors` uses the `topK` option (or the
+`CamelAwsS3VectorsTopK` header) as its page size instead.
+
+When more entries follow, the producer sets `CamelAwsS3VectorsIsTruncated` to 
`true` and
+`CamelAwsS3VectorsNextToken` to the token of the next page. Send that token 
back in `CamelAwsS3VectorsNextToken` to
+read on. On the last page the producer sets `CamelAwsS3VectorsIsTruncated` to 
`false` and **removes**
+`CamelAwsS3VectorsNextToken`, so a route that loops while the header is 
present stops by itself.
+
 === Consumer
 
 The consumer polls for vectors using similarity search. It tracks processed 
vector IDs to avoid duplicates.
diff --git 
a/components/camel-aws/camel-aws2-s3-vectors/src/generated/resources/META-INF/org/apache/camel/component/aws2/s3vectors/aws2-s3-vectors.json
 
b/components/camel-aws/camel-aws2-s3-vectors/src/generated/resources/META-INF/org/apache/camel/component/aws2/s3vectors/aws2-s3-vectors.json
index ec58028e5c3e..af9c97bf8aa2 100644
--- 
a/components/camel-aws/camel-aws2-s3-vectors/src/generated/resources/META-INF/org/apache/camel/component/aws2/s3vectors/aws2-s3-vectors.json
+++ 
b/components/camel-aws/camel-aws2-s3-vectors/src/generated/resources/META-INF/org/apache/camel/component/aws2/s3vectors/aws2-s3-vectors.json
@@ -76,7 +76,10 @@
     "CamelAwsS3VectorsDistance": { "index": 14, "kind": "header", 
"displayName": "", "group": "consumer", "label": "consumer", "required": false, 
"javaType": "Float", "deprecated": false, "autowired": false, "secret": false, 
"description": "The distance of the consumed vector from the query vector, 
computed with the distance metric of the index: the lower, the closer.", 
"constantName": 
"org.apache.camel.component.aws2.s3vectors.AWS2S3VectorsConstants#DISTANCE" },
     "CamelAwsS3VectorsResultCount": { "index": 15, "kind": "header", 
"displayName": "", "group": "consumer", "label": "consumer", "required": false, 
"javaType": "Integer", "deprecated": false, "autowired": false, "secret": 
false, "description": "The number of vectors that queryVectors returned.", 
"constantName": 
"org.apache.camel.component.aws2.s3vectors.AWS2S3VectorsConstants#RESULT_COUNT" 
},
     "CamelAwsS3VectorsIndexStatus": { "index": 16, "kind": "header", 
"displayName": "", "group": "consumer", "label": "consumer", "required": false, 
"javaType": "String", "deprecated": false, "autowired": false, "secret": false, 
"description": "Never set: the component does not set this header, and an S3 
Vectors index has no status.", "constantName": 
"org.apache.camel.component.aws2.s3vectors.AWS2S3VectorsConstants#INDEX_STATUS" 
},
-    "CamelAwsS3VectorsVectorBucketArn": { "index": 17, "kind": "header", 
"displayName": "", "group": "consumer", "label": "consumer", "required": false, 
"javaType": "String", "deprecated": false, "autowired": false, "secret": false, 
"description": "The ARN of the vector bucket that createVectorBucket created.", 
"constantName": 
"org.apache.camel.component.aws2.s3vectors.AWS2S3VectorsConstants#VECTOR_BUCKET_ARN"
 }
+    "CamelAwsS3VectorsVectorBucketArn": { "index": 17, "kind": "header", 
"displayName": "", "group": "consumer", "label": "consumer", "required": false, 
"javaType": "String", "deprecated": false, "autowired": false, "secret": false, 
"description": "The ARN of the vector bucket that createVectorBucket created.", 
"constantName": 
"org.apache.camel.component.aws2.s3vectors.AWS2S3VectorsConstants#VECTOR_BUCKET_ARN"
 },
+    "CamelAwsS3VectorsNextToken": { "index": 18, "kind": "header", 
"displayName": "", "group": "producer", "label": "producer", "required": false, 
"javaType": "String", "deprecated": false, "autowired": false, "secret": false, 
"description": "The pagination token of listVectorBuckets, listVectorIndexes 
and queryVectors. Set it to the value a previous call returned, to get the next 
page. The producer sets it after the operation to the token of the next page, 
and removes it when the page i [...]
+    "CamelAwsS3VectorsMaxResults": { "index": 19, "kind": "header", 
"displayName": "", "group": "producer", "label": "producer", "required": false, 
"javaType": "Integer", "deprecated": false, "autowired": false, "secret": 
false, "description": "The maximum number of entries that one listVectorBuckets 
or listVectorIndexes call returns. queryVectors uses the topK option or the 
CamelAwsS3VectorsTopK header instead.", "constantName": 
"org.apache.camel.component.aws2.s3vectors.AWS2S3VectorsCo [...]
+    "CamelAwsS3VectorsIsTruncated": { "index": 20, "kind": "header", 
"displayName": "", "group": "producer", "label": "producer", "required": false, 
"javaType": "Boolean", "deprecated": false, "autowired": false, "secret": 
false, "description": "Whether the answer of listVectorBuckets, 
listVectorIndexes or queryVectors was truncated, so that more pages follow. The 
producer sets it after the operation.", "constantName": 
"org.apache.camel.component.aws2.s3vectors.AWS2S3VectorsConstants#IS_ [...]
   },
   "bodyTypes": {
     "consumerOut": { "carriers": [ "pojo" ], "javaType": 
"software.amazon.awssdk.services.s3vectors.model.QueryOutputVector", 
"description": "One message per vector that the similarity search of 
consumerQueryVector finds and that was not sent before, as a QueryOutputVector 
of the AWS SDK with its key, its metadata and its distance, the key also in the 
CamelAwsS3VectorsVectorId header and the distance in the 
CamelAwsS3VectorsDistance header" },
diff --git 
a/components/camel-aws/camel-aws2-s3-vectors/src/main/docs/aws2-s3-vectors-component.adoc
 
b/components/camel-aws/camel-aws2-s3-vectors/src/main/docs/aws2-s3-vectors-component.adoc
index 7febb8033088..095c8356df61 100644
--- 
a/components/camel-aws/camel-aws2-s3-vectors/src/main/docs/aws2-s3-vectors-component.adoc
+++ 
b/components/camel-aws/camel-aws2-s3-vectors/src/main/docs/aws2-s3-vectors-component.adoc
@@ -106,6 +106,17 @@ distance, such as 
`.filter(simple("${header.CamelAwsS3VectorsDistance} < 0.3"))`
 The `dataType` option of `createVectorIndex` is `float32`, the only data type 
of S3 Vectors. The `distanceMetric`
 option is `cosine` (the default) or `euclidean`.
 
+=== Paging listVectorBuckets, listVectorIndexes and queryVectors
+
+S3 Vectors answers these three operations one page at a time. Set 
`CamelAwsS3VectorsMaxResults` to choose how many
+entries `listVectorBuckets` and `listVectorIndexes` return per call; 
`queryVectors` uses the `topK` option (or the
+`CamelAwsS3VectorsTopK` header) as its page size instead.
+
+When more entries follow, the producer sets `CamelAwsS3VectorsIsTruncated` to 
`true` and
+`CamelAwsS3VectorsNextToken` to the token of the next page. Send that token 
back in `CamelAwsS3VectorsNextToken` to
+read on. On the last page the producer sets `CamelAwsS3VectorsIsTruncated` to 
`false` and **removes**
+`CamelAwsS3VectorsNextToken`, so a route that loops while the header is 
present stops by itself.
+
 === Consumer
 
 The consumer polls for vectors using similarity search. It tracks processed 
vector IDs to avoid duplicates.
diff --git 
a/components/camel-aws/camel-aws2-s3-vectors/src/main/java/org/apache/camel/component/aws2/s3vectors/AWS2S3VectorsConstants.java
 
b/components/camel-aws/camel-aws2-s3-vectors/src/main/java/org/apache/camel/component/aws2/s3vectors/AWS2S3VectorsConstants.java
index 621802d68a4e..e1484df83180 100644
--- 
a/components/camel-aws/camel-aws2-s3-vectors/src/main/java/org/apache/camel/component/aws2/s3vectors/AWS2S3VectorsConstants.java
+++ 
b/components/camel-aws/camel-aws2-s3-vectors/src/main/java/org/apache/camel/component/aws2/s3vectors/AWS2S3VectorsConstants.java
@@ -132,4 +132,22 @@ public interface AWS2S3VectorsConstants {
               description = "The ARN of the vector bucket that 
createVectorBucket created.",
               javaType = "String")
     String VECTOR_BUCKET_ARN = "CamelAwsS3VectorsVectorBucketArn";
+
+    // Pagination
+    @Metadata(label = "producer",
+              description = "The pagination token of listVectorBuckets, 
listVectorIndexes and queryVectors. Set it to the"
+                            + " value a previous call returned, to get the 
next page. The producer sets it after the"
+                            + " operation to the token of the next page, and 
removes it when the page is the last one.",
+              javaType = "String")
+    String NEXT_TOKEN = "CamelAwsS3VectorsNextToken";
+    @Metadata(label = "producer",
+              description = "The maximum number of entries that one 
listVectorBuckets or listVectorIndexes call returns."
+                            + " queryVectors uses the topK option or the 
CamelAwsS3VectorsTopK header instead.",
+              javaType = "Integer")
+    String MAX_RESULTS = "CamelAwsS3VectorsMaxResults";
+    @Metadata(label = "producer",
+              description = "Whether the answer of listVectorBuckets, 
listVectorIndexes or queryVectors was truncated, so"
+                            + " that more pages follow. The producer sets it 
after the operation.",
+              javaType = "Boolean")
+    String IS_TRUNCATED = "CamelAwsS3VectorsIsTruncated";
 }
diff --git 
a/components/camel-aws/camel-aws2-s3-vectors/src/main/java/org/apache/camel/component/aws2/s3vectors/AWS2S3VectorsProducer.java
 
b/components/camel-aws/camel-aws2-s3-vectors/src/main/java/org/apache/camel/component/aws2/s3vectors/AWS2S3VectorsProducer.java
index 66fef5fb5fbe..5ef7a174ca0b 100644
--- 
a/components/camel-aws/camel-aws2-s3-vectors/src/main/java/org/apache/camel/component/aws2/s3vectors/AWS2S3VectorsProducer.java
+++ 
b/components/camel-aws/camel-aws2-s3-vectors/src/main/java/org/apache/camel/component/aws2/s3vectors/AWS2S3VectorsProducer.java
@@ -19,6 +19,7 @@ package org.apache.camel.component.aws2.s3vectors;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
+import java.util.function.Consumer;
 
 import org.apache.camel.Endpoint;
 import org.apache.camel.Exchange;
@@ -206,6 +207,12 @@ public class AWS2S3VectorsProducer extends DefaultProducer 
{
                     AWS2S3VectorsConstants.METADATA_FILTER + " header"));
         }
 
+        // queryVectors pages with the token only: topK is its page size
+        String nextToken = 
message.getHeader(AWS2S3VectorsConstants.NEXT_TOKEN, String.class);
+        if (ObjectHelper.isNotEmpty(nextToken)) {
+            requestBuilder.nextToken(nextToken);
+        }
+
         LOG.trace("Querying vectors in bucket [{}] index [{}] with topK [{}]", 
vectorBucketName, vectorIndexName, topK);
         QueryVectorsResponse response = 
client.queryVectors(requestBuilder.build());
         LOG.trace("Query vectors response: {}", response);
@@ -213,6 +220,7 @@ public class AWS2S3VectorsProducer extends DefaultProducer {
         // Set response headers
         message.setHeader(AWS2S3VectorsConstants.RESULT_COUNT, 
response.vectors().size());
         message.setBody(response.vectors());
+        setNextToken(message, response.nextToken());
     }
 
     private void deleteVectors(S3VectorsClient client, Exchange exchange) {
@@ -291,13 +299,15 @@ public class AWS2S3VectorsProducer extends 
DefaultProducer {
     private void listVectorBuckets(S3VectorsClient client, Exchange exchange) {
         Message message = exchange.getIn();
 
-        ListVectorBucketsRequest request = 
ListVectorBucketsRequest.builder().build();
+        ListVectorBucketsRequest.Builder requestBuilder = 
ListVectorBucketsRequest.builder();
+        applyPaging(message, requestBuilder::nextToken, 
requestBuilder::maxResults);
 
         LOG.trace("Listing vector buckets");
-        ListVectorBucketsResponse response = client.listVectorBuckets(request);
+        ListVectorBucketsResponse response = 
client.listVectorBuckets(requestBuilder.build());
         LOG.trace("List vector buckets response: {}", response);
 
         message.setBody(response.vectorBuckets());
+        setNextToken(message, response.nextToken());
     }
 
     private void describeVectorBucket(S3VectorsClient client, Exchange 
exchange) {
@@ -374,15 +384,16 @@ public class AWS2S3VectorsProducer extends 
DefaultProducer {
         Message message = exchange.getIn();
         String vectorBucketName = determineVectorBucketName(exchange);
 
-        ListIndexesRequest request = ListIndexesRequest.builder()
-                .vectorBucketName(vectorBucketName)
-                .build();
+        ListIndexesRequest.Builder requestBuilder = 
ListIndexesRequest.builder()
+                .vectorBucketName(vectorBucketName);
+        applyPaging(message, requestBuilder::nextToken, 
requestBuilder::maxResults);
 
         LOG.trace("Listing vector indexes in bucket [{}]", vectorBucketName);
-        ListIndexesResponse response = client.listIndexes(request);
+        ListIndexesResponse response = 
client.listIndexes(requestBuilder.build());
         LOG.trace("List vector indexes response: {}", response);
 
         message.setBody(response.indexes());
+        setNextToken(message, response.nextToken());
     }
 
     private void describeVectorIndex(S3VectorsClient client, Exchange 
exchange) {
@@ -403,6 +414,34 @@ public class AWS2S3VectorsProducer extends DefaultProducer 
{
         message.setBody(response);
     }
 
+    /**
+     * Reads the pagination token and the page size from the headers into a 
list request.
+     */
+    private static void applyPaging(Message message, Consumer<String> 
nextToken, Consumer<Integer> maxResults) {
+        String token = message.getHeader(AWS2S3VectorsConstants.NEXT_TOKEN, 
String.class);
+        if (ObjectHelper.isNotEmpty(token)) {
+            nextToken.accept(token);
+        }
+        Integer max = message.getHeader(AWS2S3VectorsConstants.MAX_RESULTS, 
Integer.class);
+        if (ObjectHelper.isNotEmpty(max)) {
+            maxResults.accept(max);
+        }
+    }
+
+    /**
+     * Sets the token of the next page on the message, and removes the header 
when the page just read is the last one,
+     * so that a route that loops on the header stops.
+     */
+    private static void setNextToken(Message message, String nextToken) {
+        boolean truncated = ObjectHelper.isNotEmpty(nextToken);
+        if (truncated) {
+            message.setHeader(AWS2S3VectorsConstants.NEXT_TOKEN, nextToken);
+        } else {
+            message.removeHeader(AWS2S3VectorsConstants.NEXT_TOKEN);
+        }
+        message.setHeader(AWS2S3VectorsConstants.IS_TRUNCATED, truncated);
+    }
+
     private String determineVectorBucketName(Exchange exchange) {
         String vectorBucketName = 
exchange.getIn().getHeader(AWS2S3VectorsConstants.VECTOR_BUCKET_NAME, 
String.class);
         if (ObjectHelper.isEmpty(vectorBucketName)) {
diff --git 
a/components/camel-aws/camel-aws2-s3-vectors/src/test/java/org/apache/camel/component/aws2/s3vectors/AWS2S3VectorsProducerPagingTest.java
 
b/components/camel-aws/camel-aws2-s3-vectors/src/test/java/org/apache/camel/component/aws2/s3vectors/AWS2S3VectorsProducerPagingTest.java
new file mode 100644
index 000000000000..a1135d3444a7
--- /dev/null
+++ 
b/components/camel-aws/camel-aws2-s3-vectors/src/test/java/org/apache/camel/component/aws2/s3vectors/AWS2S3VectorsProducerPagingTest.java
@@ -0,0 +1,155 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.aws2.s3vectors;
+
+import java.util.List;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Producer;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.support.DefaultExchange;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Mockito;
+import software.amazon.awssdk.services.s3vectors.S3VectorsClient;
+import software.amazon.awssdk.services.s3vectors.model.ListIndexesRequest;
+import software.amazon.awssdk.services.s3vectors.model.ListIndexesResponse;
+import 
software.amazon.awssdk.services.s3vectors.model.ListVectorBucketsRequest;
+import 
software.amazon.awssdk.services.s3vectors.model.ListVectorBucketsResponse;
+import software.amazon.awssdk.services.s3vectors.model.QueryVectorsRequest;
+import software.amazon.awssdk.services.s3vectors.model.QueryVectorsResponse;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.when;
+
+/**
+ * listVectorBuckets, listVectorIndexes and queryVectors read the pagination 
token from the headers and leave the token
+ * of the next page behind, so a route can walk a result set that does not fit 
in one answer.
+ */
+class AWS2S3VectorsProducerPagingTest {
+
+    private DefaultCamelContext context;
+    private S3VectorsClient client;
+
+    @BeforeEach
+    void setup() {
+        client = Mockito.mock(S3VectorsClient.class);
+        context = new DefaultCamelContext();
+        context.getRegistry().bind("client", client);
+        context.start();
+    }
+
+    @AfterEach
+    void tearDown() {
+        context.stop();
+    }
+
+    @Test
+    void listVectorBucketsSendsTheTokenAndThePageSize() throws Exception {
+        when(client.listVectorBuckets(any(ListVectorBucketsRequest.class)))
+                
.thenReturn(ListVectorBucketsResponse.builder().vectorBuckets(List.of()).nextToken("page-2").build());
+
+        Exchange exchange = exchange();
+        exchange.getIn().setHeader(AWS2S3VectorsConstants.NEXT_TOKEN, 
"page-1");
+        exchange.getIn().setHeader(AWS2S3VectorsConstants.MAX_RESULTS, 25);
+
+        send(AWS2S3VectorsOperations.listVectorBuckets, exchange);
+
+        ArgumentCaptor<ListVectorBucketsRequest> captor = 
ArgumentCaptor.forClass(ListVectorBucketsRequest.class);
+        Mockito.verify(client).listVectorBuckets(captor.capture());
+        assertThat(captor.getValue().nextToken()).isEqualTo("page-1");
+        assertThat(captor.getValue().maxResults()).isEqualTo(25);
+
+        
assertThat(exchange.getMessage().getHeader(AWS2S3VectorsConstants.NEXT_TOKEN)).isEqualTo("page-2");
+        
assertThat(exchange.getMessage().getHeader(AWS2S3VectorsConstants.IS_TRUNCATED)).isEqualTo(true);
+    }
+
+    @Test
+    void theLastPageDropsTheToken() throws Exception {
+        when(client.listVectorBuckets(any(ListVectorBucketsRequest.class)))
+                
.thenReturn(ListVectorBucketsResponse.builder().vectorBuckets(List.of()).build());
+
+        Exchange exchange = exchange();
+        exchange.getIn().setHeader(AWS2S3VectorsConstants.NEXT_TOKEN, 
"page-1");
+
+        send(AWS2S3VectorsOperations.listVectorBuckets, exchange);
+
+        
assertThat(exchange.getMessage().getHeader(AWS2S3VectorsConstants.NEXT_TOKEN)).isNull();
+        
assertThat(exchange.getMessage().getHeader(AWS2S3VectorsConstants.IS_TRUNCATED)).isEqualTo(false);
+    }
+
+    @Test
+    void listVectorIndexesSendsTheTokenAndThePageSize() throws Exception {
+        when(client.listIndexes(any(ListIndexesRequest.class)))
+                
.thenReturn(ListIndexesResponse.builder().indexes(List.of()).nextToken("page-2").build());
+
+        Exchange exchange = exchange();
+        exchange.getIn().setHeader(AWS2S3VectorsConstants.NEXT_TOKEN, 
"page-1");
+        exchange.getIn().setHeader(AWS2S3VectorsConstants.MAX_RESULTS, 10);
+
+        send(AWS2S3VectorsOperations.listVectorIndexes, exchange);
+
+        ArgumentCaptor<ListIndexesRequest> captor = 
ArgumentCaptor.forClass(ListIndexesRequest.class);
+        Mockito.verify(client).listIndexes(captor.capture());
+        assertThat(captor.getValue().nextToken()).isEqualTo("page-1");
+        assertThat(captor.getValue().maxResults()).isEqualTo(10);
+        assertThat(captor.getValue().vectorBucketName()).isEqualTo("bucket-a");
+
+        
assertThat(exchange.getMessage().getHeader(AWS2S3VectorsConstants.NEXT_TOKEN)).isEqualTo("page-2");
+        
assertThat(exchange.getMessage().getHeader(AWS2S3VectorsConstants.IS_TRUNCATED)).isEqualTo(true);
+    }
+
+    @Test
+    void queryVectorsPagesWithTheTokenOnly() throws Exception {
+        when(client.queryVectors(any(QueryVectorsRequest.class)))
+                
.thenReturn(QueryVectorsResponse.builder().vectors(List.of()).nextToken("page-2").build());
+
+        Exchange exchange = exchange();
+        exchange.getIn().setBody(List.of(0.1f, 0.2f));
+        exchange.getIn().setHeader(AWS2S3VectorsConstants.NEXT_TOKEN, 
"page-1");
+
+        send(AWS2S3VectorsOperations.queryVectors, exchange);
+
+        ArgumentCaptor<QueryVectorsRequest> captor = 
ArgumentCaptor.forClass(QueryVectorsRequest.class);
+        Mockito.verify(client).queryVectors(captor.capture());
+        assertThat(captor.getValue().nextToken()).isEqualTo("page-1");
+
+        
assertThat(exchange.getMessage().getHeader(AWS2S3VectorsConstants.NEXT_TOKEN)).isEqualTo("page-2");
+        
assertThat(exchange.getMessage().getHeader(AWS2S3VectorsConstants.IS_TRUNCATED)).isEqualTo(true);
+    }
+
+    private Exchange exchange() {
+        return new DefaultExchange(context);
+    }
+
+    private void send(AWS2S3VectorsOperations operation, Exchange exchange) 
throws Exception {
+        AWS2S3VectorsEndpoint endpoint = context.getEndpoint(
+                
"aws2-s3-vectors://bucket-a?vectorIndexName=index-a&operation=" + operation
+                                                             + 
"&s3VectorsClient=#client",
+                AWS2S3VectorsEndpoint.class);
+        Producer producer = endpoint.createProducer();
+        producer.start();
+        try {
+            producer.process(exchange);
+        } finally {
+            producer.stop();
+        }
+    }
+}
diff --git 
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/AWS2S3VectorsEndpointBuilderFactory.java
 
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/AWS2S3VectorsEndpointBuilderFactory.java
index ff75e7048cec..ec1413626f36 100644
--- 
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/AWS2S3VectorsEndpointBuilderFactory.java
+++ 
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/AWS2S3VectorsEndpointBuilderFactory.java
@@ -2993,6 +2993,49 @@ public interface AWS2S3VectorsEndpointBuilderFactory {
         public String awsS3VectorsVectorBucketArn() {
             return "CamelAwsS3VectorsVectorBucketArn";
         }
+        /**
+         * The pagination token of listVectorBuckets, listVectorIndexes and
+         * queryVectors. Set it to the value a previous call returned, to get
+         * the next page. The producer sets it after the operation to the token
+         * of the next page, and removes it when the page is the last one.
+         * 
+         * The option is a: {@code String} type.
+         * 
+         * Group: producer
+         * 
+         * @return the name of the header {@code AwsS3VectorsNextToken}.
+         */
+        public String awsS3VectorsNextToken() {
+            return "CamelAwsS3VectorsNextToken";
+        }
+        /**
+         * The maximum number of entries that one listVectorBuckets or
+         * listVectorIndexes call returns. queryVectors uses the topK option or
+         * the CamelAwsS3VectorsTopK header instead.
+         * 
+         * The option is a: {@code Integer} type.
+         * 
+         * Group: producer
+         * 
+         * @return the name of the header {@code AwsS3VectorsMaxResults}.
+         */
+        public String awsS3VectorsMaxResults() {
+            return "CamelAwsS3VectorsMaxResults";
+        }
+        /**
+         * Whether the answer of listVectorBuckets, listVectorIndexes or
+         * queryVectors was truncated, so that more pages follow. The producer
+         * sets it after the operation.
+         * 
+         * The option is a: {@code Boolean} type.
+         * 
+         * Group: producer
+         * 
+         * @return the name of the header {@code AwsS3VectorsIsTruncated}.
+         */
+        public String awsS3VectorsIsTruncated() {
+            return "CamelAwsS3VectorsIsTruncated";
+        }
     }
     static AWS2S3VectorsEndpointBuilder endpointBuilder(String componentName, 
String path) {
         class AWS2S3VectorsEndpointBuilderImpl extends AbstractEndpointBuilder 
implements AWS2S3VectorsEndpointBuilder, AdvancedAWS2S3VectorsEndpointBuilder {

Reply via email to