API | Operation | Description |
Creating an inventory job | Creates an inventory job for a bucket | |
Querying inventory jobs | Queries the inventory jobs of a bucket | |
Deleting an inventory job | Deletes an inventory job from a bucket |
// Bucket name in the format of BucketName-APPID (APPID is required), which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucketString bucket = "examplebucket-1250000000";PutBucketInventoryRequest putBucketInventoryRequest =new PutBucketInventoryRequest(bucket);putBucketInventoryRequest.setInventoryId("exampleInventoryId");// Indicate whether to include object versions in the inventory:// If set to All, all object versions are included in the inventory,// with additional fields VersionId, IsLatest, and DeleteMarker// If set to Current, no object versions are included in the inventoryputBucketInventoryRequest.setIncludedObjectVersions(InventoryConfiguration.IncludedObjectVersions.ALL);// Backup frequencyputBucketInventoryRequest.setScheduleFrequency(InventoryConfiguration.SCHEDULE_FREQUENCY_DAILY);// Backup pathputBucketInventoryRequest.setDestination("CSV", "1000000000","examplebucket-1250000000", "region", "dir/");cosXmlService.putBucketInventoryAsync(putBucketInventoryRequest,new CosXmlResultListener() {@Overridepublic void onSuccess(CosXmlRequest request, CosXmlResult result) {PutBucketInventoryResult putBucketInventoryResult =(PutBucketInventoryResult) result;}// If you use the Kotlin language to call this, please note that the exception in the callback method is nullable; otherwise, the onFail method will not be called back, that is:// clientException is of type CosXmlClientException? and serviceException is of type CosXmlServiceException?@Overridepublic void onFail(CosXmlRequest cosXmlRequest,@Nullable CosXmlClientException clientException,@Nullable CosXmlServiceException serviceException) {if (clientException != null) {clientException.printStackTrace();} else {serviceException.printStackTrace();}}});
Error Code | Description | Status Code |
InvalidArgument | Invalid parameter value | HTTP 400 Bad Request |
TooManyConfigurations | The number of inventories has reached the upper limit of 1,000 | HTTP 400 Bad Request |
AccessDenied | Unauthorized access. You most likely do not have access permission for the bucket | HTTP 403 Forbidden |
// Bucket name in the format of BucketName-APPID (APPID is required), which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucketString bucket = "examplebucket-1250000000";GetBucketInventoryRequest getBucketInventoryRequest =new GetBucketInventoryRequest(bucket);getBucketInventoryRequest.setInventoryId("exampleInventoryId");cosXmlService.getBucketInventoryAsync(getBucketInventoryRequest,new CosXmlResultListener() {@Overridepublic void onSuccess(CosXmlRequest request, CosXmlResult result) {GetBucketInventoryResult getBucketInventoryResult =(GetBucketInventoryResult) result;}// If you use the Kotlin language to call this, please note that the exception in the callback method is nullable; otherwise, the onFail method will not be called back, that is:// clientException is of type CosXmlClientException? and serviceException is of type CosXmlServiceException?@Overridepublic void onFail(CosXmlRequest cosXmlRequest,@Nullable CosXmlClientException clientException,@Nullable CosXmlServiceException serviceException) {if (clientException != null) {clientException.printStackTrace();} else {serviceException.printStackTrace();}}});
// Bucket name in the format of BucketName-APPID (APPID is required), which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucketString bucket = "examplebucket-1250000000";DeleteBucketInventoryRequest deleteBucketInventoryRequest =new DeleteBucketInventoryRequest(bucket);deleteBucketInventoryRequest.setInventoryId("exampleInventoryId");cosXmlService.deleteBucketInventoryAsync(deleteBucketInventoryRequest,new CosXmlResultListener() {@Overridepublic void onSuccess(CosXmlRequest request, CosXmlResult result) {DeleteBucketInventoryResult deleteBucketInventoryResult =(DeleteBucketInventoryResult) result;}// If you use the Kotlin language to call this, please note that the exception in the callback method is nullable; otherwise, the onFail method will not be called back, that is:// clientException is of type CosXmlClientException? and serviceException is of type CosXmlServiceException?@Overridepublic void onFail(CosXmlRequest cosXmlRequest,@Nullable CosXmlClientException clientException,@Nullable CosXmlServiceException serviceException) {}});
Apakah halaman ini membantu?