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"; using CSharp = import "programming_language/csharp.capnp";
$CSharp.namespace("FabAccessAPI.Schema"); $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 "resource.capnp".Resource;
using import "notify.capnp".Notifiable; using import "notify.capnp".Notifiable;
using import "interest.capnp".Interest;
using import "utils.capnp".Fallible; using import "utils.capnp".Fallible;
using import "utils.capnp".OID; using import "utils.capnp".OID;
using import "utils.capnp".Map; using import "utils.capnp".Map;
using import "utils.capnp".SturdyRef;
using import "projects.capnp".Project; using import "projects.capnp".Project;
interface Claimable { interface Claimable {
@ -20,19 +18,12 @@ interface Claimable {
# Disown the returned claim capability to unclaim it. # Disown the returned claim capability to unclaim it.
struct ClaimError { struct ClaimError {
union {
locked @0 :Text; locked @0 :Text;
} }
}
} }
interface Lockable { interface Lockable {
restore @0 ( ) -> ( lock :Lock ); lock @0 ( message :Text ) -> ( 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 );
# Take exclusive access to a resource, disowning all other claims on this # Take exclusive access to a resource, disowning all other claims on this
# resource. # resource.
# #
@ -52,20 +43,38 @@ interface Claim extends (Notifiable) {
traits @1 () -> Map(OID, AnyPointer); traits @1 () -> Map(OID, AnyPointer);
disown @2 () -> Fallible(Void, Error(DisownError)); disown @2 () -> Fallible(DisownOk, DisownError);
# Disown this claim TODO define ConstraintViolation type -> Dependencies! # Disown this claim TODO define ConstraintViolation type -> Dependencies!
makeTransferable @3 () -> Fallible(SturdyRef, Error(Void)); struct DisownOk {
makeLendable @4 () -> Fallible(( token :Sturdyref, returnToken :Interest ), Error(Void));
getDependencies @5 () -> ( dependencies: List(Claim) ); }
}
struct DisownError { struct DisownError {
union { union {
dependency @0 :List(Claim); dependency @0 :List(Claim);
badState @1 :Void; 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) );
} }
interface Lock extends (Claim) { interface Lock extends (Claim) {

View File

@ -3,9 +3,22 @@
using CSharp = import "programming_language/csharp.capnp"; using CSharp = import "programming_language/csharp.capnp";
$CSharp.namespace("FabAccessAPI.Schema"); $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 { interface Interestable {
queue @0 () -> Fallible(Interest, Error(Void)); queue @0 () -> Fallible(Interest, ReserveError);
reserve @1 ( when :When ) -> Fallible(Interest, Error(Void)); reserve @1 ( when :When ) -> Fallible(Interest, ReserveError);
struct ReserveError {
union {
permissionDenied @0 :Void;
reserveOverlapping @1 :Void;
queueFull @2 :Void;
}
}
getInterests @2 () -> ( interests :List(Interest) ); getInterests @2 () -> ( interests :List(Interest) );
# WARNING: Impersonates users # 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".OID;
using import "utils.capnp".Map; using import "utils.capnp".Map;
using import "state.capnp".Update; using import "state.capnp".Update;
using import "measure.capnp".Measurement;
interface Notifiable { interface Notifiable {
state @0 () -> ( state :Map(OID, AnyPointer) ); 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 # Subscribe to state updates. The passed in `subscriber` is an interface implemented on the
# client side that a server calls to send update notifications. # 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 ); subscribeMeasurements @3 ( subscriber :Subscriber(Measurement) ) -> ( subscription: Subscription );
} }

View File

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

View File

@ -3,13 +3,13 @@
using CSharp = import "programming_language/csharp.capnp"; using CSharp = import "programming_language/csharp.capnp";
$CSharp.namespace("FabAccessAPI.Schema"); $CSharp.namespace("FabAccessAPI.Schema");
# TODO: removed SturdyRef to build API in C#
# using import "persistent.capnp".Persistent;
using import "notify.capnp".Notifiable; using import "notify.capnp".Notifiable;
using import "interest.capnp".Interestable; using import "interest.capnp".Interestable;
using import "interest.capnp".Interest;
using import "claim.capnp".Claimable; using import "claim.capnp".Claimable;
using import "claim.capnp".Claim;
using import "claim.capnp".Lockable; using import "claim.capnp".Lockable;
using import "claim.capnp".Lock;
using import "audit.capnp".Auditable; using import "audit.capnp".Auditable;
using import "utils.capnp".OID; using import "utils.capnp".OID;
@ -57,25 +57,25 @@ struct Resource {
} }
struct Description { 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 # 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. # 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 # 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 # 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 # further identifying information or important information that users should be actively shown
# when selecting this resource. # 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 # The 'type' of Resource. Each OID in the list specifies certain behaviours that this Resource
# follows. # follows.
category @4 :Category; category @3 :Category;
# A category this resource belongs to. If a resource was not assigned a category this is empty, # 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. # 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. # 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. # 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".Resource;
using import "resource.capnp".RestoredResource; using import "resource.capnp".RestoredResource;
using import "claim.capnp".Claim; using import "claim.capnp".Claim;
using import "utils.capnp".SturdyRef;
using import "utils.capnp".Fallible;
interface Resources { interface Resources {
restore @0 () -> ( resources :List(RestoredResource) ); restore @0 () -> ( resources :List(RestoredResource) );
@ -23,5 +25,9 @@ interface Resources {
getByUrl @4 ( url :Text ) -> ( resource :Resource ); 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. # 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"; using CSharp = import "programming_language/csharp.capnp";
$CSharp.namespace("FabAccessAPI.Schema"); $CSharp.namespace("FabAccessAPI.Schema");
@ -10,6 +10,6 @@ interface TraitSuper {
struct TraitError(ConstraintError) { struct TraitError(ConstraintError) {
union { union {
permissionFailed @0 :Void; permissionFailed @0 :Void;
constraintViolation @1 ( error :ConstraintError); constraintViolation @1 :ConstraintError;
} }
} }

View File

@ -1,11 +1,12 @@
@0x80d4a09e28022edb; @0x80d4a09e28022edb;
using CSharp = import "programming_language/csharp.capnp"; using CSharp = import "../programming_language/csharp.capnp";
$CSharp.namespace("FabAccessAPI.Schema"); $CSharp.namespace("FabAccessAPI.Schema");
using import "traits.capnp".TraitSuper; using import "../traits.capnp".TraitSuper;
using import "utils.capnp".Fallible; using import "../traits.capnp".TraitError;
using import "traits_error.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 # 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; getState @0 () -> StateCheckable;
turnOn @1 () -> Fallible(TraitCheckable, TraitError(StateCheckable)); turnOn @1 () -> Fallible(TraitCheckable, TraitError(StateCheckable));
turnOff @2 () -> 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)); accept @4 () -> Fallible(TraitCheckable, TraitError(StateCheckable));
reject @5 ( reason :Text, reason_lang :Text ) -> Fallible(TraitCheckable, TraitError(StateCheckable)); reject @5 ( reason :Text, reason_lang :Text ) -> Fallible(TraitCheckable, TraitError(StateCheckable));
} }

View File

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

View File

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

View File

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

View File

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

View File

@ -4,6 +4,8 @@ using CSharp = import "programming_language/csharp.capnp";
$CSharp.namespace("FabAccessAPI.Schema"); $CSharp.namespace("FabAccessAPI.Schema");
using import "role.capnp".Role; using import "role.capnp".Role;
using import "projects.capnp".Project;
using import "utils.capnp".Fallible;
interface User { interface User {
# Intergalactic lifeform that wants to use BFFH # 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, # 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. # roles set by their choice of authentication or other context.
projects @3 () -> ( projects :List(Project) ); projects @7 () -> ( projects :List(Project) );
selfservice @3 () -> ( selfservice :SelfService ); selfservice @3 () -> ( selfservice :SelfService );
interface SelfService { interface SelfService {
changepw @0 ( old :Text, new :Text ) -> Fallible(Void, Void); changepw @0 ( old :Text, new :Text ) -> Fallible(ChangeOk, ChangePwError);
changePin @1 ( currentPassword :Text, newPin :List(u64) ) -> Fallible(Void, Void) changePin @1 ( currentPassword :Text, newPin :List(UInt64) ) -> Fallible(ChangeOk, ChangePinError);
struct ChangeOk {
} }
struct ChangePwError {
}
struct ChangePinError {
}
}
manage @4 () -> ( manage :Manage ); manage @4 () -> ( manage :Manage );
interface Manage $CSharp.name("ManageInterface") { interface Manage $CSharp.name("ManageInterface") {
addRole @0 ( role :Role ); addRole @0 ( role :Role );

View File

@ -4,19 +4,17 @@ using CSharp = import "programming_language/csharp.capnp";
$CSharp.namespace("FabAccessAPI.Schema"); $CSharp.namespace("FabAccessAPI.Schema");
using import "user.capnp".User; using import "user.capnp".User;
using import "utils.capnp".Fallible;
interface Users { interface Users {
list @0 () -> ( users :List(User) ); list @0 () -> ( users :List(User) );
addUser @1 ( username :Text ) -> ( user :User, initialPassword :Text, error :Error ); addUser @1 ( username :Text ) -> Fallible(AddUserOk, AddUserError);
# Add a new user. If adding the user succeeds then the newly created user is returned and struct AddUserOk {
# `error` is NULL / set to Error::ok. If adding the user fails `user` is NULL and `error` user @0 :User;
# contains the reason for the failure. initialPassword @1 :Text;
}
removeUser @2 ( user :User ) -> Fallible(Void, Void); struct AddUserError {
}
struct Error {
union { union {
ok @0 :Void; ok @0 :Void;
# This error is not actually set, i.e. the operation completed successfully. # This error is not actually set, i.e. the operation completed successfully.
@ -33,4 +31,16 @@ struct Error {
passwordInvalid @3 :Void; passwordInvalid @3 :Void;
# The provided password is not usable, e.g. it's zero-length. # The provided password is not usable, e.g. it's zero-length.
} }
}
removeUser @2 ( user :User ) -> Fallible(RemoveUserOk, RemoveUserError);
struct RemoveUserOk {
}
struct RemoveUserError {
union {
permissionDenied @0 :Void;
userAlreadyDeleted @1 :Void;
}
}
} }

View File

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