本文介绍 文件存储 vePFS Java SDK 的代码示例供您参考。
说明
关于下述 SDK 代码中所使用参数的定义、取值范围等信息,请参见 CreateFileSystem。
package com.volcengine.vepfs.examples; import com.volcengine.ApiClient; import com.volcengine.ApiException; import com.volcengine.sign.Credentials; import com.volcengine.vepfs.VepfsApi; import com.volcengine.vepfs.model.*; public class Main { public static VepfsApi api; public static void main(String[] args) { initClient(); createFileSystem(); } public static void createFileSystem() { CreateFileSystemRequest createFileSystemRequest = new CreateFileSystemRequest(); createFileSystemRequest.setFileSystemName("java_sdk_test"); createFileSystemRequest.setZoneId("cn-beijing-a"); createFileSystemRequest.setFileSystemType("VePFS"); createFileSystemRequest.setProtocolType("VePFS"); createFileSystemRequest.setChargeType("PayAsYouGo"); createFileSystemRequest.setCapacity(6); createFileSystemRequest.setStoreType("Advance_100"); createFileSystemRequest.setVpcId("vpc-11w4ygf1zls7*************"); createFileSystemRequest.setSubnetId("subnet-11wlfzpho**************"); // 发起请求并处理返回或异常 try { CreateFileSystemResponse response = api.createFileSystem(createFileSystemRequest); System.out.println(response); } catch (ApiException e) { System.out.println(e.getResponseBody()); } } public static void initClient() { // 详见初始化客户端部分 } }
说明
关于下述 SDK 请求中所使用参数的定义、取值范围等信息,请参见 DescribeFileSystems。
package com.volcengine.vepfs.examples; import com.volcengine.ApiClient; import com.volcengine.ApiException; import com.volcengine.sign.Credentials; import com.volcengine.vepfs.VepfsApi; import com.volcengine.vepfs.model.*; public class Main { public static VepfsApi api; public static void main(String[] args) { initClient(); describeFileSystems(); } public static void describeFileSystems() { DescribeFileSystemsRequest describeFileSystemsRequest = new DescribeFileSystemsRequest(); describeFileSystemsRequest.setFileSystemIds("vepfs-cn**************"); // 文件系统 ID // 发起请求并处理返回或异常 try { DescribeFileSystemsResponse response = api.describeFileSystems(describeFileSystemsRequest); System.out.println(response); } catch (ApiException e) { System.out.println(e.getResponseBody()); } } public static void initClient() { // 详见初始化客户端部分 } }