All Products
Search
Document Center

Object Storage Service:List vector buckets (Go SDK V2)

Last Updated:Jun 03, 2026

You can use the Go SDK V2 to call the ListVectorBuckets operation. This operation lists all vector buckets in your Alibaba Cloud account and supports paged queries.

Permissions

By default, an Alibaba Cloud account has full permissions on its resources. RAM users and RAM roles have no permissions by default. To allow a RAM user or RAM role to call this operation, an Alibaba Cloud account or a RAM administrator must grant the required permissions to the RAM user or RAM role using a RAM policy or a bucket policy.

API

Action

Description

ListVectorBuckets

oss:ListVectorBuckets

Lists vector buckets.

Method definition

func (c *VectorsClient) NewListVectorBucketsPaginator(params *ListVectorBucketsRequest, optFns ...func(*Options)) *ListVectorBucketsPaginator

Request parameters

Parameter name

Type

Description

params

*ListVectorBucketsRequest

Specifies the request parameters. For more information, see ListVectorBucketsRequest.

optFns

...func(*Options)

Optional. The interface-level configuration parameters.

For more information, see Options.

Return values

Parameter name

Type

Description

result

*ListVectorBucketsPaginator

The paginator used to traverse the list of vector buckets. For more information, see ListVectorBucketsPaginator.

Example

package main

import (
	"context"
	"flag"
	"log"

	"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss"
	"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/credentials"
	"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/vectors"
)

var (
	region    string
	accountId string
)

func init() {
	flag.StringVar(&region, "region", "", "The region in which the vector bucket is located.")
	flag.StringVar(&accountId, "account-id", "", "The ID of the vector account.")
}

func main() {
	flag.Parse()
	if len(region) == 0 {
		flag.PrintDefaults()
		log.Fatalf("invalid parameters, region required")
	}

	if len(accountId) == 0 {
		flag.PrintDefaults()
		log.Fatalf("invalid parameters, accounId required")
	}

	cfg := oss.LoadDefaultConfig().
		WithCredentialsProvider(credentials.NewEnvironmentVariableCredentialsProvider()).
		WithRegion(region).WithAccountId(accountId).
		// To access the service over the public network, set this to false or remove this line.
		WithUseInternalEndpoint(true)

	client := vectors.NewVectorsClient(cfg)

	request := &vectors.ListVectorBucketsRequest{}

	p := client.NewListVectorBucketsPaginator(request)

	var i int
	log.Println("Vector Buckets:")
	for p.HasNext() {
		i++

		page, err := p.NextPage(context.TODO())
		if err != nil {
			log.Fatalf("failed to get page %v, %v", i, err)
		}

		// Log the buckets found.
		for _, b := range page.Buckets {
			log.Printf("Bucket:%v, %v, %v\n", oss.ToString(b.Name), oss.ToString(b.ResourceGroupId), oss.ToString(b.Location))
		}
	}
}

References

For the complete sample code, see list_vector_buckets.go.