API | Operation | Description |
Creating an inventory job | Creates an inventory job for a bucket | |
Querying inventory jobs | Queries the inventory jobs of bucket | |
Deleting inventory jobs | Deletes an inventory job from a bucket |
public SetBucketInventoryConfigurationResult setBucketInventoryConfiguration(String bucketName, InventoryConfiguration inventoryConfiguration);public SetBucketInventoryConfigurationResult setBucketInventoryConfiguration(SetBucketInventoryConfigurationRequest setBucketInventoryConfigurationRequest);
// The bucket name must contain appidString bucketName = "examplebucket-1250000000";InventoryConfiguration inventoryConfiguration = new InventoryConfiguration();InventoryCosBucketDestination inventoryCosBucketDestination = new InventoryCosBucketDestination();// Set format and prefix of the destination bucket for inventory outputinventoryCosBucketDestination.setAccountId("2779643970");inventoryCosBucketDestination.setBucketArn("qcs::cos:ap-guangzhou::examplebucket-1250000000");inventoryCosBucketDestination.setEncryption(new ServerSideEncryptionCOS());inventoryCosBucketDestination.setFormat(InventoryFormat.CSV);inventoryCosBucketDestination.setPrefix("inventory-output");InventoryDestination inventoryDestination = new InventoryDestination();inventoryDestination.setCosBucketDestination(inventoryCosBucketDestination);inventoryConfiguration.setDestination(inventoryDestination);// Set inventory scheduling frequency, scan prefix, ID, etc.inventoryConfiguration.setEnabled(true);inventoryConfiguration.setId("1");InventorySchedule inventorySchedule = new InventorySchedule();inventorySchedule.setFrequency(InventoryFrequency.Daily);inventoryConfiguration.setSchedule(inventorySchedule);InventoryPrefixPredicate inventoryFilter = new InventoryPrefixPredicate("test/");inventoryConfiguration.setInventoryFilter(new InventoryFilter(inventoryFilter));inventoryConfiguration.setIncludedObjectVersions(InventoryIncludedObjectVersions.All);// Set optional output fieldsList<String> optionalFields = new LinkedList<String>();optionalFields.add(InventoryOptionalField.Size.toString());optionalFields.add(InventoryOptionalField.LastModifiedDate.toString());inventoryConfiguration.setOptionalFields(optionalFields);SetBucketInventoryConfigurationRequest setBucketInventoryConfigurationRequest = new SetBucketInventoryConfigurationRequest();setBucketInventoryConfigurationRequest.setBucketName(bucketName);setBucketInventoryConfigurationRequest.setInventoryConfiguration(inventoryConfiguration);cosClient.setBucketInventoryConfiguration(setBucketInventoryConfigurationRequest);inventoryConfiguration.setId("2");inventorySchedule.setFrequency(InventoryFrequency.Weekly);cosClient.setBucketInventoryConfiguration(setBucketInventoryConfigurationRequest);
Parameter | Description | Type |
setBucketInventoryConfigurationRequest | Request to set static website for bucket | SetBucketInventoryConfigurationRequest |
Request Member | Setting Method | Description | Type |
bucketName | Constructor or set method | Bucket for which to set an inventory job in the format of BucketName-APPID . For more information, please see Naming Conventions | String |
inventoryConfiguration | Constructor or set method | Inventory configuration of bucket | InventoryConfiguration |
InventoryConfiguration
member description:Parameter | Description | Type |
id | Inventory job name. Valid characters: a-z, A-Z, 0-9, -, _, . | String |
destination | Information of the bucket to store the inventory result after export | InventoryDestination |
isEnabled | Inventory status flag | Boolean |
inventoryFilter | Filters the objects to be analyzed. The inventory feature will analyze the objects that match the prefix set in Filter | InventoryFilter |
includedObjectVersions | Whether to include object versions in the inventory If this is set to All , the inventory will include all object versions and add VersionId , IsLatest , and DeleteMarker fields If Current , no object version information will be included in the inventory | String |
optionalFields | Name of fields that can be optionally included in the inventory result | List |
schedule | Configures inventory job frequency | InventorySchedule |
InventoryDestination
member description:Parameter | Description | Type |
cosBucketDestination | Information of the bucket to store the inventory result after export | InventoryCosBucketDestination |
InventoryCosBucketDestination
member description:Parameter | Description | Type |
accountId | Bucket owner ID | String |
bucketArn | Name of the bucket where the inventory result is stored | String |
format | File format of the inventory result. Valid values: CSV | String |
prefix | Prefix of the inventory result | String |
encryption | Option to provide server-side encryption for the inventory result | InventoryEncryption |
InventoryFilter
member description:Parameter | Description | Type |
predicate | Filters the objects to be analyzed | InventoryFilterPredicate |
InventoryFilter
is InventoryPrefixPredicate
with the following members:Parameter | Description | Type |
prefix | Prefix of the objects to be analyzed | String |
InventorySchedule
member description:Parameter | Description | Type |
frequency | Inventory job frequency. Enumerated values: Daily, Weekly | String |
CosClientException
or CosServiceException
exception thrown. For more information, please see Troubleshooting.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 |
public GetBucketInventoryConfigurationResult getBucketInventoryConfiguration(String bucketName, String id) throws CosClientException, CosServiceException;
String bucketName = "examplebucket-1250000000";String id = "1";GetBucketInventoryConfigurationResult getBucketInventoryConfigurationResult = cosClient.getBucketInventoryConfiguration(bucketName, id);
Parameter | Description | Type |
bucketName | Bucket for which to query an inventory job in the format of BucketName-APPID . For more information, please see Naming Convention | String |
id | Inventory job name. Valid characters: a-z, A-Z, 0-9, -, _, . | String |
GetBucketInventoryConfigurationResult
is returned, which contains the configuration information of the inventory corresponding to the specified ID for the bucket.CosClientException
or CosServiceException
exception thrown. For more information, please see Troubleshooting.public ListBucketInventoryConfigurationsResult listBucketInventoryConfigurations(ListBucketInventoryConfigurationsRequest listBucketInventoryConfigurationsRequest) throws CosClientException, CosServiceException;
String bucketName = "examplebucket-1250000000";ListBucketInventoryConfigurationsRequest listBucketInventoryConfigurationsRequest = new ListBucketInventoryConfigurationsRequest();listBucketInventoryConfigurationsRequest.setBucketName(bucketName);ListBucketInventoryConfigurationsResult listBucketInventoryConfigurationsResult = cosClient.listBucketInventoryConfigurations(listBucketInventoryConfigurationsRequest);
Parameter | Description | Type |
bucketName | Destination bucket to store the inventory result in the format of BucketName-APPID . For more information, please see Naming Convention | String |
continuationToken | If IsTruncated in the COS response body is true and there is a parameter value in the NextContinuationToken node, you can use this parameter as the parameter value of continuation-token to get the inventory job information of the next page | String |
ListBucketInventoryConfigurationsResult
is returned, which contains the configuration information of the inventory corresponding to the specified ID for the bucket.CosClientException
or CosServiceException
exception thrown. For more information, please see Troubleshooting.public DeleteBucketInventoryConfigurationResult deleteBucketInventoryConfiguration(String bucketName, String id) throws CosClientException, CosServiceException;
String bucketName = "examplebucket-1250000000";String id = "1";cosClient.deleteBucketInventoryConfiguration(bucketName, id);
Parameter | Description | Type |
bucketName | Bucket for which to delete an inventory job in the format of BucketName-APPID . For more information, please see Naming Convention | String |
id | Inventory job name. Valid characters: a-z, A-Z, 0-9, -, _, . | String |
CosClientException
or CosServiceException
exception thrown. For more information, please see Troubleshooting.
Apakah halaman ini membantu?