This topic describes how to create an inventory for a bucket and how to query, list, and delete the inventories configured for a bucket.
Notes
The sample code in this topic uses the region ID
cn-hangzhou
of the China (Hangzhou) region. By default, the public endpoint is used to access resources in a bucket. If you want to access resources in the bucket by using other Alibaba Cloud services in the same region in which the bucket is located, use an internal endpoint. For more information about the regions and endpoints supported by Object Storage Service (OSS), see OSS regions and endpoints.In this topic, access credentials are obtained from environment variables. For more information about how to configure access credentials, see Configure access credentials.
Make sure that you have the permissions to create, view, list, and delete inventories for a bucket. By default, the bucket owner has the permissions to perform the preceding operations. If you do not have the required permissions, contact the bucket owner to grant you the permissions.
You can configure up to 1,000 inventories for a bucket.
The source bucket for which you want to configure an inventory must be in the same region as the destination bucket in which you want to store inventory lists.
Sample code
References
For more information about the API operation that you can call to create an inventory for a bucket, see PutBucketInventory.
For more information about the API operation that you can call to query the inventory configurations of a bucket, see GetBucketInventory.
For more information about the API operation that you can call to list inventories configured for a bucket, see ListBucketInventory.
For more information about the API operation that you can call to delete the inventories configured for a bucket, see DeleteBucketInventory.