Skip to content

Commit 16201c6

Browse files
feat(api): api update
1 parent e636b6d commit 16201c6

3 files changed

Lines changed: 26 additions & 8 deletions

File tree

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 29
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-adab8df19dce27396e4a0e698287f083e1f932e63b85fd8dd4d54f80f0e0b5a8.yml
3-
openapi_spec_hash: 717fea46f446ff97bad627f200963fd7
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-ecf38e27f0c2544a8965f6cee827927343a926e1ab511aa7b34e8aa7d1866c8e.yml
3+
openapi_spec_hash: c5767791a19b95c52ef073902fa5da77
44
config_hash: ff35e224e809656528c44163aa41bebd

pkg/cmd/monitor.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,14 @@ var monitorsCreate = requestflag.WithInnerFlags(cli.Command{
8080
"webhook": {
8181
&requestflag.InnerFlag[string]{
8282
Name: "webhook.url",
83-
Usage: "Webhook URL called when a change is detected.",
83+
Usage: "Webhook URL events are delivered to.",
8484
InnerField: "url",
8585
},
86+
&requestflag.InnerFlag[[]string]{
87+
Name: "webhook.events",
88+
Usage: "Events delivered to this endpoint. `change.detected` fires only when a run detects a change; `run.completed` fires on every completed run — including runs that detected no change — and embeds the change when one was detected. Defaults to `[\"change.detected\"]` when omitted.",
89+
InnerField: "events",
90+
},
8691
&requestflag.InnerFlag[string]{
8792
Name: "webhook.secret",
8893
Usage: "Signing secret used to verify webhook authenticity. Each delivery includes an `X-Context-Signature: t=<unix>,v1=<hmac>` header, where the HMAC is SHA-256 over `\"{t}.{rawRequestBody}\"` keyed by this secret. Recompute it with a constant-time compare and reject stale timestamps to prevent replay. Generated by the API; cannot be set by clients.",
@@ -174,9 +179,14 @@ var monitorsUpdate = requestflag.WithInnerFlags(cli.Command{
174179
"webhook": {
175180
&requestflag.InnerFlag[string]{
176181
Name: "webhook.url",
177-
Usage: "Webhook URL called when a change is detected.",
182+
Usage: "Webhook URL events are delivered to.",
178183
InnerField: "url",
179184
},
185+
&requestflag.InnerFlag[[]string]{
186+
Name: "webhook.events",
187+
Usage: "Events delivered to this endpoint. `change.detected` fires only when a run detects a change; `run.completed` fires on every completed run — including runs that detected no change — and embeds the change when one was detected. Defaults to `[\"change.detected\"]` when omitted.",
188+
InnerField: "events",
189+
},
180190
&requestflag.InnerFlag[string]{
181191
Name: "webhook.secret",
182192
Usage: "Signing secret used to verify webhook authenticity. Each delivery includes an `X-Context-Signature: t=<unix>,v1=<hmac>` header, where the HMAC is SHA-256 over `\"{t}.{rawRequestBody}\"` keyed by this secret. Recompute it with a constant-time compare and reject stale timestamps to prevent replay. Generated by the API; cannot be set by clients.",

pkg/cmd/monitor_test.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func TestMonitorsCreate(t *testing.T) {
2323
"--mode", "web",
2424
"--tag", "pricing",
2525
"--tag", "competitor",
26-
"--webhook", "{url: https://example.com/webhook}",
26+
"--webhook", "{url: https://example.com/webhook, events: [change.detected, run.completed]}",
2727
)
2828
})
2929

@@ -46,6 +46,7 @@ func TestMonitorsCreate(t *testing.T) {
4646
"--tag", "pricing",
4747
"--tag", "competitor",
4848
"--webhook.url", "https://example.com/webhook",
49+
"--webhook.events", "[change.detected, run.completed]",
4950
)
5051
})
5152

@@ -68,7 +69,10 @@ func TestMonitorsCreate(t *testing.T) {
6869
" - pricing\n" +
6970
" - competitor\n" +
7071
"webhook:\n" +
71-
" url: https://example.com/webhook\n")
72+
" url: https://example.com/webhook\n" +
73+
" events:\n" +
74+
" - change.detected\n" +
75+
" - run.completed\n")
7276
mocktest.TestRunMockTestWithPipeAndFlags(
7377
t, pipeData,
7478
"--api-key", "string",
@@ -104,7 +108,7 @@ func TestMonitorsUpdate(t *testing.T) {
104108
"--tag", "pricing",
105109
"--tag", "competitor",
106110
"--target", "{type: page, url: https://acme.com/pricing, normalize_whitespace: true}",
107-
"--webhook", "{url: https://example.com/webhook}",
111+
"--webhook", "{url: https://example.com/webhook, events: [change.detected, run.completed]}",
108112
)
109113
})
110114

@@ -128,6 +132,7 @@ func TestMonitorsUpdate(t *testing.T) {
128132
"--tag", "competitor",
129133
"--target", "{type: page, url: https://acme.com/pricing, normalize_whitespace: true}",
130134
"--webhook.url", "https://example.com/webhook",
135+
"--webhook.events", "[change.detected, run.completed]",
131136
)
132137
})
133138

@@ -150,7 +155,10 @@ func TestMonitorsUpdate(t *testing.T) {
150155
" url: https://acme.com/pricing\n" +
151156
" normalize_whitespace: true\n" +
152157
"webhook:\n" +
153-
" url: https://example.com/webhook\n")
158+
" url: https://example.com/webhook\n" +
159+
" events:\n" +
160+
" - change.detected\n" +
161+
" - run.completed\n")
154162
mocktest.TestRunMockTestWithPipeAndFlags(
155163
t, pipeData,
156164
"--api-key", "string",

0 commit comments

Comments
 (0)