N-times usage policy implementation #5005
Unanswered
carlosperezdengra777
asked this question in
Q&A
Replies: 2 comments 3 replies
-
@carlosperezdengra777 any reason why you reopened the exact same discussion as #5000 again? |
Beta Was this translation helpful? Give feedback.
1 reply
-
Transfer processes do not necessarily mean the number of times a particular asset has been accessed or downloaded. It depends on how data access is modelled. Also, you should go back over the documentation to understand the relationship between a transfer process, a contract agreement, and a contract negotiation. To be honest, this use case seems contrived. What are you trying to achieve? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Question: Implementing a usage-based access policy in EDC
Hello,
I'm currently working on a custom policy evaluation function that restricts access to an asset once it has been used more than N times (e.g., N successful transfers). I'm following the recommended pattern by:
resources/<...>/extensions.policy
PolicyFunctionsExtension
classUsageCountConstraintFunction
that retrieves the number of completed transfers for a givenassetId
My function currently tries to call the
/transferprocesses/request
API to count how many completed transfers exist for a given asset:However, the evaluation function is not triggered or doesn't behave as expected — I don't see it being logged even when policies are evaluated during negotiation. Regarding this topic, I have a few questions:
1.- Is it correct to assume that the number of "accesses" means the number of completed transfer processes, and not just contract negotiations?
2.- Is there a supported or recommended way to access assetId and connectorId inside the evaluation function during contract negotiation?
3.- I tried context.getContextData(...) but those values are not available at that point — as expected.
4.- I noticed that the sample LocationConstraintFunction uses claims configured externally (e.g., via the participant agent). Is this the only reliable way to inject dynamic context values into the policy evaluation at negotiation time?
5.- Finally, is calling an external API like /transferprocesses/request inside a policy evaluation function considered an anti-pattern? Or is there a more idiomatic way in EDC to query internal transfer state for policy logic?
Thank you very much in advance — any guidance, clarification or examples are greatly appreciated!
Similar questions have been related: #4032, but do not satisfy the reason of the consultation.
Beta Was this translation helpful? Give feedback.
All reactions