Update user-defined filter

Updates a specified user-defined filter.

HTTP Request

PUT /api/sonar/user-defined-filters
cURL Example
curl -H "Authorization: Bearer <API_KEY>" \
     -H "Content-Type: application/json" \
     -d '{
       "guid": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
       "name": "Internal IP filter",
       "description": "Updated internal network IP address filter",
       "predicate": {
         "src_ip": "10.0.0.0/8"
       }
     }' \
     -X PUT \
     https://HOSTNAME/api/sonar/user-defined-filters
Request Parameters
KeyRequiredTypeDescriptionNote
guidYesStringUser-defined filter GUID36 characters
nameYesStringUser-defined filter name
descriptionNoStringUser-defined filter description
predicateYesString key/value mapFilter predicate conditionExpression tree object

The predicate is a recursive expression tree. Each node contains the following keys:

  • type (String, required): Node type. One of and, or, eq, neq, in, is_null, is_not_null, gt, gte, lt, lte, starts_with, ends_with, contains, value, expr
  • args (Array): List of child conditions for logical operators such as and and or. Each item follows the same expression tree structure.
  • value (String): Comparison value used by value and expr types
  • comment (String, optional): Condition description

Success Response

{}

Error Responses

Required argument is missing

HTTP status code 400.

{
  "error_code": "null-argument",
  "error_msg": "name should be not null"
}
User-defined filter is not found

HTTP status code 500.

{
  "error_code": "illegal-state",
  "error_msg": "user defined filter not found: a1b2c3d4-e5f6-7890-abcd-ef1234567890"
}
Duplicate filter name

HTTP status code 500.

{
  "error_code": "illegal-state",
  "error_msg": "duplicated user defined filter name: Internal IP filter"
}
No privilege to manage user-defined filters

HTTP status code 500.

{
  "error_code": "illegal-state",
  "error_msg": "no-permission"
}