Class PlanBuilder


  • public class PlanBuilder
    extends Object
    A fluent builder for provisioning plans, especially useful for quickly writing rules or test cases.

    Import the methods from this class statically and begin with one of the plan() methods. The builder model will enforce only calling appropriate operations in any given context.

    The interfaces nested within this class will be used to implement a chain of modifiers to the ‘current’ object.

    Example:

    ProvisioningPlan plan =
      PlanBuilder.plan(existingLink,
        removeAllValues(existingLink, "emails"),
        attribute("firstName", set("John")));
    

    This results in a ProvisioningPlan containing an AccountRequest to modify the given account. The AccountRequest contains AttributeRequests to remove all existing values from ‘email’ and to set the ‘firstName’ attribute to ‘John’.

    • Method Detail

      • application

        public static PlanBuilder.AccountRequestModifier application​(String application)
        Returns an AccountRequestModifier that sets the application on the account request
        Parameters:
        application - The application name
        Returns:
        The AccountRequestModifier
      • argument

        public static PlanBuilder.AnyModifier argument​(String name,
                                                       Object value)
        Returns a modifier for any object that adds an argument to the object’s arguments Map.

        This method works on plans, requests, and attributes.

        Parameters:
        name - The argument name
        value - The argument value
        Returns:
        The modifier
      • identity

        public static PlanBuilder.PlanModifier identity​(sailpoint.object.Identity identity)
        Sets the identity on the plan to the given identity
        Parameters:
        identity - The identity to set
        Returns:
        A plan modifier that changes the plan Identity
      • identity

        public static PlanBuilder.PlanModifier identity​(String idOrName)
                                                 throws sailpoint.tools.GeneralException
        Creates a plan modifier that sets the identity on the plan to the identity with the given name or ID
        Parameters:
        idOrName - The identity name or ID
        Returns:
        The plan modifier
        Throws:
        sailpoint.tools.GeneralException - if the identity cannot be found
      • operation

        public static PlanBuilder.OperationModifier operation​(String op)
        Creates an OperationModifier that sets the operation on the account request or attribute request
        Parameters:
        op - The operation to set, as a string
        Returns:
        The OperationModifier
      • operation

        public static PlanBuilder.AttributeRequestModifier operation​(sailpoint.object.ProvisioningPlan.Operation operation)
        Creates an AttributeRequestModifier that sets the operation on the attribute request
        Parameters:
        operation - The operation to set
        Returns:
        The AttributeRequestModifier
      • operation

        public static PlanBuilder.AccountRequestModifier operation​(sailpoint.object.ProvisioningPlan.AccountRequest.Operation operation)
        Creates an AccountRequestModifier that sets the operation on the account request
        Parameters:
        operation - The operation to set
        Returns:
        The AccountRequestModifier
      • plan

        public static sailpoint.object.ProvisioningPlan plan​(sailpoint.object.Link toModify,
                                                             PlanBuilder.ExistingLinkModifier... modifiers)
                                                      throws sailpoint.tools.GeneralException
        Creates a provisioning plan based on the given link and any modifiers.

        This method is one of the entry points to the PlanBuilder.

        Parameters:
        toModify - The link to modify
        modifiers - Any modifiers to apply to the plan or account request
        Returns:
        The resulting plan
        Throws:
        sailpoint.tools.GeneralException - if anything goes wrong
      • plan

        public static sailpoint.object.ProvisioningPlan plan​(PlanBuilder.PlanModifier... planModifiers)
                                                      throws sailpoint.tools.GeneralException
        Creates a provisioning plan based on the given modifiers.

        This method is one of the entry points to the PlanBuilder.

        Parameters:
        planModifiers - Any modifiers to apply to the plan
        Returns:
        The resulting plan
        Throws:
        sailpoint.tools.GeneralException - if anything goes wrong
      • removeAllValues

        public static PlanBuilder.AccountRequestModifier removeAllValues​(sailpoint.object.Link existing,
                                                                         String field)
        Generates a complex AccountRequestModifier that removes all existing values from the given field
        Parameters:
        existing - The Link from which to extract existing values
        field - The field to remove values from
        Returns:
        The AccountRequestModifier
      • set

        public static PlanBuilder.AttributeRequestModifier set​(Object value)
        Shortcut for ‘operation(“Set”), value(value)’
        Parameters:
        value - The value to set in the attribute request
        Returns:
        The AttributeRequestModifier
      • value

        public static PlanBuilder.AttributeRequestModifier value​(Object... values)
        Adds the given value(s) to the Plan.

        If only one value is passed, it will be added as a single value. If value() is called more than once, if more than one value is passed, or if the attribute request already has a value, it will be transformed into a list and merged.

        Parameters:
        values - The values
        Returns:
        The input