# NSKeyService > NS密钥相关服务 --- ## countAllNSKeys > 计算密钥数量 - 角色:`admin`, `user` - HTTP:`POST https://backend.dooki.cloud/NSKeyService/countAllNSKeys` - RPC:`rpc countAllNSKeys (CountAllNSKeysRequest) returns (RPCCountResponse);` **请求对象 (`CountAllNSKeysRequest`)** ```json { "nsDomainId": "int64", "nsZoneId": "int64" } ``` **响应对象 (`RPCCountResponse`)** ```json { "count": "int64 // 数量" } ``` **调用示例** ```bash curl -X POST "https://backend.dooki.cloud/NSKeyService/countAllNSKeys" \ -H "Content-Type: application/json" \ -H "X-Edge-Access-Token: " \ -d '{ ... }' ``` --- ## createNSKey > 创建密钥 - 角色:`admin`, `user` - HTTP:`POST https://backend.dooki.cloud/NSKeyService/createNSKey` - RPC:`rpc createNSKey (CreateNSKeyRequest) returns (CreateNSKeyResponse);` **请求对象 (`CreateNSKeyRequest`)** ```json { "nsDomainId": "int64", "nsZoneId": "int64", "name": "string // 名称", "algo": "string", "secret": "string", "secretType": "string" } ``` **响应对象 (`CreateNSKeyResponse`)** ```json { "nsKeyId": "int64" } ``` **调用示例** ```bash curl -X POST "https://backend.dooki.cloud/NSKeyService/createNSKey" \ -H "Content-Type: application/json" \ -H "X-Edge-Access-Token: " \ -d '{ ... }' ``` --- ## deleteNSKey > 删除密钥 - 角色:`admin`, `user` - HTTP:`POST https://backend.dooki.cloud/NSKeyService/deleteNSKey` - RPC:`rpc deleteNSKey (DeleteNSKeyRequest) returns (RPCSuccess);` **请求对象 (`DeleteNSKeyRequest`)** ```json { "nsKeyId": "int64" } ``` **响应对象 (`RPCSuccess`)** ```json {} ``` **调用示例** ```bash curl -X POST "https://backend.dooki.cloud/NSKeyService/deleteNSKey" \ -H "Content-Type: application/json" \ -H "X-Edge-Access-Token: " \ -d '{ ... }' ``` --- ## findNSKey > 查找单个密钥 - 角色:`admin`, `user` - HTTP:`POST https://backend.dooki.cloud/NSKeyService/findNSKey` - RPC:`rpc findNSKey (FindNSKeyRequest) returns (FindNSKeyResponse);` **请求对象 (`FindNSKeyRequest`)** ```json { "nsKeyId": "int64" } ``` **响应对象 (`FindNSKeyResponse`)** ```json { "nsKey": "NSKey" } ``` **调用示例** ```bash curl -X POST "https://backend.dooki.cloud/NSKeyService/findNSKey" \ -H "Content-Type: application/json" \ -H "X-Edge-Access-Token: " \ -d '{ ... }' ``` --- ## listNSKeys > 列出单页密钥 - 角色:`admin`, `user` - HTTP:`POST https://backend.dooki.cloud/NSKeyService/listNSKeys` - RPC:`rpc listNSKeys (ListNSKeysRequest) returns (ListNSKeysResponse);` **请求对象 (`ListNSKeysRequest`)** ```json { "nsDomainId": "int64", "nsZoneId": "int64", "offset": "int64 // 读取位置", "size": "int64 // 数量,通常不能小于0" } ``` **响应对象 (`ListNSKeysResponse`)** ```json { "nsKeys": "[]NSKey" } ``` **调用示例** ```bash curl -X POST "https://backend.dooki.cloud/NSKeyService/listNSKeys" \ -H "Content-Type: application/json" \ -H "X-Edge-Access-Token: " \ -d '{ ... }' ``` --- ## updateNSKey > 修改密钥 - 角色:`admin`, `user` - HTTP:`POST https://backend.dooki.cloud/NSKeyService/updateNSKey` - RPC:`rpc updateNSKey (UpdateNSKeyRequest) returns (RPCSuccess);` **请求对象 (`UpdateNSKeyRequest`)** ```json { "nsKeyId": "int64", "name": "string // 名称", "algo": "string", "secret": "string", "secretType": "string", "isOn": "bool // 是否启用" } ``` **响应对象 (`RPCSuccess`)** ```json {} ``` **调用示例** ```bash curl -X POST "https://backend.dooki.cloud/NSKeyService/updateNSKey" \ -H "Content-Type: application/json" \ -H "X-Edge-Access-Token: " \ -d '{ ... }' ``` ---