A vector bucket is a container for vector data and vector indexes. You can use the Python SDK V2 to call the PutVectorBucket operation to create a vector bucket.
Permissions
An Alibaba Cloud account has all permissions by default. A Resource Access Management (RAM) user or RAM role has no permissions by default. To perform this operation, the RAM user or RAM role must be granted permissions by an Alibaba Cloud account or an administrator using 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 long. It can contain only lowercase letters, digits, and hyphens (-). It cannot start or end with a hyphen. |
Method definition
put_vector_bucket(request: PutVectorBucketRequest, **kwargs) → PutVectorBucketResultRequest parameters
Parameter | Type | Description |
request | PutVectorBucketRequest | Sets the request parameters, such as the name of the vector bucket. For more information, see PutVectorBucketRequest. |
Return values
Type | Description |
PutVectorBucketResult | The return value. For more information, see PutVectorBucketResult. |
For the complete definition of the method, see put_vector_bucket.
Sample code
The following code creates a 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 domain names that other services can use to access OSS')
parser.add_argument('--account_id', help='The account id.', required=True)
def main():
args = parser.parse_args()
# Loading credentials values from the environment variables
credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()
# Using 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
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 the complete sample code for creating a vector bucket, see put_vector_bucket.py.