Class PhilterClient
java.lang.Object
ai.philterd.philter.AbstractClient
ai.philterd.philter.PhilterClient
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.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intFields inherited from class AbstractClient
SERVICE_UNAVAILABLE, UNAUTHORIZED -
Method Summary
Modifier and TypeMethodDescriptioncompilePolicy(String policy) Compiles a policy, returning the compiled representation.createContext(String name, Boolean entityTypeDisambiguation, Boolean ledger) Creates a context.createHold(LegalHoldRequest request) Creates a legal hold.createRedactList(String json) Creates a redact list.deleteContext(String name) Deletes a context.deleteContextEntries(String name) Deletes all entries for a context.deleteContextEntry(String name, String entryId) Deletes a single entry from a context.voiddeleteDocument(String documentId) Deletes a stored document.voiddeleteHold(String reference) Deletes a legal hold.voiddeleteList(String list) Deletes a custom list.voiddeletePolicy(String policyName) Deletes a policy.Send text to Philter to be filtered and get an explanation.exportContextEntries(String name, String owner) Exports the entries for a context.exportLedger(String documentId) Exports the ledger entry for a document.Send text to Philter to be filtered.Send a PDF document to Philter to be filtered.getContext(String name) Gets a context by name.getContextEntries(String name) Gets the entries for a context.Gets the configured contexts.byte[]getDocument(String documentId) Gets a stored document by ID.Gets the stored documents.getDocumentStatus(String documentId) Gets the processing status of a document.Gets a legal hold by reference.getHolds()Gets the legal holds.Queries the redaction ledger.getLedgerEntry(String documentId) Gets the ledger entry for a document.Gets the values of a custom list.getLists()Gets the custom lists.Gets a list of policy names.getPolicies(String owner, Integer offset, Integer limit) Gets a list of policy names.Gets the content of a policy.getPolicyDiff(String policyName, int from, int to) Gets the difference between two revisions of a policy.getPolicyVersion(String policyName, int revision) Gets a specific revision of a policy.getPolicyVersions(String policyName) Gets the revision history for a policy.Gets the redact lists.Gets Philter's public signing key.health()Gets the health of Philter.importContextEntries(String name, String onConflict, String owner, String json) Imports entries into a context.isLedgerValid(String documentId) Checks whether the ledger for a document is valid.reidentify(String owner, ReidentifyRequest request) Re-identifies previously redacted values.rollbackPolicy(String policyName, int revision) Rolls a policy back to a prior revision.Saves (or overwrites) a custom list.voidsavePolicy(String name, String json) Saves (or overwrites) the policy.status()Gets the status of Philter.updateContext(String name, Boolean entityTypeDisambiguation, Boolean ledger) Updates a context.updateRedactList(String json) Updates a redact list.Methods inherited from class AbstractClient
execute, executeVoid, toException
-
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
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 benull.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
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
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
Re-identifies previously redacted values.- Parameters:
owner- The owner of the values. May benull.request- TheReidentifyRequest.- Returns:
- The re-identification result.
- Throws:
IOException- Thrown if the request can not be completed.
-
health
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
Gets the status of Philter.- Returns:
- The
StatusResponse. - Throws:
IOException- Thrown if the request can not be completed.
-
getSigningKey
Gets Philter's public signing key.- Returns:
- The signing key.
- Throws:
IOException- Thrown if the request can not be completed.
-
getPolicies
Gets a list of policy names.- Returns:
- A list of policy names.
- Throws:
IOException- Thrown if the call can not be executed.
-
getPolicies
Gets a list of policy names.- Parameters:
owner- The owner of the policies. May benull.offset- The pagination offset. May benull.limit- The pagination limit. May benull.- Returns:
- A list of policy names.
- Throws:
IOException- Thrown if the call can not be executed.
-
getPolicy
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
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
Deletes a policy.- Parameters:
policyName- The name of the policy to delete.- Throws:
IOException- Thrown if the call can not be executed.
-
getPolicyVersions
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
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
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
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
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 benull.ledger- Whether the redaction ledger is enabled. May benull.- Returns:
- A
GenericResponse. - Throws:
IOException- Thrown if the call can not be executed.
-
getContext
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 benull.ledger- Whether the redaction ledger is enabled. May benull.- Returns:
- A
GenericResponse. - Throws:
IOException- Thrown if the call can not be executed.
-
deleteContext
Deletes a context.- Parameters:
name- The name of the context.- Returns:
- A
GenericResponse. - Throws:
IOException- Thrown if the call can not be executed.
-
getContextEntries
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
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
Exports the entries for a context.- Parameters:
name- The name of the context.owner- The owner. May benull.- 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 benullto use the server default.owner- The owner. May benull.json- The entries to import as JSON.- Returns:
- The import result.
- Throws:
IOException- Thrown if the call can not be executed.
-
deleteContextEntry
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
Gets the stored documents.- Returns:
- The documents.
- Throws:
IOException- Thrown if the call can not be executed.
-
getDocument
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
Deletes a stored document.- Parameters:
documentId- The document ID.- Throws:
IOException- Thrown if the call can not be executed.
-
getDocumentStatus
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
Gets the legal holds.- Returns:
- A list of
LegalHoldResponse. - Throws:
IOException- Thrown if the call can not be executed.
-
createHold
Creates a legal hold.- Parameters:
request- TheLegalHoldRequest.- Returns:
- The created
LegalHoldResponse. - Throws:
IOException- Thrown if the call can not be executed.
-
getHold
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
Deletes a legal hold.- Parameters:
reference- The legal hold reference.- Throws:
IOException- Thrown if the call can not be executed.
-
getLedger
Queries the redaction ledger.- Parameters:
query- The query. May benull.- Returns:
- The matching ledger entries.
- Throws:
IOException- Thrown if the call can not be executed.
-
getLedgerEntry
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
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
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
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 benull.values- The values in the list.- Returns:
- A
GenericResponse. - Throws:
IOException- Thrown if the call can not be executed.
-
deleteList
Deletes a custom list.- Parameters:
list- The name of the list.- Throws:
IOException- Thrown if the call can not be executed.
-
getList
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
Gets the redact lists.- Returns:
- The redact lists.
- Throws:
IOException- Thrown if the call can not be executed.
-
createRedactList
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
Updates a redact list.- Parameters:
json- The redact list as JSON.- Returns:
- A
GenericResponse. - Throws:
IOException- Thrown if the call can not be executed.
-