This commit is contained in:
Nadja von Reitzenstein Čerpnjak 2024-04-16 15:54:47 +02:00
parent d28a3ea5aa
commit 8f9770ac22
6 changed files with 87 additions and 4 deletions

View File

@ -24,7 +24,7 @@ interface Claimable {
}
interface Lockable {
lock @0 ( message :Text ) -> ( lock :Lock );
lock @0 ( message_lang :Text, message :Text ) -> ( lock :Lock );
# Take exclusive access to a resource, disowning all other claims on this
# resource.
#

View File

@ -20,8 +20,6 @@ interface Interestable {
queueFull @2 :Void;
}
}
getInterests @2 () -> ( interests :List(Interest) );
# WARNING: Impersonates users
}
interface Interest extends (Owned) {
@ -30,3 +28,10 @@ interface Interest extends (Owned) {
drop @2 ();
upgrade @3 () -> ( claim :Claim );
}
struct InterestKind {
union {
Queue @0 :UInt64;
Reservation @1 :When;
}
}

View File

@ -13,6 +13,9 @@ interface Notifiable {
state @0 () -> ( state :Map(OID, AnyPointer) );
# Returns the current state of a resource.
getStateOid @4 ( oid :OID ) -> AnyPointer;
# Return only the state of the trait with the given OID
subscribe @1 ( subscriber :Subscriber(Update) ) -> ( subscription :Subscription );
# Subscribe to state updates. The passed in `subscriber` is an interface implemented on the
# client side that a server calls to send update notifications.

View File

@ -27,6 +27,10 @@ interface Resources {
acceptToken @5 ( token :SturdyRef ) -> Fallible(Claim, AcceptTokenError);
setAlias @6 ( original_resource_id :Text ) -> ( alias_id :Text );
# Replace any set alias for the given resource id with a newly generated
# random id. The new ID is returned as `alias_id`.
struct AcceptTokenError {
permissionDenied @0 :Void;
}

64
traits/claimable.capnp Normal file
View File

@ -0,0 +1,64 @@
@0xcdb148188bb77a8e;
using CSharp = import "../programming_language/csharp.capnp";
$CSharp.namespace("FabAccessAPI.Schema");
using import "../traits.capnp".TraitSuper;
using import "../traits.capnp".TraitError;
using import "../utils.capnp".Fallible;
using import "../utils.capnp".L10NString;
using import "../claim.capnp".Claim;
using import "../claim.capnp".Lock;
using import "../owned.capnp".Owned;
using import "../interest.capnp".Interest;
using import "../interest.capnp".InterestKind;
# OID for this trait: 1.3.6.1.4.1.61783.612.1.0
# │ │ │ │
# RLKM UG PEN ╯ │ │ │
# │ │ │
# FabAccess subtree ╯ │ │
# │ │
# Traits ╯ │
# │
# Claimable ╯
interface TraitClaimable extends (TraitSuper) {
getState @0 () -> StateClaimable;
}
struct StateClaimable {
claims @0 :List(ClaimView);
maxClaims @1 :UInt64;
interests @2 :List(InterestView);
lock @3 :LockView;
}
struct ClaimView {
claim @0 :Claim;
# NULL if caller lacks impersonate permission.
# The list is still populated, so the number of entries is the number of
# currently outstanding claims.
owner @1 :Owned;
# NULL if caller lacks manage permission.
}
struct InterestView {
interest @0 :Interest;
# NULL if caller lacks impersonate permission.
# The list is still populated, so the number of entries is the number of
# currently outstanding interests.
owner @1 :Owned;
# NULL if caller lacks manage permission.
kind @2 :InterestKind;
}
struct LockView {
isLocked @0 :Bool;
lock @0 :Lock;
# NULL if caller lacks impersonate permission.
lockReason @1 :L10NString;
# Only set if resource is locked *and* a lock reason was set.
}

View File

@ -91,8 +91,15 @@ struct Duration {
nanoseconds @1 :UInt64;
}
struct Timestamp {
# An UNIX timestamp in the UTC timezone
seconds @0 :Int64;
nanoseconds @1 :UInt64;
}
using SturdyRef = Data;
struct When {
# TODO: define this
start @0 :Timestamp;
end @1 :Timestamp;
}