Hi! what would be the syntax to concatenate a Vari...
# help
s
Hi! what would be the syntax to concatenate a Variable into an output json? This is NOT OK, what should it be? output: when: ruleActivated: |- {"devicepam_response_attributes": {"User-Message": "Username exceeds V.nxos_username_max_length characters, this is not supported on NX-OS"}}
o
Hi! You could do it like this:
Copy code
output:
  when:
    ruleActivated: |-
      { "key": "value " + V.some_variable }
c
You can also do printf style formatting:
"foo_%s_%d".format(["bar", 1])
s
didn't yet got it to work within a (nested) json response as in my example..
o
Does this look like what you are trying to do?: https://play.cerbos.dev/p/tl2u67d14413K1hnz7KXUn4h6igQdRf4 You could send a request to test the policy in the above playground like this:
Copy code
curl -X POST '<https://demo-pdp.cerbos.cloud/api/check/resources>' \
--header 'Playground-Instance: tl2u67d14413K1hnz7KXUn4h6igQdRf4' \
--header 'Content-Type: application/json' \
--data-raw '{
  "requestId": "123123",
  "principal": {
    "id": "alex",
    "roles": [
      "ADMIN"
    ],
    "attr": {}
  },
  "resources": [
    {
      "resource": {
        "kind": "leave_request",
        "id": "1",
        "attr": {}
      },
      "actions": [
        "delete"
      ]
    }
  ]
}'
❤️ 1
s
Awesome thanks!