tencent cloud

Cloud Object Storage

Release Notes and Announcements
Release Notes
Announcements
Product Introduction
Overview
Features
Use Cases
Strengths
Concepts
Regions and Access Endpoints
Specifications and Limits
Service Regions and Service Providers
Billing
Billing Overview
Billing Method
Billable Items
Free Tier
Billing Examples
Viewing and Downloading Bill
Payment Overdue
FAQs
Getting Started
Console
Getting Started with COSBrowser
User Guide
Creating Request
Bucket
Object
Data Management
Batch Operation
Global Acceleration
Monitoring and Alarms
Operations Center
Data Processing
Content Moderation
Smart Toolbox
Data Processing Workflow
Application Integration
User Tools
Tool Overview
Installation and Configuration of Environment
COSBrowser
COSCLI (Beta)
COSCMD
COS Migration
FTP Server
Hadoop
COSDistCp
HDFS TO COS
GooseFS-Lite
Online Tools
Diagnostic Tool
Use Cases
Overview
Access Control and Permission Management
Performance Optimization
Accessing COS with AWS S3 SDK
Data Disaster Recovery and Backup
Domain Name Management Practice
Image Processing
Audio/Video Practices
Workflow
Direct Data Upload
Content Moderation
Data Security
Data Verification
Big Data Practice
COS Cost Optimization Solutions
Using COS in the Third-party Applications
Migration Guide
Migrating Local Data to COS
Migrating Data from Third-Party Cloud Storage Service to COS
Migrating Data from URL to COS
Migrating Data Within COS
Migrating Data Between HDFS and COS
Data Lake Storage
Cloud Native Datalake Storage
Metadata Accelerator
GooseFS
Data Processing
Data Processing Overview
Image Processing
Media Processing
Content Moderation
File Processing Service
File Preview
Troubleshooting
Obtaining RequestId
Slow Upload over Public Network
403 Error for COS Access
Resource Access Error
POST Object Common Exceptions
API Documentation
Introduction
Common Request Headers
Common Response Headers
Error Codes
Request Signature
Action List
Service APIs
Bucket APIs
Object APIs
Batch Operation APIs
Data Processing APIs
Job and Workflow
Content Moderation APIs
Cloud Antivirus API
SDK Documentation
SDK Overview
Preparations
Android SDK
C SDK
C++ SDK
.NET(C#) SDK
Flutter SDK
Go SDK
iOS SDK
Java SDK
JavaScript SDK
Node.js SDK
PHP SDK
Python SDK
React Native SDK
Mini Program SDK
Error Codes
Harmony SDK
Endpoint SDK Quality Optimization
Security and Compliance
Data Disaster Recovery
Data Security
Cloud Access Management
FAQs
Popular Questions
General
Billing
Domain Name Compliance Issues
Bucket Configuration
Domain Names and CDN
Object Operations
Logging and Monitoring
Permission Management
Data Processing
Data Security
Pre-signed URL Issues
SDKs
Tools
APIs
Agreements
Service Level Agreement
Privacy Policy
Data Processing And Security Agreement
Contact Us
Glossary

Inventory

PDF
聚焦模式
字号
最后更新时间: 2024-02-02 16:24:05

Overview

This document provides an overview of APIs and SDK code samples related to COS inventory.
API
Operation
Description
Creating an inventory job
Creates an inventory job for a bucket
Querying inventory jobs
Queries the inventory jobs of bucket
Deleting inventory jobs
Deletes an inventory job from a bucket

Creating Inventory Job

Feature description

This API (PUT Bucket inventory) is used to create an inventory job for a bucket.

Method prototype

public SetBucketInventoryConfigurationResult setBucketInventoryConfiguration(String bucketName, InventoryConfiguration inventoryConfiguration);
public SetBucketInventoryConfigurationResult setBucketInventoryConfiguration(SetBucketInventoryConfigurationRequest setBucketInventoryConfigurationRequest);

Sample request

// The bucket name must contain appid
String bucketName = "examplebucket-1250000000";

InventoryConfiguration inventoryConfiguration = new InventoryConfiguration();
InventoryCosBucketDestination inventoryCosBucketDestination = new InventoryCosBucketDestination();
// Set format and prefix of the destination bucket for inventory output
inventoryCosBucketDestination.setAccountId("2779643970");
inventoryCosBucketDestination.setBucketArn("qcs::cos:ap-guangzhou::examplebucket-1250000000");
inventoryCosBucketDestination.setEncryption(new ServerSideEncryptionCOS());
inventoryCosBucketDestination.setFormat(InventoryFormat.CSV);
inventoryCosBucketDestination.setPrefix("inventory-output");
InventoryDestination inventoryDestination = new InventoryDestination();
inventoryDestination.setCosBucketDestination(inventoryCosBucketDestination);
inventoryConfiguration.setDestination(inventoryDestination);

// Set inventory scheduling frequency, scan prefix, ID, etc.
inventoryConfiguration.setEnabled(true);
inventoryConfiguration.setId("1");
InventorySchedule inventorySchedule = new InventorySchedule();
inventorySchedule.setFrequency(InventoryFrequency.Daily);
inventoryConfiguration.setSchedule(inventorySchedule);
InventoryPrefixPredicate inventoryFilter = new InventoryPrefixPredicate("test/");
inventoryConfiguration.setInventoryFilter(new InventoryFilter(inventoryFilter));
inventoryConfiguration.setIncludedObjectVersions(InventoryIncludedObjectVersions.All);
// Set optional output fields
List<String> optionalFields = new LinkedList<String>();
optionalFields.add(InventoryOptionalField.Size.toString());
optionalFields.add(InventoryOptionalField.LastModifiedDate.toString());
inventoryConfiguration.setOptionalFields(optionalFields);
SetBucketInventoryConfigurationRequest setBucketInventoryConfigurationRequest = new SetBucketInventoryConfigurationRequest();
setBucketInventoryConfigurationRequest.setBucketName(bucketName);
setBucketInventoryConfigurationRequest.setInventoryConfiguration(inventoryConfiguration);
cosClient.setBucketInventoryConfiguration(setBucketInventoryConfigurationRequest);

inventoryConfiguration.setId("2");
inventorySchedule.setFrequency(InventoryFrequency.Weekly);
cosClient.setBucketInventoryConfiguration(setBucketInventoryConfigurationRequest);

Parameter description

Parameter
Description
Type
setBucketInventoryConfigurationRequest
Request to set static website for bucket
SetBucketInventoryConfigurationRequest
Request member description:
Request Member
Setting Method
Description
Type
bucketName
Constructor or set method
Bucket for which to set an inventory job in the format of BucketName-APPID. For more information, please see Naming Conventions
String
inventoryConfiguration
Constructor or set method
Inventory configuration of bucket
InventoryConfiguration
InventoryConfiguration member description:
Parameter
Description
Type
id
Inventory job name. Valid characters: a-z, A-Z, 0-9, -, _, .
String
destination
Information of the bucket to store the inventory result after export
InventoryDestination
isEnabled
Inventory status flag
Boolean
inventoryFilter
Filters the objects to be analyzed. The inventory feature will analyze the objects that match the prefix set in Filter
InventoryFilter
includedObjectVersions
Whether to include object versions in the inventory
If this is set to All, the inventory will include all object versions and add VersionId, IsLatest, and DeleteMarker fields
If Current, no object version information will be included in the inventory
String
optionalFields
Name of fields that can be optionally included in the inventory result
List
schedule
Configures inventory job frequency
InventorySchedule
InventoryDestination member description:
Parameter
Description
Type
cosBucketDestination
Information of the bucket to store the inventory result after export
InventoryCosBucketDestination
InventoryCosBucketDestination member description:
Parameter
Description
Type
accountId
Bucket owner ID
String
bucketArn
Name of the bucket where the inventory result is stored
String
format
File format of the inventory result. Valid values: CSV
String
prefix
Prefix of the inventory result
String
encryption
Option to provide server-side encryption for the inventory result
InventoryEncryption
InventoryFilter member description:
Parameter
Description
Type
predicate
Filters the objects to be analyzed
InventoryFilterPredicate
An implementation class of InventoryFilter is InventoryPrefixPredicate with the following members:
Parameter
Description
Type
prefix
Prefix of the objects to be analyzed
String
InventorySchedule member description:
Parameter
Description
Type
frequency
Inventory job frequency. Enumerated values: Daily, Weekly
String

Response description

Success: no value is returned.
Failure: an error (such as authentication failure) occurs, with a CosClientException or CosServiceException exception thrown. For more information, please see Troubleshooting.

Error code description

The following describes some common errors that may occur when you make requests using this API.
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

Querying Inventory Jobs

Feature description

This API (GET Bucket inventory) is used to query the inventory job information in a bucket.

Method prototype

public GetBucketInventoryConfigurationResult getBucketInventoryConfiguration(String bucketName, String id) throws CosClientException, CosServiceException;

Sample request

String bucketName = "examplebucket-1250000000";
String id = "1";
GetBucketInventoryConfigurationResult getBucketInventoryConfigurationResult = cosClient.getBucketInventoryConfiguration(bucketName, id);

Parameter description

Parameter
Description
Type
bucketName
Bucket for which to query an inventory job in the format of BucketName-APPID. For more information, please see Naming Convention
String
id
Inventory job name. Valid characters: a-z, A-Z, 0-9, -, _, .
String

Response description

Success: GetBucketInventoryConfigurationResult is returned, which contains the configuration information of the inventory corresponding to the specified ID for the bucket.
Failure: an error (such as authentication failure) occurs, with a CosClientException or CosServiceException exception thrown. For more information, please see Troubleshooting.

Querying All Inventories

Feature description

This API (List Bucket Inventory Configurations) is used to request that all inventory jobs in a bucket be returned.

Method prototype

public ListBucketInventoryConfigurationsResult listBucketInventoryConfigurations(ListBucketInventoryConfigurationsRequest listBucketInventoryConfigurationsRequest) throws CosClientException, CosServiceException;

Sample request

String bucketName = "examplebucket-1250000000";
ListBucketInventoryConfigurationsRequest listBucketInventoryConfigurationsRequest = new ListBucketInventoryConfigurationsRequest();
listBucketInventoryConfigurationsRequest.setBucketName(bucketName);
ListBucketInventoryConfigurationsResult listBucketInventoryConfigurationsResult = cosClient.listBucketInventoryConfigurations(listBucketInventoryConfigurationsRequest);

Parameter description

Parameter
Description
Type
bucketName
Destination bucket to store the inventory result in the format of BucketName-APPID. For more information, please see Naming Convention
String
continuationToken
If IsTruncated in the COS response body is true and there is a parameter value in the NextContinuationToken node, you can use this parameter as the parameter value of continuation-token to get the inventory job information of the next page
String

Response description

Success: ListBucketInventoryConfigurationsResult is returned, which contains the configuration information of the inventory corresponding to the specified ID for the bucket.
Failure: an error (such as authentication failure) occurs, with a CosClientException or CosServiceException exception thrown. For more information, please see Troubleshooting.

Deleting Inventory Job

Feature description

This API (DELETE Bucket inventory) is used to delete a specified inventory job of a bucket.

Method prototype

public DeleteBucketInventoryConfigurationResult deleteBucketInventoryConfiguration(String bucketName, String id) throws CosClientException, CosServiceException;

Sample request

String bucketName = "examplebucket-1250000000";
String id = "1";
cosClient.deleteBucketInventoryConfiguration(bucketName, id);

Parameter description

Parameter
Description
Type
bucketName
Bucket for which to delete an inventory job in the format of BucketName-APPID. For more information, please see Naming Convention
String
id
Inventory job name. Valid characters: a-z, A-Z, 0-9, -, _, .
String

Response description

Success: no value is returned.
Failure: an error (such as authentication failure) occurs, with a CosClientException or CosServiceException exception thrown. For more information, please see Troubleshooting.

帮助和支持

本页内容是否解决了您的问题?

填写满意度调查问卷,共创更好文档体验。

文档反馈