Inventory

Last updated: 2020-03-20 09:45:23

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

public Guzzle\Service\Resource\Model PutBucketInventory(array $args = array());

Request Sample

try {
    $result = $cosClient->putBucketInventory(array(
        'Bucket' => 'examplebucket-1250000000', 
        'Id' => 'string',
        'Destination' => array(
            'COSBucketDestination'=>array(
                'Format' => 'CSV',
                'AccountId' => '100000000001',
                'Bucket' => 'qcs::cos:ap-chengdu::examplebucket-1250000000',
                'Prefix' => 'string',
            )
        ),      
        'IsEnabled' => 'True',
        'Schedule' => array(
            'Frequency' => 'Daily',
        ),  
        'Filter' => array(
            'Prefix' => 'string',
        ),  
        'IncludedObjectVersions' => 'Current',
        'OptionalFields' => array(
            'Size', 
            'ETag',
        )
    ));
    print_r($result);
} catch (\Exception $e) {
    echo "$e\n";
}

Parameter description

Parameter name Parent node Description Type Is it required?
Bucket None Set the format of Bucket of inventory and job to BucketName-APPID. For more information, please see Naming convention String 、 Array Yes
Id None The name of inventory, which corresponds to the id in the request parameters Array Yes
IsEnabled None The logo of whether inventory is enabled:
  • If set to true, inventory function will take effect.
  • If set to false, no inventory will be generated.
  • String Yes
    IncludedObjectVersions None Whether to include the object version in inventory:
  • If set to All, all object versions will be included in inventory, and the fields VersionId,IsLatest,DeleteMarker will be added to inventory.
  • If set to Current, inventory does not contain object version information.
  • String Yes
    Filter None Filter the objects to be analyzed. Inventory function will analyze objects that conform to the prefix set in Filter Array No
    Prefix Filter Prefix of the object to be analyzed String No
    OptionalFields None The name of the analysis project that can be included in inventory's result. Optional fields include: Size,LastModifiedDate,StorageClass,ETag,IsMultipartUploaded,ReplicationStatus Array No
    Schedule None Configure inventory job cycle Array Yes
    Frequency Schedule Inventory job cycle. Options are daily or weekly. Enumerated values: Daily, Weekly String Yes
    Destination None Describe the information that stores inventory's results Array Yes
    COSBucketDestination Destination Inventory results Bucket information stored after Export Array Yes
    Bucket COSBucketDestination Bucket name of inventory's analysis result String Yes
    AccountId COSBucketDestination The owner of Bucket, UIN, for example, 100000000001 String No
    Prefix COSBucketDestination The prefix of inventory's analysis result String No
    Format COSBucketDestination The file form of inventory's analysis results, optional is CSV format String Yes
    Encryption COSBucketDestination Provide server-side encryption options for inventory results Array No
    SSE-COS Encryption The encryption method of COS managed key, which does not need to be populated. String No

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

    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

    The GET Bucket inventory API is used to query the inventory task information in a bucket.

    Method prototype

    public Guzzle\Service\Resource\Model GutBucketInventory(array $args = array());
    

    Request Sample

    try {
        $result = $cosClient->getBucketInvnetory(array(
            'Bucket' => 'examplebucket-1250000000', 
            'Id' => 'string',
        ));
        print_r($result);
    } catch (\Exception $e) {
        echo($e);
    }
    

    Parameter description

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

    Return an example of the result

    GuzzleHttp\Command\Result Object
    (
        [Destination] => Array
            (
                [COSBucketDestination] => Array
                    (
                        [Format] => CSV
                        [AccountId] => 100000000001
                        [Bucket] => qcs::cos:ap-chengdu::examplebucket-1250000000
                        [Prefix] => String
                    )
    
            )
    
        [Schedule] => Array
            (
                [Frequency] => Daily
            )
    
        [OptionalFields] => Array
            (
                [0] => Size
                [1] => ETag
            )
    
        [IsEnabled] => true
        [Id] => string
        [IncludedObjectVersions] => Current
        [RequestId] => NWRmMzQwMDVfMjNiMjU4NjRfOGQ4MV9iN2Jk****
    )

    Return result description

    Parameter name Description Type
    Bucket Bucket's name is in BucketName-APPID format. For more information, please see Naming convention String 、 Array
    Id The name of inventory, which corresponds to the id in the request parameters Array
    IsEnabled The logo of whether inventory is enabled:
  • If set to true, inventory function will take effect.
  • If set to false, no inventory will be generated.
  • String
    IncludedObjectVersions Whether to include the object version in inventory:
  • If set to All, all object versions will be included in inventory, and the fields VersionId,IsLatest,DeleteMarker will be added to inventory.
  • If set to Current, inventory does not contain object version information.
  • String
    Filter Filter the objects to be analyzed. Inventory function will analyze objects that conform to the prefix set in Filter Array
    Prefix Prefix of the object to be analyzed String
    OptionalFields The name of the analysis project that can be included in inventory's result. Optional fields include: Size,LastModifiedDate,StorageClass,ETag,IsMultipartUploaded,ReplicationStatus Array
    Schedule Configure inventory job cycle Array
    Frequency Inventory job cycle. Options are daily or weekly. Enumerated values: Daily, Weekly String
    Destination Describe the information that stores inventory's results Array
    COSBucketDestination Inventory results Bucket information stored after Export Array
    Bucket Bucket name of inventory's analysis result String
    AccountId The owner of Bucket, UIN, for example, 100000000001 String
    Prefix The prefix of inventory's analysis result String
    Format The file form of inventory's analysis results String
    Encryption Provide server-side encryption options for inventory results Array
    SSE-COS The encryption method of COS managed key, which does not need to be populated. String

    Delete inventory job

    Function description

    DELETE Bucket inventory deletes inventory and job as specified in Bucket.

    Method prototype

    public Guzzle\Service\Resource\Model DeleteBucketInventory(array $args = array());

    Request Sample

    try {
        $result = $cosClient->deleteBucketInvnetory(array(
            'Bucket' => 'examplebucket-1250000000', 
            'Id' => 'string',
        ));
        print_r($result);
    } catch (\Exception $e) {
        echo($e);
    }
    

    Parameter description

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