API | Operation | Description |
Creating an inventory job | Creates an inventory job for a bucket | |
Querying inventory jobs | Queries the inventory jobs of a bucket | |
Deleting an inventory job | Deletes an inventory job from a bucket |
QCloudPutBucketInventoryRequest *putReq = [QCloudPutBucketInventoryRequest new];// Bucket name in the format of BucketName-APPID, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucketputReq.bucket= @"examplebucket-1250000000";// Name of the inventory jobputReq.inventoryID = @"list1";// You can use XML to set specific configuration information for the inventory job in the request body, including the objects to be analyzed by the inventory job,// analysis frequency, analysis dimensions, result format, and storage location.QCloudInventoryConfiguration *config = [QCloudInventoryConfiguration new];// Inventory name, corresponding to the ID in the request parameterconfig.identifier = @"list1";// Specifies whether inventory is enabled:// if it is set to true, inventory is enabled;// if false, no inventories will be generatedconfig.isEnabled = @"True";// Information on the storage of the inventory resultQCloudInventoryDestination *des = [QCloudInventoryDestination new];QCloudInventoryBucketDestination *btDes =[QCloudInventoryBucketDestination new];// File format of the inventory result. Valid value: CSVbtDes.cs = @"CSV";// ID of the bucket ownerbtDes.account = @"1278687956";// Bucket name in the format of BucketName-APPID, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucketbtDes.bucket = @"qcs::cos:ap-guangzhou::examplebucket-1250000000";// Prefix of the inventory resultbtDes.prefix = @"list1";// Encryption with a COS-managed keyQCloudInventoryEncryption *enc = [QCloudInventoryEncryption new];enc.ssecos = @"";// Option to provide server-side encryption for the inventory resultbtDes.encryption = enc;// Information on the bucket where the inventory result is stored after exportdes.bucketDestination = btDes;// Information on the storage of the inventory resultconfig.destination = des;// Configure the frequency of the inventory jobQCloudInventorySchedule *sc = [QCloudInventorySchedule new];// Inventory job frequency. Enumerated values: Daily, Weeklysc.frequency = @"Daily";config.schedule = sc;QCloudInventoryFilter *fileter = [QCloudInventoryFilter new];fileter.prefix = @"myPrefix";config.filter = fileter;config.includedObjectVersions = QCloudCOSIncludedObjectVersionsAll;QCloudInventoryOptionalFields *fields = [QCloudInventoryOptionalFields new];fields.field = @[ @"Size",@"LastModifiedDate",@"ETag",@"StorageClass",@"IsMultipartUploaded",@"ReplicationStatus"];// Set the analysis items that should be included in the inventory resultconfig.optionalFields = fields;putReq.inventoryConfiguration = config;[putReq setFinishBlock:^(id outputObject, NSError *error) {// outputObject contains information such as the ETag or custom headers in the responseNSDictionary * result = (NSDictionary *)outputObject;}];[[QCloudCOSXMLService defaultCOSXML] PutBucketInventory:putReq];
let putReq = QCloudPutBucketInventoryRequest.init();// Bucket name in the format of BucketName-APPID, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucketputReq.bucket = "examplebucket-1250000000";// Name of the inventory jobputReq.inventoryID = "list1";// You can use XML to set specific configuration information for the inventory job in the request body, including the objects to be analyzed by the inventory job,// analysis frequency, analysis dimensions, result format, and storage location.let config = QCloudInventoryConfiguration.init();// Inventory name, corresponding to the ID in the request parameterconfig.identifier = "list1";// Specifies whether inventory is enabled:// if it is set to true, inventory is enabled;// if false, no inventories will be generatedconfig.isEnabled = "True";// Information on the storage of the inventory resultlet des = QCloudInventoryDestination.init();let btDes = QCloudInventoryBucketDestination.init();// File format of the inventory result. Valid value: CSVbtDes.cs = "CSV";// ID of the bucket ownerbtDes.account = "1278687956";// Name of the bucket where the inventory result is storedbtDes.bucket = "qcs::cos:ap-guangzhou::examplebucket-1250000000";// Prefix of the inventory resultbtDes.prefix = "list1";// Encryption with a COS-managed keylet enc = QCloudInventoryEncryption.init();enc.ssecos = "";// Option to provide server-side encryption for the inventory resultbtDes.encryption = enc;// Information on the bucket where the inventory result is stored after exportdes.bucketDestination = btDes;// Information on the storage of the inventory resultconfig.destination = des;// Configure the frequency of the inventory joblet sc = QCloudInventorySchedule.init();// Inventory job frequency. Enumerated values: Daily, Weeklysc.frequency = "Daily";config.schedule = sc;let fileter = QCloudInventoryFilter.init();fileter.prefix = "myPrefix";config.filter = fileter;config.includedObjectVersions = .all;let fields = QCloudInventoryOptionalFields.init();fields.field = [ "Size","LastModifiedDate","ETag","StorageClass","IsMultipartUploaded","ReplicationStatus"];// Set the analysis items that should be included in the inventory resultconfig.optionalFields = fields;putReq.inventoryConfiguration = config;putReq.finishBlock = {(result,error) inif let result = result {// result contains response headers} else{print(error!);}}QCloudCOSXMLService.defaultCOSXML().putBucketInventory(putReq);
Error Code | Description | Status Code |
InvalidArgument | Invalid parameter value | HTTP 400 Bad Request |
TooManyConfigurations | The number of inventories has reached the upper limit of 1,000 | HTTP 400 Bad Request |
AccessDenied | Unauthorized access. You most likely do not have access permission for the bucket | HTTP 403 Forbidden |
QCloudGetBucketInventoryRequest *getReq = [QCloudGetBucketInventoryRequest new];// Bucket name in the format of BucketName-APPID, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucketgetReq.bucket = @"examplebucket-1250000000";// Name of the inventory jobgetReq.inventoryID = @"list1";[getReq setFinishBlock:^(QCloudInventoryConfiguration * _Nonnull result,NSError * _Nonnull error) {// result contains the inventory information}];[[QCloudCOSXMLService defaultCOSXML] GetBucketInventory:getReq];
let req = QCloudGetBucketInventoryRequest.init();// Bucket name in the format of BucketName-APPID, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucketreq.bucket = "examplebucket-1250000000";// Name of the inventory jobreq.inventoryID = "list1";req.setFinish {(result,error) inif let result = result {// Job informationlet enabled = result.isEnabled} else{print(error!);}}QCloudCOSXMLService.defaultCOSXML().getBucketInventory(req);
QCloudDeleteBucketInventoryRequest *delReq = [QCloudDeleteBucketInventoryRequest new];// Bucket name in the format of BucketName-APPID, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucketdelReq.bucket = @"examplebucket-1250000000";// Name of the inventory jobdelReq.inventoryID = @"list1";[delReq setFinishBlock:^(id outputObject, NSError *error) {// outputObject contains information such as the ETag or custom headers in the responseNSDictionary * result = (NSDictionary *)outputObject;}];[[QCloudCOSXMLService defaultCOSXML] DeleteBucketInventory:delReq];
let delReq = QCloudDeleteBucketInventoryRequest.init();// Bucket name in the format of BucketName-APPID, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucketdelReq.bucket = "examplebucket-1250000000";// Name of the inventory jobdelReq.inventoryID = "list1";delReq.finishBlock = {(result,error) inif let result = result {// result contains response headers} else{print(error!);}}QCloudCOSXMLService.defaultCOSXML().deleteBucketInventory(delReq);
Apakah halaman ini membantu?