private static Permission ToPermission(Authpb.Permission perm) { ByteSequence key = ByteSequence.from(perm.Key); ByteSequence rangeEnd = ByteSequence.from(perm.RangeEnd); Permission.Type type; switch (perm.PermType) { case Authpb.Permission.Types.Type.Read: type = Permission.Type.READ; break; case Authpb.Permission.Types.Type.Write: type = Permission.Type.WRITE; break; case Authpb.Permission.Types.Type.Readwrite: type = Permission.Type.READWRITE; break; default: type = Permission.Type.UNRECOGNIZED; break; } return(new Permission(type, key, rangeEnd)); }
public AuthRoleGrantPermissionResponse RoleGrantPermission(ByteSequence role, ByteSequence key, ByteSequence rangeEnd, auth.Permission.Type permType) { Authpb.Permission.Types.Type type; switch (permType) { case Permission.Type.WRITE: type = Authpb.Permission.Types.Type.Write; break; case Permission.Type.READWRITE: type = Authpb.Permission.Types.Type.Readwrite; break; case Permission.Type.READ: type = Authpb.Permission.Types.Type.Read; break; default: type = Authpb.Permission.Types.Type.Readwrite; break; } Authpb.Permission perm = new Authpb.Permission(); perm.Key = key.GetByteString(); perm.RangeEnd = rangeEnd.GetByteString(); perm.PermType = type; Etcdserverpb.AuthRoleGrantPermissionRequest roleGrantPermissionRequest = new Etcdserverpb.AuthRoleGrantPermissionRequest(); roleGrantPermissionRequest.Name = role.ToString(); roleGrantPermissionRequest.Perm = perm; var rsp = authClient.RoleGrantPermission(roleGrantPermissionRequest); AuthRoleGrantPermissionResponse response = new AuthRoleGrantPermissionResponse(rsp); return(response); // return Util.ToCompletableFuture( // this.stub.roleGrantPermission(roleGrantPermissionRequest), // new FunctionResponse<Etcdserverpb.AuthRoleGrantPermissionRequest, AuthRoleGrantPermissionResponse>()); }