CloseMetaQuery (Java SDK V2)
This topic explains how to use the OSS Java SDK V2 to disable metadata management for a bucket.
Prerequisites
You have installed the OSS Java SDK V2. If you use Maven, add the
com.aliyun:alibabacloud-oss-v2dependency to your pom.xml.You have configured your access credentials as environment variables. The provided code example uses
EnvironmentVariableCredentialsProviderto read theOSS_ACCESS_KEY_IDandOSS_ACCESS_KEY_SECRETenvironment variables.
Permissions
An Alibaba Cloud account has all permissions by default. A RAM user or RAM role does not have any permissions by default. You must grant the required permissions to the RAM user or RAM role to call this operation.
API | Action | Description |
CloseMetaQuery |
| Disables metadata management. |
Example code
import com.aliyun.sdk.service.oss2.credentials.CredentialsProvider;
import com.aliyun.sdk.service.oss2.credentials.EnvironmentVariableCredentialsProvider;
import com.aliyun.sdk.service.oss2.dataprocess.OSSDataProcessClient;
import com.aliyun.sdk.service.oss2.dataprocess.OSSDataProcessClientBuilder;
import com.aliyun.sdk.service.oss2.dataprocess.models.*;
public class CloseMetaQuerySample {
public static void main(String[] args) throws Exception {
String endpoint = null;
String region = "cn-hangzhou";
String bucket = "examplebucket";
CredentialsProvider provider = new EnvironmentVariableCredentialsProvider();
OSSDataProcessClientBuilder clientBuilder = OSSDataProcessClient.newBuilder()
.credentialsProvider(provider)
.region(region);
if (endpoint != null) {
clientBuilder.endpoint(endpoint);
}
try (OSSDataProcessClient client = clientBuilder.build()) {
CloseMetaQueryResult result = client.closeMetaQuery(
CloseMetaQueryRequest.newBuilder()
.bucket(bucket)
.build());
System.out.printf("Status code:%d, request id:%s%n",
result.statusCode(), result.requestId());
} catch (Exception e) {
System.out.printf("error:%n%s", e);
}
}
}References
For a synchronous example, see CloseMetaQuery.java.
For an asynchronous example, see CloseMetaQueryAsync.java.