Package com.mtnfog.philter
Class PhilterClient
- java.lang.Object
-
- com.mtnfog.philter.PhilterClient
-
public class PhilterClient extends java.lang.Object
Client class for Philter's API. Philter finds and manipulates sensitive information in text.
-
-
Field Summary
Fields Modifier and Type Field Description static int
KEEP_ALIVE_DURATION_MS
static int
MAX_IDLE_CONNECTIONS
static int
TIMEOUT_SEC
-
Constructor Summary
Constructors Constructor Description PhilterClient(java.lang.String endpoint)
Create a new client.PhilterClient(java.lang.String endpoint, okhttp3.OkHttpClient okHttpClient)
Create a new client.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ExplainResponse
explain(java.lang.String context, java.lang.String documentId, java.lang.String filterProfileName, java.lang.String text)
Send text to Philter to be filtered and get an explanation.FilterResponse
filter(java.lang.String context, java.lang.String documentId, java.lang.String filterProfileName, java.lang.String text)
Send text to Philter to be filtered.java.util.List<FilteredSpan>
replacements(java.lang.String documentId)
Gets the values replaced during a previous filter request.StatusResponse
status()
Gets the status of Philter.
-
-
-
Field Detail
-
TIMEOUT_SEC
public static final int TIMEOUT_SEC
- See Also:
- Constant Field Values
-
MAX_IDLE_CONNECTIONS
public static final int MAX_IDLE_CONNECTIONS
- See Also:
- Constant Field Values
-
KEEP_ALIVE_DURATION_MS
public static final int KEEP_ALIVE_DURATION_MS
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
PhilterClient
public PhilterClient(java.lang.String endpoint)
Create a new client.- Parameters:
endpoint
- The Philter endpoint, e.g.https://127.0.0.1:8080
.
-
PhilterClient
public PhilterClient(java.lang.String endpoint, okhttp3.OkHttpClient okHttpClient)
Create a new client.- Parameters:
endpoint
- The Philter endpoint, e.g.https://127.0.0.1:8080
.okHttpClient
- Provide a customOkHttpClient
.
-
-
Method Detail
-
filter
public FilterResponse filter(java.lang.String context, java.lang.String documentId, java.lang.String filterProfileName, java.lang.String text) throws java.io.IOException
Send text to Philter to be filtered.- Parameters:
context
- The context. Contexts can be used to group text based on some arbitrary property.documentId
- The document ID. Leave empty for Philter to assign a document ID to the request.filterProfileName
- The name of the filter profile to apply to the text.text
- The text to be filtered.- Returns:
- The filtered text.
- Throws:
java.io.IOException
- Thrown if the request can not be completed.
-
explain
public ExplainResponse explain(java.lang.String context, java.lang.String documentId, java.lang.String filterProfileName, java.lang.String text) throws java.io.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.documentId
- The document ID. Leave empty for Philter to assign a document ID to the request.filterProfileName
- The name of the filter profile to apply to the text.text
- The text to be filtered.- Returns:
- The filter
ExplainResponse
. - Throws:
java.io.IOException
- Thrown if the request can not be completed.
-
replacements
public java.util.List<FilteredSpan> replacements(java.lang.String documentId) throws java.io.IOException
Gets the values replaced during a previous filter request. Philter's store feature must be enabled for this call to work. Check Philter's documentation for how to enable the store.- Parameters:
documentId
- The document ID.- Returns:
- A list of
spans
. - Throws:
java.io.IOException
- Thrown if the request can not be completed.
-
status
public StatusResponse status() throws java.io.IOException
Gets the status of Philter.- Returns:
- A
StatusResponse
object. - Throws:
java.io.IOException
- Thrown if the request can not be completed.
-
-