UserService

  • gRPC服务地址:/fusion.discoveryx.grpc.UserService
  • REST URL前缀:/fusion/discoveryx/console/user

REST URL路径由 REST URL前缀 + 服务名组织,均使用 POST 方法的请求,JSON序例化格式。如查询实例接口访问地址为:POST /fusion/discoveryx/console/sign/Login。Protobuf与JSON格式转换请参阅: JSON 说明

Login

  • REST URI:POST /fusion/discoveryx/console/sign/Login

gRPC

rpc Login (fusion.discoveryx.server.protocol.Login) returns (fusion.discoveryx.server.protocol.UserResponse) {
}

请求

message Login {
    string account = 1;
    string password = 2;
}

响应

message UserResponse {
    int32 status = 1;
    string message = 2;
    oneof data {
        User user = 3;
        ListedUser listed = 4;
        Logined logined = 5;
        Logouted logouted = 6;
    }
}

oneof字段logined将返回登录结果和Session Token:

message Logined {
    string token = 1;
    string account = 2;
    string name = 3;
}

Logout

  • REST URI:POST /fusion/discoveryx/console/sign/Logout

gRPC

rpc Logout (fusion.discoveryx.server.protocol.Logout) returns (fusion.discoveryx.server.protocol.UserResponse) {
}

请求

message Logout {
    string account = 1;
}

响应

message UserResponse {
    int32 status = 1;
    string message = 2;
    oneof data {
        User user = 3;
        ListedUser listed = 4;
        Logined logined = 5;
        Logouted logouted = 6;
    }
}

Current Session User

通过Session获取当前登录用户,REST API用户不需要传body(将从cookie及http header头中获取)。

  • REST URIPOST|GET /fusion/discoveryx/console/sign/ or POST|GET /fusion/discoveryx/console/sign/CurrentSessionUser

gRPC

rpc CurrentSessionUser (fusion.discoveryx.server.protocol.CurrentSessionUser) returns (fusion.discoveryx.server.protocol.UserResponse) {
}

请求

message CurrentSessionUser {
    string token = 1;
}

响应

message UserResponse {
    int32 status = 1;
    string message = 2;
    oneof data {
        User user = 3;
        ListedUser listed = 4;
        Logined logined = 5;
        Logouted logouted = 6;
    }
}

oneof字段user将返回已当前登录Session的用户

User

enum UserRole {
    DEFAULT = 0;
    USER = 1;
    ADMIN = 2;
}
message User {
    // Valid format: email or [a-zA-Z0-9\-\.\_]
    string account = 1;
    string name = 2;
    UserRole userRole = 3;
}

ListUser

gRPC

rpc ListUser (fusion.discoveryx.server.protocol.ListUser) returns (fusion.discoveryx.server.protocol.UserResponse) {
}

请求

message ListUser {
    google.protobuf.StringValue account = 1;
    google.protobuf.StringValue name = 2;
    int32 page = 3;
    int32 size = 4;
}

响应

message UserResponse {
    int32 status = 1;
    string message = 2;
    oneof data {
        User user = 3;
        ListedUser listed = 4;
        Logined logined = 5;
        Logouted logouted = 6;
    }
}

oneof字段listed将返回匹配的用户

message ListedUser {
    repeated User users = 1;
    int32 page = 2;
    int32 size = 3;
    int32 total_elements = 4;
}

CreateUser

gRPC

rpc CreateUser (fusion.discoveryx.server.protocol.CreateUser) returns (fusion.discoveryx.server.protocol.UserResponse) {
}

请求

message CreateUser {
    option (scalapb.message).extends = "fusion.discoveryx.server.user.UserEntity.Event";

    string account = 1;
    string password = 2;
    string name = 3;
    UserRole userRole = 4;
}

响应

message UserResponse {
    int32 status = 1;
    string message = 2;
    oneof data {
        User user = 3;
        ListedUser listed = 4;
        Logined logined = 5;
        Logouted logouted = 6;
    }
}

oneof字段user将返回已创建的用户

ModifyUser

gRPC

rpc ModifyUser (fusion.discoveryx.server.protocol.ModifyUser) returns (fusion.discoveryx.server.protocol.UserResponse) {
}

请求

message ModifyUser {
    option (scalapb.message).extends = "fusion.discoveryx.server.user.UserEntity.Event";

    string account = 1;
    google.protobuf.StringValue name = 2;
    UserRole userRole = 3;
    google.protobuf.StringValue password = 4;
}

响应

message UserResponse {
    int32 status = 1;
    string message = 2;
    oneof data {
        User user = 3;
        ListedUser listed = 4;
        Logined logined = 5;
        Logouted logouted = 6;
    }
}

oneof字段user将返回已修改后的用户

RemoveUser

gRPC

rpc RemoveUser (fusion.discoveryx.server.protocol.RemoveUser) returns (fusion.discoveryx.server.protocol.UserResponse) {
}

请求

message RemoveUser {
    option (scalapb.message).extends = "fusion.discoveryx.server.user.UserEntity.Event";

    string account = 1;
}

响应

message UserResponse {
    int32 status = 1;
    string message = 2;
    oneof data {
        User user = 3;
        ListedUser listed = 4;
        Logined logined = 5;
        Logouted logouted = 6;
    }
}

oneof字段user将返回已删除的用户

在此文档中发现错误?该页面的源代码可以在 这里 找到。欢迎随时编辑并提交Pull Request。