You need to enable JavaScript to run this app.
文档中心
向量数据库VikingDB

向量数据库VikingDB

复制全文
下载 pdf
用户管理(Users)
ListOpenVikingUser - 库用户列表
复制全文
下载 pdf
ListOpenVikingUser - 库用户列表

概述

ListOpenVikingUser 接口用于查询指定库下的用户列表,返回脱敏的 API Key(统一返回掩码)。

前置条件

完成 "数据库管理使用说明" 页面的 AK/SK 获取后,可调用本接口。

请求接口

Action

ListOpenVikingUser

接口标识

请求方法

POST

客户端请求类型

请求参数

字段

类型

必填

说明

ResourceID

string

✅

库 ID

OpenVikingAccountID

string

否

仅返回该数据空间下用户;缺省回退默认数据空间 default

UserID

string

否

按用户过滤

Role

string

否

按角色过滤

Page

int

否

页码

Limit

int

否

每页数量

响应消息

字段

类型

说明

UserList

array

用户列表,ApiKey 固定脱敏(统一返回掩码)

Total

int

总数

UserList 元素结构:

字段

类型

说明

UserID

string

用户 ID

Role

string

用户角色

ApiKey

string

API Key(脱敏)

常见错误码

HTTP 状态

Error.Code

含义 / 触发场景

404

ResourceNotExist

指定库不存在

完整示例

Python 请求示例

import os
import datetime
import hashlib
import hmac
from urllib.parse import quote

import requests, json

def norm_query(params):
    query = ""
    for key in sorted(params.keys()):
        if type(params[key]) == list:
            for k in params[key]:
                query = (
                        query + quote(key, safe="-_.~") + "=" + quote(k, safe="-_.~") + "&"
                )
        else:
            query = (query + quote(key, safe="-_.~") + "=" + quote(params[key], safe="-_.~") + "&")
    query = query[:-1]
    return query.replace("+", "%20")

def hmac_sha256(key: bytes, content: str):
    return hmac.new(key, content.encode("utf-8"), hashlib.sha256).digest()

def hash_sha256(content: str):
    return hashlib.sha256(content.encode("utf-8")).hexdigest()

class ClientForConsoleApi:
    def __init__(self, ak, sk, host, region):
        self.ak = ak
        self.sk = sk
        self.host = host
        self.region = region
        self.service_code = "vikingdb"
        self.version = "2025-06-09"

    def request(self, method, action, body, query=None, header=None):
        if query is None:
            query = {}
        if header is None:
            header = {}
        credential = {
            "access_key_id": self.ak,
            "secret_access_key": self.sk,
            "service": self.service_code,
            "region": self.region,
        }
        request_param = {
            "body": json.dumps(body),
            "host": self.host,
            "path": "/",
            "method": method,
            "content_type": 'application/json',
            "date": datetime.datetime.utcnow(),
            "query": {"Action": action, "Version": self.version, **query},
        }
        if body is None:
            request_param["body"] = ""
        x_date = request_param["date"].strftime("%Y%m%dT%H%M%SZ")
        short_x_date = x_date[:8]
        x_content_sha256 = hash_sha256(request_param["body"])
        sign_result = {
            "Host": request_param["host"],
            "X-Content-Sha256": x_content_sha256,
            "X-Date": x_date,
            "Content-Type": request_param["content_type"],
        }
        signed_headers_str = ";".join(
            ["content-type", "host", "x-content-sha256", "x-date"]
        )
        canonical_request_str = "\n".join(
            [request_param["method"].upper(),
             request_param["path"],
             norm_query(request_param["query"]),
             "\n".join(
                 [
                     "content-type:" + request_param["content_type"],
                     "host:" + request_param["host"],
                     "x-content-sha256:" + x_content_sha256,
                     "x-date:" + x_date,
                 ]
             ),
             "",
             signed_headers_str,
             x_content_sha256,
             ]
        )

        hashed_canonical_request = hash_sha256(canonical_request_str)
        credential_scope = "/".join([short_x_date, credential["region"], credential["service"], "request"])
        string_to_sign = "\n".join(["HMAC-SHA256", x_date, credential_scope, hashed_canonical_request])

        k_date = hmac_sha256(credential["secret_access_key"].encode("utf-8"), short_x_date)
        k_region = hmac_sha256(k_date, credential["region"])
        k_service = hmac_sha256(k_region, credential["service"])
        k_signing = hmac_sha256(k_service, "request")
        signature = hmac_sha256(k_signing, string_to_sign).hex()

        sign_result["Authorization"] = "HMAC-SHA256 Credential={}, SignedHeaders={}, Signature={}".format(
            credential["access_key_id"] + "/" + credential_scope,
            signed_headers_str,
            signature,
        )
        header = {**header, **sign_result}
        r = requests.request(method=method,
                             url="https://{}{}".format(request_param["host"], request_param["path"]),
                             headers=header,
                             params=request_param["query"],
                             data=request_param["body"],
                             )
        return r.status_code, r.headers, r.json()

if __name__ == '__main__':
    client = ClientForConsoleApi(
        ak = "*",#替换为您的 AK
        sk ="*" ,#替换为您的 SK
        host="vikingdb.cn-beijing.volcengineapi.com", #替换为您所在地区的域名
        region="cn-beijing"
    )
    http_code, _, result_json = client.request(
        method="POST",
        action="ListOpenVikingUser",#action替换为当前操作
        body={
          "ResourceID": "ov-20250609abcdef01",
          "OpenVikingAccountID": "default",
          "Page": 1,
          "Limit": 20
        }
    )
    print("req http status code: ", http_code)
    print("req result: \n", result_json)

响应示例

{
    "ResponseMetadata": {
        "RequestId": "20250609xxxxxxxxxxxxxxxx",
        "Action": "ListOpenVikingUser",
        "Version": "2025-06-09",
        "Service": "vikingdb",
        "Region": "cn-beijing"
    },
    "Result": {
        "UserList": [
            {
                "UserID": "default",
                "Role": "admin",
                "ApiKey": "sk-********************"
            },
            {
                "UserID": "user1",
                "Role": "user",
                "ApiKey": "sk-********************"
            }
        ],
        "Total": 2
    }
}
最近更新时间:2026.09.17 15:38:21
这个页面对您有帮助吗?
有用
有用
无用
无用