Class PhilterClient

java.lang.Object
ai.philterd.philter.AbstractClient
ai.philterd.philter.PhilterClient

public class PhilterClient extends AbstractClient
Client class for Philter's API. Philter finds and manipulates sensitive information in text. This client targets the Philter 4.0.0 API. For more information on Philter see https://www.philterd.ai.

Instances are created with the PhilterClient.PhilterClientBuilder, for example:

PhilterClient client = new PhilterClient.PhilterClientBuilder()
        .withEndpoint("https://localhost:8080")
        .withApiKey("your-api-key")
        .build();

In addition to the checked IOException thrown when a request cannot be executed, the operation methods throw an unchecked UnauthorizedException on an HTTP 401, a ServiceUnavailableException on an HTTP 503, and a ClientException on any other non-successful response.

  • Field Details

    • DEFAULT_TIMEOUT_SEC

      public static final int DEFAULT_TIMEOUT_SEC
      See Also:
    • DEFAULT_MAX_IDLE_CONNECTIONS

      public static final int DEFAULT_MAX_IDLE_CONNECTIONS
      See Also:
    • DEFAULT_KEEP_ALIVE_DURATION_MS

      public static final int DEFAULT_KEEP_ALIVE_DURATION_MS
      See Also:
  • Method Details

    • filter

      public FilterResponse filter(String context, String policyName, String text) throws IOException
      Send text to Philter to be filtered.
      Parameters:
      context - The context. Contexts can be used to group text based on some arbitrary property.
      policyName - The name of the policy to apply to the text.
      text - The text to be filtered.
      Returns:
      The filtered text.
      Throws:
      IOException - Thrown if the request can not be completed.
    • filter

      public BinaryFilterResponse filter(String context, String policyName, String filename, File file) throws IOException
      Send a PDF document to Philter to be filtered.
      Parameters:
      context - The context. Contexts can be used to group text based on some arbitrary property.
      policyName - The name of the policy to apply to the document.
      filename - The name of the file being filtered. May be null.
      file - The PDF file to be filtered.
      Returns:
      The filtered document as a ZIP archive.
      Throws:
      IOException - Thrown if the request can not be completed.
    • explain

      public ExplainResponse explain(String context, String policyName, String text) throws IOException
      Send text to Philter to be filtered and get an explanation.
      Parameters:
      context - The context. Contexts can be used to group text based on some arbitrary property.
      policyName - The name of the policy to apply to the text.
      text - The text to be filtered.
      Returns:
      The filter ExplainResponse.
      Throws:
      IOException - Thrown if the request can not be completed.
    • compilePolicy

      public String compilePolicy(String policy) throws IOException
      Compiles a policy, returning the compiled representation.
      Parameters:
      policy - The policy to compile.
      Returns:
      The compiled policy.
      Throws:
      IOException - Thrown if the request can not be completed.
    • reidentify

      public String reidentify(String owner, ReidentifyRequest request) throws IOException
      Re-identifies previously redacted values.
      Parameters:
      owner - The owner of the values. May be null.
      request - The ReidentifyRequest.
      Returns:
      The re-identification result.
      Throws:
      IOException - Thrown if the request can not be completed.
    • health

      public StatusResponse health() throws IOException
      Gets the health of Philter. This endpoint does not require authentication.
      Returns:
      The StatusResponse.
      Throws:
      IOException - Thrown if the request can not be completed.
    • status

      public StatusResponse status() throws IOException
      Gets the status of Philter.
      Returns:
      The StatusResponse.
      Throws:
      IOException - Thrown if the request can not be completed.
    • getSigningKey

      public String getSigningKey() throws IOException
      Gets Philter's public signing key.
      Returns:
      The signing key.
      Throws:
      IOException - Thrown if the request can not be completed.
    • getPolicies

      public List<String> getPolicies() throws IOException
      Gets a list of policy names.
      Returns:
      A list of policy names.
      Throws:
      IOException - Thrown if the call can not be executed.
    • getPolicies

      public List<String> getPolicies(String owner, Integer offset, Integer limit) throws IOException
      Gets a list of policy names.
      Parameters:
      owner - The owner of the policies. May be null.
      offset - The pagination offset. May be null.
      limit - The pagination limit. May be null.
      Returns:
      A list of policy names.
      Throws:
      IOException - Thrown if the call can not be executed.
    • getPolicy

      public String getPolicy(String policyName) throws IOException
      Gets the content of a policy.
      Parameters:
      policyName - The name of the policy to get.
      Returns:
      The content of the policy as JSON.
      Throws:
      IOException - Thrown if the call can not be executed.
    • savePolicy

      public void savePolicy(String name, String json) throws IOException
      Saves (or overwrites) the policy.
      Parameters:
      name - The name of the policy.
      json - The body of the policy.
      Throws:
      IOException - Thrown if the call can not be executed.
    • deletePolicy

      public void deletePolicy(String policyName) throws IOException
      Deletes a policy.
      Parameters:
      policyName - The name of the policy to delete.
      Throws:
      IOException - Thrown if the call can not be executed.
    • getPolicyVersions

      public List<PolicyVersionSummary> getPolicyVersions(String policyName) throws IOException
      Gets the revision history for a policy.
      Parameters:
      policyName - The name of the policy.
      Returns:
      A list of PolicyVersionSummary.
      Throws:
      IOException - Thrown if the call can not be executed.
    • getPolicyVersion

      public String getPolicyVersion(String policyName, int revision) throws IOException
      Gets a specific revision of a policy.
      Parameters:
      policyName - The name of the policy.
      revision - The revision number.
      Returns:
      The policy content as JSON.
      Throws:
      IOException - Thrown if the call can not be executed.
    • getPolicyDiff

      public String getPolicyDiff(String policyName, int from, int to) throws IOException
      Gets the difference between two revisions of a policy.
      Parameters:
      policyName - The name of the policy.
      from - The starting revision number.
      to - The ending revision number.
      Returns:
      The difference.
      Throws:
      IOException - Thrown if the call can not be executed.
    • rollbackPolicy

      public PolicyRollbackResponse rollbackPolicy(String policyName, int revision) throws IOException
      Rolls a policy back to a prior revision.
      Parameters:
      policyName - The name of the policy.
      revision - The revision number to roll back to.
      Returns:
      The PolicyRollbackResponse.
      Throws:
      IOException - Thrown if the call can not be executed.
    • getContexts

      public String getContexts() throws IOException
      Gets the configured contexts.
      Returns:
      The contexts.
      Throws:
      IOException - Thrown if the call can not be executed.
    • createContext

      public GenericResponse createContext(String name, Boolean entityTypeDisambiguation, Boolean ledger) throws IOException
      Creates a context.
      Parameters:
      name - The name of the context.
      entityTypeDisambiguation - Whether entity type disambiguation is enabled. May be null.
      ledger - Whether the redaction ledger is enabled. May be null.
      Returns:
      A GenericResponse.
      Throws:
      IOException - Thrown if the call can not be executed.
    • getContext

      public String getContext(String name) throws IOException
      Gets a context by name.
      Parameters:
      name - The name of the context.
      Returns:
      The context.
      Throws:
      IOException - Thrown if the call can not be executed.
    • updateContext

      public GenericResponse updateContext(String name, Boolean entityTypeDisambiguation, Boolean ledger) throws IOException
      Updates a context.
      Parameters:
      name - The name of the context.
      entityTypeDisambiguation - Whether entity type disambiguation is enabled. May be null.
      ledger - Whether the redaction ledger is enabled. May be null.
      Returns:
      A GenericResponse.
      Throws:
      IOException - Thrown if the call can not be executed.
    • deleteContext

      public GenericResponse deleteContext(String name) throws IOException
      Deletes a context.
      Parameters:
      name - The name of the context.
      Returns:
      A GenericResponse.
      Throws:
      IOException - Thrown if the call can not be executed.
    • getContextEntries

      public String getContextEntries(String name) throws IOException
      Gets the entries for a context.
      Parameters:
      name - The name of the context.
      Returns:
      The context entries.
      Throws:
      IOException - Thrown if the call can not be executed.
    • deleteContextEntries

      public GenericResponse deleteContextEntries(String name) throws IOException
      Deletes all entries for a context.
      Parameters:
      name - The name of the context.
      Returns:
      A GenericResponse.
      Throws:
      IOException - Thrown if the call can not be executed.
    • exportContextEntries

      public String exportContextEntries(String name, String owner) throws IOException
      Exports the entries for a context.
      Parameters:
      name - The name of the context.
      owner - The owner. May be null.
      Returns:
      The exported entries.
      Throws:
      IOException - Thrown if the call can not be executed.
    • importContextEntries

      public String importContextEntries(String name, String onConflict, String owner, String json) throws IOException
      Imports entries into a context.
      Parameters:
      name - The name of the context.
      onConflict - The conflict resolution strategy. May be null to use the server default.
      owner - The owner. May be null.
      json - The entries to import as JSON.
      Returns:
      The import result.
      Throws:
      IOException - Thrown if the call can not be executed.
    • deleteContextEntry

      public GenericResponse deleteContextEntry(String name, String entryId) throws IOException
      Deletes a single entry from a context.
      Parameters:
      name - The name of the context.
      entryId - The entry ID.
      Returns:
      A GenericResponse.
      Throws:
      IOException - Thrown if the call can not be executed.
    • getDocuments

      public String getDocuments() throws IOException
      Gets the stored documents.
      Returns:
      The documents.
      Throws:
      IOException - Thrown if the call can not be executed.
    • getDocument

      public byte[] getDocument(String documentId) throws IOException
      Gets a stored document by ID.
      Parameters:
      documentId - The document ID.
      Returns:
      The document bytes.
      Throws:
      IOException - Thrown if the call can not be executed.
    • deleteDocument

      public void deleteDocument(String documentId) throws IOException
      Deletes a stored document.
      Parameters:
      documentId - The document ID.
      Throws:
      IOException - Thrown if the call can not be executed.
    • getDocumentStatus

      public String getDocumentStatus(String documentId) throws IOException
      Gets the processing status of a document.
      Parameters:
      documentId - The document ID.
      Returns:
      The document status.
      Throws:
      IOException - Thrown if the call can not be executed.
    • getHolds

      public List<LegalHoldResponse> getHolds() throws IOException
      Gets the legal holds.
      Returns:
      A list of LegalHoldResponse.
      Throws:
      IOException - Thrown if the call can not be executed.
    • createHold

      public LegalHoldResponse createHold(LegalHoldRequest request) throws IOException
      Creates a legal hold.
      Parameters:
      request - The LegalHoldRequest.
      Returns:
      The created LegalHoldResponse.
      Throws:
      IOException - Thrown if the call can not be executed.
    • getHold

      public LegalHoldResponse getHold(String reference) throws IOException
      Gets a legal hold by reference.
      Parameters:
      reference - The legal hold reference.
      Returns:
      The LegalHoldResponse.
      Throws:
      IOException - Thrown if the call can not be executed.
    • deleteHold

      public void deleteHold(String reference) throws IOException
      Deletes a legal hold.
      Parameters:
      reference - The legal hold reference.
      Throws:
      IOException - Thrown if the call can not be executed.
    • getLedger

      public String getLedger(String query) throws IOException
      Queries the redaction ledger.
      Parameters:
      query - The query. May be null.
      Returns:
      The matching ledger entries.
      Throws:
      IOException - Thrown if the call can not be executed.
    • getLedgerEntry

      public String getLedgerEntry(String documentId) throws IOException
      Gets the ledger entry for a document.
      Parameters:
      documentId - The document ID.
      Returns:
      The ledger entry.
      Throws:
      IOException - Thrown if the call can not be executed.
    • exportLedger

      public String exportLedger(String documentId) throws IOException
      Exports the ledger entry for a document.
      Parameters:
      documentId - The document ID.
      Returns:
      The exported ledger entry.
      Throws:
      IOException - Thrown if the call can not be executed.
    • isLedgerValid

      public String isLedgerValid(String documentId) throws IOException
      Checks whether the ledger for a document is valid.
      Parameters:
      documentId - The document ID.
      Returns:
      The validity result.
      Throws:
      IOException - Thrown if the call can not be executed.
    • getLists

      public String getLists() throws IOException
      Gets the custom lists.
      Returns:
      The custom lists.
      Throws:
      IOException - Thrown if the call can not be executed.
    • saveList

      public GenericResponse saveList(String list, String description, List<String> values) throws IOException
      Saves (or overwrites) a custom list.
      Parameters:
      list - The name of the list.
      description - The description of the list. May be null.
      values - The values in the list.
      Returns:
      A GenericResponse.
      Throws:
      IOException - Thrown if the call can not be executed.
    • deleteList

      public void deleteList(String list) throws IOException
      Deletes a custom list.
      Parameters:
      list - The name of the list.
      Throws:
      IOException - Thrown if the call can not be executed.
    • getList

      public GetListsResponse getList(String name) throws IOException
      Gets the values of a custom list.
      Parameters:
      name - The name of the list.
      Returns:
      The GetListsResponse.
      Throws:
      IOException - Thrown if the call can not be executed.
    • getRedactLists

      public String getRedactLists() throws IOException
      Gets the redact lists.
      Returns:
      The redact lists.
      Throws:
      IOException - Thrown if the call can not be executed.
    • createRedactList

      public GenericResponse createRedactList(String json) throws IOException
      Creates a redact list.
      Parameters:
      json - The redact list as JSON.
      Returns:
      A GenericResponse.
      Throws:
      IOException - Thrown if the call can not be executed.
    • updateRedactList

      public GenericResponse updateRedactList(String json) throws IOException
      Updates a redact list.
      Parameters:
      json - The redact list as JSON.
      Returns:
      A GenericResponse.
      Throws:
      IOException - Thrown if the call can not be executed.