Skip to content

Commit cec72c3

Browse files
authored
docs: require control data in create examples (#32)
* docs: require control data in create examples * docs: fix python regex escaping in testing example
1 parent fda5c54 commit cec72c3

4 files changed

Lines changed: 41 additions & 19 deletions

File tree

‎components/server.mdx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ GET /api/v1/agents/{agent_name}/controls
173173
```bash
174174
# Create control
175175
PUT /api/v1/controls
176-
Body: { "name": "my-control" }
176+
Body: { "name": "my-control", "data": {...} }
177177

178178
# List controls (cursor-based)
179179
GET /api/v1/controls?cursor=123&limit=100
@@ -188,7 +188,7 @@ Body: { "name": "new-name", "enabled": true }
188188
# Get control data
189189
GET /api/v1/controls/{control_id}/data
190190

191-
# Update control data
191+
# Update existing control data
192192
PUT /api/v1/controls/{control_id}/data
193193
Body: { "data": {...} }
194194

‎concepts/controls.mdx‎

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -429,17 +429,10 @@ Via curl:
429429

430430
```bash
431431

432-
# Step 1: Create control
433-
434432
CONTROL_ID=$(curl -X PUT http://localhost:8000/api/v1/controls \
435-
-H "Content-Type: application/json" \
436-
-d '{"name": "block-ssn-output"}' | jq -r '.control_id')
437-
438-
# Step 2: Set control configuration
439-
440-
curl -X PUT "http://localhost:8000/api/v1/controls/$CONTROL_ID/data" \
441433
-H "Content-Type: application/json" \
442434
-d '{
435+
"name": "block-ssn-output",
443436
"data": {
444437
"description": "Block Social Security Numbers in responses",
445438
"enabled": true,
@@ -454,7 +447,7 @@ curl -X PUT "http://localhost:8000/api/v1/controls/$CONTROL_ID/data" \
454447
},
455448
"action": {"decision": "deny"}
456449
}
457-
}'
450+
}' | jq -r '.control_id')
458451
```
459452

460453
Regex pattern note: the pattern itself is `\b\d{3}-\d{2}-\d{4}\b`. Python raw strings render that as `r"\b\d{3}-\d{2}-\d{4}\b"`, while JSON payloads must escape backslashes as `"\\b\\d{3}-\\d{2}-\\d{4}\\b"`.
@@ -498,15 +491,10 @@ Via curl:
498491

499492
```bash
500493

501-
# Create control with Luna-2 evaluator
502-
503494
CONTROL_ID=$(curl -X PUT http://localhost:8000/api/v1/controls \
504-
-H "Content-Type: application/json" \
505-
-d '{"name": "block-toxic-input"}' | jq -r '.control_id')
506-
507-
curl -X PUT "http://localhost:8000/api/v1/controls/$CONTROL_ID/data" \
508495
-H "Content-Type: application/json" \
509496
-d '{
497+
"name": "block-toxic-input",
510498
"data": {
511499
"description": "Block toxic or harmful user messages",
512500
"enabled": true,
@@ -525,7 +513,7 @@ curl -X PUT "http://localhost:8000/api/v1/controls/$CONTROL_ID/data" \
525513
},
526514
"action": {"decision": "deny"}
527515
}
528-
}'
516+
}' | jq -r '.control_id')
529517
```
530518

531519
> **Note**: For the Luna-2 evaluator, set the `GALILEO_API_KEY` environment variable. See the [Evaluators](/concepts/evaluators/overview) for all available evaluators.

‎sdk/typescript-sdk.mdx‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,24 @@ console.log(agents.agents.length);
5151

5252
const created = await client.controls.create({
5353
name: "deny-pii",
54+
data: {
55+
action: { decision: "deny" },
56+
description: "Block SSNs in output",
57+
enabled: true,
58+
evaluator: {
59+
name: "regex",
60+
config: {
61+
pattern: "\\b\\d{3}-\\d{2}-\\d{4}\\b",
62+
},
63+
},
64+
execution: "server",
65+
scope: {
66+
stages: ["post"],
67+
},
68+
selector: {
69+
path: "output",
70+
},
71+
},
5472
});
5573
console.log(created.controlId);
5674
```

‎testing.mdx‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,23 @@ def test_scope_rejects_invalid_step_name_regex() -> None:
9696
```python
9797
def test_create_control_returns_id(client: TestClient) -> None:
9898
# Given: a valid control payload
99-
payload = {"name": "pii-protection"}
99+
payload = {
100+
"name": "pii-protection",
101+
"data": {
102+
"description": "Block SSNs in output",
103+
"enabled": True,
104+
"execution": "server",
105+
"scope": {"stages": ["post"]},
106+
"condition": {
107+
"selector": {"path": "output"},
108+
"evaluator": {
109+
"name": "regex",
110+
"config": {"pattern": r"\b\d{3}-\d{2}-\d{4}\b"},
111+
},
112+
},
113+
"action": {"decision": "deny"},
114+
},
115+
}
100116

101117
# When: creating the control via the public API
102118
response = client.put("/api/v1/controls", json=payload)

0 commit comments

Comments
 (0)