Inventory

Last updated: 2020-03-20 11:04:40

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
List Bucket Inventory Configurations Inquire about all inventory Inquire about all 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

func (s *BucketService) PutInventory(ctx context.Context, id string, opt *BucketPutInventoryOptions) (*Response, error)

Request Sample

opt := &cos.BucketPutInventoryOptions{
    ID: "test_id",
    // True or False
    IsEnabled:              "True",
    IncludedObjectVersions: "All",
    Filter: &cos.BucketInventoryFilter{
        Prefix: "test",
    },
    OptionalFields: &cos.BucketInventoryOptionalFields{
        BucketInventoryFields: []string{
            "Size", "LastModifiedDate",
        },
    },
    Schedule: &cos.BucketInventorySchedule{
        // Weekly or Daily
        Frequency: "Daily",
    },
    Destination: &cos.BucketInventoryDestination{
        Bucket: dBucket,
        Format: "CSV",
    },
}
resp, err := client.Bucket.PutInventory(context.Background(), id, opt)

Parameter description

type BucketInventoryFilter struct {
    Prefix string 
}
type BucketInventoryOptionalFields struct {
    BucketInventoryFields []string 
}
type BucketInventorySchedule struct {
    Frequency string 
}
type BucketInventoryEncryption struct {
    SSECOS string 
}
type BucketInventoryDestination struct {
    Bucket     string                     
    AccountId  string                     
    Prefix     string                    
    Format     string
    Encryption *BucketInventoryEncryption 
}
// BucketPutInventoryOptions ...
type BucketPutInventoryOptions struct {
    XMLName                xml.Name                     
    ID                     string                         
    IsEnabled              string                       
    IncludedObjectVersions string                      
    Filter                 *BucketInventoryFilter        
    OptionalFields         *BucketInventoryOptionalFields 
    Schedule               *BucketInventorySchedule      
    Destination            *BucketInventoryDestination
}
Parameter name Description Type
BucketPutInventoryOptions Bucket inventory configuration information Struct
Id The name of inventory, which corresponds to the ID in the request parameters String
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 Struct
    Prefix Prefix of the object to be analyzed String
    OptionalFields Set the analysis items that should be included in inventory's results Struct
    BucketInventoryFields The name of the analysis project that can be included in inventory's result. Optional fields include: Size,LastModifiedDate,StorageClass,ETag,IsMultipartUploaded,ReplicationStatus [] String
    Schedule Inventory job cycle Struct
    Frequency Inventory job cycle. Options are daily or weekly. Enumerated values: Daily, Weekly String
    Destination Describe the information that stores inventory's results Struct
    Bucket Bucket name of inventory's analysis result String
    AccountId The owner of Bucket, ID, for example, 100000000001 String
    Prefix The prefix of inventory's analysis result String
    Format The file form of inventory's analysis results, optional is CSV format String
    Encryption Provide server-side encryption options for inventory results Struct
    SSECOS Use SSE-COS encryption String

    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

    func (s *BucketService) GetInventory(ctx context.Context, id string) (*BucketGetInventoryResult, *Response, error)

    Request Sample

    v, response, err := client.Bucket.GetInventory(context.Background(), id)

    Return result description

    type BucketGetInventoryResult BucketPutInventoryOptions
    Parameter name Description Type
    BucketPutInventoryOptions Bucket inventory configuration information Struct
    Id The name of inventory, which corresponds to the ID in the request parameters String
    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 Struct
    Prefix Prefix of the object to be analyzed String
    OptionalFields Set the analysis items that should be included in inventory's results Struct
    BucketInventoryFields The name of the analysis project that can be included in inventory's result. Optional fields include: Size,LastModifiedDate,StorageClass,ETag,IsMultipartUploaded,ReplicationStatus [] String
    Schedule Inventory job cycle Struct
    Frequency Inventory job cycle. Options are daily or weekly. Enumerated values: Daily, Weekly String
    Destination Describe the information that stores inventory's results Struct
    Bucket Bucket name of inventory's analysis result String
    AccountId The owner of Bucket, ID, for example, 100000000001 String
    Prefix The prefix of inventory's analysis result String
    Format The file form of inventory's analysis results, optional is CSV format String
    Encryption Provide server-side encryption options for inventory results Struct
    SSECOS Use SSE-COS encryption String

    Inquire about all inventory

    Function description

    List Bucket Inventory Configurations requests all inventory tasks in a bucket. Up to 1,000 inventory tasks can be configured in one bucket.

    Method prototype

    func (s *BucketService) ListInventoryConfigurations(ctx context.Context, token string) (*ListBucketInventoryConfigResult, *Response, error)

    Request Sample

    v, resp, err := client.Bucket.ListInventoryConfigurations(context.Background(), "")

    Return result description

    type BucketListInventoryConfiguartion BucketPutInventoryOptions
    
    type ListBucketInventoryConfigResult struct {
        XMLName                 xml.Name          
        InventoryConfigurations []BucketListInventoryConfiguartion 
        IsTruncated             bool   
        ContinuationToken       string    
        NextContinuationToken   string
    }
    Parameter name Description Type
    ListBucketInventoryConfigResult Bucket all inventory configuration information Struct
    InventoryConfigurations Inventory configuration Information Struct
    IsTruncated Whether the logo of all inventory and job information has been listed. False, if it has been displayed; otherwise, true. Bool
    ContinuationToken When the page inventory list logo, can be understood as the number of pages. This identity corresponds to the continuation-token parameter in the request String
    NextContinuationToken The logo of the list of inventory on the next page. If there is a value in this parameter, you can use it as a continuation-token parameter and initiate a GET request to get the next page of inventory and job information String

    Delete inventory job

    Function description

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

    Method prototype

    func (s *BucketService) DeleteInventory(ctx context.Context, id string) (*Response, error)
    

    Request Sample

    resp, err = client.Bucket.DeleteInventory(context.Background(), "test_id")
    

    Parameter description

    Parameter name Description Type
    Id The name of inventory String