Class AgentGrants

java.lang.Object
com.axelor.ai.agent.AgentGrants

public final class AgentGrants extends Object
An agent's permissions, as entries: what an agent file's permissions lists and what the Agent Builder sets, one entry per object — "*" for every operation on every model, "Order read update" for those operations on one.
  • Method Details

    • parse

      public static List<AgentGrants.Grant> parse(Collection<String> entries)
      The entries, read: each an object and the operations it grants, none naming all four. An entry naming an object twice merges.
      Throws:
      IllegalArgumentException - naming every entry that names nothing or an unknown operation
    • of

      public static List<AgentGrants.Grant> of(AiAgent agent)
      The agent's permissions, by object.
    • replace

      public static void replace(AiAgent agent, List<AgentGrants.Grant> grants)
      Replaces the agent's permissions with these, in place: a row on an object both name keeps its id and takes the new operations, since inserting its replacement before removing it would break the unique object per agent. The agent must be saved after.
    • validate

      public static void validate(AiAgent agent)
      Keeps the agent's rows canonical: each object as PermissionObjects.canonical(java.lang.String) gives it, and named once.
      Throws:
      IllegalArgumentException - naming every row that names nothing, or an object twice
    • entries

      public static List<String> entries(List<AgentGrants.Grant> grants)
      The entries as an agent file lists them.