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

Torch Object Storage

Copy page
Download PDF
Vector bucket
DeleteVectorBucketPolicy(TOS Vectors Java SDK)
Copy page
Download PDF
DeleteVectorBucketPolicy(TOS Vectors Java SDK)
The deleteVectorBucketPolicy interface deletes the policy of a specified vector bucket. This article explains how to perform this operation using the deleteVectorBucketPolicy interface in the TOS Vectors Java SDK.​
Notes​
  • You need to fill in the region and endpoint in the sample code according to your actual situation. For details, see Region and Endpoint.​
  • To prevent key leakage, the sample code reads the Access Key ID and Secret Access Key from environment variables. Therefore, before using the SDK, you need to configure long-term access credentials. For details, see Configure Long-Term Access Credentials.​
  • The TOS Vectors Java SDK supports temporary access credentials and multiple mechanisms such as timeout settings and retry policies. You can flexibly configure these based on business needs to enhance application security. For details, see Common Configuration Scenarios.​
  • Before deleting a vector bucket, ensure it is empty; that is, all vector indexes in the bucket have been deleted.​
Permissions required​
The main account has full permissions by default, but IAM users have no permissions by default. If you need to use a sub-account to perform the deleteVectorBucketPolicy operation, the main account must grant the sub-account the following permissions through IAM policies and bucket policies:​
tosvectors:DeleteVectorBucketPolicy​
Code example​
Delete vector bucket IAM policy​
​
// Delete the IAM policy for the 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.DeleteVectorBucketPolicyInput;​
import com.volcengine.tos.model.vectors.DeleteVectorBucketPolicyOutput;​
​
public class DeleteVectorBucketPolicyExample {​
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 BucketName.​
String bucketName = 'Provide your bucket name';​
​
// Initialize client​
TOSVectors client = new TOSVectorsClientBuilder().build(region, endpoint, accessKey, secretKey);​
​
try {​
// Create input parameters for deleting vector bucket policies.​
DeleteVectorBucketPolicyInput input = DeleteVectorBucketPolicyInput.builder()​
.vectorBucketName(bucketName) // Set the vector bucket name.​
.accountId(accountID) // Set account ID.​
.build();​
​
// Call the delete vector bucket policy API.​
DeleteVectorBucketPolicyOutput output = client.deleteVectorBucketPolicy(input);​
​
// Print the request result information.​
System.out.println("RequestID: " + output.getRequestInfo().getRequestId());​
System.out.println("StatusCode: " + output.getRequestInfo().getStatusCode());​
System.out.println("Delete vector bucket IAM policy 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 DeleteVectorBucketPolicy, see DeleteVectorBucketPolicy.​
Last updated: 2026.02.06 18:01:48