|
67 | 67 | import com.qcloud.cos.internal.XmlResponsesSaxParser.CompleteMultipartUploadHandler; |
68 | 68 | import com.qcloud.cos.internal.XmlResponsesSaxParser.CopyObjectResultHandler; |
69 | 69 | import com.qcloud.cos.model.*; |
| 70 | +import com.qcloud.cos.model.IntelligentTiering.BucketIntelligentTieringConfiguration; |
70 | 71 | import com.qcloud.cos.model.bucketcertificate.BucketDomainCertificateRequest; |
71 | 72 | import com.qcloud.cos.model.bucketcertificate.BucketGetDomainCertificate; |
72 | 73 | import com.qcloud.cos.model.bucketcertificate.BucketPutDomainCertificate; |
@@ -3874,6 +3875,24 @@ public void setBucketIntelligentTieringConfiguration(SetBucketIntelligentTierCon |
3874 | 3875 | invoke(request, voidCosResponseHandler); |
3875 | 3876 | } |
3876 | 3877 |
|
| 3878 | + public List<BucketIntelligentTieringConfiguration> listBucketIntelligentTieringConfiguration(String bucketName) throws CosServiceException, CosClientException { |
| 3879 | + rejectEmpty(bucketName, |
| 3880 | + "The bucket name parameter must be specified when listing bucket IntelligentTieringConfiguration"); |
| 3881 | + CosHttpRequest<CosServiceRequest> request = createRequest(bucketName, null, new CosServiceRequest(), HttpMethodName.GET); |
| 3882 | + request.addParameter("intelligent-tiering", null); |
| 3883 | + |
| 3884 | + try { |
| 3885 | + return invoke(request, new Unmarshallers.ListBucketTieringConfigurationUnmarshaller()); |
| 3886 | + } catch (CosServiceException cse) { |
| 3887 | + switch (cse.getStatusCode()) { |
| 3888 | + case 404: |
| 3889 | + return null; |
| 3890 | + default: |
| 3891 | + throw cse; |
| 3892 | + } |
| 3893 | + } |
| 3894 | + } |
| 3895 | + |
3877 | 3896 | @Override |
3878 | 3897 | public MediaJobResponse createMediaJobs(MediaJobsRequest req) { |
3879 | 3898 | this.rejectStartWith(req.getCallBack(),"http","The CallBack parameter mush start with http or https"); |
@@ -5353,5 +5372,108 @@ private String buildPrivateM3U8Url(CosHttpRequest<PrivateM3U8Request> request) |
5353 | 5372 | URL url = generatePresignedUrl(request.getBucketName(), request.getResourcePath(), expiredTime, HttpMethodName.GET, new HashMap<String, String>(), params, false, false); |
5354 | 5373 | return url.toString(); |
5355 | 5374 | } |
| 5375 | + |
| 5376 | + public void putBucketEncryptionConfiguration(String bucketName, BucketEncryptionConfiguration bucketEncryptionConfiguration) |
| 5377 | + throws CosClientException, CosServiceException { |
| 5378 | + rejectEmpty(bucketName, |
| 5379 | + "The bucket name parameter must be specified when putting bucket encryption"); |
| 5380 | + |
| 5381 | + CosHttpRequest<CosServiceRequest> request = createRequest(bucketName, null, new CosServiceRequest(), HttpMethodName.PUT); |
| 5382 | + request.addParameter("encryption", null); |
| 5383 | + |
| 5384 | + rejectEmpty(bucketEncryptionConfiguration.getSseAlgorithm(), |
| 5385 | + "The SseAlgorithm parameter must be specified when putting bucket encryption"); |
| 5386 | + |
| 5387 | + byte[] bytes = new BucketConfigurationXmlFactory().convertToXmlByteArray(bucketEncryptionConfiguration); |
| 5388 | + request.setContent(new ByteArrayInputStream(bytes)); |
| 5389 | + request.addHeader(Headers.CONTENT_LENGTH, String.valueOf(bytes.length)); |
| 5390 | + |
| 5391 | + invoke(request, voidCosResponseHandler); |
| 5392 | + } |
| 5393 | + |
| 5394 | + public BucketEncryptionConfiguration getBucketEncryptionConfiguration(String bucketName) throws CosClientException, CosServiceException { |
| 5395 | + rejectEmpty(bucketName, |
| 5396 | + "The bucket name parameter must be specified when getting bucket encryption"); |
| 5397 | + |
| 5398 | + CosHttpRequest<CosServiceRequest> request = createRequest(bucketName, null, new CosServiceRequest(), HttpMethodName.GET); |
| 5399 | + request.addParameter("encryption", null); |
| 5400 | + |
| 5401 | + return invoke(request, new Unmarshallers.BucketEncryptionConfigurationUnmarshaller()); |
| 5402 | + } |
| 5403 | + |
| 5404 | + public void deleteBucketEncryptionConfiguration(String bucketName) throws CosClientException, CosServiceException { |
| 5405 | + rejectEmpty(bucketName, |
| 5406 | + "The bucket name parameter must be specified when deleting bucket encryption"); |
| 5407 | + |
| 5408 | + CosHttpRequest<CosServiceRequest> request = createRequest(bucketName, null, new CosServiceRequest(), HttpMethodName.DELETE); |
| 5409 | + request.addParameter("encryption", null); |
| 5410 | + |
| 5411 | + invoke(request, voidCosResponseHandler); |
| 5412 | + } |
| 5413 | + |
| 5414 | + public BucketObjectLockConfiguration getBucketObjectLockConfiguration(String bucketName) throws CosClientException, CosServiceException { |
| 5415 | + rejectEmpty(bucketName, |
| 5416 | + "The bucket name parameter must be specified when getting bucket object lock configuration"); |
| 5417 | + |
| 5418 | + CosHttpRequest<CosServiceRequest> request = createRequest(bucketName, null, new CosServiceRequest(), HttpMethodName.GET); |
| 5419 | + request.addParameter("object-lock", null); |
| 5420 | + |
| 5421 | + try { |
| 5422 | + return invoke(request, new Unmarshallers.BucketObjectLockConfigurationUnmarshaller()); |
| 5423 | + } catch (CosServiceException cse) { |
| 5424 | + switch (cse.getStatusCode()) { |
| 5425 | + case 404: |
| 5426 | + return null; |
| 5427 | + default: |
| 5428 | + throw cse; |
| 5429 | + } |
| 5430 | + } |
| 5431 | + } |
| 5432 | + |
| 5433 | + public BucketGetMetadataResult getBucketMetadata(String bucketName) throws CosClientException, CosServiceException { |
| 5434 | + rejectEmpty(bucketName, |
| 5435 | + "The bucket name parameter must be specified when getting bucket metadata"); |
| 5436 | + BucketGetMetadataResult result = new BucketGetMetadataResult(); |
| 5437 | + HeadBucketResult headBucketResult = headBucket(new HeadBucketRequest(bucketName)); |
| 5438 | + result.bucketName = bucketName; |
| 5439 | + StringBuilder strBuilder = new StringBuilder(); |
| 5440 | + strBuilder.append(clientConfig.getHttpProtocol().toString()).append("://"); |
| 5441 | + strBuilder.append(clientConfig.getEndpointBuilder() |
| 5442 | + .buildGeneralApiEndpoint(formatBucket(bucketName, null))); |
| 5443 | + result.bucketUrl = strBuilder.toString(); |
| 5444 | + result.isMaz = headBucketResult.isMazBucket(); |
| 5445 | + result.isOFS = headBucketResult.isMergeBucket(); |
| 5446 | + result.location = headBucketResult.getBucketRegion(); |
| 5447 | + |
| 5448 | + try { |
| 5449 | + BucketEncryptionConfiguration encryptionConfiguration = getBucketEncryptionConfiguration(bucketName); |
| 5450 | + result.encryptionConfiguration = encryptionConfiguration; |
| 5451 | + } catch (CosServiceException cse) { |
| 5452 | + if (cse.getStatusCode() != 404) { |
| 5453 | + throw cse; |
| 5454 | + } |
| 5455 | + } |
| 5456 | + |
| 5457 | + result.accessControlList = getBucketAcl(bucketName); |
| 5458 | + result.websiteConfiguration = getBucketWebsiteConfiguration(bucketName); |
| 5459 | + result.loggingConfiguration = getBucketLoggingConfiguration(bucketName); |
| 5460 | + result.crossOriginConfiguration = getBucketCrossOriginConfiguration(bucketName); |
| 5461 | + result.versioningConfiguration = getBucketVersioningConfiguration(bucketName); |
| 5462 | + result.lifecycleConfiguration = getBucketLifecycleConfiguration(bucketName); |
| 5463 | + |
| 5464 | + try { |
| 5465 | + result.replicationConfiguration = getBucketReplicationConfiguration(bucketName); |
| 5466 | + } catch (CosServiceException cse) { |
| 5467 | + if (cse.getStatusCode() != 404) { |
| 5468 | + throw cse; |
| 5469 | + } |
| 5470 | + } |
| 5471 | + |
| 5472 | + result.taggingConfiguration = getBucketTaggingConfiguration(bucketName); |
| 5473 | + result.tieringConfigurations = listBucketIntelligentTieringConfiguration(bucketName); |
| 5474 | + result.bucketObjectLockConfiguration = getBucketObjectLockConfiguration(bucketName); |
| 5475 | + |
| 5476 | + return result; |
| 5477 | + } |
5356 | 5478 | } |
5357 | 5479 |
|
0 commit comments