Make compile

This commit is contained in:
Nadja von Reitzenstein Čerpnjak 2024-04-16 15:03:10 +02:00
parent 568c7ac50a
commit 1378c8722d
16 changed files with 162 additions and 91 deletions

View File

@ -3,15 +3,13 @@
using CSharp = import "programming_language/csharp.capnp";
$CSharp.namespace("FabAccessAPI.Schema");
# TODO: removed SturdyRef to build API in C#
# using import "/capnp/rpc.capnp".SturdyRef;
# using import "persistent.capnp".Persistent;
using import "resource.capnp".Resource;
using import "notify.capnp".Notifiable;
using import "interest.capnp".Interest;
using import "utils.capnp".Fallible;
using import "utils.capnp".OID;
using import "utils.capnp".Map;
using import "utils.capnp".SturdyRef;
using import "projects.capnp".Project;
interface Claimable {
@ -20,19 +18,12 @@ interface Claimable {
# Disown the returned claim capability to unclaim it.
struct ClaimError {
union {
locked @0 :Text;
}
locked @0 :Text;
}
}
interface Lockable {
restore @0 ( ) -> ( lock :Lock );
# TODO: removed SturdyRef to build API in C#
# restore @0 ( sturdy :SturdyRef ) -> ( lock :Lock );
# Restore a previously saved SturdyRef pointing to a Lock
lock @1 ( message :Text ) -> ( lock :Lock );
lock @0 ( message :Text ) -> ( lock :Lock );
# Take exclusive access to a resource, disowning all other claims on this
# resource.
#
@ -52,22 +43,40 @@ interface Claim extends (Notifiable) {
traits @1 () -> Map(OID, AnyPointer);
disown @2 () -> Fallible(Void, Error(DisownError));
disown @2 () -> Fallible(DisownOk, DisownError);
# Disown this claim TODO define ConstraintViolation type -> Dependencies!
makeTransferable @3 () -> Fallible(SturdyRef, Error(Void));
makeLendable @4 () -> Fallible(( token :Sturdyref, returnToken :Interest ), Error(Void));
struct DisownOk {
}
struct DisownError {
union {
dependency @0 :List(Claim);
badState @1 :Void;
}
}
makeTransferable @3 () -> Fallible(SturdyRef, MakeTransferableError);
struct MakeTransferableError {
permissionDenied @0 :Void;
}
makeLendable @4 () -> Fallible(MakeLendableOk, MakeLendableError);
struct MakeLendableOk {
token @0 :SturdyRef;
returnToken @1 :Interest;
}
struct MakeLendableError {
permissionDenied @0 :Void;
}
getDependencies @5 () -> ( dependencies: List(Claim) );
}
struct DisownError {
union {
dependency @0 :List(Claim);
badState @1 :Void;
}
}
interface Lock extends (Claim) {
# An exclusive claim on a resource. Only a single Lock may exist for any given resource.

View File

@ -3,9 +3,22 @@
using CSharp = import "programming_language/csharp.capnp";
$CSharp.namespace("FabAccessAPI.Schema");
using import "resource.capnp".Resource;
using import "resource.capnp".Description;
using import "claim.capnp".Claim;
using import "utils.capnp".When;
using import "utils.capnp".Fallible;
interface Interestable {
queue @0 () -> Fallible(Interest, Error(Void));
reserve @1 ( when :When ) -> Fallible(Interest, Error(Void));
queue @0 () -> Fallible(Interest, ReserveError);
reserve @1 ( when :When ) -> Fallible(Interest, ReserveError);
struct ReserveError {
union {
permissionDenied @0 :Void;
reserveOverlapping @1 :Void;
queueFull @2 :Void;
}
}
getInterests @2 () -> ( interests :List(Interest) );
# WARNING: Impersonates users
}

5
measure.capnp Normal file
View File

@ -0,0 +1,5 @@
@0xdb815f35cc321540;
struct Measurement {
}

View File

@ -7,6 +7,7 @@ using import "resource.capnp".Resource;
using import "utils.capnp".OID;
using import "utils.capnp".Map;
using import "state.capnp".Update;
using import "measure.capnp".Measurement;
interface Notifiable {
state @0 () -> ( state :Map(OID, AnyPointer) );
@ -16,7 +17,7 @@ interface Notifiable {
# Subscribe to state updates. The passed in `subscriber` is an interface implemented on the
# client side that a server calls to send update notifications.
measurements @2 () -> ( measurements :Map(Oid, AnyPointer) );
measurements @2 () -> ( measurements :Map(OID, AnyPointer) );
subscribeMeasurements @3 ( subscriber :Subscriber(Measurement) ) -> ( subscription: Subscription );
}

View File

@ -1,3 +1,4 @@
@0xdcc65f4a7b1b013a;
interface Project {

View File

@ -3,13 +3,13 @@
using CSharp = import "programming_language/csharp.capnp";
$CSharp.namespace("FabAccessAPI.Schema");
# TODO: removed SturdyRef to build API in C#
# using import "persistent.capnp".Persistent;
using import "notify.capnp".Notifiable;
using import "interest.capnp".Interestable;
using import "interest.capnp".Interest;
using import "claim.capnp".Claimable;
using import "claim.capnp".Claim;
using import "claim.capnp".Lockable;
using import "claim.capnp".Lock;
using import "audit.capnp".Auditable;
using import "utils.capnp".OID;
@ -57,25 +57,25 @@ struct Resource {
}
struct Description {
name @1 :L10NString;
name @0 :L10NString;
# A human-facing name for this resource. A name should be short and recognizable, and is meant
# as the primary identifier for users to find a resource.
description @2 :L10NString;
description @1 :L10NString;
# A human-facing description for this resource. Descriptions are longer-form text that give
# additional information about a resource beyond a name. They are meant to provide either
# further identifying information or important information that users should be actively shown
# when selecting this resource.
types @3 :List(OID);
types @2 :List(OID);
# The 'type' of Resource. Each OID in the list specifies certain behaviours that this Resource
# follows.
category @4 :Category;
category @3 :Category;
# A category this resource belongs to. If a resource was not assigned a category this is empty,
# see the definition of [`Category`](struct::Category) for details.
metadata @5 :Map(Text, Metadata);
metadata @4 :Map(Text, Metadata);
# Metadata associated with this resource. This can be things like links to wikis or similar.
# Common keys are pre-defined as constants in this file.
}

View File

@ -6,6 +6,8 @@ $CSharp.namespace("FabAccessAPI.Schema");
using import "resource.capnp".Resource;
using import "resource.capnp".RestoredResource;
using import "claim.capnp".Claim;
using import "utils.capnp".SturdyRef;
using import "utils.capnp".Fallible;
interface Resources {
restore @0 () -> ( resources :List(RestoredResource) );
@ -23,5 +25,9 @@ interface Resources {
getByUrl @4 ( url :Text ) -> ( resource :Resource );
# Returns a NULL capability if the resource doesn't exist or a user doesn't have read permission for that resource.
acceptToken @5 ( token :SturdyRef ) -> Fallible(Claim, Error(Void));
acceptToken @5 ( token :SturdyRef ) -> Fallible(Claim, AcceptTokenError);
struct AcceptTokenError {
permissionDenied @0 :Void;
}
}

View File

@ -1,4 +1,4 @@
@0xc0542f62613a5c5e
@0xc0542f62613a5c5e;
using CSharp = import "programming_language/csharp.capnp";
$CSharp.namespace("FabAccessAPI.Schema");
@ -10,6 +10,6 @@ interface TraitSuper {
struct TraitError(ConstraintError) {
union {
permissionFailed @0 :Void;
constraintViolation @1 ( error :ConstraintError);
constraintViolation @1 :ConstraintError;
}
}

View File

@ -1,11 +1,12 @@
@0x80d4a09e28022edb;
using CSharp = import "programming_language/csharp.capnp";
using CSharp = import "../programming_language/csharp.capnp";
$CSharp.namespace("FabAccessAPI.Schema");
using import "traits.capnp".TraitSuper;
using import "utils.capnp".Fallible;
using import "traits_error.capnp".TraitError;
using import "../traits.capnp".TraitSuper;
using import "../traits.capnp".TraitError;
using import "../utils.capnp".Fallible;
using import "../utils.capnp".L10NString;
# OID for this trait: 1.3.6.1.4.1.61783.612.1.3
# │ │ │ │
@ -21,7 +22,7 @@ interface TraitCheckable extends (TraitSuper) {
getState @0 () -> StateCheckable;
turnOn @1 () -> Fallible(TraitCheckable, TraitError(StateCheckable));
turnOff @2 () -> Fallible(TraitCheckable, TraitError(StateCheckable));
giveBack @3 () -> Fallible(TraitCheckable, TraitError(StateCheckable));;
giveBack @3 () -> Fallible(TraitCheckable, TraitError(StateCheckable));
accept @4 () -> Fallible(TraitCheckable, TraitError(StateCheckable));
reject @5 ( reason :Text, reason_lang :Text ) -> Fallible(TraitCheckable, TraitError(StateCheckable));
}

View File

@ -1,12 +1,12 @@
@0xccad643c8c6f6b25;
using CSharp = import "programming_language/csharp.capnp";
using CSharp = import "../programming_language/csharp.capnp";
$CSharp.namespace("FabAccessAPI.Schema");
using import "traits.capnp".TraitSuper;
using import "utils.capnp".Fallible;
using import "utils.capnp".Duration;
using import "traits_error.capnp".TraitError;
using import "../traits.capnp".TraitSuper;
using import "../traits.capnp".TraitError;
using import "../utils.capnp".Fallible;
using import "../utils.capnp".Duration;
# OID for this trait: 1.3.6.1.4.1.61783.612.1.2
# │ │ │ │
@ -27,8 +27,8 @@ interface TraitDoorable extends (TraitSuper) {
struct StateDoorable {
union {
Closed @0 :Void;
Open @1 :Void;
TempOpen @2 :Void;
closed @0 :Void;
open @1 :Void;
tempOpen @2 :Void;
}
}

View File

@ -1,12 +1,12 @@
@0x9fa2b43397f34e02;
using CSharp = import "programming_language/csharp.capnp";
using CSharp = import "../programming_language/csharp.capnp";
$CSharp.namespace("FabAccessAPI.Schema");
using import "traits.capnp".TraitSuper;
using import "utils.capnp".Fallible;
using import "utils.capnp".Duration;
using import "traits.capnp".TraitError;
using import "../traits.capnp".TraitSuper;
using import "../traits.capnp".TraitError;
using import "../utils.capnp".Fallible;
using import "../utils.capnp".Duration;
# OID for this trait: 1.3.6.1.4.1.61783.612.1.5
# │ │ │ │
@ -20,9 +20,13 @@ using import "traits.capnp".TraitError;
interface TraitLocateable extends (TraitSuper) {
getState @0 () -> ();
identify @1 ( time :Duration ) -> Fallible(TraitLocateable, TraitError(Void));
setActive @2 () -> Fallible(TraitLocateable, TraitError(Void));
setIdle @2 () -> Fallible(TraitLocateable, TraitError(Void));
identify @1 ( time :Duration ) -> Fallible(TraitLocateable, TraitError(ErrorLocateable));
setActive @2 () -> Fallible(TraitLocateable, TraitError(ErrorLocateable));
setIdle @3 () -> Fallible(TraitLocateable, TraitError(ErrorLocateable));
}
struct ErrorLocateable {
}
struct StateLocateable {

View File

@ -1,11 +1,11 @@
@0x82abdb5c1dcf399d;
using CSharp = import "programming_language/csharp.capnp";
using CSharp = import "../programming_language/csharp.capnp";
$CSharp.namespace("FabAccessAPI.Schema");
using import "traits.capnp".TraitSuper;
using import "utils.capnp".Fallible;
using import "traits_error.capnp".TraitError;
using import "../traits.capnp".TraitSuper;
using import "../traits.capnp".TraitError;
using import "../utils.capnp".Fallible;
# OID for this trait: 1.3.6.1.4.1.61783.612.1.4
# │ │ │ │
@ -19,7 +19,7 @@ using import "traits_error.capnp".TraitError;
interface TraitLocker extends (TraitSuper) {
getState @0 () -> StateLocker;
engage @1 () -> Fallible(TraitLocker, TraitError(ErrorLocker))
engage @1 () -> Fallible(TraitLocker, TraitError(ErrorLocker));
unengage @2 () -> Fallible(TraitLocker, TraitError(ErrorLocker));
}

View File

@ -1,11 +1,11 @@
@0xbab3de8275be2271;
using CSharp = import "programming_language/csharp.capnp";
using CSharp = import "../programming_language/csharp.capnp";
$CSharp.namespace("FabAccessAPI.Schema");
using import "traits.capnp".TraitSuper;
using import "utils.capnp".Fallible;
using import "traits_error.capnp".TraitError;
using import "../traits.capnp".TraitSuper;
using import "../utils.capnp".Fallible;
using import "../traits.capnp".TraitError;
# OID for this trait: 1.3.6.1.4.1.61783.612.1.1
# │ │ │ │
@ -25,7 +25,7 @@ interface TraitPowerable extends (TraitSuper) {
struct StatePowerable {
union {
Off @0 :Void;
On @1 :Void;
off @0 :Void;
on @1 :Void;
}
}

View File

@ -4,6 +4,8 @@ using CSharp = import "programming_language/csharp.capnp";
$CSharp.namespace("FabAccessAPI.Schema");
using import "role.capnp".Role;
using import "projects.capnp".Project;
using import "utils.capnp".Fallible;
interface User {
# Intergalactic lifeform that wants to use BFFH
@ -18,14 +20,27 @@ interface User {
# lists explicit roles for this user. A session may have a number of additional, implicit,
# roles set by their choice of authentication or other context.
projects @3 () -> ( projects :List(Project) );
projects @7 () -> ( projects :List(Project) );
selfservice @3 () -> ( selfservice :SelfService );
interface SelfService {
changepw @0 ( old :Text, new :Text ) -> Fallible(Void, Void);
changePin @1 ( currentPassword :Text, newPin :List(u64) ) -> Fallible(Void, Void)
changepw @0 ( old :Text, new :Text ) -> Fallible(ChangeOk, ChangePwError);
changePin @1 ( currentPassword :Text, newPin :List(UInt64) ) -> Fallible(ChangeOk, ChangePinError);
struct ChangeOk {
}
struct ChangePwError {
}
struct ChangePinError {
}
}
manage @4 () -> ( manage :Manage );
interface Manage $CSharp.name("ManageInterface") {
addRole @0 ( role :Role );

View File

@ -4,33 +4,43 @@ using CSharp = import "programming_language/csharp.capnp";
$CSharp.namespace("FabAccessAPI.Schema");
using import "user.capnp".User;
using import "utils.capnp".Fallible;
interface Users {
list @0 () -> ( users :List(User) );
addUser @1 ( username :Text ) -> ( user :User, initialPassword :Text, error :Error );
# Add a new user. If adding the user succeeds then the newly created user is returned and
# `error` is NULL / set to Error::ok. If adding the user fails `user` is NULL and `error`
# contains the reason for the failure.
addUser @1 ( username :Text ) -> Fallible(AddUserOk, AddUserError);
struct AddUserOk {
user @0 :User;
initialPassword @1 :Text;
}
struct AddUserError {
union {
ok @0 :Void;
# This error is not actually set, i.e. the operation completed successfully.
# This field is necessary because a NULL struct pointer may be interpreted as a struct with
# default values. In that case this will appear as an `Error` with the `ok` field set.
removeUser @2 ( user :User ) -> Fallible(Void, Void);
}
exists @1 :Void;
# There is already an user with the requested username
struct Error {
union {
ok @0 :Void;
# This error is not actually set, i.e. the operation completed successfully.
# This field is necessary because a NULL struct pointer may be interpreted as a struct with
# default values. In that case this will appear as an `Error` with the `ok` field set.
usernameInvalid @2 :Void;
# The provided username is not usable, e.g. contains invalid characters, is too long, or too
# short.
exists @1 :Void;
# There is already an user with the requested username
passwordInvalid @3 :Void;
# The provided password is not usable, e.g. it's zero-length.
}
}
usernameInvalid @2 :Void;
# The provided username is not usable, e.g. contains invalid characters, is too long, or too
# short.
removeUser @2 ( user :User ) -> Fallible(RemoveUserOk, RemoveUserError);
struct RemoveUserOk {
passwordInvalid @3 :Void;
# The provided password is not usable, e.g. it's zero-length.
}
struct RemoveUserError {
union {
permissionDenied @0 :Void;
userAlreadyDeleted @1 :Void;
}
}
}

View File

@ -90,3 +90,9 @@ struct Duration {
seconds @0 :UInt64;
nanoseconds @1 :UInt64;
}
using SturdyRef = Data;
struct When {
# TODO: define this
}