api.fabaccess-api/claim.capnp

88 lines
2.8 KiB
Cap'n Proto
Raw Normal View History

2022-10-31 15:19:56 +01:00
@0xf8f8864ba0678056;
using CSharp = import "programming_language/csharp.capnp";
$CSharp.namespace("FabAccessAPI.Schema");
2024-04-16 15:12:44 +02:00
using import "owned.capnp".Owned;
using import "resource.capnp".Resource;
using import "notify.capnp".Notifiable;
2024-04-16 15:03:10 +02:00
using import "interest.capnp".Interest;
using import "utils.capnp".Fallible;
using import "utils.capnp".OID;
using import "utils.capnp".Map;
2024-04-16 15:03:10 +02:00
using import "utils.capnp".SturdyRef;
2024-04-15 16:28:23 +02:00
using import "projects.capnp".Project;
2022-10-31 15:19:56 +01:00
2022-11-01 12:11:53 +01:00
interface Claimable {
2024-04-15 16:28:23 +02:00
claim @0 ( project :Project ) -> Fallible(Claim, ClaimError);
2024-03-30 19:20:42 +01:00
# Returns NULL if the resource is *currently* not claimable.
# Disown the returned claim capability to unclaim it.
2024-04-15 16:28:23 +02:00
struct ClaimError {
2024-04-16 15:03:10 +02:00
locked @0 :Text;
}
2022-10-31 15:19:56 +01:00
}
2022-11-01 12:11:53 +01:00
interface Lockable {
2024-04-16 15:54:47 +02:00
lock @0 ( message_lang :Text, message :Text ) -> ( lock :Lock );
2024-03-01 15:39:30 +01:00
# Take exclusive access to a resource, disowning all other claims on this
# resource.
2022-11-01 12:11:53 +01:00
#
2024-03-01 15:39:30 +01:00
# On resources that do not allow concurrent claims to exist this method
# behaves similar to `claim`, however it will also succeed if a resource is
# already claimed, disowning the previous claim. On resources that do
# allow concurrent claims this method will disown all current claims on a
# resource and prevent new claims from being granted until the returned
# Lock capability is dropped. A call to `lock` on a resource that is
# already locked will succeed, invalidating the former lock.
2022-11-01 12:11:53 +01:00
}
2024-04-16 15:12:44 +02:00
interface Claim extends (Notifiable, Owned) {
2024-03-27 19:43:37 +01:00
resource @0 () -> ( resource :Resource, dummy :UInt8 = 0 );
# Pointer back to the resource this claim comes from. Primarily useful when restoring persisted
# claims or restoring after a connection failure.
2022-11-01 11:54:01 +01:00
traits @1 () -> Map(OID, AnyPointer);
2024-04-16 15:03:10 +02:00
disown @2 () -> Fallible(DisownOk, DisownError);
2024-04-15 16:28:23 +02:00
# Disown this claim TODO define ConstraintViolation type -> Dependencies!
2024-04-16 15:03:10 +02:00
struct DisownOk {
2024-04-16 14:37:41 +02:00
2024-04-16 15:03:10 +02:00
}
2024-04-16 14:37:41 +02:00
2024-04-16 15:03:10 +02:00
struct DisownError {
union {
dependency @0 :List(Claim);
badState @1 :Void;
}
2024-04-16 14:37:41 +02:00
}
2024-04-16 15:03:10 +02:00
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) );
2022-10-31 15:19:56 +01:00
}
2022-11-01 12:11:53 +01:00
2024-04-16 15:12:44 +02:00
interface Lock extends (Claim, Owned) {
2022-11-01 12:11:53 +01:00
# An exclusive claim on a resource. Only a single Lock may exist for any given resource.
downgrade @0 () -> ( claim :Claim );
# Downgrade a lock to a claim, allowing additional claims to be granted on resources that allow
2022-11-01 12:44:33 +01:00
# for concurrent access. Calling this capability will invalidate the Lock capability.
2022-11-01 12:11:53 +01:00
}