Inventory

Last updated: 2020-03-20 10:35:55

PDF

Note

This document provides an overview of inventory's API and SDK sample code.

API Operation name pedagogical operation
PUT Bucket inventory Set up inventory job Inventory and job who set up Bucket
GET Bucket inventory Inquire about inventory job Inquire about inventory and job of Bucket
DELETE Bucket inventory Delete inventory job Delete inventory and job of Bucket

Set up inventory job

Function description

PUT Bucket inventory is used to create inventory and job in Bucket.

Method prototype

PutBucketInventoryResult putBucketInventory(PutBucketInventoryRequest request);

void putBucketInventoryAsync(PutBucketInventoryRequest request, COSXML.Callback.OnSuccessCallback<CosResult> successCallback, COSXML.Callback.OnFailedCallback failCallback);

Request Sample

CosXmlConfig config = new CosXmlConfig.Builder()
  .SetConnectionTimeoutMs(60000)  
  .SetReadWriteTimeoutMs(40000)  
  .IsHttps(true)  
  .SetAppid("1250000000") 
  .SetRegion("ap-guangzhou") 
  .Build();

string secretId = "COS_SECRETID";   
string secretKey = "COS_SECRETKEY"; 
long durationSecond = 600;          
QCloudCredentialProvider qCloudCredentialProvider = new DefaultQCloudCredentialProvider(secretId, 
  secretKey, durationSecond);

CosXml cosXml = new CosXmlServer(config, qCloudCredentialProvider);

try
{
  string inventoryId = "aInventoryId";
  string bucket = "examplebucket-1250000000"; 
  PutBucketInventoryRequest putRequest = new PutBucketInventoryRequest(bucket);
  putRequest.SetInventoryId(inventoryId);
  putRequest.SetDestination("CSV", "100000000001", "examplebucket-1250000000", "ap-guangzhou","list1");
  putRequest.IsEnable(true);
  putRequest.SetScheduleFrequency("Daily");
  PutBucketInventoryResult putResult = cosXml.putBucketInventory(putRequest); 

  Console.WriteLine(result.GetResultInfo());
}
catch (COSXML.CosException.CosClientException clientEx)
{
  Console.WriteLine("CosClientException: " + clientEx);
}
catch (COSXML.CosException.CosServerException serverEx)
{
  Console.WriteLine("CosServerException: " + serverEx.GetInfo());
}

Parameter description

Parameter name Description Type
Bucket Set the format of Bucket of inventory and job to BucketName-APPID. For more information, please see Naming convention String

For other inventory configuration parameters, please refer to API Documentation.

Return result description

Member variable Description Type
HttpCode HTTP Code, The operation is successful within the range[200, 300) , otherwise it failed Int

Error code description

Some common special errors that may occur in this request are as follows:

Error Codes Description Status Code
InvalidArgument Invalid's parameter value HTTP 400 Bad Request
TooManyConfigurations The number of inventory has reached the upper limit of 1000. HTTP 400 Bad Request
AccessDenied Unauthorized Access. You may not have Permission of Access and Bucket. HTTP 403 Forbidden

Inquire about inventory job

Function description

GET Bucket inventory is used to query inventory and job information of users in Bucket.

Method prototype

GetBucketInventoryResult getBucketInventory(GetBucketInventoryRequest request);

void getBucketInventoryAsync(GetBucketInventoryRequest request, COSXML.Callback.OnSuccessCallback<CosResult> successCallback, COSXML.Callback.OnFailedCallback failCallback);

Request Sample

CosXmlConfig config = new CosXmlConfig.Builder()
  .SetConnectionTimeoutMs(60000)  
  .SetReadWriteTimeoutMs(40000)  
  .IsHttps(true)  
  .SetAppid("1250000000") 
  .SetRegion("ap-guangzhou") 
  .Build();

string secretId = "COS_SECRETID";   
string secretKey = "COS_SECRETKEY"; 
long durationSecond = 600;          
QCloudCredentialProvider qCloudCredentialProvider = new DefaultQCloudCredentialProvider(secretId, 
  secretKey, durationSecond);

CosXml cosXml = new CosXmlServer(config, qCloudCredentialProvider);

try
{
  string inventoryId = "aInventoryId";
  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());
}

Parameter description

Parameter name Description Type
Bucket Query inventory job's Bucket in BucketName-APPID format. For more information, please see Naming convention Bucket
InventoryId The name of inventory job, Valid character: a muri zmena Alyzjimi 0muri 9mai, _ ,. String

Return result description

Member variable Description Type
HttpCode HTTP Code, The operation is successful within the range[200, 300) , otherwise it failed Int
InventoryConfiguration Inventory configuration InventoryConfiguration

Delete inventory job

Function description

DELETE Bucket inventory is used to delete inventory and job specified in Bucket.

Method prototype

DeleteBucketInventoryResult deleteBucketInventory(DeleteBucketInventoryRequest request);

void deleteInventoryAsync(DeleteBucketInventoryRequest request, COSXML.Callback.OnSuccessCallback<CosResult> successCallback, COSXML.Callback.OnFailedCallback failCallback);

Request Sample

CosXmlConfig config = new CosXmlConfig.Builder()
  .SetConnectionTimeoutMs(60000)  
  .SetReadWriteTimeoutMs(40000)  
  .IsHttps(true)  
  .SetAppid("1250000000") 
  .SetRegion("ap-guangzhou") 
  .Build();

string secretId = "COS_SECRETID";   
string secretKey = "COS_SECRETKEY"; 
long durationSecond = 600;          
QCloudCredentialProvider qCloudCredentialProvider = new DefaultQCloudCredentialProvider(secretId, 
  secretKey, durationSecond);

CosXml cosXml = new CosXmlServer(config, qCloudCredentialProvider);

try
{
  string inventoryId = "aInventoryId";
  string bucket = "examplebucket-1250000000"; 
  DeleteBucketInventoryRequest deleteRequest = new DeleteBucketInventoryRequest(bucket);
  deleteRequest.SetInventoryId(inventoryId);
  DeleteBucketInventoryResult deleteResult = cosXml.deleteBucketInventory(deleteRequest);

  Console.WriteLine(result.GetResultInfo());
}
catch (COSXML.CosException.CosClientException clientEx)
{
  Console.WriteLine("CosClientException: " + clientEx);
}
catch (COSXML.CosException.CosServerException serverEx)
{
  Console.WriteLine("CosServerException: " + serverEx.GetInfo());
}

Parameter description

Parameter name Description Type
Bucket Bucket of inventory job is deleted in BucketName-APPID format. For more information, please see Naming convention String
InventoryId The name of inventory job, Valid character: a muri zmena Alyzjimi 0muri 9mai, _ ,. String

Return result description

Member variable Description Type
HttpCode HTTP Code, The operation is successful within the range[200, 300) , otherwise it failed Int