You need to enable JavaScript to run this app.
Torch Object Storage

Torch Object Storage

Copy page
Download PDF
Vector bucket
GetVectorBucket(TOS Vectors Java SDK)
Copy page
Download PDF
GetVectorBucket(TOS Vectors Java SDK)
The getVectorBucket interface retrieves metadata of a vector bucket. This article explains how to use the getVectorBucket interface in the TOS Vectors Java SDK to query the creation time, number of vector indices, and status of a vector bucket.​
Notes​
  • To prevent key leaks, the sample code in this article reads the Access Key ID and Secret Access Key from environment variables. Therefore, before using the SDK, configure long-term access credentials. For details, see Configure Long-Term Access Credentials.​
  • The TOS Vectors Java SDK supports temporary access credentials and also supports configuring timeout mechanisms, retry policies, and other options. You can adjust these flexibly based on business needs to enhance application security. For details, see Common Configuration Scenarios.​
Permissions required​
The primary account has all permissions by default, but IAM users have no permissions by default. If you want a sub-account to perform the getVectorBucket operation, the primary account must grant the following permissions to that sub-account through IAM policies and bucket policies:​
tosvectors:GetVectorBucket​
Code example​
Query information for the specified vector bucket​
​
// Query information about the specified vector bucket.​
import com.volcengine.tos.TOSVectorsClientBuilder;​
import com.volcengine.tos.TOSVectors;​
import com.volcengine.tos.TosClientException;​
import com.volcengine.tos.TosServerException;​
import com.volcengine.tos.model.vectors.GetVectorBucketInput;​
import com.volcengine.tos.model.vectors.GetVectorBucketOutput;​
​
public class GetVectorBucketExample {​
public static void main(String[] args) {​
String endpoint = 'Provide your endpoint';​
String region = 'Provide your region';​
String accessKey = System.getenv("TOS_ACCESS_KEY");​
String secretKey = System.getenv("TOS_SECRET_KEY");​
String accountID = System.getenv("TOS_ACCOUNT_ID");​
​
// Fill in the vector bucket name.​
String vectorBucketName = 'Provide your vector bucket name';​
​
// Initialize client.​
TOSVectors client = new TOSVectorsClientBuilder().build(region, endpoint, accessKey, secretKey);​
​
try {​
// Create input parameters for querying vector bucket information.​
GetVectorBucketInput input = GetVectorBucketInput.builder()​
.vectorBucketName(vectorBucketName) // Set the name of the vector bucket to query.​
.accountId(accountID) // Set account ID.​
.build();​
​
// Call the query vector bucket information interface.​
GetVectorBucketOutput output = client.getVectorBucket(input);​
​
// Print request information.​
System.out.println("RequestID: " + output.getRequestInfo().getRequestId());​
System.out.println("StatusCode: " + output.getRequestInfo().getStatusCode());​
​
// Print vector bucket details.​
if (output.getVectorBucket() != null) {​
System.out.println("Vector bucket name: " + output.getVectorBucket().getVectorBucketName());​
System.out.println("Vector bucket TRN: " + output.getVectorBucket().getVectorBucketTrn());​
System.out.println("Project name: " + output.getVectorBucket().getProjectName());​
System.out.println("Creation time: " + output.getVectorBucket().getCreationTime());​
}​
​
System.out.println("Query vector bucket information successfully");​
​
} catch (TosClientException e) {​
// Operation failed, caught a Client exception. Generally, it is due to incorrect request parameters, and in this case, the request was not sent.​
System.out.println("Operation failed");​
System.out.println("Message: " + e.getMessage());​
if (e.getCause() != null) {​
e.getCause().printStackTrace();​
}​
} catch (TosServerException e) {​
// Operation failed, server exception captured, and detailed error information returned from the server can be obtained.​
System.out.println("Operation failed");​
System.out.println("StatusCode: " + e.getStatusCode());​
System.out.println("Code: " + e.getCode());​
System.out.println("Message: " + e.getMessage());​
System.out.println("RequestID: " + e.getRequestID());​
} catch (Throwable t) {​
// As a fallback to catch other exceptions, it generally won't execute here.​
System.out.println("Operation failed");​
System.out.println("unexpected exception, message: " + t.getMessage());​
}​
}​
}​
​
Related documentation​
For the API documentation on GetVectorBucket, see GetVectorBucket.​
Last updated: 2026.02.06 18:01:48