简介
本文档提供关于清单的 API 概览以及 SDK 示例代码。
API | 操作名 | 操作描述 |
设置清单任务 | 设置存储桶的清单任务 | |
查询清单任务 | 查询存储桶的清单任务 | |
删除清单任务 | 删除存储桶的清单任务 |
SDK API 参考
设置清单任务
功能说明
PUT Bucket inventory 用于在存储桶中创建清单任务。
示例代码
try{string inventoryId = "aInventoryId";// 存储桶名称,此处填入格式必须为 bucketname-APPID, 其中 APPID 获取参考 https://console.cloud.tencent.com/developerstring bucket = "examplebucket-1250000000";PutBucketInventoryRequest putRequest = new PutBucketInventoryRequest(bucket, inventoryId);putRequest.SetDestination("CSV", "100000000001", "examplebucket-1250000000", "ap-guangzhou","list1");putRequest.IsEnable(true);// 清单任务周期,枚举值:Daily、WeeklyputRequest.SetScheduleFrequency("Daily");// 是否在清单中包含对象版本,枚举值:All、CurrentputRequest.SetIncludedObjectVersions("All");//执行请求PutBucketInventoryResult putResult = cosXml.PutBucketInventory(putRequest);//请求成功Console.WriteLine(putResult.GetResultInfo());}catch (COSXML.CosException.CosClientException clientEx){//请求失败Console.WriteLine("CosClientException: " + clientEx);}catch (COSXML.CosException.CosServerException serverEx){//请求失败Console.WriteLine("CosServerException: " + serverEx.GetInfo());}
说明
错误码说明
该请求可能会发生的一些常见的特殊错误如下:
错误码 | 描述 | 状态码 |
InvalidArgument | 不合法的参数值 | HTTP 400 Bad Request |
TooManyConfigurations | 清单数量已经达到1000条的上限 | HTTP 400 Bad Request |
AccessDenied | 未授权的访问。您可能不具备访问该存储桶的权限 | HTTP 403 Forbidden |
查询清单任务
功能说明
GET Bucket inventory 用于查询存储桶中用户的清单任务信息。
示例代码
try{string inventoryId = "aInventoryId";// 存储桶名称,此处填入格式必须为 bucketname-APPID, 其中 APPID 获取参考 https://console.cloud.tencent.com/developerstring bucket = "examplebucket-1250000000";GetBucketInventoryRequest getRequest = new GetBucketInventoryRequest(bucket);getRequest.SetInventoryId(inventoryId);GetBucketInventoryResult getResult = cosXml.GetBucketInventory(getRequest);InventoryConfiguration configuration = getResult.inventoryConfiguration;}catch (COSXML.CosException.CosClientException clientEx){//请求失败Console.WriteLine("CosClientException: " + clientEx);}catch (COSXML.CosException.CosServerException serverEx){//请求失败Console.WriteLine("CosServerException: " + serverEx.GetInfo());}
说明
删除清单任务
功能说明
DELETE Bucket inventory 用于删除存储桶中指定的清单任务。
示例代码
try{string inventoryId = "aInventoryId";// 存储桶名称,此处填入格式必须为 bucketname-APPID, 其中 APPID 获取参考 https://console.cloud.tencent.com/developerstring bucket = "examplebucket-1250000000";DeleteBucketInventoryRequest deleteRequest = new DeleteBucketInventoryRequest(bucket);deleteRequest.SetInventoryId(inventoryId);DeleteBucketInventoryResult deleteResult = cosXml.DeleteBucketInventory(deleteRequest);//请求成功Console.WriteLine(deleteResult.GetResultInfo());}catch (COSXML.CosException.CosClientException clientEx){//请求失败Console.WriteLine("CosClientException: " + clientEx);}catch (COSXML.CosException.CosServerException serverEx){//请求失败Console.WriteLine("CosServerException: " + serverEx.GetInfo());}
说明