Updated on 2026-07-27 GMT+08:00

Configuring Bucket Inventories

Function

The bucket inventory function periodically generates a list of object metadata information for a bucket, helping you better understand object statuses in the bucket. You can call this API to configure bucket inventories. For more information and constraints about bucket inventories, see Bucket Inventories.

Constraints

Table 1 Constraints on bucket inventories

Item

Description

Bucket version

Inventories can be generated only for OBS 3.0 buckets, but the bucket that stores the inventory files can be any OBS version.

Maximum number of bucket inventories

A bucket can have a maximum of 10 inventories.

Source and destination buckets

  • The source bucket (for which a bucket inventory rule is configured) and the destination bucket (where the generated inventory files are stored) must belong to the same account.
  • The source and destination buckets must be in the same region.
  • The destination bucket cannot have server-side encryption enabled.

Functions

  • Inventory files must be in the CSV format.
  • Inventories can apply to all objects in a bucket or to a set of objects with the same name prefix.
  • The filter criteria of multiple inventory rules within the same bucket must not overlap.
    • If there is already an inventory rule for all objects in the bucket, any other inventory rule with an object name prefix specified cannot be created. To create a rule for only a set of objects, delete the inventory rule that applies to all objects first.
    • If there is already an inventory rule for a set of objects, a rule for all objects in the bucket cannot be created. To create a rule for all objects, delete all inventory rules that use a prefix filter.
    • Assume there is an inventory rule that uses the ab prefix as a filter. Any new inventory rule whose prefix overlaps with ab, such as a or abc, cannot be created. To create a rule with prefix a or abc, delete the overlapping rule first.
  • Only SSE-KMS can be used to encrypt bucket inventories.

Permissions

OBS must be authorized to upload inventory files to the destination bucket. The destination bucket needs a policy that grants OBS write permissions, with the Principal set to {"Service": "obs"}.

Others

  • The bucket inventory feature is not available to federated users.

Authorization

To call this API, you must be the bucket owner or have the permission to configure inventories for a bucket. You are advised to use IAM or bucket policies for authorization. For details about OBS authorization methods, see Differences Between OBS Permissions Control Methods.

  • If you use IAM for authorization, you need to use either role/policy-based authorization or identity policy-based authorization and configure the required permissions:
    • If you use role/policy-based authorization (IAM v3 APIs in the old IAM version), you must have the obs:bucket:PutBucketInventoryConfiguration permission. For details, see Creating a Custom IAM Policy.
    • If you use identity policy-based authorization (IAM v5 APIs in the new IAM version), you must have the obs:bucket:putBucketInventoryConfiguration permission, as shown in the following table. For details, see Creating a Custom IAM Identity Policy.

      Action

      Access Level

      Resource Type (*: Required)

      Condition Key

      Alias

      Dependencies

      obs:bucket:putBucketInventoryConfiguration

      Write

      bucket *

      -

      -

      -

      • obs:EpochTime
      • obs:SourceIp
      • obs:TlsVersion
      • obs:CustomDomain
  • If you use bucket policies for authorization, you must have the obs:bucket:PutBucketInventoryConfiguration permission. For details, see Creating a Custom Bucket Policy.

URI

PUT /

Calling Method

For details, see Calling APIs. Before calling this API, calculate the API signature and add it to the request.

You can debug this API in API Explorer.

Request Syntax

The following is an example request. Replace BucketName with your bucket name and RegionID with the ID of the region where your bucket resides. You can obtain the region ID by referring to Supported Regions.

PUT /?inventory&id=configuration-id  HTTP/1.1
User-Agent: curl/7.29.0
Host: BucketName.obs.RegionID.myhuaweicloud.com 
Accept: */*
Date: GMT Date
Authorization: SignatureValue
Content-Length: BodyLength
Expect: 100-continue

<InventoryConfiguration>
   <Id>configuration-id</Id>
   <IsEnabled>true</IsEnabled>
   <Filter>
         <Prefix>inventoryTestPrefix</Prefix>
   </Filter>
   <Destination>
         <Format>CSV</Format>
         <Bucket>destbucket</Bucket>
         <Prefix>dest-prefix</Prefix>
   </Destination>
   <Schedule>
          <Frequency>Daily</Frequency>
   </Schedule>
   <IncludedObjectVersions>All</IncludedObjectVersions>
   <OptionalFields>
          <Field>Size</Field>
          <Field>LastModifiedDate</Field>
          <Field>ETag</Field>
          <Field>StorageClass</Field>
          <Field>IsMultipartUploaded</Field>
          <Field>ReplicationStatus</Field>
          <Field>EncryptionStatus</Field>
   </OptionalFields>
</InventoryConfiguration>

URI Parameters

Table 2 URI parameters

Parameter

Type

Mandatory

Description

inventory

String

Yes

Definition

An identifier that marks this API as related to bucket inventory.

Constraints

When calculating the signature, add /BucketName/?inventory to CanonicalizedResource. For details, see Using an Authorization Header.

Range

inventory

Default Value

N/A

id

String

Yes

Definition

ID of the inventory configuration, which must be consistent with the inventory configuration ID in the message body.

Constraints

N/A

Range

The value can contain a maximum of 64 bytes, including letters (a–z and A–Z), digits (0–9), hyphens (-), underscores (_), and periods (.).

Default Value

N/A

Request Headers

This request uses common headers. For details, see Table 3.

Request Body

In this request, you must include the bucket inventory configuration in the request body. The inventory configuration is uploaded in an XML file. Table 3 lists the configuration elements.

Table 3 Request body parameters for configuring a bucket inventory

Element

Mandatory

Type

Description

InventoryConfiguration

Yes

Container

Definition

Inventory configuration. InventoryConfiguration is the parent node of Id, IsEnabled, Filter, Destination, Schedule, IncludedObjectVersions, and OptionalFields.

Constraints

N/A

Range

N/A

Default Value

N/A

Id

Yes

String

Definition

ID of an inventory configuration, which must be consistent with the inventory configuration ID specified in the request.

Parent: InventoryConfiguration

Constraints

N/A

Range

The value can contain a maximum of 64 bytes, including letters (a–z and A–Z), digits (0–9), hyphens (-), underscores (_), and periods (.).

Default Value

N/A

IsEnabled

Yes

Boolean

Definition

Whether the inventory rule is enabled. If this parameter is set to true, inventory files will be generated. If not, inventory files will not be generated.

Parent: InventoryConfiguration

Constraints

N/A

Range

true: Inventory files will be generated.

false: Inventory files will not be generated.

Default Value

N/A

Filter

No

Container

Definition

Inventory filter configuration. If configured, inventory files contain only objects that meet the filter criteria (filtering by object name prefix). If no filter criteria are configured, all objects are included.

Parent: InventoryConfiguration

Constraints

N/A

Range

N/A

Default Value

N/A

Prefix

No

String

Definition

Filtering by name prefix. Only objects with the specified name prefix are included in inventory files.

Parent: Filter

Constraints

N/A

Range

The value can contain a maximum of 1,024 characters.

Default Value

N/A

Schedule

Yes

Container

Definition

Time scheduled for generation of inventory files.

Parent: InventoryConfiguration

Constraints

N/A

Range

N/A

Default Value

N/A

Frequency

Yes

String

Definition

Intervals when inventory files are generated. You can set this parameter to Daily or Weekly. An inventory file is generated within one hour after bucket inventory is configured for the first time. Then, inventory files are generated at the specified intervals.

Parent: Schedule

Constraints

N/A

Range

Daily: Inventory files are generated once a day.

Weekly: Inventory files are generated once a week.

Default Value

N/A

Destination

Yes

Container

Definition

Destination configuration of an inventory.

Parent: InventoryConfiguration

Constraints

N/A

Range

N/A

Default Value

N/A

Format

Yes

String

Definition

Inventory file format. Only the CSV format is supported.

Parent: Destination

Constraints

N/A

Range

The value can only be CSV.

Default Value

N/A

Bucket

Yes

String

Definition

Name of the bucket for storing inventory files.

Parent: Destination

Constraints

N/A

Range

N/A

Default Value

N/A

Prefix

No

String

Definition

Name prefix for inventory files. If no prefix is configured, the inventory file names will start with the BucketInventory prefix by default.

Parent: Destination

Constraints

N/A

Range

The value can contain a maximum of 254 characters and cannot contain the following special characters: \*?"<>|

Default Value

N/A

IncludedObjectVersions

Yes

String

Definition

Whether the inventory files contain object versioning information.

Parent: InventoryConfiguration

Constraints

N/A

Range

  • All: Versioning related fields including VersionId, IsLatest, and DeleteMarker will appear in inventory files, and information about all object versions will be included.
  • Current: Versioning related fields including VersionId, IsLatest, and DeleteMarker will not appear in inventory files, and only information about the current object version will be included.

Default Value

N/A

OptionalFields

No

Container

Definition

Additional object metadata fields that can be included in inventory files.

Parent: InventoryConfiguration

Constraints

This parameter is used together with Field.

Range

N/A

Default Value

N/A

Field

No

String

Definition

An optional field. An OptionalFields can contain multiple field elements. You can add additional object metadata fields.

Parent: OptionalFields

Constraints

N/A

Range

Size: object size.

LastModifiedDate: time when the object was created.

ETag: object ETag.

StorageClass: object storage class.

IsMultipartUploaded: whether it is a multipart upload object. The value can be true or false.

ReplicationStatus: replication status of a CRR object.

EncryptionStatus: server-side encryption method.

BucketKeyStatus: key status, which can be ENABLED or DISABLED.

UserMeta: user-defined metadata.

CRC64: CRC64 check on the data content.

ObjectType: object type.

Default Value

N/A

Response Syntax

1
2
3
4
5
HTTP/1.1 status_code
x-obs-request-id: request id
x-obs-id-2: id
Date: date
Content-Length: length

Response Headers

This response uses common headers. For details, see Table 1.

Response Body

This response does not contain a response body.

Error Responses

In addition to common error codes, this API also returns some special error codes. Table 4 lists the special error codes and their possible causes.

Table 4 Special errors for configuring a bucket inventory

Error Code

Description

HTTP Status Code

MalformedXML

Incorrect XML format of the inventory.

400 Bad Request

InvalidArgument

Invalid parameter.

400 Bad Request

InventoryCountOverLimit

The number of inventories reached the upper limit.

400 Bad Request

PrefixExistInclusionRelationship

The prefix configured for this inventory overlaps with prefixes of existing inventories.

400 Bad Request

Sample Request

PUT /?inventory&id=test_id HTTP/1.1
User-Agent: curl/7.29.0
Host: examplebucket.obs.region.myhuaweicloud.com
Accept: */*
Date: Tue, 08 Jan 2019 08:17:10 +0000
Authorization: OBS UDSIAMSTUBTEST000001:/e2fqSfzLDb+0M36D4Op/s5KKr0=
Content-Length: 600
Expect: 100-continue

<InventoryConfiguration>
   <Id>test_id</Id>
   <IsEnabled>true</IsEnabled>
   <Filter>
         <Prefix>inventoryTestPrefix</Prefix>
   </Filter>
   <Destination>
         <Format>CSV</Format>
         <Bucket>destbucket</Bucket>
         <Prefix>dest-prefix</Prefix>
   </Destination>
   <Schedule>
          <Frequency>Daily</Frequency>
   </Schedule>
   <IncludedObjectVersions>All</IncludedObjectVersions>
   <OptionalFields>
          <Field>Size</Field>
          <Field>LastModifiedDate</Field>
          <Field>ETag</Field>
          <Field>StorageClass</Field>
          <Field>IsMultipartUploaded</Field>
          <Field>ReplicationStatus</Field>
          <Field>EncryptionStatus</Field>
   </OptionalFields>
</InventoryConfiguration>

Sample Response

1
2
3
4
5
6
HTTP/1.1 200 OK
Server: OBS
x-obs-request-id: 000001682C8545B0680893425D60AB83
x-obs-id-2: 32AAAQAAEAABAAAQAAEAABAAAQAAEAABCSIGTuRtBfo7lpHSt0ZknhdDHmllwd/p
Date: Tue, 08 Jan 2019 08:12:38 GMT
Content-Length: 0

Using SDKs to Call APIs

You are advised to use OBS SDKs to call APIs. SDKs encapsulate APIs to simplify development. You can call SDK API functions to access OBS without manually calculating signatures.

Java

Python: not supported

C: not supported

Go: not supported

BrowserJS: not supported

.NET: not supported

Android: not supported

iOS: not supported

PHP: not supported

Node.js: not supported

Helpful Links

  • For more information about configuring bucket inventories, see Bucket Inventories.
  • For details about the billing items involved in API operations, see Billing Items.