A vector bucket stores vector indexes and vector data. You can call the put_vector_bucket method of Python SDK V2 to create a vector bucket.
Permissions
An Alibaba Cloud account has all permissions by default. RAM users and RAM roles have no permissions by default and must be granted access through a RAM policy or a bucket policy.
|
API |
Action |
Description |
|
PutVectorBucket |
|
Creates a vector bucket. The name of a vector bucket must be unique for a UID within the same region. The name must be 3 to 32 characters in length. It can contain only lowercase letters, digits, and hyphens (-). The name cannot start or end with a hyphen. |
Method definition
put_vector_bucket(request: PutVectorBucketRequest, **kwargs) → PutVectorBucketResult
Request parameters
|
Parameter |
Type |
Description |
|
request |
PutVectorBucketRequest |
The request parameters, such as the name of the vector bucket. For more information, see PutVectorBucketRequest. |
Return value
|
Type |
Description |
|
PutVectorBucketResult |
The return value. For more information, see PutVectorBucketResult. |
For the complete definition of the put_vector_bucket method, see put_vector_bucket.
Sample code
The following code shows how to create a vector bucket.
import argparse
import alibabacloud_oss_v2 as oss
import alibabacloud_oss_v2.vectors as oss_vectors
parser = argparse.ArgumentParser(description="vector put bucket sample")
parser.add_argument('--region', help='The region in which the bucket is located.', required=True)
parser.add_argument('--bucket', help='The name of the bucket.', required=True)
parser.add_argument('--endpoint', help='The endpoint for accessing OSS.', required=False)
parser.add_argument('--account_id', help='The account id.', required=True)
def main():
args = parser.parse_args()
# Load credentials from environment variables
credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()
# Use the SDK's default configuration
cfg = oss.config.load_default()
cfg.credentials_provider = credentials_provider
cfg.region = args.region
cfg.account_id = args.account_id
cfg.use_internal_endpoint = True # Set this to False or delete this line if you want to access OSS over the public network.
if args.endpoint is not None:
cfg.endpoint = args.endpoint
vector_client = oss_vectors.Client(cfg)
result = vector_client.put_vector_bucket(oss_vectors.models.PutVectorBucketRequest(
bucket=args.bucket,
))
print(f'status code: {result.status_code},'
f' request id: {result.request_id},'
)
if __name__ == "__main__":
main()
References
For complete sample code, see put_vector_bucket.py.