PingAM

Create a script

To create a script in a realm, send an HTTP POST request to the /json{/realm}/scripts endpoint, with an _action parameter set to create. Include a JSON representation of the script in the POST data.

The value for script must be in UTF-8 format and then encoded into Base64.

If the realm is not specified in the URL, AM creates the script in the top level realm.

The iPlanetDirectoryPro header is required and should contain the SSO token of an administrative user, such as amAdmin, who has access to perform the operation.

$ curl \
--request POST \
--header "Content-Type: application/json" \
--header "Cookie:amlbcookie-01; iPlanetDirectoryPro: AQIC5wM…​TU3OQ*" \
--header "Accept-API-Version: resource=1.1" \
--data '{
  "name": "MyJavaScript",
  "script": "dmFyIGEgPSAxMjM7CnZhciBiID0gNDU2Ow==",
  "language": "JAVASCRIPT",
  "context": "POLICY_CONDITION",
  "description": "An example script"
}' \
https://am.example.com:8443/am/json/realms/root/realms/myrealm/scripts/?_action=create
{
  "_id": "0168d494-015a-420f-ae5a-6a2a5c1126af",
  "name": "MyJavaScript",
  "description": "An example script",
  "script": "dmFyIGEgPSAxMjM7CnZhciBiID0gNDU2Ow==",
  "language": "JAVASCRIPT",
  "context": "POLICY_CONDITION",
  "createdBy": "id=amadmin,ou=user,dc=am,dc=example,dc=com",
  "creationDate": 1436807766258,
  "lastModifiedBy": "id=amadmin,ou=user,dc=am,dc=example,dc=com",
  "lastModifiedDate": 1436807766258,
  "evaluatorVersion": "1.0"
}

Create a global library script

To create a global library script that can be accessed from all realms, send an HTTP POST request to the /json/scripts endpoint, with an _action parameter set to createGlobal.

$ curl \
--request POST \
--header "Content-Type: application/json" \
--header "Cookie: amlbcookie=01; iPlanetDirectoryPro: AQIC5wM…​TU3OQ*" \
--header "Accept-API-Version: resource=1.1" \
--data '{
  "name": "My global library",
  "script": "Ly2FnZSkgPT4gbGKTs=",
  "language": "JAVASCRIPT",
  "context": "LIBRARY",
  "description": "A global script"
}' \
https://am.example.com:8443/am/json/scripts/?_action=createGlobal
{
  "_id":"834e548d-5b38-4f7a-bb04-2ff54059b62a",
  "name":"My global library",
  "description": "A global script",
  "script":"Ly2FnZSkgPT4gbGKTs=",
  "default":false,
  "language":"JAVASCRIPT",
  "context":"LIBRARY",
  "createdBy": "id=amadmin,ou=user,dc=am,dc=example,dc=com",
  "creationDate":1767784565856,
  "lastModifiedBy": "id=amadmin,ou=user,dc=am,dc=example,dc=com",
  "lastModifiedDate":1767784565856,
  "evaluatorVersion":"2.0"
}

To list all the global library scripts you have created, include the global query filter field, for example:

https://am.example.com:8443/am/json/scripts?_queryFilter=context%20eq%20%22LIBRARY%22%20and%20global%20eq%20true%20"