/policyengine/v1/policies -d '<data>': POST
Creates a policy.
The
/policyengine/v1/policies: POST
endpoint
creates a policy with the characteristics that are specified in the request data. For a description
of the request parameters, see Endpoints for working with policy management. The following table shows which
roles can access this REST API endpoint:
Data admin | Collection Admin | Collection user | Data user | Admin | Service user |
---|---|---|---|---|---|
✓ | ✓ | X | ✓1, 2 | Χ | Χ |
1The command allows access only if the
schedule attribute is set to
NOW. 2The command applies the policy only in collections where the user has a datauser role. |
Synopsis of the request URL
curl -k -H 'Authorization: Bearer <token>'
https://<spectrum_discover_host>/policyengine/v1/policies -d '<data>'
-X POST -H "Content-Type: application/json"
Supported request types, input fields, and response formats
Supported request types:
Supported response formats:- POST
- JSON
Examples
- The following example creates an AUTOTAG policy named
pol2
to start immediately:- Issue the following request on one
line:
curl -k -H 'Authorization: Bearer <token>' https://<spectrum_discover_host>/policyengine/v1/policies -d '{ "pol_id":"pol2", "pol_filter": "user='research1'", "action_id": "AUTOTAG", "action_params": {"tags": {"tag4":"val4", "tag5":"val5"}}, "schedule":"NOW" }' -X POST -H "Content-Type: application/json"
- The following response is returned:
Policy 'pol2' added
- Issue the following request on one
line:
- The following example creates a AUTOTAG policy named
pol2
to start at a scheduled time:Note: For information about using the AUTOTAG action, see the topic Adding fields with the AUTOTAG action.- Issue the following request on one
line:
curl -k -H 'Authorization: Bearer <token>' https://<spectrum_discover_host>/policyengine/v1/policies -d ' { "pol_id":"pol2", "action_id":"AUTOTAG", "action_params":{ "tags": { "test_tag1": "test1" } }, "pol_filter":"filename LIKE 'f0%'", "schedule": { "dayOfWeek": "*", "hour": "13", "month": "*", "timezone": "UTC", "minute": "31", "dayOfMonth": "*" } }' -X POST -H "Content-Type: application/json"
Note: The API supports the creation of a schedule using a timezone parameter. Internally this is converted to Coordinated Universal Time (UTC). It is recommended that the timezone parameter is not used or that the default of Coordinated Universal Time (UTC) is used in the API, because the policy schedule time is not displayed in the GUI. The GUI assumes all times are in UTC. - The following response is returned:
Policy 'pol2' added
- Issue the following request on one
line: