Make the API be more proper regarding user mgmnt

This commit is contained in:
Nadja Reitzenstein 2022-04-28 19:01:15 +02:00
parent f02afb3736
commit 750ae0c34b
2 changed files with 25 additions and 1 deletions

View File

@ -33,3 +33,13 @@ struct Optional(T) {
just @1 :T;
}
}
struct Fallible(T, E) {
# Some operations can fail in several expected ways.
# In those cases returning an `Optional` doesn't transfer information about the way that the
# operation failed. `Fallible` contains this information in the generic `E` type.
union {
successful @0 :T;
failed @1 :E;
}
}

View File

@ -8,6 +8,8 @@ $CSharp.namespace("FabAccessAPI.Schema");
using General = import "general.capnp";
using User = import "user.capnp".User;
using Optional = General.Optional;
using Fallible = General.Fallible;
struct UserSystem
{
@ -16,11 +18,23 @@ struct UserSystem
getUserSelf @0 ( ) -> User;
}
search @2 :Search;
interface Search $CSharp.name("SearchInterface") {
getUserByName @0 (username: Text) -> Optional(User);
}
manage @1 :Manage;
interface Manage $CSharp.name("ManageInterface") {
getUserList @0 () -> ( user_list :List(User) );
addUser @1 (username :Text, password: Text) -> User;
enum AddUserError {
alreadyExists @0;
# An user with that username already exists
usernameInvalid @1;
# The provided username is unusable, e.g. contains invalid characters,
# is too long or too short.
}
addUser @1 (username :Text, password: Text) -> Fallible(User, AddUserError);
removeUser @2 (user: User);
}
}