use of com.qcloud.cos.model.SetBucketVersioningConfigurationRequest in project cos-java-sdk-v5 by tencentyun.
the class BucketReplicationTest method setGetDelBucketReplicationTest.
@Test
public void setGetDelBucketReplicationTest() {
if (!judgeUserInfoValid()) {
return;
}
BucketVersioningConfiguration bucketVersioningEnabled = new BucketVersioningConfiguration(BucketVersioningConfiguration.ENABLED);
cosclient.setBucketVersioningConfiguration(new SetBucketVersioningConfigurationRequest(bucket, bucketVersioningEnabled));
try {
Thread.sleep(5000L);
} catch (InterruptedException e) {
fail(e.toString());
}
ReplicationRule replicationRule = new ReplicationRule();
String prefix = "copy1_folder/";
replicationRule.setPrefix(prefix);
replicationRule.setStatus(ReplicationRuleStatus.Enabled);
ReplicationDestinationConfig replicationDestinationConfig = new ReplicationDestinationConfig();
String bucketQCS = "qcs:id/0:cos:ap-chengdu:appid/1251668577:chengwus3cd";
replicationDestinationConfig.setBucketQCS(bucketQCS);
replicationDestinationConfig.setStorageClass(StorageClass.Standard);
replicationRule.setDestinationConfig(replicationDestinationConfig);
BucketReplicationConfiguration bucketReplicationConfiguration = new BucketReplicationConfiguration();
String ruleName = "qcs::cam::uin/123456789:uin/987654543";
bucketReplicationConfiguration.setRoleName(ruleName);
String ruleId = "cctest1";
replicationRule.setID(ruleId);
bucketReplicationConfiguration.addRule(replicationRule);
cosclient.setBucketReplicationConfiguration(bucket, bucketReplicationConfiguration);
// replication设置后, 立刻获取会需要一段时间
try {
Thread.sleep(5000L);
} catch (InterruptedException e) {
fail(e.toString());
}
BucketReplicationConfiguration replicaConfigGet = cosclient.getBucketReplicationConfiguration(bucket);
assertEquals(ruleName, replicaConfigGet.getRoleName());
assertEquals(1, replicaConfigGet.getRules().size());
ReplicationRule replicationRule2 = replicaConfigGet.getRules().get(0);
assertEquals(bucketQCS, replicationRule2.getDestinationConfig().getBucketQCS());
assertEquals(StorageClass.Standard.toString(), replicationRule2.getDestinationConfig().getStorageClass());
assertEquals(ReplicationRuleStatus.Enabled.toString(), replicationRule2.getStatus());
assertEquals(prefix, replicationRule2.getPrefix());
cosclient.deleteBucketReplicationConfiguration(bucket);
}
use of com.qcloud.cos.model.SetBucketVersioningConfigurationRequest in project cos-java-sdk-v5 by tencentyun.
the class PutGetLifeCycleConfigTest method testPutGetDelLifeCycleForBucketWithVersions.
@Ignore
public void testPutGetDelLifeCycleForBucketWithVersions() {
if (!judgeUserInfoValid()) {
return;
}
BucketVersioningConfiguration bucketVersionConfig = new BucketVersioningConfiguration(BucketVersioningConfiguration.ENABLED);
SetBucketVersioningConfigurationRequest setBucketVersionReq = new SetBucketVersioningConfigurationRequest(bucket, bucketVersionConfig);
cosclient.setBucketVersioningConfiguration(setBucketVersionReq);
List<Rule> rules = new ArrayList<>();
Rule standardIaRule = new Rule();
standardIaRule.setId("standard_ia transition for version");
standardIaRule.setFilter(new LifecycleFilter(new LifecyclePrefixPredicate("standard_ia/")));
List<Transition> standardIaTransitions = new ArrayList<>();
Transition standardTransition = new Transition();
standardTransition.setDays(20);
standardTransition.setStorageClass(StorageClass.Standard_IA.toString());
standardIaTransitions.add(standardTransition);
standardIaRule.setTransitions(standardIaTransitions);
standardIaRule.setStatus(BucketLifecycleConfiguration.DISABLED);
standardIaRule.setNoncurrentVersionExpirationInDays(360);
List<NoncurrentVersionTransition> noncurrentVersionTransitions = new ArrayList<>();
NoncurrentVersionTransition noncurrentVersionTransition = new NoncurrentVersionTransition();
noncurrentVersionTransition.setDays(30);
noncurrentVersionTransition.setStorageClass(StorageClass.Standard_IA);
standardIaRule.setNoncurrentVersionTransitions(noncurrentVersionTransitions);
standardIaRule.setExpirationInDays(120);
rules.add(standardIaRule);
testPutGetDelRules(rules);
bucketVersionConfig.setStatus(BucketVersioningConfiguration.SUSPENDED);
SetBucketVersioningConfigurationRequest closeBucketVersionReq = new SetBucketVersioningConfigurationRequest(bucket, bucketVersionConfig);
cosclient.setBucketVersioningConfiguration(closeBucketVersionReq);
}
use of com.qcloud.cos.model.SetBucketVersioningConfigurationRequest in project cos-java-sdk-v5 by tencentyun.
the class BucketVersioningTest method testBucketVersioningEnabled.
@Test
public void testBucketVersioningEnabled() {
if (!judgeUserInfoValid()) {
return;
}
BucketVersioningConfiguration bucketVersioningEnabled = new BucketVersioningConfiguration(BucketVersioningConfiguration.ENABLED);
cosclient.setBucketVersioningConfiguration(new SetBucketVersioningConfigurationRequest(bucket, bucketVersioningEnabled));
try {
Thread.sleep(5000L);
} catch (InterruptedException e) {
fail(e.toString());
}
BucketVersioningConfiguration bucketVersioningRet = cosclient.getBucketVersioningConfiguration(bucket);
assertEquals(BucketVersioningConfiguration.ENABLED, bucketVersioningRet.getStatus());
}
use of com.qcloud.cos.model.SetBucketVersioningConfigurationRequest in project cos-java-sdk-v5 by tencentyun.
the class BucketVersioningTest method testBucketVersioningSuspended.
@Test
public void testBucketVersioningSuspended() {
if (!judgeUserInfoValid()) {
return;
}
BucketVersioningConfiguration bucketVersioningEnabled = new BucketVersioningConfiguration(BucketVersioningConfiguration.SUSPENDED);
cosclient.setBucketVersioningConfiguration(new SetBucketVersioningConfigurationRequest(bucket, bucketVersioningEnabled));
try {
Thread.sleep(5000L);
} catch (InterruptedException e) {
fail(e.toString());
}
BucketVersioningConfiguration bucketVersioningRet = cosclient.getBucketVersioningConfiguration(bucket);
assertEquals(BucketVersioningConfiguration.SUSPENDED, bucketVersioningRet.getStatus());
}
Aggregations