2121import io .swagger .v3 .oas .annotations .parameters .RequestBody ;
2222import io .swagger .v3 .oas .annotations .responses .ApiResponse ;
2323import io .swagger .v3 .oas .annotations .tags .Tag ;
24+ import javax .ws .rs .Consumes ;
2425import org .glassfish .jersey .server .JSONP ;
2526
2627import javax .servlet .http .HttpServletRequest ;
@@ -62,6 +63,13 @@ public EmbeddingsResource() {
6263 * @param response the HttpServletResponse object.
6364 * @return a Response object containing a map with "type" as key and "embeddings" as value.
6465 */
66+ @ Operation (
67+ summary = "Test AI embeddings service" ,
68+ description = "Returns a test response to verify the AI embeddings service is operational"
69+ )
70+ @ ApiResponse (responseCode = "200" ,
71+ description = "Test response returned successfully" ,
72+ content = @ Content (mediaType = "application/json" ))
6573 @ GET
6674 @ JSONP
6775 @ Path ("/test" )
@@ -80,12 +88,29 @@ public final Response textResource(@Context final HttpServletRequest request,
8088 * @param embeddingsForm the form data for creating embeddings.
8189 * @return a Response object containing the result of the embeddings creation.
8290 */
91+ @ Operation (
92+ summary = "Create AI embeddings" ,
93+ description = "Creates embeddings for content based on the provided form data, processing up to 10,000 content items"
94+ )
95+ @ ApiResponse (responseCode = "200" ,
96+ description = "Embeddings created successfully" ,
97+ content = @ Content (mediaType = "application/json" ))
98+ @ ApiResponse (responseCode = "401" ,
99+ description = "Unauthorized - backend user authentication required" ,
100+ content = @ Content (mediaType = "application/json" ))
101+ @ ApiResponse (responseCode = "500" ,
102+ description = "Internal server error during embeddings creation" ,
103+ content = @ Content (mediaType = "application/json" ))
83104 @ POST
84105 @ JSONP
85106 @ Path ("/" )
86107 @ Produces (MediaType .APPLICATION_JSON )
108+ @ Consumes (MediaType .APPLICATION_JSON )
87109 public final Response embed (@ Context final HttpServletRequest request ,
88110 @ Context final HttpServletResponse response ,
111+ @ RequestBody (description = "Form data containing query, limit, offset, and index configuration for embeddings creation" ,
112+ required = true ,
113+ content = @ Content (schema = @ Schema (implementation = EmbeddingsForm .class )))
89114 final EmbeddingsForm embeddingsForm ) {
90115
91116 // force authentication
@@ -141,12 +166,26 @@ public final Response embed(@Context final HttpServletRequest request,
141166 * @param json the JSON object containing the data for the embeddings to be deleted.
142167 * @return a Response object containing the result of the embeddings' deletion.
143168 */
169+ @ Operation (
170+ summary = "Delete AI embeddings" ,
171+ description = "Deletes embeddings based on provided criteria such as query, identifier, inode, or content type"
172+ )
173+ @ ApiResponse (responseCode = "200" ,
174+ description = "Embeddings deleted successfully" ,
175+ content = @ Content (mediaType = "application/json" ))
176+ @ ApiResponse (responseCode = "401" ,
177+ description = "Unauthorized - backend user authentication required" ,
178+ content = @ Content (mediaType = "application/json" ))
144179 @ DELETE
145180 @ JSONP
146181 @ Path ("/" )
147182 @ Produces (MediaType .APPLICATION_JSON )
183+ @ Consumes (MediaType .APPLICATION_JSON )
148184 public final Response delete (@ Context final HttpServletRequest request ,
149185 @ Context final HttpServletResponse response ,
186+ @ RequestBody (description = "JSON object containing deletion criteria (deleteQuery, indexName, identifier, language, inode, contentType, site)" ,
187+ required = true ,
188+ content = @ Content (schema = @ Schema (implementation = JSONObject .class )))
150189 final JSONObject json ) {
151190
152191 final User user = new WebResource .InitBuilder (request , response ).requiredBackendUser (true ).init ().getUser ();
@@ -181,12 +220,29 @@ public final Response delete(@Context final HttpServletRequest request,
181220 * @param json the JSON object containing the data for the operation.
182221 * @return a Response object containing the result of the operation.
183222 */
223+ @ Operation (
224+ summary = "Drop and recreate embeddings tables" ,
225+ description = "Drops and recreates the embeddings database tables. Requires CMS Administrator role."
226+ )
227+ @ ApiResponse (responseCode = "200" ,
228+ description = "Tables dropped and recreated successfully" ,
229+ content = @ Content (mediaType = "application/json" ))
230+ @ ApiResponse (responseCode = "401" ,
231+ description = "Unauthorized - backend user authentication required" ,
232+ content = @ Content (mediaType = "application/json" ))
233+ @ ApiResponse (responseCode = "403" ,
234+ description = "Forbidden - CMS Administrator role required" ,
235+ content = @ Content (mediaType = "application/json" ))
184236 @ DELETE
185237 @ JSONP
186238 @ Path ("/db" )
187239 @ Produces (MediaType .APPLICATION_JSON )
240+ @ Consumes (MediaType .APPLICATION_JSON )
188241 public final Response dropAndRecreateTables (@ Context final HttpServletRequest request ,
189242 @ Context final HttpServletResponse response ,
243+ @ RequestBody (description = "JSON object (can be empty) for the operation" ,
244+ required = true ,
245+ content = @ Content (schema = @ Schema (implementation = JSONObject .class )))
190246 final JSONObject json ) {
191247
192248 new WebResource .InitBuilder (request , response )
@@ -215,18 +271,35 @@ public final Response dropAndRecreateTables(@Context final HttpServletRequest re
215271 * @param fieldVar the fieldVar parameter.
216272 * @return a Response object containing the count of embeddings.
217273 */
274+ @ Operation (
275+ summary = "Count embeddings (GET)" ,
276+ description = "Counts embeddings based on provided query parameters such as site, content type, index name, etc."
277+ )
278+ @ ApiResponse (responseCode = "200" ,
279+ description = "Embeddings count retrieved successfully" ,
280+ content = @ Content (mediaType = "application/json" ))
281+ @ ApiResponse (responseCode = "401" ,
282+ description = "Unauthorized - backend user authentication required" ,
283+ content = @ Content (mediaType = "application/json" ))
218284 @ GET
219285 @ JSONP
220286 @ Path ("/count" )
221287 @ Produces (MediaType .APPLICATION_JSON )
222288 public final Response count (@ Context final HttpServletRequest request ,
223289 @ Context final HttpServletResponse response ,
290+ @ Parameter (description = "Site identifier" )
224291 @ QueryParam ("site" ) final String site ,
292+ @ Parameter (description = "Content type" )
225293 @ QueryParam ("contentType" ) final String contentType ,
294+ @ Parameter (description = "Index name" )
226295 @ QueryParam ("indexName" ) final String indexName ,
296+ @ Parameter (description = "Language identifier" )
227297 @ QueryParam ("language" ) final String language ,
298+ @ Parameter (description = "Content identifier" )
228299 @ QueryParam ("identifier" ) final String identifier ,
300+ @ Parameter (description = "Content inode" )
229301 @ QueryParam ("inode" ) final String inode ,
302+ @ Parameter (description = "Field variable name" )
230303 @ QueryParam ("fieldVar" ) final String fieldVar ) {
231304
232305 new WebResource .InitBuilder (request , response ).requiredBackendUser (true ).init ().getUser ();
@@ -249,12 +322,26 @@ public final Response count(@Context final HttpServletRequest request,
249322 * @param form the form data for counting embeddings.
250323 * @return a Response object containing the count of embeddings.
251324 */
325+ @ Operation (
326+ summary = "Count embeddings (POST)" ,
327+ description = "Counts embeddings based on provided form data containing search criteria"
328+ )
329+ @ ApiResponse (responseCode = "200" ,
330+ description = "Embeddings count retrieved successfully" ,
331+ content = @ Content (mediaType = "application/json" ))
332+ @ ApiResponse (responseCode = "401" ,
333+ description = "Unauthorized - backend user authentication required" ,
334+ content = @ Content (mediaType = "application/json" ))
252335 @ POST
253336 @ JSONP
254337 @ Path ("/count" )
255338 @ Produces (MediaType .APPLICATION_JSON )
339+ @ Consumes (MediaType .APPLICATION_JSON )
256340 public final Response count (@ Context final HttpServletRequest request ,
257341 @ Context final HttpServletResponse response ,
342+ @ RequestBody (description = "Form data containing count criteria (site, contentType, language, fieldVar, indexName)" ,
343+ required = false ,
344+ content = @ Content (schema = @ Schema (implementation = CompletionsForm .class )))
258345 final CompletionsForm form ) {
259346
260347 new WebResource .InitBuilder (request , response ).requiredBackendUser (true ).init ().getUser ();
@@ -273,6 +360,19 @@ public final Response count(@Context final HttpServletRequest request,
273360 * @param response the HttpServletResponse response.
274361 * @return a Response object containing the count of embeddings by index.
275362 */
363+ @ Operation (
364+ summary = "Count embeddings by index" ,
365+ description = "Returns count of embeddings grouped by index name. Requires CMS Administrator role."
366+ )
367+ @ ApiResponse (responseCode = "200" ,
368+ description = "Index count retrieved successfully" ,
369+ content = @ Content (mediaType = "application/json" ))
370+ @ ApiResponse (responseCode = "401" ,
371+ description = "Unauthorized - backend user authentication required" ,
372+ content = @ Content (mediaType = "application/json" ))
373+ @ ApiResponse (responseCode = "403" ,
374+ description = "Forbidden - CMS Administrator role required" ,
375+ content = @ Content (mediaType = "application/json" ))
276376 @ GET
277377 @ JSONP
278378 @ Path ("/indexCount" )
0 commit comments