All Products
Search
Document Center

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

Last Updated:Sep 26, 2025

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

Permissions

By default, an Alibaba Cloud account has all permissions. A Resource Access Management (RAM) user or a RAM role under an Alibaba Cloud account has no permissions by default. The Alibaba Cloud account or an administrator must grant the required permissions using a RAM Policy 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 vector 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, accounId required")
	}

	cfg := oss.LoadDefaultConfig().
		WithCredentialsProvider(credentials.NewEnvironmentVariableCredentialsProvider()).
		WithRegion(region).WithAccountId(accountId)

	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.