清单 - inventory

最近更新时间:2025-09-18 15:49:12

我的收藏
inventory 命令用于设置清单、查询清单、删除清单、列出清单以及发起一次性清单。
注意:
如需查询清单,在您进行 授权策略 时,action 需要设置为 cos:GetBucketInventory
如需设置清单,在您进行 授权策略 时,action 需要设置为 cos:PutBucketInventory
如需删除清单,在您进行 授权策略 时,action 需要设置为 cos:DeleteBucketInventory
如需列出清单,在您进行 授权策略 时,action 需要设置为 cos:GetBucketInventory
如需发起一次性清单,在您进行 授权策略 时,action 需要设置为 cos:PostBucketInventory
更多授权请参见 支持 CAM 的业务接口

命令格式

./coscli inventory --method [method] cos://<bucket-name>
inventory 命令包含以下参数:
参数格式
参数用途
示例
cos://<bucket-name>
指定需要访问的存储桶。支持使用 配置参数 中的桶别名,或桶名称进行访问。如使用桶名称访问,需要额外携带 endpoint flag
使用桶别名访问:cos://example-alias
使用桶名称访问:cos://examplebucket-1250000000
inventory 命令包含以下可选 flag:
flag 简写
flag 全称
flag 用途
-h
--help
查看该命令的具体用法
--method
指定需要进行的操作,包括 put(设置存储桶清单)、get(查询存储桶清单)、delete(删除存储桶清单)、list(列出存储桶清单)、post(发起一次性清单)
--task-id
清单任务 ID
--configuration
清单配置(支持 JSON 格式、XML 格式或直接指定文件路径,例如 /data/configuration.txt 需要指定为file:///data/configuration.txt
说明:
关于此命令的其他通用选项(例如切换存储桶、切换用户账号等),请参见 通用选项 文档。

设置存储桶清单

操作示例

设置桶别名为 example-alias 的清单。命令如下(具体格式可参考 设置存储桶清单):
./coscli inventory --method put cos://example-alias --task-id list4 --configuration "<InventoryConfiguration>...</InventoryConfiguration>"

查询存储桶清单

操作示例

查询桶别名为 example-alias 的 list4清单任务。
./coscli inventory --method get cos://example-alias --task-id list4
输出以下结果。
SECTION | KEY | VALUE
------------------+-------------------+------------------------------------------------
Basic | ID | list4
+ +-------------------+-----------------------------------------------+
| Enabled | false
+ +-------------------+-----------------------------------------------+
| Included Versions | All
+-----------------+-------------------+-----------------------------------------------+
| |
+-----------------+-------------------+-----------------------------------------------+
Schedule | Frequency | Weekly
+-----------------+-------------------+-----------------------------------------------+
| |
+-----------------+-------------------+-----------------------------------------------+
Destination | Bucket | qcs::cos:ap-nanjing::test-125000000
+ +-------------------+-----------------------------------------------+
| Format | CSV
+ +-------------------+-----------------------------------------------+
| Account ID | 100000000
+ +-------------------+-----------------------------------------------+
| Prefix | list4
+-----------------+-------------------+-----------------------------------------------+
| |
+-----------------+-------------------+-----------------------------------------------+
Filter | Prefix | myPrefix
+ +-------------------+-----------------------------------------------+
| Tag | age=18
+ +-------------------+-----------------------------------------------+
| Period | 2026-01-18 to 2019-09-17
+-----------------+-------------------+-----------------------------------------------+
| |
+-----------------+-------------------+-----------------------------------------------+
Optional Fields | Field | Size
+ + +-----------------------------------------------+
| | ETag
+ + +-----------------------------------------------+
| | StorageClass
+ + +-----------------------------------------------+
| | IsMultipartUploaded
+ + +-----------------------------------------------+
| | Tag
+ + +-----------------------------------------------+
| | LastModifiedDate
------------------+-------------------+------------------------------------------------
Inventory Configuration Details

删除存储桶清单

操作示例

删除桶别名为 example-alias 的存储桶的 list4清单任务。命令如下:
./coscli inventory --method delete cos://example-alias --task-id list4

列出所有存储桶清单

操作示例

列出桶别名为 example-alias 的所有清单任务。
./coscli inventory --method list cos://example-alias
输出以下结果。
ID | STATUS | SCHEDULE | INCLUDEDOBJECTVERSIONS | DESTINATION | FILTER | FIELDS
--------+----------+-------------------+------------------------+-------------------------------------------------------+----------------------------------+----------------------
list1 | Enabled | Frequency: Daily | All | Bucket: qcs::cos:ap-nanjing::test-125000000 | Period: 2019-09-17 to 2019-09-17 | Size
| | | | Format: CSV | | ETag
| | | | Account: 1000000000 | | StorageClass
| | | | Prefix: list1 | | IsMultipartUploaded
| | | | | | ReplicationStatus
| | | | | | LastModifiedDate
--------+----------+-------------------+------------------------+-------------------------------------------------------+----------------------------------+----------------------
list3 | Disabled | Frequency: Weekly | All | Bucket: qcs::cos:ap-nanjing::test-125000000 | Period: 2026-01-18 to 2019-09-17 | Size
| | | | Format: CSV | | ETag
| | | | Account: 1000000000 | | StorageClass
| | | | Prefix: list3 | | IsMultipartUploaded
| | | | | | ReplicationStatus
| | | | | | LastModifiedDate
--------+----------+-------------------+------------------------+-------------------------------------------------------+----------------------------------+----------------------
list4 | Disabled | Frequency: Weekly | All | Bucket: qcs::cos:ap-nanjing::test-125000000 | Prefix: myPrefix | Size
| | | | Format: CSV | Tags: age=18 | ETag
| | | | Account: 1000000000 | Period: 2026-01-18 to 2019-09-17 | StorageClass
| | | | Prefix: list4 | | IsMultipartUploaded
| | | | | | Tag
| | | | | | LastModifiedDate
--------+----------+-------------------+------------------------+-------------------------------------------------------+----------------------------------+----------------------
Detailed COS Bucket Inventory Configurations

Total inventory configurations: 3


发起一次性清单

操作示例

为桶别名为 example-alias 发起一次性清单任务。命令如下(具体格式可参考 发起一次性清单任务):
./coscli inventory --method post cos://example-alias --task-id list4 --configuration "<InventoryConfiguration>...</InventoryConfiguration>"