/policyengine/v1/policies/<policy_name> -d '<data>': PUT

Updates a policy.

The /policyengine/v1/policies/<policy_id> -d '<data>': PUT endpoint updates an existing policy with the attribute values that are specified in the request data. Attributes that are not updated keep the same values that they had before the update. The following attributes can be updated: action_parameters, schedule, pol_filter, and pol_state. The action_id attribute cannot be updated. However, you can delete an existing policy and then create a new one with the same name and attributes as the deleted policy but with a different action_id. For more information about the attributes in the request data, see Endpoints for working with policy management.

Note: You cannot update a policy while it is running.
The following table shows which roles can access this REST API endpoint:
Table 1. Access by role
Data admin Data user Collection Admin Collection user Admin Service user
1, 2 X X Χ Χ
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/<policy_name> -d '<data>' 
-X PUT -H "Content-Type: application/json"

Supported request types and response formats

Supported request types:
  • PUT
Supported response formats:
  • JSON

Examples

  1. The following example updates a policy named pol2:
    1. Issue the following request on one line:
      curl -k -H 'Authorization: Bearer \<token>' 
      https://<spectrum_discover_host>
      /policyengine/v1/policies/<policy_name>
      -d '{
         "pol_filter": "user='research1'",
         "pol_state": "active"
         "action_params": {"tags": {"tag4":"val4", "tag5":"val5"}},
         "schedule":"NOW"
      }'
       -X POST -H "Content-Type: application/json"
    2. The following response is returned:
      Policy 'pol2' updated
    To verify that the policy is created, issue a GET request to list the information about the specified policy or about all the policies in the system. For more information, see /policyengine/v1/policies: GET and /policyengine/v1/policies/<policy_name>: GET.