Search in sources :

Example 1 with BucketIntelligentTierConfiguration

use of com.qcloud.cos.model.BucketIntelligentTierConfiguration in project cos-java-sdk-v5 by tencentyun.

the class BucketIntelligentTierDemo method main.

public static void main(String[] args) {
    // 1 初始化用户身份信息(secretId, secretKey)
    COSCredentials cred = new BasicCOSCredentials("SECRET_ID", "SECRET_KEY");
    // 2 设置bucket的区域, COS地域的简称请参照 https://www.qcloud.com/document/product/436/6224
    ClientConfig clientConfig = new ClientConfig(new Region("ap-guangzhou"));
    // 3 生成cos客户端
    COSClient cosclient = new COSClient(cred, clientConfig);
    // bucket名需包含appid
    String bucketName = "mybucket-1251668577";
    BucketIntelligentTierConfiguration bucketIntelligentTierConfiguration = new BucketIntelligentTierConfiguration();
    bucketIntelligentTierConfiguration.setStatus(BucketIntelligentTierConfiguration.ENABLED);
    bucketIntelligentTierConfiguration.setTransition(new BucketIntelligentTierConfiguration.Transition(30));
    SetBucketIntelligentTierConfigurationRequest setBucketIntelligentTierConfigurationRequest = new SetBucketIntelligentTierConfigurationRequest();
    setBucketIntelligentTierConfigurationRequest.setBucketName(bucketName);
    setBucketIntelligentTierConfigurationRequest.setIntelligentTierConfiguration(bucketIntelligentTierConfiguration);
    cosclient.setBucketIntelligentTieringConfiguration(setBucketIntelligentTierConfigurationRequest);
    BucketIntelligentTierConfiguration bucketIntelligentTierConfiguration1 = cosclient.getBucketIntelligentTierConfiguration(bucketName);
    System.out.println(bucketIntelligentTierConfiguration1.getStatus());
    System.out.println(bucketIntelligentTierConfiguration1.getTransition().getDays());
}
Also used : COSClient(com.qcloud.cos.COSClient) COSCredentials(com.qcloud.cos.auth.COSCredentials) BasicCOSCredentials(com.qcloud.cos.auth.BasicCOSCredentials) BucketIntelligentTierConfiguration(com.qcloud.cos.model.BucketIntelligentTierConfiguration) SetBucketIntelligentTierConfigurationRequest(com.qcloud.cos.model.SetBucketIntelligentTierConfigurationRequest) BasicCOSCredentials(com.qcloud.cos.auth.BasicCOSCredentials) Region(com.qcloud.cos.region.Region) ClientConfig(com.qcloud.cos.ClientConfig)

Example 2 with BucketIntelligentTierConfiguration

use of com.qcloud.cos.model.BucketIntelligentTierConfiguration in project cos-java-sdk-v5 by tencentyun.

the class BucketIntelligentTest method setGetBucketIntelligentTest.

@Test
public void setGetBucketIntelligentTest() {
    BucketIntelligentTierConfiguration bucketIntelligentTierConfiguration = new BucketIntelligentTierConfiguration();
    bucketIntelligentTierConfiguration.setStatus(BucketIntelligentTierConfiguration.ENABLED);
    bucketIntelligentTierConfiguration.setTransition(new BucketIntelligentTierConfiguration.Transition(30));
    SetBucketIntelligentTierConfigurationRequest setBucketIntelligentTierConfigurationRequest = new SetBucketIntelligentTierConfigurationRequest();
    setBucketIntelligentTierConfigurationRequest.setBucketName(bucket);
    setBucketIntelligentTierConfigurationRequest.setIntelligentTierConfiguration(bucketIntelligentTierConfiguration);
    cosclient.setBucketIntelligentTieringConfiguration(setBucketIntelligentTierConfigurationRequest);
    BucketIntelligentTierConfiguration bucketIntelligentTierConfiguration1 = cosclient.getBucketIntelligentTierConfiguration(bucket);
    Assert.assertEquals(bucketIntelligentTierConfiguration1.getStatus(), BucketIntelligentTierConfiguration.ENABLED);
    Assert.assertEquals(bucketIntelligentTierConfiguration1.getTransition().getDays(), 30);
}
Also used : BucketIntelligentTierConfiguration(com.qcloud.cos.model.BucketIntelligentTierConfiguration) SetBucketIntelligentTierConfigurationRequest(com.qcloud.cos.model.SetBucketIntelligentTierConfigurationRequest) Test(org.junit.Test)

Aggregations

BucketIntelligentTierConfiguration (com.qcloud.cos.model.BucketIntelligentTierConfiguration)2 SetBucketIntelligentTierConfigurationRequest (com.qcloud.cos.model.SetBucketIntelligentTierConfigurationRequest)2 COSClient (com.qcloud.cos.COSClient)1 ClientConfig (com.qcloud.cos.ClientConfig)1 BasicCOSCredentials (com.qcloud.cos.auth.BasicCOSCredentials)1 COSCredentials (com.qcloud.cos.auth.COSCredentials)1 Region (com.qcloud.cos.region.Region)1 Test (org.junit.Test)1