put-bucket-inventory介面用於為指定儲存空間(Bucket)配置清單(Inventory)規則。
注意事項
命令格式
ossutil api put-bucket-inventory --bucket value --inventory-id value --inventory-configuration value [flags]參數 | 類型 | 說明 |
--bucket | string | Bucket的名稱。 |
--inventory-configuration | string | 儲存清單配置資訊。 |
--inventory-id | string | 清單任務Id。 |
說明
put-bucket-inventory命令對應API介面PutBucketInventory。關於API中的具體參數含義,請參見PutBucketInventory。
--inventory-configuration
--inventory-configuration 配置選項既支援XML文法也支援JSON文法,當選項值包含file://首碼時,表示從檔案中讀取配置。
XML文法:
<InventoryConfiguration> <Id>string</Id> <IsEnabled>boolean</IsEnabled> <Destination> <OSSBucketDestination> <Bucket>string</Bucket> <Prefix>string</Prefix> <Encryption> <SSE-OSS> </SSE-OSS> <SSE-KMS> <KeyId>string</KeyId> </SSE-KMS> </Encryption> <Format>string</Format> <AccountId>string</AccountId> <RoleArn>string</RoleArn> </OSSBucketDestination> </Destination> <Schedule> <Frequency>string</Frequency> </Schedule> <Filter> <Prefix>string</Prefix> </Filter> <IncludedObjectVersions>string</IncludedObjectVersions> <OptionalFields> <Field>string</Field> ... </OptionalFields> <IncrementalInventory> <IsEnabled>boolean</IsEnabled> <Schedule> <Frequency>integer</Frequency> </Schedule> <OptionalFields> <Field>string</Field> ... </OptionalFields> </IncrementalInventory> </InventoryConfiguration>JSON文法:
[ { "Id": "string", "IsEnabled": boolean, "Destination": { "OSSBucketDestination": { "Format": "string", "AccountId": "string", "RoleArn": "string", "Bucket": "string", "Prefix": "string", "Encryption": { "SSE-OSS": { }, "SSE-KMS": { "KeyId": "string" } } } }, "Schedule": { "Frequency": "string" }, "Filter": { "Prefix": "string" }, "IncludedObjectVersions": "string", "OptionalFields": { "Field": [ "string", ... ] }, "IncrementalInventory": { "IsEnabled": "boolean", "Schedule": { "Frequency": "integer" }, "OptionalFields": { "Field": [ "string", ... ] } } ]
說明
關於支援的全域命令列選項,請參見支援的全域命令列選項。
使用樣本
配置清單規則
以下樣本展示了如何為名為examplebucket的儲存空間設定清單名稱為report1的清單規則。
使用XML設定檔,inventory-configuration.xml內容如下:
<?xml version="1.0" encoding="UTF-8"?> <InventoryConfiguration> <Id>report1</Id> <IsEnabled>true</IsEnabled> <Filter> <Prefix>Pics/</Prefix> <LastModifyBeginTimeStamp>1637883649</LastModifyBeginTimeStamp> <LastModifyEndTimeStamp>1638347592</LastModifyEndTimeStamp> <LowerSizeBound>1024</LowerSizeBound> <UpperSizeBound>1048576</UpperSizeBound> <StorageClass>Standard,IA</StorageClass> </Filter> <Destination> <OSSBucketDestination> <Format>CSV</Format> <AccountId>100000000000000</AccountId> <RoleArn>acs:ram::100000000000000:role/AliyunOSSRole</RoleArn> <Bucket>acs:oss:::destbucket</Bucket> <Prefix>prefix1/</Prefix> <Encryption> <SSE-KMS> <KeyId>keyId</KeyId> </SSE-KMS> </Encryption> </OSSBucketDestination> </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>EncryptionStatus</Field> </OptionalFields> </InventoryConfiguration>命令樣本如下:
ossutil api put-bucket-inventory --bucket examplebucket --inventory-id report1 --inventory-configuration file://inventory-configuration.xml使用JSON設定檔,inventory-configuration.json 內容如下:
{ "Id": "report1", "IsEnabled": "true", "Filter": { "Prefix": "Pics/", "LastModifyBeginTimeStamp": "1637883649", "LastModifyEndTimeStamp": "1638347592", "LowerSizeBound": "1024", "UpperSizeBound": "1048576", "StorageClass": "Standard,IA" }, "Destination": { "OSSBucketDestination": { "Format": "CSV", "AccountId": "100000000000000", "RoleArn": "acs:ram::100000000000000:role/AliyunOSSRole", "Bucket": "acs:oss:::destbucket", "Prefix": "prefix1/", "Encryption": { "SSE-KMS": { "KeyId": "keyId" } } } }, "Schedule": { "Frequency": "Daily" }, "IncludedObjectVersions": "All", "OptionalFields": { "Field": [ "Size", "LastModifiedDate", "ETag", "StorageClass", "IsMultipartUploaded", "EncryptionStatus" ] } }命令樣本如下:
ossutil api put-bucket-inventory --bucket examplebucket --inventory-id report1 --inventory-configuration file://inventory-configuration.json使用JSON配置參數,命令樣本如下:
ossutil api put-bucket-inventory --bucket examplebucket --inventory-id report1 --inventory-configuration "{\"Id\":\"report1\",\"IsEnabled\":\"true\",\"Filter\":{\"Prefix\":\"Pics/\",\"LastModifyBeginTimeStamp\":\"1637883649\",\"LastModifyEndTimeStamp\":\"1638347592\",\"LowerSizeBound\":\"1024\",\"UpperSizeBound\":\"1048576\",\"StorageClass\":\"Standard,IA\"},\"Destination\":{\"OSSBucketDestination\":{\"Format\":\"CSV\",\"AccountId\":\"100000000000000\",\"RoleArn\":\"acs:ram::100000000000000:role/AliyunOSSRole\",\"Bucket\":\"acs:oss:::destbucket\",\"Prefix\":\"prefix1/\",\"Encryption\":{\"SSE-KMS\":{\"KeyId\":\"keyId\"}}}},\"Schedule\":{\"Frequency\":\"Daily\"},\"IncludedObjectVersions\":\"All\",\"OptionalFields\":{\"Field\":[\"Size\",\"LastModifiedDate\",\"ETag\",\"StorageClass\",\"IsMultipartUploaded\",\"EncryptionStatus\"]}}"
配置增量清單規則
以下樣本展示了如何為名為examplebucket的儲存空間設定清單名稱為report1的清單規則。
使用XML設定檔,inventory-configuration.xml內容如下:
<?xml version="1.0" encoding="UTF-8"?> <InventoryConfiguration> <Id>Report-1</Id> <IsEnabled>true</IsEnabled> <Filter> <Prefix>test</Prefix> </Filter> <Destination> <OSSBucketDestination> <Format>CSV</Format> <AccountId>12xxxxxx29</AccountId> <RoleArn>acs:ram::12xxxxxx29:role/bucket-inventory-role</RoleArn> <Bucket>acs:oss:::test-inc-bi-bj</Bucket> <Prefix>Report-1</Prefix> </OSSBucketDestination> </Destination> <Schedule> <Frequency>Weekly</Frequency> </Schedule> <IncludedObjectVersions>All</IncludedObjectVersions> <OptionalFields> <Field>Size</Field> <Field>LastModifiedDate</Field> <Field>ETag</Field> <Field>StorageClass</Field> </OptionalFields> <IncrementalInventory> <IsEnabled>true</IsEnabled> <Schedule> <Frequency>600</Frequency> </Schedule> <OptionalFields> <Field>SequenceNumber</Field> <Field>RecordType</Field> <Field>RecordTimestamp</Field> <Field>Requester</Field> <Field>RequestId</Field> <Field>SourceIp</Field> <Field>Size</Field> <Field>StorageClass</Field> <Field>LastModifiedDate</Field> <Field>ETag</Field> <Field>IsMultipartUploaded</Field> <Field>ObjectType</Field> <Field>ObjectAcl</Field> <Field>Crc64</Field> <Field>EncryptionStatus</Field> </OptionalFields> </IncrementalInventory> </InventoryConfiguration>命令樣本如下:
ossutil api put-bucket-inventory --bucket examplebucket --inventory-id report1 --inventory-configuration file://inventory-configuration.xml