Just a few additions to the PBJ (PBCS REST API Java Library) regarding substitution variables. All of the new functionality is added to the
PbcsApplication interface, for now. Since variables can exist in a specific plan type, it may make sense in the future to add a new interface/implementation that models a specific plan type. Anyway, here are the four new methods for now:
/** * Gets all substitution variables in the application * * @return a list of the substitution variables, an empty list if there are * none */ public Set<SubstitutionVariable> getSubstitutionVariables(); /** * Fetch a substitution variable with a particular name from this * application * * @param name the name of the variable to fetch * @return the variable object, if it exists * @throws PbcsNoSuchVariableException if the variable does not exist */ public SubstitutionVariable getSubstitutionVariable(String name); /** * Update a set of substitution variables. This does not replace all of the * variables in the application, it just updates the ones that have been * specified in the collection (contrary to what the REST API docs seem to * imply) * * @param variables the variables to update */ public void updateSubstitutionVariables(Collection<SubstitutionVariable> variables); /** * Convenience method to update a single substitution variable value. * * @param name the name of the variable * @param value the value of the variable */ public void updateSubstitutionVariable(String name, String value);
A few things to note:
getSubstitutionVariablesmethod returns a
Set<SubstitutionVariable>, as opposed to a List. Since a variable should be unique with respect to its combination of plan type, name, and value, a Set makes a little more sense here because the ordering implied by a List is irrelevant
- All methods work with/return a
SubstitutionVariableobject. This is a new POJO class with three fields:
- You can fetch just a single substitution variable by name as a convenience method. Although there is a technically a specific REST API endpoint for doing so, right now it just calls the other method and filters it.
- You can update a set of variables
- As a convenience, you can update a single variable/value for all plan types using the
updateSubstitutionVariable(String name, String value)method.
The PBJ CLI (an “über” JAR that is runnable an implements a basic CLI to PBCS) has also gotten a couple of updates to reflect the new capabilities in the library. For example, you can quickly list all variables in an app:
java -jar pbj-pbcs-client-1.0.4-jar --conn-properties pbcs-client.properties list-variables --application=Vision
And get a list back:
And as an added bonus, you can even provide your own format string if you want. This might help for people doing automation and need to get the data into a particular format with having to do some weird batch/shell string tweaks:
java -jar pbj-pbcs-client-1.0.4-jar --conn-properties pbcs-client.properties list-variables --application=Vision --format=%s|%s|%s%n
All For Now
These latest updates are in the 1.0.4 branch of the PBJ GitHub repository. You can clone it and build your own copy of the library and runnable CLI JAR (if you’re so inclined) by checking that out. Eventually this branch will be merged into the master, pending more testing.