File Classification
APIs for the File Classification Service.
The following APIs are exposed for the File Classification Service.
- Text
- JSON
- XML
Detect Text
This API classifies sensitive entities in plain text unstructured data.
POST http://<Host Address>/pty/data-discovery/detection/v2/detect/text
- Content type must be a plain text and in an UTF-8 format.
score_threshold
- Type:
float - Description: Optional. Exclude results with a score lower than this threshold.
- Values: Must be greater than 0.
- Default:
0.7
Body
Content type must be multipart/form-data.
The
contentfield contains the plain text to scan.Length of the content is limited to 5 MB.
Sample Request
curl -X POST "http://localhost:8053/pty/data-discovery/detection/v2/detect/text" \
-F "file=@customer_data.txt"import os
import json
import requests
# Path to the text file to submit
INPUT_FILEPATH = os.path.join(os.path.dirname(__file__), "fixtures", "example.txt")
#INPUT_FILEPATH = os.path.abspath("/opt/workspaces/discover/classification/deployment_qa/tests/features/common/detection/fixtures/xml_data/5mb_with_pii.xml")
# Detection service endpoint
url = "http://localhost:8053/pty/data-discovery/detection/v2/detect/text"
with open(INPUT_FILEPATH, "rb") as input_file:
response = requests.post(
url,
files={
"file": (
os.path.basename(INPUT_FILEPATH),
input_file
)
}
)
print("Status Code:", response.status_code)
try:
print("Response:", json.dumps(response.json(), indent=2))
except ValueError:
print("Response is not valid JSON:", response.text)URL: POST `http://<Host_address>/pty/data-discovery/detection/v2/detect/text`
Query Parameters:
-score_threshold (optional), float greater than 0 and up to 1.0, default: 0.7
Headers:
-Content-Type: multipart/form-data
Body (form-data):
-content: You can reach Dave Elliot by phone 203-555-1286Classify JSON Files API
Query Parameters
score_threshold
- Type:
float - Description: Optional. Exclude results with a score lower than this threshold.
- Values: Must be greater than 0.
- Default:
0.7
Body
Content type must be multipart/form-data.
The
contentfield contains the JSON text to scan.Length of the content is limited to 5 MB.
Sample Request
curl -X POST "http://localhost:8053/pty/data-discovery/detection/v2/detect/json" \
-F "file=@customer_data.json"import os
import json
import requests
# Path to the text file to submit
INPUT_FILEPATH = os.path.join(os.path.dirname(__file__), "fixtures", "complex_hr.json")
# Detection service endpoint
url = "http://localhost:8053/pty/data-discovery/detection/v2/detect/json"
with open(INPUT_FILEPATH, "rb") as input_file:
response = requests.post(
url,
files={
"file": (
os.path.basename(INPUT_FILEPATH),
input_file
)
}
)
print("Status Code:", response.status_code)
try:
print("Response:", json.dumps(response.json(), indent=2))
except ValueError:
print("Response is not valid JSON:", response.text)URL: POST `http://<Host_address>/pty/data-discovery/detection/v2/detect/json`
Query Parameters:
-score_threshold (optional), float greater than 0 and up to 1.0, default: 0.7
Headers:
-Content-Type: multipart/form-data
Body (form-data):
-content: You can reach Dave Elliot by phone 203-555-1286Classify XML Files API
POST http://<Host Address>/pty/data-discovery/detection/v2/detect/xml
score_threshold
- Type:
float - Description: Optional. Exclude results with a score lower than this threshold.
- Values: Must be greater than 0.
- Default:
0.7
Body
Content type must be multipart/form-data.
The
contentfield contains the XML text to scan.Length of the content is limited to 5 MB.
Sample Request
curl -X POST \
"http://localhost:8053/pty/data-discovery/detection/v2/detect/xml" \
-F "file=@/path/to/fixtures/complex_hr.xml"import os
import json
import requests
# Path to the text file to submit
INPUT_FILEPATH = os.path.join(os.path.dirname(__file__), "fixtures", "complex_hr.xml")
# Detection service endpoint
url = "http://localhost:8053/pty/data-discovery/detection/v2/detect/xml"
with open(INPUT_FILEPATH, "rb") as input_file:
response = requests.post(
url,
files={
"file": (
os.path.basename(INPUT_FILEPATH),
input_file
)
}
)
print("Status Code:", response.status_code)
try:
print("Response:", json.dumps(response.json(), indent=2))
except ValueError:
print("Response is not valid JSON:", response.text)URL: POST `http://<Host_address>/pty/data-discovery/detection/v2/detect/xml`
Query Parameters:
-score_threshold (optional), float greater than 0 and up to 1.0, default: 0.7
Headers:
-Content-Type: multipart/form-data
Body (form-data):
-content: You can reach Dave Elliot by phone 203-555-1286Response Codes
| Response Code | Description |
|---|---|
| 200 | Successful Response. |
| 206 | Partial Content. Some classifications succeeded; others failed. |
| 400 | Bad Request. Invalid input parameters or content. |
| 413 | Payload too large. |
| 422 | Validation Error. |
| 500 | Internal server error. Check server logs. |
| 502 | Bad Gateway. More than half of the classification calls failed. |
Feedback
Was this page helpful?