This topic describes how to manage the tags of a bucket.
Usage notes
The sample code in this topic uses the China (Hangzhou) region (
cn-hangzhou) as an example. By default, a public endpoint is used. If you want to access OSS from other Alibaba Cloud products in the same region as the bucket, use an internal endpoint. For more information about the mappings between OSS regions and endpoints, see Regions and endpoints.In this topic, access credentials are obtained from environment variables. For more information about how to configure the access credentials, see Configure access credentials.
Method
Configure tags for a bucket
func (c *Client) PutBucketTags(ctx context.Context, request *PutBucketTagsRequest, optFns ...func(*Options)) (*PutBucketTagsResult, error)Query the tags of a bucket
func (c *Client) GetBucketTags(ctx context.Context, request *GetBucketTagsRequest, optFns ...func(*Options)) (*GetBucketTagsResult, error)Delete the tags of a bucket
func (c *Client) DeleteBucketTags(ctx context.Context, request *DeleteBucketTagsRequest, optFns ...func(*Options)) (*DeleteBucketTagsResult, error)Request parameters
Parameter | Type | Description |
ctx | context.Context | The context of the request, which can be used to specify the total duration of the request. |
request | *PutBucketTagsRequest | Specifies the parameters of a specific API operation. For more information, see PutBucketTagsRequest. |
*GetBucketTagsRequest | Specifies the parameters of a specific API operation. For more information, see GetBucketTagsRequest. | |
*DeleteBucketTagsRequest | Specifies the parameters of a specific API operation. For more information, see DeleteBucketTagsRequest. | |
optFns | ...func(*Options) | Optional. The operation-level parameter. For more information, see Options. |
Response parameters
Parameter | Type | Description |
result | *PutBucketTagsResult | The response to the operation. This parameter is valid when the value of err is nil. For more information, see PutBucketTagsResult. |
*GetBucketTagsRequest | The response to the operation. This parameter is valid when the value of err is nil. For more information, see GetBucketTagsResult. | |
*DeleteBucketTagsRequest | The response to the operation. This parameter is valid when the value of err is nil. For more information, see DeleteBucketTagsResult. | |
err | error | The status of the request. If the request fails, the value of err cannot be nil. |
Examples
References
For more information about the API operation that you can call to configure tags for a bucket, visit PutBucketTags.
For more information about the API operation that you can call to query the tags of a bucket, visit GetBucketTags.
For more information about the API operation that you can call to delete the tags of a bucket, visit DeleteBucketTags.