Attach and Manage Policy References

You can use the Policy Set REST APIs to attach and manage policy references.

The cURL command examples use the URL structure:
http(s)://host:port/wsm-pmrest/v2/policyset/{name}/policyreference

The following use case shows you how to:

  • Attach a policy reference

  • Modify the a policy reference

  • View the policy reference

  • Delete the policy reference

To manage the policy set:

  1. Specify the headers on the cURL command line:
    -H Accept:application/json
  2. Attach the oracle/wss_username_token_service_policy and the oracle/log_policy policies to the myPolicySet1 policy set by running the following command:
    curl -i -X POST -u username:password -H Content-type:application/json http://host:port/wsm-pmrest/v2/policyset/{name}/policyreference

    Example

    curl -i -X POST -u Smith:Password -H Content-type:application/json http://myhost:7001/wsm-pmrest/v2/policyset/myPolicySet1/policyreference

    See Add PolicyReference(s).

    The following shows an example of the request body.

    [
      {
        "uri": "oracle/log_policy",
        "status": "enabled",
        "category": "management"
      },
      {
        "uri": "oracle/wss_username_token_service_policy",
        "status": "enabled",
        "category": "security"
      }
    ]

    The following shows an example of the response indicating the request succeeded.

    {
      "STATUSCODE": "20011",
      "MESSAGE": "Policies [oracle/log_policy, oracle/wss_username_token_service_policy] are successfully attached."
    }
  3. Enable the oracle/log_policy policy reference for the myPolicySet1 policy set by running the following command:
    curl -i -X PATCH -u username:password -H Content-type:application/json http://host:port/wsm-pmrest/v2/policyset/{name}/policyreference/{policyuri}

    Example

    curl -i -X PATCH -u Smith:Password -H Content-type:application/json http://myhost:7001/wsm-pmrest/v2/policyset/myPolicySet1/policyreference/oracle%2Flog_policy

    Note:

    In the URL, the "/" character in the name of a policy is encoded with "2%F"

    See Update a PolicyReference by its URI.

    The following shows an example of the request body.

    {
      "uri": "log_policy",
      "status": "enabled"
    }

    The following shows an example of the response indicating the request succeeded.

    {
      "STATUSCODE": "20002",
      "MESSAGE": "Policies oracle/log_policy" are successfully updated."
    }
  4. View all the attached policies for the policy set myPolicySet1 by running the following command:
    curl -i -X GET -u username:password -H Content-type:application/json http://host:port/wsm-pmrest/v2/policyset/{name}/policyreference

    Example

    curl -i -X GET -u Smith:Password -H Content-type:application/json http://myhost:7001/wsm-pmrest/v2/policyset/myPolicySet1/policyreference

    See Get PolicyReference(s).

    The following shows an example of the response body:

    [
      {
        "uri": "wss_username_token_service_policy",
        "status": "enabled"
      },
      {
        "uri": "log_policy",
        "status": "disabled"
      }
    ]
  5. Optionally, detach a policy reference based on the URI from myPolicySet1 by running the following command:
    curl -i -X DELETE -u username:password -H Content-type:application/json http://host:port/wsm-pmrest/v2/policyset/{name}/policyreference/{policyuri}

    Example

    curl -i -X DELETE -u Smith:Password -H Content-type:application/json http://myhost:7001/wsm-pmrest/v2/policyset/myPolicySet1/policyreference/oracle%2Flog_policy

    Note:

    In the URL, the "/" character in the name of a policy is encoded with "2%F"

    See Delete a PolicyReference by its URI.

    The following shows an example of the response indicating the request succeeded.

    {
      "STATUSCODE": "20014",
      "MESSAGE": "Policies oracle/log_policy are successfully detached."
    }
  6. Optionally, detach all the policies from the policy set myPolicySet1 by running the following command:
    curl -i -X DELETE -u username:password -H Content-type:application/json http://host:port/wsm-pmrest/v2/policyset/{name}/policyreference

    Example

    curl -i -X DELETE -u Smith:Password -H Content-type:application/json http://myhost:7001/wsm-pmrest/v2/policyset/myPolicySet1/policyreference

    See Delete PolicyReference(s).

    The following shows an example of the response indicating the request succeeded.

    {
      "STATUSCODE": "20014",
      "MESSAGE": "Policies are successfully detached."
    }