use of com.qcloud.cos.model.BucketLifecycleConfiguration.NoncurrentVersionTransition in project cos-java-sdk-v5 by tencentyun.
the class BucketConfigurationXmlFactory method addNoncurrentTransitions.
private void addNoncurrentTransitions(XmlWriter xml, List<NoncurrentVersionTransition> transitions) {
if (transitions == null || transitions.isEmpty()) {
return;
}
for (NoncurrentVersionTransition t : transitions) {
if (t != null) {
xml.start("NoncurrentVersionTransition");
if (t.getDays() != -1) {
xml.start("NoncurrentDays");
xml.value(Integer.toString(t.getDays()));
xml.end();
}
xml.start("StorageClass");
xml.value(t.getStorageClassAsString());
// </StorageClass>
xml.end();
// </NoncurrentVersionTransition>
xml.end();
}
}
}
use of com.qcloud.cos.model.BucketLifecycleConfiguration.NoncurrentVersionTransition 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);
}
Aggregations