All Products
Search
Document Center

Object Storage Service:Get vector bucket information (Go SDK V2)

Last Updated:Jun 03, 2026

You can use the Go SDK V2 to call the GetVectorBucket operation and retrieve information about a vector bucket.

Permissions

An Alibaba Cloud account has all permissions by default. By default, Resource Access Management (RAM) users and RAM roles do not have permissions. The Alibaba Cloud account owner or an administrator must grant permissions for this operation using a RAM policy overview or a bucket policy.

API

Action

Description

GetVectorBucket

oss:GetVectorBucket

Gets information about a vector bucket.

Method definition

func (c *VectorsClient) GetVectorBucket(ctx context.Context, request *GetVectorBucketRequest, optFns ...func(*Options)) (*GetVectorBucketResult, error)

Request parameters

Parameter

Type

Description

ctx

context.Context

The request context.

request

*GetVectorBucketRequest

The request parameters. For more information, see GetVectorBucketRequest.

optFns

...func(*Options)

(Optional) The operation-level configuration parameters.

For more information, see Options.

Return values

Parameter

Type

Description

result

*GetVectorBucketResult

The return value. This parameter is valid only if the value of err is nil. For more information, see GetVectorBucketResult.

err

error

The error message. If the operation is successful, the value is nil.

Sample code

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
	bucketName string
	accountId  string
)

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

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

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

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

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

	client := vectors.NewVectorsClient(cfg)

	request := &vectors.GetVectorBucketRequest{
		Bucket: oss.Ptr(bucketName),
	}
	result, err := client.GetVectorBucket(context.TODO(), request)
	if err != nil {
		log.Fatalf("failed to get vector bucket %v", err)
	}
	log.Printf("get vector bucket result:%#v\n", result)
}

References

For the complete sample code that shows how to retrieve information about a vector bucket, see get_vector_bucket.go.