Example: Create a DeepInspect policy using the application
Use the POST /policyengine/v1/policies/extractpol endpoint to create a policy that makes use of the registered application.
Synopsis of the request URL
curl -k -H “Authorization: Bearer <token>” -H "Content-Type: application/json" -X POST
https://<spectrum_discover_host>:443/policyengine/v1/policies/extractpol
Supported request types and response formats
Supported request types:
- POST
- JSON
Examples
Registering an application involves the following steps.
- Define the policy details in a JSON file as shown in the following example:
cat testpol { "action_params": { "extract_tags": ["vin", "sensor”], "agent": "extractapplication" }, "pol_id": "extractpol", "schedule": "NOW", "pol_filter": "size>23", "action_id": "DEEPINSPECT" }
- Submit the following request:
curl -k-H “Authorization: Bearer <token>”https://<spectrum_discover_host>/policyengine/v1/policies/extractpol -X POST -d @testpol -H "Content-Type: application/json"
As the policy is created, as the policy schedule is ‘NOW’. The job request messages are immediately pushed to the Kafka work topic corresponding to the registered application as shown in the following example:
The following example provides a JSON message request.
{
"mo_ver": "1.0",
"action_id": "deepinspect",
"action_params": {
"agent": "extractapplication",
"tags": {"extract_tags": ["vin", "sensor"]}
},
"agent": " extractapplication",
"policy_id": " extractpol",
"docs": [
{"path": "/fs1/path1/file1.txt", "fkey": "spectrumscale.cluster.example"},
{"path": "/fs1/path1/file2.txt", "fkey": "spectrumscale.cluster.example"},
......
{"origpath": "/fs1/path1/file3.txt", "fkey": "spectrumscale.cluster.example"}
]
}
The following table lists the job request message format.
Field | Value Type | Description |
---|---|---|
mo_ver | Float | The message version |
policy_id | String | The name of the policy ID that requested the job. |
action_id | String | The name of the action ID |
agent | String | The name of the application |
action_params | Object | JSON object of custom application parameters |
docs | Array | The array of JSON objects, each containing information about documents (files or objects) to be inspected. |
The following example provides a JSON message
response:
{
"mo_ver": "1.0",
"policy_id": " extractpol",
"docs": [
{"status": "success", "tags": {"vin": "vin-value", "sensor": "sensor-value"}, "path": "/fs1/path1/file1.txt", "fkey": "spectrumscale.cluster.example "},
{"status": "success", "tags": {"vin": "vin-value", "sensor": "sensor-value"}, "path": "/fs1/path1/file1.txt", "fkey": "spectrumscale.cluster.example "},
{"status": "failed", "tags": {}, "path": "/fs1/path1/file1.txt", "fkey": "spectrumscale.cluster.example "}
]
}
The following table lists the job response message format.
Field | Value Type | Description |
---|---|---|
mo_ver | Float | The message version |
policy_id | String | The name of the policy ID that requested the job. |
docs | Array | The array of JSON objects, each containing information about documents (files/objects) to be inspected. |