Bucket tag

Last updated: 2020-03-20 11:00:49

PDF

Note

This document provides an overview of API on Bucket tags and sample SDK code.

API Operation name pedagogical operation
PUT Bucket tagging Set Bucket tag Set the label for the existing Bucket
GET Bucket tagging Query Bucket tag Query the existing Bucket tags under the specified Bucket
DELETE Bucket tagging Delete Bucket tag Delete the specified Bucket tag

Set Bucket tag

Function description

PUT Bucket tagging is used to label the existing Bucket.

Method prototype

func (s *BucketService) PutTagging(ctx context.Context, opt *BucketPutTaggingOptions) (*Response, error)

Request Sample

opt := &cos.BucketPutTaggingOptions{
    TagSet: []cos.BucketTaggingTag{
    {   
        Key:   "testk1",
        Value: "testv1",
    },  
    {   
        Key:   "testk2",
        Value: "testv2",
    },  
    },  
}   
resp, err := client.Bucket.PutTagging(context.Background(), opt)

Parameter description

type BucketTaggingTag struct {
    Key   string
    Value string
}
type BucketPutTaggingOptions struct {
    XMLName xml.Name           
    TagSet  []BucketTaggingTag 
}
Parameter name Description Type
BucketPutTaggingOptions Bucket tag configuration parameters Struct
TagSet Bucket tag configuration information Struct
Key The Key, length of the label is no more than 128byte. It supports letters, numbers, spaces, plus sign, minus sign, underscore, equal sign, period, colon and slash. String
Value The Value, length of the label is no more than 256bytes. It supports letters, numbers, spaces, plus sign, minus sign, underscore, equal sign, period, colon and slash. String

Query Bucket tag

Function description

GET Bucket tagging is used to query the existing Bucket tags under the specified Bucket.

Method prototype

func (s *BucketService) GetTagging(ctx context.Context) (*BucketGetTaggingResult, *Response, error)

Request Sample

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

Return result description

type BucketTaggingTag struct {
    Key   string
    Value string
}
type BucketGetTaggingResult struct {
    XMLName xml.Name           
    TagSet  []BucketTaggingTag 
}
Parameter name Description Type
BucketGetTaggingResult Bucket tag configuration parameters Struct
TagSet Bucket tag configuration information Struct
Key The Key, length of the label is no more than 128byte. It supports letters, numbers, spaces, plus sign, minus sign, underscore, equal sign, period, colon and slash. String
Value The Value, length of the label is no more than 256bytes. It supports letters, numbers, spaces, plus sign, minus sign, underscore, equal sign, period, colon and slash. String

Delete Bucket tag

Function description

DELETE Bucket tagging is used to delete the existing Bucket tag under the specified Bucket.

Method prototype

func (s *BucketService) DeleteTagging(ctx context.Context) (*Response, error)

Request Sample

resp, err := client.Bucket.DeleteTagging(context.Background())