Skip to content

Commit 3c2c3c2

Browse files
feat(api): api update
1 parent 0b487b1 commit 3c2c3c2

3 files changed

Lines changed: 23 additions & 25 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: 32
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-242450ea46eb8c3e843fd6c4bf87e73192b5f62f6da697cd091d13c6aa7a991b.yml
3-
openapi_spec_hash: c1c561976de1abcacede71fd5ab9b3d9
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-2bf2b44f6593c44b2948683469bbb2b09cd8e90c97b12057fac6220cf0d2eee7.yml
3+
openapi_spec_hash: ae8b5109ec997cac8d3e6ec96040f6c8
44
config_hash: 70e7e80b5e87f94981bee396c6cd41e8

‎pkg/cmd/monitor.go‎

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,34 +19,32 @@ var monitorsCreate = requestflag.WithInnerFlags(cli.Command{
1919
Usage: "Creates a monitor. The request body is a union of the supported target/change\ndetection combinations. The monitor runs immediately after creation to create\nits initial baseline.",
2020
Suggest: true,
2121
Flags: []cli.Flag{
22-
&requestflag.Flag[map[string]any]{
23-
Name: "change-detection",
24-
Usage: "Discriminated union describing how changes are detected.",
25-
Required: true,
26-
BodyPath: "change_detection",
27-
},
2822
&requestflag.Flag[string]{
2923
Name: "name",
3024
Required: true,
3125
BodyPath: "name",
3226
},
33-
&requestflag.Flag[map[string]any]{
34-
Name: "schedule",
35-
Usage: "Run the monitor on a fixed interval defined by a frequency and a unit, e.g. every 6 hours or every 2 days. The total interval (frequency × unit) must be between 10 minutes and 1 year.",
36-
Required: true,
37-
BodyPath: "schedule",
38-
},
3927
&requestflag.Flag[map[string]any]{
4028
Name: "target",
4129
Usage: "Discriminated union describing what the monitor watches.",
4230
Required: true,
4331
BodyPath: "target",
4432
},
33+
&requestflag.Flag[map[string]any]{
34+
Name: "change-detection",
35+
Usage: "Discriminated union describing how changes are detected.",
36+
BodyPath: "change_detection",
37+
},
4538
&requestflag.Flag[string]{
4639
Name: "mode",
4740
Usage: "Top-level monitor category. Always `web` today; the concrete behavior is described by `target` and `change_detection`.",
4841
BodyPath: "mode",
4942
},
43+
&requestflag.Flag[map[string]any]{
44+
Name: "schedule",
45+
Usage: "Run the monitor on a fixed interval defined by a frequency and a unit, e.g. every 6 hours or every 2 days. The total interval (frequency × unit) must be between 10 minutes and 1 year.",
46+
BodyPath: "schedule",
47+
},
5048
&requestflag.Flag[[]string]{
5149
Name: "tag",
5250
Usage: "User-defined tags for grouping and filtering monitors and their changes. Duplicates are removed.",

‎pkg/cmd/monitor_test.go‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ func TestMonitorsCreate(t *testing.T) {
1616
t,
1717
"--api-key", "string",
1818
"monitors", "create",
19-
"--change-detection", "{type: exact}",
2019
"--name", "Acme pricing page",
21-
"--schedule", "{frequency: 6, type: interval, unit: hours}",
2220
"--target", "{type: page, url: https://acme.com/pricing, normalize_whitespace: true}",
21+
"--change-detection", "{type: exact}",
2322
"--mode", "web",
23+
"--schedule", "{frequency: 6, type: interval, unit: hours}",
2424
"--tag", "pricing",
2525
"--tag", "competitor",
2626
"--webhook", "{url: https://example.com/webhook, events: [change.detected, run.completed]}",
@@ -36,13 +36,13 @@ func TestMonitorsCreate(t *testing.T) {
3636
t,
3737
"--api-key", "string",
3838
"monitors", "create",
39-
"--change-detection", "{type: exact}",
4039
"--name", "Acme pricing page",
40+
"--target", "{type: page, url: https://acme.com/pricing, normalize_whitespace: true}",
41+
"--change-detection", "{type: exact}",
42+
"--mode", "web",
4143
"--schedule.frequency", "6",
4244
"--schedule.type", "interval",
4345
"--schedule.unit", "hours",
44-
"--target", "{type: page, url: https://acme.com/pricing, normalize_whitespace: true}",
45-
"--mode", "web",
4646
"--tag", "pricing",
4747
"--tag", "competitor",
4848
"--webhook.url", "https://example.com/webhook",
@@ -53,18 +53,18 @@ func TestMonitorsCreate(t *testing.T) {
5353
t.Run("piping data", func(t *testing.T) {
5454
// Test piping YAML data over stdin
5555
pipeData := []byte("" +
56-
"change_detection:\n" +
57-
" type: exact\n" +
5856
"name: Acme pricing page\n" +
59-
"schedule:\n" +
60-
" frequency: 6\n" +
61-
" type: interval\n" +
62-
" unit: hours\n" +
6357
"target:\n" +
6458
" type: page\n" +
6559
" url: https://acme.com/pricing\n" +
6660
" normalize_whitespace: true\n" +
61+
"change_detection:\n" +
62+
" type: exact\n" +
6763
"mode: web\n" +
64+
"schedule:\n" +
65+
" frequency: 6\n" +
66+
" type: interval\n" +
67+
" unit: hours\n" +
6868
"tags:\n" +
6969
" - pricing\n" +
7070
" - competitor\n" +

0 commit comments

Comments
 (0)