Inventory

Last updated: 2020-03-20 12:27:42

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)throws CosXmlClientException, CosXmlServiceException;

void putBucketInventoryAsync(PutBucketInventoryRequest request, CosXmlResultListener cosXmlResultListener);

Request Sample

String bucket = "examplebucket-1250000000"; 
PutBucketInventoryRequest putBucketInventoryRequest = new PutBucketInventoryRequest(bucket);
putBucketInventoryRequest.setInventoryId("inventoryId");
putBucketInventoryRequest.setIncludedObjectVersions(InventoryConfiguration.IncludedObjectVersions.ALL);
putBucketInventoryRequest.setScheduleFrequency(InventoryConfiguration.SCHEDULE_FREQUENCY_DAILY);
putBucketInventoryRequest.setDestination("CSV", "1000000000", "examplebucket-1250000000", "region", "objectPrefix");

try {
    PutBucketInventoryResult putBucketInventoryResult = cosXmlService.putBucketInventory(putBucketInventoryRequest);
} catch (CosXmlClientException e) {
    e.printStackTrace();
} catch (CosXmlServiceException e) {
    e.printStackTrace();
}

cosXmlService.putBucketInventoryAsync(putBucketInventoryRequest, new CosXmlResultListener() {
    @Override
    public void onSuccess(CosXmlRequest request, CosXmlResult result) {
        PutBucketInventoryResult putBucketInventoryResult = (PutBucketInventoryResult) result;
    }

    @Override
    public void onFail(CosXmlRequest cosXmlRequest, CosXmlClientException clientException, CosXmlServiceException serviceException)  {
    }
});

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
InventoryId Inventory job setting String
IncludedObjectVersions Whether to include the object version in inventory Enumerate
ScheduleFrequency Inventory job cycle Enumerate
Destination Describe the information that stores inventory's results Object

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)throws CosXmlClientException, CosXmlServiceException;

void getBucketInventoryAsync(GetBucketInventoryRequest request, CosXmlResultListener cosXmlResultListener);

Request Sample

String bucket = "examplebucket-1250000000"; 
GetBucketInventoryRequest getBucketInventoryRequest = new GetBucketInventoryRequest(bucket);
Set<String> headerKeys = new HashSet<>();
headerKeys.add("Host");
getBucketInventoryRequest.setSignParamsAndHeaders(null, headerKeys);
getBucketInventoryRequest.setInventoryId("inventoryId");
try {
    GetBucketInventoryResult getBucketInventoryResult = cosXmlService.getBucketInventory(getBucketInventoryRequest);
} catch (CosXmlClientException e) {
    e.printStackTrace();
} catch (CosXmlServiceException e) {
    e.printStackTrace();
}

cosXmlService.getBucketInventoryAsync(getBucketInventoryRequest, new CosXmlResultListener() {
    @Override
    public void onSuccess(CosXmlRequest request, CosXmlResult result) {
        GetBucketInventoryResult getBucketInventoryResult = (GetBucketInventoryResult)result;
    }

    @Override
    public void onFail(CosXmlRequest cosXmlRequest, CosXmlClientException clientException, CosXmlServiceException serviceException)  {
    }
});

Parameter description

Parameter name Description Type
Bucket Query inventory job's Bucket 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
InventoryConfiguration Returns Bucket object InventoryConfiguration information 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) throws CosXmlClientException, CosXmlServiceException;

void deleteBucketInventoryAsync(DeleteBucketInventoryRequest request, CosXmlResultListener cosXmlResultListener);

Request Sample

String bucket = "examplebucket-1250000000"; 
DeleteBucketInventoryRequest deleteBucketInventoryRequest = new DeleteBucketInventoryRequest(bucket);
Set<String> headerKeys = new HashSet<>();
headerKeys.add("Host");
deleteBucketInventoryRequest.setSignParamsAndHeaders(null, headerKeys);
getBucketInventoryRequest.setInventoryId("inventoryId");
try {
    DeleteBucketInventoryResult deleteBucketInventoryResult = cosXmlService.deleteBucketInventory(deleteBucketInventoryRequest);
} catch (CosXmlClientException e) {
    e.printStackTrace();
} catch (CosXmlServiceException e) {
    e.printStackTrace();
}

cosXmlService.deleteBucketInventoryAsync(deleteBucketInventoryRequest, new CosXmlResultListener() {
    @Override
    public void onSuccess(CosXmlRequest request, CosXmlResult result) {
        DeleteBucketInventoryResult deleteBucketInventoryResult = (DeleteBucketInventoryResult)result;
    }

    @Override
    public void onFail(CosXmlRequest cosXmlRequest, CosXmlClientException clientException, CosXmlServiceException serviceException)  {
    }
});

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