Package com.osohq.oso_cloud.querybuilder
Interface QueryComposer<T>
-
- All Known Subinterfaces:
AsyncQueryBuilder,QueryBuilder
- All Known Implementing Classes:
AsyncQueryBuilderImpl,QueryBuilderImpl
public interface QueryComposer<T>Fluent interface for building query conditions. Common functionality between the synchronous and asynchronous QueryBuilders.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Tand(java.lang.String predicate, QueryArg... args)Add another condition that must be true of the query results.Tin(TypedVar variable, java.util.List<java.lang.String> values)Constrain a query variable to be one of a set of values.TwithContextFacts(java.util.List<Fact> facts)Add context facts to the query.
-
-
-
Method Detail
-
and
T and(java.lang.String predicate, QueryArg... args)
Add another condition that must be true of the query results. For example:// Query for all the repos on which the user can perform read action, // and require the repos to belong to a specific folder TypedVar repo = new TypedVar("Repo"); List<String> authorizedReposInFolder = oso .buildQuery("allow", new Value("User", "user123"), new Value("read"), repo) .and("has_relation", repo, new Value("folder"), new Value("Folder", "folder456")) .evaluate(repo);- Parameters:
predicate- The predicate of the conditionargs- The arguments to the condition- Returns:
- A new QueryBuilder with the added condition
-
in
T in(TypedVar variable, java.util.List<java.lang.String> values)
Constrain a query variable to be one of a set of values. For example:TypedVar repo = new TypedVar("Repo"); TypedVar action = new TypedVar("String"); // Get all the actions a user can perform on specific repos List<String> authorizedActions = oso .buildQuery("allow", new Value("User", "user123"), action, repo) .in(repo, Arrays.asList("acme", "anvil")) .evaluate(action);- Parameters:
variable- The variable to constrainvalues- The set of allowed values for the constrained variable- Returns:
- A new QueryBuilder with the added constraint
- Throws:
java.lang.IllegalArgumentException- if the variable is not used in the query or values have already been set
-
-