文档捉虫大赛:人工智能与机器学习专题> HOT

简介

本文档提供关于清单的 API 概览以及 SDK 示例代码。
API
操作名
操作描述
设置清单任务
设置存储桶的清单任务
查询清单任务
查询存储桶的清单任务
删除清单任务
删除存储桶的清单任务

SDK API 参考

SDK 所有接口的具体参数与方法说明,请参考 SDK API

设置清单任务

功能说明

PUT Bucket inventory 用于在存储桶中创建清单任务。

示例代码

try
{
string inventoryId = "aInventoryId";
// 存储桶名称,此处填入格式必须为 bucketname-APPID, 其中 APPID 获取参考 https://console.cloud.tencent.com/developer
string bucket = "examplebucket-1250000000";
PutBucketInventoryRequest putRequest = new PutBucketInventoryRequest(bucket, inventoryId);
putRequest.SetDestination("CSV", "100000000001", "examplebucket-1250000000", "ap-guangzhou","list1");
putRequest.IsEnable(true);
// 清单任务周期,枚举值:Daily、Weekly
putRequest.SetScheduleFrequency("Daily");
// 是否在清单中包含对象版本,枚举值:All、Current
putRequest.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());
}
说明
更多完整示例,请前往 GitHub 查看。

错误码说明

该请求可能会发生的一些常见的特殊错误如下:
错误码
描述
状态码
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/developer
string 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());
}
说明
更多完整示例,请前往 GitHub 查看。

删除清单任务

功能说明

DELETE Bucket inventory 用于删除存储桶中指定的清单任务。

示例代码

try
{
string inventoryId = "aInventoryId";
// 存储桶名称,此处填入格式必须为 bucketname-APPID, 其中 APPID 获取参考 https://console.cloud.tencent.com/developer
string 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());
}
说明
更多完整示例,请前往 GitHub 查看。