1919import com .sap .ai .sdk .grounding .model .DocumentKeyValueListPair ;
2020import com .sap .ai .sdk .grounding .model .DocumentWithoutChunks ;
2121import com .sap .ai .sdk .grounding .model .EmbeddingConfig ;
22+ import com .sap .ai .sdk .grounding .model .GetPipeline ;
2223import com .sap .ai .sdk .grounding .model .KeyValueListPair ;
23- import com .sap .ai .sdk .grounding .model .Pipeline ;
24+ import com .sap .ai .sdk .grounding .model .MSSharePointPipelineGetResponse ;
25+ import com .sap .ai .sdk .grounding .model .RetrievalSearchConfiguration ;
2426import com .sap .ai .sdk .grounding .model .RetrievalSearchFilter ;
25- import com .sap .ai .sdk .grounding .model .RetrievalSearchInput ;
26- import com .sap .ai .sdk .grounding .model .SearchConfiguration ;
27+ import com .sap .ai .sdk .grounding .model .S3PipelineGetResponse ;
28+ import com .sap .ai .sdk .grounding .model .SFTPPipelineGetResponse ;
29+ import com .sap .ai .sdk .grounding .model .SearchInput ;
2730import com .sap .ai .sdk .grounding .model .TextOnlyBaseChunk ;
2831import com .sap .cloud .sdk .services .openapi .core .OpenApiResponse ;
2932import java .time .format .TextStyle ;
3033import java .util .ArrayList ;
3134import java .util .List ;
3235import java .util .Locale ;
3336import java .util .Map ;
37+ import java .util .NoSuchElementException ;
3438import java .util .UUID ;
3539import javax .annotation .Nonnull ;
3640import javax .annotation .Nullable ;
@@ -58,21 +62,34 @@ class GroundingController {
5862 @ GetMapping ("/pipelines/list" )
5963 Object getAllPipelines (
6064 @ Nullable @ RequestParam (value = "format" , required = false ) final String format ) {
61- final var pipelines = CLIENT_PIPELINES .getAllPipelines (RESOURCE_GROUP , 10 , 0 , true );
65+ final var pipelines =
66+ CLIENT_PIPELINES .pipelineV1PipelineEndpointsGetAllPipeline (RESOURCE_GROUP , 10 , 0 , true );
6267 log .info ("Found {} pipelines" , pipelines .getResources ().size ());
6368
6469 if ("json" .equals (format )) {
6570 return pipelines ;
6671 }
67- final var ids = pipelines .getResources ().stream ().map (Pipeline ::getId ).collect (joining (", " ));
72+ final var ids = new ArrayList <>();
73+ for (final GetPipeline pipeline : pipelines .getResources ()) {
74+ if (pipeline instanceof MSSharePointPipelineGetResponse p ) {
75+ ids .add (p .getId ());
76+ } else if (pipeline instanceof S3PipelineGetResponse p ) {
77+ ids .add (p .getId ());
78+ } else if (pipeline instanceof SFTPPipelineGetResponse p ) {
79+ ids .add (p .getId ());
80+ } else {
81+ throw new NoSuchElementException ("Unknown pipeline type: " + pipeline .getClass ().getName ());
82+ }
83+ }
6884 return "Found pipelines with ids: " + ids ;
6985 }
7086
7187 /** Retrieve all grounding data repositories. */
7288 @ GetMapping ("/retrieval/repositories" )
7389 Object getAllRepositories (
7490 @ Nullable @ RequestParam (value = "format" , required = false ) final String format ) {
75- final var repositories = CLIENT_RETRIEVAL .getDataRepositories (RESOURCE_GROUP );
91+ final var repositories =
92+ CLIENT_RETRIEVAL .retrievalV1RetrievalEndpointsGetDataRepositories (RESOURCE_GROUP );
7693 log .info ("Found {} data repositories" , repositories .getResources ().size ());
7794
7895 if ("json" .equals (format )) {
@@ -92,8 +109,8 @@ Object searchInDocuments(
92109 .id ("question" )
93110 .dataRepositoryType (DataRepositoryType .VECTOR )
94111 .dataRepositories (List .of ("*" ))
95- .searchConfiguration (SearchConfiguration .create ().maxChunkCount (10 ));
96- final var q = RetrievalSearchInput .create ().query ("When was the last upload?" ).filters (filter );
112+ .searchConfiguration (RetrievalSearchConfiguration .create ().maxChunkCount (10 ));
113+ final var q = SearchInput .create ().query ("When was the last upload?" ).filters (filter );
97114 final var results = CLIENT_RETRIEVAL .search (RESOURCE_GROUP , q );
98115
99116 if ("json" .equals (format )) {
@@ -102,7 +119,7 @@ Object searchInDocuments(
102119 final var messages =
103120 results .getResults ().stream ()
104121 .flatMap (resultsInner1 -> resultsInner1 .getResults ().stream ())
105- .flatMap (result -> result .getDataRepository (). getDocuments ().stream ())
122+ .flatMap (result -> result .getDocuments ().stream ())
106123 .flatMap (dataRepositorySearchResult -> dataRepositorySearchResult .getChunks ().stream ())
107124 .map (Chunk ::getContent )
108125 .toList ();
@@ -113,7 +130,7 @@ Object searchInDocuments(
113130 @ GetMapping ("/vector/collections" )
114131 Object getAllCollections (
115132 @ Nullable @ RequestParam (value = "format" , required = false ) final String format ) {
116- final var collections = CLIENT_VECTOR .getAllCollections (RESOURCE_GROUP );
133+ final var collections = CLIENT_VECTOR .vectorV1VectorEndpointsGetAllCollections (RESOURCE_GROUP );
117134 if ("json" .equals (format )) {
118135 return collections ;
119136 }
@@ -127,7 +144,8 @@ Object getAllCollections(
127144 Object getDocumentsByCollectionId (
128145 @ Nonnull @ PathVariable ("id" ) final UUID collectionId ,
129146 @ Nullable @ RequestParam (value = "format" , required = false ) final String format ) {
130- final var documents = CLIENT_VECTOR .getAllDocuments (RESOURCE_GROUP , collectionId );
147+ final var documents =
148+ CLIENT_VECTOR .vectorV1VectorEndpointsGetAllDocuments (RESOURCE_GROUP , collectionId );
131149 if ("json" .equals (format )) {
132150 return documents ;
133151 }
@@ -142,7 +160,8 @@ String createCollection(
142160 final var embeddingConfig = EmbeddingConfig .create ().modelName (TEXT_EMBEDDING_3_SMALL .name ());
143161 final var request =
144162 CollectionRequest .create ().embeddingConfig (embeddingConfig ).title (COLLECTION_TITLE );
145- final var documents = CLIENT_VECTOR .createCollection (RESOURCE_GROUP , request );
163+ final var documents =
164+ CLIENT_VECTOR .vectorV1VectorEndpointsCreateCollection (RESOURCE_GROUP , request );
146165 final Map <String , List <String >> headers = documents .getHeaders ();
147166
148167 final var locationHeader = headers .get ("Location" ).get (0 );
@@ -162,7 +181,8 @@ Object createDocument(
162181 final var docMeta = DocumentKeyValueListPair .create ().key ("purpose" ).value ("testing" );
163182 final var doc = BaseDocument .create ().chunks (chunk ).metadata (docMeta );
164183 final var request = DocumentCreateRequest .create ().documents (doc );
165- final var response = CLIENT_VECTOR .createDocuments (RESOURCE_GROUP , collectionId , request );
184+ final var response =
185+ CLIENT_VECTOR .vectorV1VectorEndpointsCreateDocuments (RESOURCE_GROUP , collectionId , request );
166186
167187 if ("json" .equals (format )) {
168188 return response ;
@@ -184,18 +204,22 @@ Object deleteCollection(
184204 final var doc = BaseDocument .create ().chunks (chunk ).metadata (docMeta );
185205 final var request = DocumentCreateRequest .create ().documents (doc );
186206
187- final var documents = CLIENT_VECTOR .getAllDocuments (RESOURCE_GROUP , collectionId );
207+ final var documents =
208+ CLIENT_VECTOR .vectorV1VectorEndpointsGetAllDocuments (RESOURCE_GROUP , collectionId );
188209 final var ids = documents .getResources ().stream ().map (DocumentWithoutChunks ::getId ).toList ();
189210 log .info ("Deleting collection {} with {} documents: {}" , collectionId , ids .size (), ids );
190211
191212 for (final var documentId : ids ) {
192- final var del = CLIENT_VECTOR .deleteDocumentById (RESOURCE_GROUP , collectionId , documentId );
213+ final var del =
214+ CLIENT_VECTOR .vectorV1VectorEndpointsDeleteDocument (
215+ RESOURCE_GROUP , collectionId , documentId );
193216 if (del .getStatusCode () >= 400 ) {
194217 final var msg = "Document {} could not be deleted, status code [{}], headers: {}" ;
195218 log .error (msg , documentId , del .getStatusCode (), del .getHeaders ());
196219 }
197220 }
198- final var response = CLIENT_VECTOR .deleteCollectionById (RESOURCE_GROUP , collectionId + "" );
221+ final var response =
222+ CLIENT_VECTOR .vectorV1VectorEndpointsDeleteCollection (RESOURCE_GROUP , collectionId + "" );
199223
200224 if ("json" .equals (format )) {
201225 return response ;
@@ -209,7 +233,9 @@ Object getDocumentChunksById(
209233 @ Nonnull @ PathVariable ("collectionId" ) final UUID collectionId ,
210234 @ Nonnull @ PathVariable ("documentId" ) final UUID documentId ,
211235 @ Nullable @ RequestParam (value = "format" , required = false ) final String format ) {
212- final var document = CLIENT_VECTOR .getDocumentById (RESOURCE_GROUP , collectionId , documentId );
236+ final var document =
237+ CLIENT_VECTOR .vectorV1VectorEndpointsGetDocumentById (
238+ RESOURCE_GROUP , collectionId , documentId );
213239 if ("json" .equals (format )) {
214240 return document ;
215241 }
0 commit comments