Skip to content

Commit 5dc3a1c

Browse files
committed
chore: document WeaviateApiException thrown in WeaviateCollectionsClient
1 parent a667584 commit 5dc3a1c

File tree

1 file changed

+86
-0
lines changed

1 file changed

+86
-0
lines changed

src/main/java/io/weaviate/client6/v1/api/collections/WeaviateCollectionsClient.java

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import java.util.Optional;
77
import java.util.function.Function;
88

9+
import io.weaviate.client6.v1.api.WeaviateApiException;
910
import io.weaviate.client6.v1.internal.ObjectBuilder;
1011
import io.weaviate.client6.v1.internal.grpc.GrpcTransport;
1112
import io.weaviate.client6.v1.internal.orm.CollectionDescriptor;
@@ -20,42 +21,127 @@ public WeaviateCollectionsClient(RestTransport restTransport, GrpcTransport grpc
2021
this.grpcTransport = grpcTransport;
2122
}
2223

24+
/**
25+
* Obtain a handle to send requests to a particular collection.
26+
* The returned object is thread-safe.
27+
*
28+
* @returns a handle for a collection with {@code Map<String, Object>}
29+
* properties.
30+
*/
2331
public CollectionHandle<Map<String, Object>> use(String collectionName) {
2432
return new CollectionHandle<>(restTransport, grpcTransport, CollectionDescriptor.ofMap(collectionName));
2533
}
2634

35+
/**
36+
* Create a new Weaviate collection with default configuration.
37+
*
38+
* @returns the configuration of the created collection.
39+
* @throws WeaviateApiException in case the server returned with an
40+
* error status code.
41+
* @throws IOException in case the request was not sent successfully
42+
* due to a malformed request, a networking error
43+
* or the server being unavailable.
44+
*/
2745
public CollectionConfig create(String name) throws IOException {
2846
return create(CollectionConfig.of(name));
2947
}
3048

49+
/**
50+
* Create and configure a new Weaviate collection. See
51+
* {@link CollectionConfig.Builder} for available options.
52+
*
53+
* @returns the configuration of the created collection.
54+
* @throws WeaviateApiException in case the server returned with an
55+
* error status code.
56+
* @throws IOException in case the request was not sent successfully
57+
* due to a malformed request, a networking error
58+
* or the server being unavailable.
59+
*/
3160
public CollectionConfig create(String name,
3261
Function<CollectionConfig.Builder, ObjectBuilder<CollectionConfig>> fn) throws IOException {
3362
return create(CollectionConfig.of(name, fn));
3463
}
3564

65+
/**
66+
* Create a new Weaviate collection with {@link CollectionConfig}.
67+
*
68+
* @returns the configuration of the created collection.
69+
* @throws WeaviateApiException in case the server returned with an
70+
* error status code.
71+
* @throws IOException in case the request was not sent successfully
72+
* due to a malformed request, a networking error
73+
* or the server being unavailable.
74+
*/
3675
public CollectionConfig create(CollectionConfig collection) throws IOException {
3776
return this.restTransport.performRequest(new CreateCollectionRequest(collection),
3877
CreateCollectionRequest._ENDPOINT);
3978
}
4079

80+
/**
81+
* Fetch Weaviate collection configuration.
82+
*
83+
* @returns the collection configuration if one with this name exists.
84+
* @throws WeaviateApiException in case the server returned with an
85+
* error status code.
86+
* @throws IOException in case the request was not sent successfully
87+
* due to a malformed request, a networking error
88+
* or the server being unavailable.
89+
*/
4190
public Optional<CollectionConfig> getConfig(String name) throws IOException {
4291
return this.restTransport.performRequest(new GetConfigRequest(name), GetConfigRequest._ENDPOINT);
4392
}
4493

94+
/**
95+
* Fetch configurations for all collections in Weaviate.
96+
*
97+
* @returns a list of collection configurations.
98+
* @throws WeaviateApiException in case the server returned with an
99+
* error status code.
100+
* @throws IOException in case the request was not sent successfully
101+
* due to a malformed request, a networking error
102+
* or the server being unavailable.
103+
*/
45104
public List<CollectionConfig> list() throws IOException {
46105
return this.restTransport.performRequest(new ListCollectionRequest(), ListCollectionRequest._ENDPOINT);
47106
}
48107

108+
/**
109+
* Delete a Weaviate collection.
110+
*
111+
* @throws WeaviateApiException in case the server returned with an
112+
* error status code.
113+
* @throws IOException in case the request was not sent successfully
114+
* due to a malformed request, a networking error
115+
* or the server being unavailable.
116+
*/
49117
public void delete(String name) throws IOException {
50118
this.restTransport.performRequest(new DeleteCollectionRequest(name), DeleteCollectionRequest._ENDPOINT);
51119
}
52120

121+
/**
122+
* Delete all collections in Weaviate.
123+
*
124+
* @throws WeaviateApiException in case the server returned with an
125+
* error status code.
126+
* @throws IOException in case the request was not sent successfully
127+
* due to a malformed request, a networking error
128+
* or the server being unavailable.
129+
*/
53130
public void deleteAll() throws IOException {
54131
for (var collection : list()) {
55132
delete(collection.collectionName());
56133
}
57134
}
58135

136+
/**
137+
* Check if a collection with this name exists.
138+
*
139+
* @throws WeaviateApiException in case the server returned with an
140+
* error status code.
141+
* @throws IOException in case the request was not sent successfully
142+
* due to a malformed request, a networking error
143+
* or the server being unavailable.
144+
*/
59145
public boolean exists(String name) throws IOException {
60146
return getConfig(name).isPresent();
61147
}

0 commit comments

Comments
 (0)