|
9 | 9 | import com.qcloud.cos.model.ListBucketInventoryConfigurationsResult;
|
10 | 10 | import com.qcloud.cos.model.SetBucketInventoryConfigurationRequest;
|
11 | 11 | import com.qcloud.cos.model.DeleteBucketInventoryConfigurationRequest;
|
12 |
| -import com.qcloud.cos.model.PostBucketInventoryConfigurationResult; |
| 12 | +import com.qcloud.cos.model.inventory.PostBucketInventoryConfigurationResult; |
13 | 13 | import com.qcloud.cos.model.inventory.InventoryConfiguration;
|
14 | 14 | import com.qcloud.cos.model.inventory.InventoryCosBucketDestination;
|
15 | 15 | import com.qcloud.cos.model.inventory.InventoryFrequency;
|
|
18 | 18 | import com.qcloud.cos.model.inventory.InventoryDestination;
|
19 | 19 | import com.qcloud.cos.model.inventory.InventorySchedule;
|
20 | 20 | import com.qcloud.cos.model.inventory.InventoryPrefixPredicate;
|
| 21 | +import com.qcloud.cos.model.inventory.InventoryAndPredicate; |
21 | 22 | import com.qcloud.cos.model.inventory.InventoryFilter;
|
22 | 23 | import com.qcloud.cos.model.inventory.InventoryIncludedObjectVersions;
|
23 | 24 | import com.qcloud.cos.model.inventory.InventoryOptionalField;
|
| 25 | +import com.qcloud.cos.model.Tag.Tag; |
24 | 26 | import com.qcloud.cos.region.Region;
|
25 | 27 |
|
| 28 | +import java.util.ArrayList; |
26 | 29 | import java.util.LinkedList;
|
27 | 30 | import java.util.List;
|
28 | 31 |
|
@@ -172,16 +175,29 @@ private static void postBucketInventoryDemo() {
|
172 | 175 | inventoryDestination.setCosBucketDestination(inventoryCosBucketDestination);
|
173 | 176 | inventoryConfiguration.setDestination(inventoryDestination);
|
174 | 177 |
|
175 |
| - // 设置清单的调度周期,扫描前缀和id等 |
176 |
| - inventoryConfiguration.setId("4"); |
| 178 | + // 设置清单,扫描前缀和id等 |
| 179 | + inventoryConfiguration.setId("1"); |
| 180 | + // prefix filter |
177 | 181 | InventoryPrefixPredicate inventoryFilter = new InventoryPrefixPredicate("test/");
|
178 | 182 | inventoryConfiguration.setInventoryFilter(new InventoryFilter(inventoryFilter));
|
| 183 | + |
| 184 | + // and Filter |
| 185 | +// InventoryAndPredicate inventoryAndPredicate = new InventoryAndPredicate(); |
| 186 | +// inventoryAndPredicate.setPrefix("bbb"); |
| 187 | +// List<Tag> filterTags = new ArrayList<>(); |
| 188 | +// filterTags.add(new Tag("Testkey1", "value1")); |
| 189 | +// filterTags.add(new Tag("Testkey2", "value2")); |
| 190 | +// inventoryAndPredicate.setTags(filterTags); |
| 191 | +// inventoryConfiguration.setInventoryFilter(new InventoryFilter(inventoryAndPredicate)); |
| 192 | + |
179 | 193 | inventoryConfiguration.setIncludedObjectVersions(InventoryIncludedObjectVersions.All);
|
180 | 194 | // 设置可选的输出字段
|
181 | 195 | List<String> optionalFields = new LinkedList<String>();
|
182 | 196 | optionalFields.add(InventoryOptionalField.Size.toString());
|
183 | 197 | optionalFields.add(InventoryOptionalField.LastModifiedDate.toString());
|
| 198 | + optionalFields.add(InventoryOptionalField.Tag.toString()); |
184 | 199 | inventoryConfiguration.setOptionalFields(optionalFields);
|
| 200 | + |
185 | 201 | SetBucketInventoryConfigurationRequest setBucketInventoryConfigurationRequest = new SetBucketInventoryConfigurationRequest();
|
186 | 202 | setBucketInventoryConfigurationRequest.setBucketName(bucketName);
|
187 | 203 | setBucketInventoryConfigurationRequest.setInventoryConfiguration(inventoryConfiguration);
|
|
0 commit comments