Skip to content

Commit dc8b495

Browse files
lentitude2tkclaude
andcommitted
Add DescribeVolume API and EXTERNAL volume support to VolumeManager
- Add DescribeVolume API (GET /v2/volumes/{volumeName}) with DescribeVolumeRequest and VolumeInfo response - Add EXTERNAL volume fields (type, storageIntegrationId, path) to CreateVolumeRequest - Add type filter to ListVolumesRequest for filtering by MANAGED/EXTERNAL - Extend VolumeInfo with full fields: type, regionId, storageIntegrationId, path, status, createTime - Add describeVolume method to DataVolumeUtils and VolumeManager - Update VolumeManagerExample with describeVolume, createExternalVolume, and type filter examples - Add VolumeManagerTest with 26 test cases covering all request/response builders and serialization Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: lentitude2tk <xushuang.hu@zilliz.com>
1 parent b6d229b commit dc8b495

File tree

8 files changed

+744
-0
lines changed

8 files changed

+744
-0
lines changed

examples/src/main/java/io/milvus/v2/VolumeManagerExample.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@
2323
import io.milvus.bulkwriter.VolumeManagerParam;
2424
import io.milvus.bulkwriter.request.volume.CreateVolumeRequest;
2525
import io.milvus.bulkwriter.request.volume.DeleteVolumeRequest;
26+
import io.milvus.bulkwriter.request.volume.DescribeVolumeRequest;
2627
import io.milvus.bulkwriter.request.volume.ListVolumesRequest;
2728
import io.milvus.bulkwriter.response.volume.ListVolumesResponse;
29+
import io.milvus.bulkwriter.response.volume.VolumeInfo;
2830

2931

3032
public class VolumeManagerExample {
@@ -44,6 +46,8 @@ public class VolumeManagerExample {
4446

4547
public static void main(String[] args) throws Exception {
4648
createVolume();
49+
// createExternalVolume();
50+
describeVolume();
4751
listVolumes();
4852
deleteVolume();
4953
}
@@ -56,12 +60,39 @@ private static void createVolume() {
5660
System.out.printf("\nVolume %s created%n", VOLUME_NAME);
5761
}
5862

63+
private static void createExternalVolume() {
64+
CreateVolumeRequest request = CreateVolumeRequest.builder()
65+
.projectId(PROJECT_ID).regionId(REGION_ID).volumeName("ext-volume")
66+
.type("EXTERNAL")
67+
.storageIntegrationId("si-xxxx")
68+
.path("s3://my-bucket/data/")
69+
.build();
70+
volumeManager.createVolume(request);
71+
System.out.printf("\nExternal volume %s created%n", "ext-volume");
72+
}
73+
74+
private static void describeVolume() {
75+
DescribeVolumeRequest request = DescribeVolumeRequest.builder()
76+
.volumeName(VOLUME_NAME)
77+
.build();
78+
VolumeInfo volumeInfo = volumeManager.describeVolume(request);
79+
System.out.println("\ndescribeVolume result: " + new Gson().toJson(volumeInfo));
80+
}
81+
5982
private static void listVolumes() {
6083
ListVolumesRequest request = ListVolumesRequest.builder()
6184
.projectId(PROJECT_ID).currentPage(1).pageSize(10)
6285
.build();
6386
ListVolumesResponse response = volumeManager.listVolumes(request);
6487
System.out.println("\nlistVolumes results: " + new Gson().toJson(response));
88+
89+
// List volumes filtered by type
90+
ListVolumesRequest filteredRequest = ListVolumesRequest.builder()
91+
.projectId(PROJECT_ID).currentPage(1).pageSize(10)
92+
.type("EXTERNAL")
93+
.build();
94+
ListVolumesResponse filteredResponse = volumeManager.listVolumes(filteredRequest);
95+
System.out.println("\nlistVolumes (EXTERNAL) results: " + new Gson().toJson(filteredResponse));
6596
}
6697

6798
private static void deleteVolume() {

sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/VolumeManager.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@
2222
import com.google.gson.Gson;
2323
import io.milvus.bulkwriter.request.volume.CreateVolumeRequest;
2424
import io.milvus.bulkwriter.request.volume.DeleteVolumeRequest;
25+
import io.milvus.bulkwriter.request.volume.DescribeVolumeRequest;
2526
import io.milvus.bulkwriter.request.volume.ListVolumesRequest;
2627
import io.milvus.bulkwriter.response.volume.ListVolumesResponse;
28+
import io.milvus.bulkwriter.response.volume.VolumeInfo;
2729
import io.milvus.bulkwriter.restful.DataVolumeUtils;
2830

2931
public class VolumeManager {
@@ -42,6 +44,14 @@ public void createVolume(CreateVolumeRequest request) {
4244
DataVolumeUtils.createVolume(cloudEndpoint, apiKey, request);
4345
}
4446

47+
/**
48+
* Get detailed information about a specific volume.
49+
*/
50+
public VolumeInfo describeVolume(DescribeVolumeRequest request) {
51+
String result = DataVolumeUtils.describeVolume(cloudEndpoint, apiKey, request);
52+
return new Gson().fromJson(result, VolumeInfo.class);
53+
}
54+
4555
/**
4656
* Delete a volume.
4757
*/

sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/volume/CreateVolumeRequest.java

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ public class CreateVolumeRequest {
2323
private String projectId;
2424
private String regionId;
2525
private String volumeName;
26+
private String type;
27+
private String storageIntegrationId;
28+
private String path;
2629

2730
public CreateVolumeRequest() {
2831
}
@@ -37,6 +40,9 @@ protected CreateVolumeRequest(CreateVolumeRequestBuilder builder) {
3740
this.projectId = builder.projectId;
3841
this.regionId = builder.regionId;
3942
this.volumeName = builder.volumeName;
43+
this.type = builder.type;
44+
this.storageIntegrationId = builder.storageIntegrationId;
45+
this.path = builder.path;
4046
}
4147

4248
public String getProjectId() {
@@ -63,12 +69,39 @@ public void setVolumeName(String volumeName) {
6369
this.volumeName = volumeName;
6470
}
6571

72+
public String getType() {
73+
return type;
74+
}
75+
76+
public void setType(String type) {
77+
this.type = type;
78+
}
79+
80+
public String getStorageIntegrationId() {
81+
return storageIntegrationId;
82+
}
83+
84+
public void setStorageIntegrationId(String storageIntegrationId) {
85+
this.storageIntegrationId = storageIntegrationId;
86+
}
87+
88+
public String getPath() {
89+
return path;
90+
}
91+
92+
public void setPath(String path) {
93+
this.path = path;
94+
}
95+
6696
@Override
6797
public String toString() {
6898
return "CreateVolumeRequest{" +
6999
"projectId='" + projectId + '\'' +
70100
", regionId='" + regionId + '\'' +
71101
", volumeName='" + volumeName + '\'' +
102+
", type='" + type + '\'' +
103+
", storageIntegrationId='" + storageIntegrationId + '\'' +
104+
", path='" + path + '\'' +
72105
'}';
73106
}
74107

@@ -80,6 +113,9 @@ public static class CreateVolumeRequestBuilder {
80113
private String projectId;
81114
private String regionId;
82115
private String volumeName;
116+
private String type;
117+
private String storageIntegrationId;
118+
private String path;
83119

84120
private CreateVolumeRequestBuilder() {
85121
this.projectId = "";
@@ -102,6 +138,21 @@ public CreateVolumeRequestBuilder volumeName(String volumeName) {
102138
return this;
103139
}
104140

141+
public CreateVolumeRequestBuilder type(String type) {
142+
this.type = type;
143+
return this;
144+
}
145+
146+
public CreateVolumeRequestBuilder storageIntegrationId(String storageIntegrationId) {
147+
this.storageIntegrationId = storageIntegrationId;
148+
return this;
149+
}
150+
151+
public CreateVolumeRequestBuilder path(String path) {
152+
this.path = path;
153+
return this;
154+
}
155+
105156
public CreateVolumeRequest build() {
106157
return new CreateVolumeRequest(this);
107158
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package io.milvus.bulkwriter.request.volume;
21+
22+
public class DescribeVolumeRequest {
23+
private String volumeName;
24+
25+
public DescribeVolumeRequest() {
26+
}
27+
28+
public DescribeVolumeRequest(String volumeName) {
29+
this.volumeName = volumeName;
30+
}
31+
32+
protected DescribeVolumeRequest(DescribeVolumeRequestBuilder builder) {
33+
this.volumeName = builder.volumeName;
34+
}
35+
36+
public String getVolumeName() {
37+
return volumeName;
38+
}
39+
40+
public void setVolumeName(String volumeName) {
41+
this.volumeName = volumeName;
42+
}
43+
44+
@Override
45+
public String toString() {
46+
return "DescribeVolumeRequest{" +
47+
"volumeName='" + volumeName + '\'' +
48+
'}';
49+
}
50+
51+
public static DescribeVolumeRequestBuilder builder() {
52+
return new DescribeVolumeRequestBuilder();
53+
}
54+
55+
public static class DescribeVolumeRequestBuilder {
56+
private String volumeName;
57+
58+
private DescribeVolumeRequestBuilder() {
59+
this.volumeName = "";
60+
}
61+
62+
public DescribeVolumeRequestBuilder volumeName(String volumeName) {
63+
this.volumeName = volumeName;
64+
return this;
65+
}
66+
67+
public DescribeVolumeRequest build() {
68+
return new DescribeVolumeRequest(this);
69+
}
70+
}
71+
}

sdk-bulkwriter/src/main/java/io/milvus/bulkwriter/request/volume/ListVolumesRequest.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public class ListVolumesRequest {
2424
private String projectId;
2525
private Integer pageSize;
2626
private Integer currentPage;
27+
private String type;
2728

2829
public ListVolumesRequest() {
2930
}
@@ -38,6 +39,7 @@ protected ListVolumesRequest(ListVolumesRequestBuilder builder) {
3839
this.projectId = builder.projectId;
3940
this.pageSize = builder.pageSize;
4041
this.currentPage = builder.currentPage;
42+
this.type = builder.type;
4143
}
4244

4345
public String getProjectId() {
@@ -64,12 +66,21 @@ public void setCurrentPage(Integer currentPage) {
6466
this.currentPage = currentPage;
6567
}
6668

69+
public String getType() {
70+
return type;
71+
}
72+
73+
public void setType(String type) {
74+
this.type = type;
75+
}
76+
6777
@Override
6878
public String toString() {
6979
return "ListVolumesRequest{" +
7080
"projectId='" + projectId + '\'' +
7181
", pageSize=" + pageSize +
7282
", currentPage=" + currentPage +
83+
", type='" + type + '\'' +
7384
'}';
7485
}
7586

@@ -81,6 +92,7 @@ public static class ListVolumesRequestBuilder {
8192
private String projectId;
8293
private Integer pageSize;
8394
private Integer currentPage;
95+
private String type;
8496

8597
private ListVolumesRequestBuilder() {
8698
this.projectId = "";
@@ -103,6 +115,11 @@ public ListVolumesRequestBuilder currentPage(Integer currentPage) {
103115
return this;
104116
}
105117

118+
public ListVolumesRequestBuilder type(String type) {
119+
this.type = type;
120+
return this;
121+
}
122+
106123
public ListVolumesRequest build() {
107124
return new ListVolumesRequest(this);
108125
}

0 commit comments

Comments
 (0)