瀏覽代碼

Closes #8376: Correct example condition defitinions; call out value vs label ealuation for choice fields

jeremystretch 4 年之前
父節點
當前提交
4b81d86311
共有 3 個文件被更改,包括 22 次插入15 次删除
  1. 17 0
      docs/additional-features/webhooks.md
  2. 0 13
      docs/models/extras/webhook.md
  3. 5 2
      docs/reference/conditions.md

+ 17 - 0
docs/additional-features/webhooks.md

@@ -1,5 +1,22 @@
 {!models/extras/webhook.md!}
 {!models/extras/webhook.md!}
 
 
+## Conditional Webhooks
+
+A webhook may include a set of conditional logic expressed in JSON used to control whether a webhook triggers for a specific object. For example, you may wish to trigger a webhook for devices only when the `status` field of an object is "active":
+
+```json
+{
+  "and": [
+    {
+      "attr": "status.value",
+      "value": "active"
+    }
+  ]
+}
+```
+
+For more detail, see the reference documentation for NetBox's [conditional logic](../reference/conditions.md).
+
 ## Webhook Processing
 ## Webhook Processing
 
 
 When a change is detected, any resulting webhooks are placed into a Redis queue for processing. This allows the user's request to complete without needing to wait for the outgoing webhook(s) to be processed. The webhooks are then extracted from the queue by the `rqworker` process and HTTP requests are sent to their respective destinations. The current webhook queue and any failed webhooks can be inspected in the admin UI under System > Background Tasks.
 When a change is detected, any resulting webhooks are placed into a Redis queue for processing. This allows the user's request to complete without needing to wait for the outgoing webhook(s) to be processed. The webhooks are then extracted from the queue by the `rqworker` process and HTTP requests are sent to their respective destinations. The current webhook queue and any failed webhooks can be inspected in the admin UI under System > Background Tasks.

+ 0 - 13
docs/models/extras/webhook.md

@@ -81,16 +81,3 @@ If no body template is specified, the request body will be populated with a JSON
     }
     }
 }
 }
 ```
 ```
-
-## Conditional Webhooks
-
-A webhook may include a set of conditional logic expressed in JSON used to control whether a webhook triggers for a specific object. For example, you may wish to trigger a webhook for devices only when the `status` field of an object is "active":
-
-```json
-{
-  "attr": "status",
-  "value": "active"
-}
-```
-
-For more detail, see the reference documentation for NetBox's [conditional logic](../reference/conditions.md).

+ 5 - 2
docs/reference/conditions.md

@@ -81,13 +81,16 @@ The following condition will evaluate as true:
 
 
 ```json
 ```json
 {
 {
-  "attr": "status",
+  "attr": "status.value",
   "value": ["planned", "staging"],
   "value": ["planned", "staging"],
   "op": "in",
   "op": "in",
   "negate": true
   "negate": true
 }
 }
 ```
 ```
 
 
+!!! note "Evaluating static choice fields"
+    Pay close attention when evaluating static choice fields, such as the `status` field above. These fields typically render as a dictionary specifying both the field's raw value (`value`) and its human-friendly label (`label`). be sure to specify on which of these you want to match.
+
 ## Condition Sets
 ## Condition Sets
 
 
 Multiple conditions can be combined into nested sets using AND or OR logic. This is done by declaring a JSON object with a single key (`and` or `or`) containing a list of condition objects and/or child condition sets.
 Multiple conditions can be combined into nested sets using AND or OR logic. This is done by declaring a JSON object with a single key (`and` or `or`) containing a list of condition objects and/or child condition sets.
@@ -102,7 +105,7 @@ Multiple conditions can be combined into nested sets using AND or OR logic. This
     {
     {
       "and": [
       "and": [
         {
         {
-          "attr": "status",
+          "attr": "status.value",
           "value": "active"
           "value": "active"
         },
         },
         {
         {