Evaluate rules within a context on the provided object

POST /v1/{contextId}/evaluate

Evaluate rules within a context on the provided object

Path parameters

  • contextId string Required

    The parent context ID, for example, "contextID1/rules/{rule_id}/versions"

application/json

Body Required

  • contextId string

    The parent context ID, for example, "contextID1/rules/{rule_id}/versions"

  • object object

    The object to evaluate the ruleset on

  • overrideRules array[object]

    Rules to be applied instead of the stored rules of the context. This is mostly useful for testing purposes or ad-hoc / one-off requests where there is not context set up prior to the evaluation.

    Hide overrideRules attributes Show overrideRules attributes object
    • id string

      example:"rule_01h89qfdhbejtb3jwqq1gazbm5"

    • sequence integer(uint32)

      The sequence number of the rule within the context

    • description string
    • actions array[object]
      Hide actions attributes Show actions attributes object
      • kind string

        The name of the action example:"$set"

      • target object

        The target the action applies to

        Hide target attributes Show target attributes object
        • kind string

          This is what determines the type of the id field's value example:"jsonpath" example:"myTargetKind"

        • id string

          The identifier for the target. It can be a jsonpath a simple property name or an arbitrary third party id example:"$.prop" example:"propKey" example:"target_01h89qgxe5e7wregw6gb94d5p6"

        • value string(bytes)

          The target value to be set (it is the json serialized representation of the value)

      • id string
    • expression object

      A variadic condition expression Expression: type: object oneOf: - $ref: '#/components/schemas/And' - $ref: '#/components/schemas/Or' - $ref: '#/components/schemas/Condition'

      Hide expression attributes Show expression attributes object
      • and object
        Hide and attribute Show and attribute object
        • expression array[object]
      • or object
        Hide or attribute Show or attribute object
        • expression array[object]
      • condition object

        A condition expression

        Hide condition attributes Show condition attributes object
        • key string

          Holds a direct object key to be used the value extraction

        • ref object

          Holds a dref reference (see dalí project for details)

          Hide ref attributes Show ref attributes object
          • src string
          • dst string
          • value string(bytes)
        • kind string(enum)

          The type of this condition, based on the internally defined ConditionType

          Values are e, hv, eq, neq, px, npx, sx, nsx, in, nin, some, all, none, rgx, nrgx, or cel.

        • value string(bytes)

          A condition parameter holds a target value (right hand side) for a comparison

  • overrideCode string

    Assembled code can be provided, in this case the saved ruleset of the context is ignored. This is mostly useful for testing purposes or ad-hoc / one-off requests where there is not context set up prior to the evaluation.

Responses

  • 200 application/json

    OK

    Hide response attribute Show response attribute object
    • results array[object]
      Hide results attributes Show results attributes object
      • action string

        The action to be applied

      • target object

        The target the action needs to be applied to

        Hide target attributes Show target attributes object
        • kind string

          This is what determines the type of the id field's value example:"jsonpath" example:"myTargetKind"

        • id string

          The identifier for the target. It can be a jsonpath a simple property name or an arbitrary third party id example:"$.prop" example:"propKey" example:"target_01h89qgxe5e7wregw6gb94d5p6"

        • value string(bytes)

          The target value to be set (it is the json serialized representation of the value)

      • by object

        The truthy rule ID responsible for this result This field is used by the frontend devtools packages.

        Hide by attributes Show by attributes object
        • id string

          example:"rule_01h89qfdhbejtb3jwqq1gazbm5"

        • description string

          example:"rule_01h89qfdhbejtb3jwqq1gazbm5"

  • default application/json

    Default error response

    Hide response attributes Show response attributes object
    • code integer(int32)

      The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code].

    • message string

      A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client.

    • details array[object]

      A list of messages that carry the error details. There is a common set of message types for APIs to use.

      Contains an arbitrary serialized message along with a @type that describes the type of the serialized message.

      Hide details attribute Show details attribute object
      • @type string

        The type of the serialized message.

POST /v1/{contextId}/evaluate
curl \
 --request POST 'https://api.brease.run/v1/{contextId}/evaluate' \
 --header "Content-Type: application/json" \
 --data '{"contextId":"string","object":{},"overrideRules":[{"id":"string","sequence":42,"description":"string","actions":[{"kind":"string","target":{"kind":"string","id":"string","value":"string"},"id":"string"}],"expression":{"and":{"expression":[{}]},"or":{"expression":[{}]},"condition":{"key":"string","ref":{"src":"string","dst":"string","value":"string"},"kind":"e","value":"string"}}}],"overrideCode":"string"}'
Request examples
{
  "contextId": "string",
  "object": {},
  "overrideRules": [
    {
      "id": "string",
      "sequence": 42,
      "description": "string",
      "actions": [
        {
          "kind": "string",
          "target": {
            "kind": "string",
            "id": "string",
            "value": "string"
          },
          "id": "string"
        }
      ],
      "expression": {
        "and": {
          "expression": [
            {}
          ]
        },
        "or": {
          "expression": [
            {}
          ]
        },
        "condition": {
          "key": "string",
          "ref": {
            "src": "string",
            "dst": "string",
            "value": "string"
          },
          "kind": "e",
          "value": "string"
        }
      }
    }
  ],
  "overrideCode": "string"
}
Response examples (200)
{
  "results": [
    {
      "action": "string",
      "target": {
        "kind": "string",
        "id": "string",
        "value": "string"
      },
      "by": {
        "id": "string",
        "description": "string"
      }
    }
  ]
}
Response examples (default)
{
  "code": 42,
  "message": "string",
  "details": [
    {
      "@type": "string"
    }
  ]
}