diff --git a/claim.capnp b/claim.capnp index e853550..8459f33 100644 --- a/claim.capnp +++ b/claim.capnp @@ -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. # diff --git a/interest.capnp b/interest.capnp index e18cb32..3bc4dbc 100644 --- a/interest.capnp +++ b/interest.capnp @@ -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; + } +} diff --git a/notify.capnp b/notify.capnp index 46f86d7..f2ddaaf 100644 --- a/notify.capnp +++ b/notify.capnp @@ -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. diff --git a/resources.capnp b/resources.capnp index 19ebfe3..e8d05c4 100644 --- a/resources.capnp +++ b/resources.capnp @@ -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; } diff --git a/traits/claimable.capnp b/traits/claimable.capnp new file mode 100644 index 0000000..3718560 --- /dev/null +++ b/traits/claimable.capnp @@ -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. +} diff --git a/utils.capnp b/utils.capnp index ea459db..4ea8b81 100644 --- a/utils.capnp +++ b/utils.capnp @@ -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; }