Skip to content

Commit bc4d104

Browse files
authored
feat: [DevOps] Update document-grounding specification (#693)
* Update document-grounding based on main * Update document-grounding based on main
1 parent 4eb2c35 commit bc4d104

File tree

5 files changed

+696
-2
lines changed

5 files changed

+696
-2
lines changed

core-services/document-grounding/src/main/java/com/sap/ai/sdk/grounding/client/VectorApi.java

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import com.sap.ai.sdk.grounding.model.Collection;
55
import com.sap.ai.sdk.grounding.model.CollectionRequest;
66
import com.sap.ai.sdk.grounding.model.CollectionsListResponse;
7+
import com.sap.ai.sdk.grounding.model.DocumentBulkDeleteRequest;
8+
import com.sap.ai.sdk.grounding.model.DocumentBulkDeleteResponse;
79
import com.sap.ai.sdk.grounding.model.DocumentCreateRequest;
810
import com.sap.ai.sdk.grounding.model.DocumentResponse;
911
import com.sap.ai.sdk.grounding.model.DocumentUpdateRequest;
@@ -217,6 +219,77 @@ public DocumentsListResponse createDocuments(
217219
localVarReturnType);
218220
}
219221

222+
/**
223+
* Delete list of documents across collections
224+
*
225+
* <p>Deletes list of documents across collections.
226+
*
227+
* <p><b>200</b> - Successful Response
228+
*
229+
* <p><b>400</b> - The specification of the resource was incorrect
230+
*
231+
* <p><b>404</b> - The specification of the resource was incorrect
232+
*
233+
* <p><b>422</b> - There are validation issues with the data.
234+
*
235+
* @param aiResourceGroup Resource Group ID
236+
* @param documentBulkDeleteRequest The value for the parameter documentBulkDeleteRequest
237+
* @return DocumentBulkDeleteResponse
238+
* @throws OpenApiRequestException if an error occurs while attempting to invoke the API
239+
*/
240+
@Nonnull
241+
public DocumentBulkDeleteResponse deleteAllDocuments(
242+
@Nonnull final String aiResourceGroup,
243+
@Nonnull final DocumentBulkDeleteRequest documentBulkDeleteRequest)
244+
throws OpenApiRequestException {
245+
final Object localVarPostBody = documentBulkDeleteRequest;
246+
247+
// verify the required parameter 'aiResourceGroup' is set
248+
if (aiResourceGroup == null) {
249+
throw new OpenApiRequestException(
250+
"Missing the required parameter 'aiResourceGroup' when calling deleteAllDocuments");
251+
}
252+
253+
// verify the required parameter 'documentBulkDeleteRequest' is set
254+
if (documentBulkDeleteRequest == null) {
255+
throw new OpenApiRequestException(
256+
"Missing the required parameter 'documentBulkDeleteRequest' when calling vectorV1VectorEndpointsDeleteAllDocuments");
257+
}
258+
259+
final String localVarPath =
260+
UriComponentsBuilder.fromPath("/vector/documents").build().toUriString();
261+
262+
final MultiValueMap<String, String> localVarQueryParams =
263+
new LinkedMultiValueMap<String, String>();
264+
final HttpHeaders localVarHeaderParams = new HttpHeaders();
265+
final MultiValueMap<String, Object> localVarFormParams =
266+
new LinkedMultiValueMap<String, Object>();
267+
268+
if (aiResourceGroup != null)
269+
localVarHeaderParams.add("AI-Resource-Group", apiClient.parameterToString(aiResourceGroup));
270+
271+
final String[] localVarAccepts = {"application/json"};
272+
final List<MediaType> localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
273+
final String[] localVarContentTypes = {"application/json"};
274+
final MediaType localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
275+
276+
final String[] localVarAuthNames = new String[] {};
277+
278+
final ParameterizedTypeReference<DocumentBulkDeleteResponse> localVarReturnType =
279+
new ParameterizedTypeReference<DocumentBulkDeleteResponse>() {};
280+
return apiClient.invokeAPI(
281+
localVarPath,
282+
HttpMethod.DELETE,
283+
localVarQueryParams,
284+
localVarPostBody,
285+
localVarHeaderParams,
286+
localVarFormParams,
287+
localVarAccept,
288+
localVarContentType,
289+
localVarAuthNames,
290+
localVarReturnType);
291+
}
292+
220293
/**
221294
* Delete collection by ID
222295
*

core-services/document-grounding/src/main/java/com/sap/ai/sdk/grounding/model/CollectionRequest.java

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.util.NoSuchElementException;
2323
import java.util.Objects;
2424
import java.util.Set;
25+
import java.util.UUID;
2526
import javax.annotation.Nonnull;
2627
import javax.annotation.Nullable;
2728

@@ -39,6 +40,9 @@ public class CollectionRequest
3940
@JsonProperty("metadata")
4041
private List<VectorKeyValueListPair> metadata = new ArrayList<>();
4142

43+
@JsonProperty("id")
44+
private UUID id;
45+
4246
@JsonAnySetter @JsonAnyGetter
4347
private final Map<String, Object> cloudSdkCustomFields = new LinkedHashMap<>();
4448

@@ -156,6 +160,37 @@ public void setMetadata(@Nullable final List<VectorKeyValueListPair> metadata) {
156160
this.metadata = metadata;
157161
}
158162

163+
/**
164+
* Set the id of this {@link CollectionRequest} instance and return the same instance.
165+
*
166+
* @param id Unique identifier of a collection.
167+
* @return The same instance of this {@link CollectionRequest} class
168+
*/
169+
@Nonnull
170+
public CollectionRequest id(@Nullable final UUID id) {
171+
this.id = id;
172+
return this;
173+
}
174+
175+
/**
176+
* Unique identifier of a collection.
177+
*
178+
* @return id The id of this {@link CollectionRequest} instance.
179+
*/
180+
@Nonnull
181+
public UUID getId() {
182+
return id;
183+
}
184+
185+
/**
186+
* Set the id of this {@link CollectionRequest} instance.
187+
*
188+
* @param id Unique identifier of a collection.
189+
*/
190+
public void setId(@Nullable final UUID id) {
191+
this.id = id;
192+
}
193+
159194
/**
160195
* Get the names of the unrecognizable properties of the {@link CollectionRequest}.
161196
*
@@ -197,6 +232,7 @@ public Map<String, Object> toMap() {
197232
if (title != null) declaredFields.put("title", title);
198233
if (embeddingConfig != null) declaredFields.put("embeddingConfig", embeddingConfig);
199234
if (metadata != null) declaredFields.put("metadata", metadata);
235+
if (id != null) declaredFields.put("id", id);
200236
return declaredFields;
201237
}
202238

@@ -224,12 +260,13 @@ public boolean equals(@Nullable final java.lang.Object o) {
224260
return Objects.equals(this.cloudSdkCustomFields, collectionRequest.cloudSdkCustomFields)
225261
&& Objects.equals(this.title, collectionRequest.title)
226262
&& Objects.equals(this.embeddingConfig, collectionRequest.embeddingConfig)
227-
&& Objects.equals(this.metadata, collectionRequest.metadata);
263+
&& Objects.equals(this.metadata, collectionRequest.metadata)
264+
&& Objects.equals(this.id, collectionRequest.id);
228265
}
229266

230267
@Override
231268
public int hashCode() {
232-
return Objects.hash(title, embeddingConfig, metadata, cloudSdkCustomFields);
269+
return Objects.hash(title, embeddingConfig, metadata, id, cloudSdkCustomFields);
233270
}
234271

235272
@Override
@@ -240,6 +277,7 @@ public String toString() {
240277
sb.append(" title: ").append(toIndentedString(title)).append("\n");
241278
sb.append(" embeddingConfig: ").append(toIndentedString(embeddingConfig)).append("\n");
242279
sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n");
280+
sb.append(" id: ").append(toIndentedString(id)).append("\n");
243281
cloudSdkCustomFields.forEach(
244282
(k, v) ->
245283
sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n"));
Lines changed: 214 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
1+
/*
2+
* Grounding
3+
* Grounding is a service designed to handle data-related tasks, such as grounding and retrieval, using vector databases. It provides specialized data retrieval through these databases, grounding the retrieval process with your own external and context-relevant data. Grounding combines generative AI capabilities with the ability to use real-time, precise data to improve decision-making and business operations for specific AI-driven business solutions.
4+
*
5+
*
6+
*
7+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
8+
* https://openapi-generator.tech
9+
* Do not edit the class manually.
10+
*/
11+
12+
package com.sap.ai.sdk.grounding.model;
13+
14+
import com.fasterxml.jackson.annotation.JsonAnyGetter;
15+
import com.fasterxml.jackson.annotation.JsonAnySetter;
16+
import com.fasterxml.jackson.annotation.JsonIgnore;
17+
import com.fasterxml.jackson.annotation.JsonProperty;
18+
import java.util.ArrayList;
19+
import java.util.Arrays;
20+
import java.util.LinkedHashMap;
21+
import java.util.List;
22+
import java.util.Map;
23+
import java.util.NoSuchElementException;
24+
import java.util.Objects;
25+
import java.util.Set;
26+
import java.util.UUID;
27+
import javax.annotation.Nonnull;
28+
import javax.annotation.Nullable;
29+
30+
/** A request to delete documents by their IDs. */
31+
// CHECKSTYLE:OFF
32+
public class DocumentBulkDeleteRequest
33+
// CHECKSTYLE:ON
34+
{
35+
@JsonProperty("ids")
36+
private List<UUID> ids = new ArrayList<>();
37+
38+
@JsonAnySetter @JsonAnyGetter
39+
private final Map<String, Object> cloudSdkCustomFields = new LinkedHashMap<>();
40+
41+
/** Default constructor for DocumentBulkDeleteRequest. */
42+
protected DocumentBulkDeleteRequest() {}
43+
44+
/**
45+
* Set the ids of this {@link DocumentBulkDeleteRequest} instance and return the same instance.
46+
*
47+
* @param ids List of document IDs to delete
48+
* @return The same instance of this {@link DocumentBulkDeleteRequest} class
49+
*/
50+
@Nonnull
51+
public DocumentBulkDeleteRequest ids(@Nonnull final List<UUID> ids) {
52+
this.ids = ids;
53+
return this;
54+
}
55+
56+
/**
57+
* Add one ids instance to this {@link DocumentBulkDeleteRequest}.
58+
*
59+
* @param idsItem The ids that should be added
60+
* @return The same instance of type {@link DocumentBulkDeleteRequest}
61+
*/
62+
@Nonnull
63+
public DocumentBulkDeleteRequest addIdsItem(@Nonnull final UUID idsItem) {
64+
if (this.ids == null) {
65+
this.ids = new ArrayList<>();
66+
}
67+
this.ids.add(idsItem);
68+
return this;
69+
}
70+
71+
/**
72+
* List of document IDs to delete
73+
*
74+
* @return ids The ids of this {@link DocumentBulkDeleteRequest} instance.
75+
*/
76+
@Nonnull
77+
public List<UUID> getIds() {
78+
return ids;
79+
}
80+
81+
/**
82+
* Set the ids of this {@link DocumentBulkDeleteRequest} instance.
83+
*
84+
* @param ids List of document IDs to delete
85+
*/
86+
public void setIds(@Nonnull final List<UUID> ids) {
87+
this.ids = ids;
88+
}
89+
90+
/**
91+
* Get the names of the unrecognizable properties of the {@link DocumentBulkDeleteRequest}.
92+
*
93+
* @return The set of properties names
94+
*/
95+
@JsonIgnore
96+
@Nonnull
97+
public Set<String> getCustomFieldNames() {
98+
return cloudSdkCustomFields.keySet();
99+
}
100+
101+
/**
102+
* Get the value of an unrecognizable property of this {@link DocumentBulkDeleteRequest} instance.
103+
*
104+
* @deprecated Use {@link #toMap()} instead.
105+
* @param name The name of the property
106+
* @return The value of the property
107+
* @throws NoSuchElementException If no property with the given name could be found.
108+
*/
109+
@Nullable
110+
@Deprecated
111+
public Object getCustomField(@Nonnull final String name) throws NoSuchElementException {
112+
if (!cloudSdkCustomFields.containsKey(name)) {
113+
throw new NoSuchElementException(
114+
"DocumentBulkDeleteRequest has no field with name '" + name + "'.");
115+
}
116+
return cloudSdkCustomFields.get(name);
117+
}
118+
119+
/**
120+
* Get the value of all properties of this {@link DocumentBulkDeleteRequest} instance including
121+
* unrecognized properties.
122+
*
123+
* @return The map of all properties
124+
*/
125+
@JsonIgnore
126+
@Nonnull
127+
public Map<String, Object> toMap() {
128+
final Map<String, Object> declaredFields = new LinkedHashMap<>(cloudSdkCustomFields);
129+
if (ids != null) declaredFields.put("ids", ids);
130+
return declaredFields;
131+
}
132+
133+
/**
134+
* Set an unrecognizable property of this {@link DocumentBulkDeleteRequest} instance. If the map
135+
* previously contained a mapping for the key, the old value is replaced by the specified value.
136+
*
137+
* @param customFieldName The name of the property
138+
* @param customFieldValue The value of the property
139+
*/
140+
@JsonIgnore
141+
public void setCustomField(@Nonnull String customFieldName, @Nullable Object customFieldValue) {
142+
cloudSdkCustomFields.put(customFieldName, customFieldValue);
143+
}
144+
145+
@Override
146+
public boolean equals(@Nullable final java.lang.Object o) {
147+
if (this == o) {
148+
return true;
149+
}
150+
if (o == null || getClass() != o.getClass()) {
151+
return false;
152+
}
153+
final DocumentBulkDeleteRequest documentBulkDeleteRequest = (DocumentBulkDeleteRequest) o;
154+
return Objects.equals(this.cloudSdkCustomFields, documentBulkDeleteRequest.cloudSdkCustomFields)
155+
&& Objects.equals(this.ids, documentBulkDeleteRequest.ids);
156+
}
157+
158+
@Override
159+
public int hashCode() {
160+
return Objects.hash(ids, cloudSdkCustomFields);
161+
}
162+
163+
@Override
164+
@Nonnull
165+
public String toString() {
166+
final StringBuilder sb = new StringBuilder();
167+
sb.append("class DocumentBulkDeleteRequest {\n");
168+
sb.append(" ids: ").append(toIndentedString(ids)).append("\n");
169+
cloudSdkCustomFields.forEach(
170+
(k, v) ->
171+
sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n"));
172+
sb.append("}");
173+
return sb.toString();
174+
}
175+
176+
/**
177+
* Convert the given object to string with each line indented by 4 spaces (except the first line).
178+
*/
179+
private String toIndentedString(final java.lang.Object o) {
180+
if (o == null) {
181+
return "null";
182+
}
183+
return o.toString().replace("\n", "\n ");
184+
}
185+
186+
/**
187+
* Create a type-safe, fluent-api builder object to construct a new {@link
188+
* DocumentBulkDeleteRequest} instance with all required arguments.
189+
*/
190+
public static Builder create() {
191+
return (ids) -> new DocumentBulkDeleteRequest().ids(ids);
192+
}
193+
194+
/** Builder helper class. */
195+
public interface Builder {
196+
/**
197+
* Set the ids of this {@link DocumentBulkDeleteRequest} instance.
198+
*
199+
* @param ids List of document IDs to delete
200+
* @return The DocumentBulkDeleteRequest instance.
201+
*/
202+
DocumentBulkDeleteRequest ids(@Nonnull final List<UUID> ids);
203+
204+
/**
205+
* Set the ids of this {@link DocumentBulkDeleteRequest} instance.
206+
*
207+
* @param ids List of document IDs to delete
208+
* @return The DocumentBulkDeleteRequest instance.
209+
*/
210+
default DocumentBulkDeleteRequest ids(@Nonnull final UUID... ids) {
211+
return ids(Arrays.asList(ids));
212+
}
213+
}
214+
}

0 commit comments

Comments
 (0)