Skip to content

Commit 226b29c

Browse files
feat(api): api update
1 parent 3764f98 commit 226b29c

5 files changed

Lines changed: 98 additions & 128 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

‎src/context/dev/resources/monitors.py‎

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,11 @@ def with_streaming_response(self) -> MonitorsResourceWithStreamingResponse:
7373
def create(
7474
self,
7575
*,
76-
change_detection: monitor_create_params.ChangeDetection,
7776
name: str,
78-
schedule: monitor_create_params.Schedule,
7977
target: monitor_create_params.Target,
78+
change_detection: monitor_create_params.ChangeDetection | Omit = omit,
8079
mode: Literal["web"] | Omit = omit,
80+
schedule: monitor_create_params.Schedule | Omit = omit,
8181
tags: SequenceNotStr[str] | Omit = omit,
8282
webhook: Optional[monitor_create_params.Webhook] | Omit = omit,
8383
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -94,17 +94,17 @@ def create(
9494
its initial baseline.
9595
9696
Args:
97+
target: Discriminated union describing what the monitor watches.
98+
9799
change_detection: Discriminated union describing how changes are detected.
98100
101+
mode: Top-level monitor category. Always `web` today; the concrete behavior is
102+
described by `target` and `change_detection`.
103+
99104
schedule: Run the monitor on a fixed interval defined by a frequency and a unit, e.g.
100105
every 6 hours or every 2 days. The total interval (frequency × unit) must be
101106
between 10 minutes and 1 year.
102107
103-
target: Discriminated union describing what the monitor watches.
104-
105-
mode: Top-level monitor category. Always `web` today; the concrete behavior is
106-
described by `target` and `change_detection`.
107-
108108
tags: User-defined tags for grouping and filtering monitors and their changes.
109109
Duplicates are removed.
110110
@@ -120,11 +120,11 @@ def create(
120120
"/monitors",
121121
body=maybe_transform(
122122
{
123-
"change_detection": change_detection,
124123
"name": name,
125-
"schedule": schedule,
126124
"target": target,
125+
"change_detection": change_detection,
127126
"mode": mode,
127+
"schedule": schedule,
128128
"tags": tags,
129129
"webhook": webhook,
130130
},
@@ -749,11 +749,11 @@ def with_streaming_response(self) -> AsyncMonitorsResourceWithStreamingResponse:
749749
async def create(
750750
self,
751751
*,
752-
change_detection: monitor_create_params.ChangeDetection,
753752
name: str,
754-
schedule: monitor_create_params.Schedule,
755753
target: monitor_create_params.Target,
754+
change_detection: monitor_create_params.ChangeDetection | Omit = omit,
756755
mode: Literal["web"] | Omit = omit,
756+
schedule: monitor_create_params.Schedule | Omit = omit,
757757
tags: SequenceNotStr[str] | Omit = omit,
758758
webhook: Optional[monitor_create_params.Webhook] | Omit = omit,
759759
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -770,17 +770,17 @@ async def create(
770770
its initial baseline.
771771
772772
Args:
773+
target: Discriminated union describing what the monitor watches.
774+
773775
change_detection: Discriminated union describing how changes are detected.
774776
777+
mode: Top-level monitor category. Always `web` today; the concrete behavior is
778+
described by `target` and `change_detection`.
779+
775780
schedule: Run the monitor on a fixed interval defined by a frequency and a unit, e.g.
776781
every 6 hours or every 2 days. The total interval (frequency × unit) must be
777782
between 10 minutes and 1 year.
778783
779-
target: Discriminated union describing what the monitor watches.
780-
781-
mode: Top-level monitor category. Always `web` today; the concrete behavior is
782-
described by `target` and `change_detection`.
783-
784784
tags: User-defined tags for grouping and filtering monitors and their changes.
785785
Duplicates are removed.
786786
@@ -796,11 +796,11 @@ async def create(
796796
"/monitors",
797797
body=await async_maybe_transform(
798798
{
799-
"change_detection": change_detection,
800799
"name": name,
801-
"schedule": schedule,
802800
"target": target,
801+
"change_detection": change_detection,
803802
"mode": mode,
803+
"schedule": schedule,
804804
"tags": tags,
805805
"webhook": webhook,
806806
},

‎src/context/dev/types/monitor_create_params.py‎

Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -9,91 +9,48 @@
99

1010
__all__ = [
1111
"MonitorCreateParams",
12-
"ChangeDetection",
13-
"ChangeDetectionMonitorsExactChangeDetection",
14-
"ChangeDetectionMonitorsSemanticChangeDetection",
15-
"Schedule",
1612
"Target",
1713
"TargetMonitorsPageTarget",
1814
"TargetMonitorsSitemapTarget",
1915
"TargetMonitorsExtractTarget",
16+
"ChangeDetection",
17+
"ChangeDetectionMonitorsExactChangeDetection",
18+
"ChangeDetectionMonitorsSemanticChangeDetection",
19+
"Schedule",
2020
"Webhook",
2121
]
2222

2323

2424
class MonitorCreateParams(TypedDict, total=False):
25-
change_detection: Required[ChangeDetection]
26-
"""Discriminated union describing how changes are detected."""
27-
2825
name: Required[str]
2926

30-
schedule: Required[Schedule]
31-
"""Run the monitor on a fixed interval defined by a frequency and a unit, e.g.
32-
33-
every 6 hours or every 2 days. The total interval (frequency × unit) must be
34-
between 10 minutes and 1 year.
35-
"""
36-
3727
target: Required[Target]
3828
"""Discriminated union describing what the monitor watches."""
3929

30+
change_detection: ChangeDetection
31+
"""Discriminated union describing how changes are detected."""
32+
4033
mode: Literal["web"]
4134
"""Top-level monitor category.
4235
4336
Always `web` today; the concrete behavior is described by `target` and
4437
`change_detection`.
4538
"""
4639

47-
tags: SequenceNotStr[str]
48-
"""User-defined tags for grouping and filtering monitors and their changes.
49-
50-
Duplicates are removed.
51-
"""
52-
53-
webhook: Optional[Webhook]
54-
55-
56-
class ChangeDetectionMonitorsExactChangeDetection(TypedDict, total=False):
57-
"""Detect exact changes.
58-
59-
For page targets, this means visible text diffs. For sitemap targets, this means URL additions and removals.
60-
"""
61-
62-
type: Required[Literal["exact"]]
63-
64-
65-
class ChangeDetectionMonitorsSemanticChangeDetection(TypedDict, total=False):
66-
"""
67-
Detect meaning-level changes to tracked page content, ignoring cosmetic or paraphrase-only differences. Which changes are meaningful is judged against the extract target's `instructions` (and `schema`, when provided).
68-
"""
69-
70-
type: Required[Literal["semantic"]]
71-
72-
confidence_threshold: float
73-
74-
75-
ChangeDetection: TypeAlias = Union[
76-
ChangeDetectionMonitorsExactChangeDetection, ChangeDetectionMonitorsSemanticChangeDetection
77-
]
78-
79-
80-
class Schedule(TypedDict, total=False):
40+
schedule: Schedule
8141
"""Run the monitor on a fixed interval defined by a frequency and a unit, e.g.
8242
83-
every 6 hours or every 2 days. The total interval (frequency × unit) must be between 10 minutes and 1 year.
43+
every 6 hours or every 2 days. The total interval (frequency × unit) must be
44+
between 10 minutes and 1 year.
8445
"""
8546

86-
frequency: Required[int]
87-
"""Number of units between runs.
47+
tags: SequenceNotStr[str]
48+
"""User-defined tags for grouping and filtering monitors and their changes.
8849
89-
The resulting interval (frequency × unit) must be at least 10 minutes and at
90-
most 1 year (e.g. minimum 10 when unit is minutes; maximum 365 when unit is
91-
days).
50+
Duplicates are removed.
9251
"""
9352

94-
type: Required[Literal["interval"]]
95-
96-
unit: Required[Literal["minutes", "hours", "days"]]
53+
webhook: Optional[Webhook]
9754

9855

9956
class TargetMonitorsPageTarget(TypedDict, total=False):
@@ -169,6 +126,49 @@ class TargetMonitorsExtractTarget(TypedDict, total=False):
169126
Target: TypeAlias = Union[TargetMonitorsPageTarget, TargetMonitorsSitemapTarget, TargetMonitorsExtractTarget]
170127

171128

129+
class ChangeDetectionMonitorsExactChangeDetection(TypedDict, total=False):
130+
"""Detect exact changes.
131+
132+
For page targets, this means visible text diffs. For sitemap targets, this means URL additions and removals.
133+
"""
134+
135+
type: Required[Literal["exact"]]
136+
137+
138+
class ChangeDetectionMonitorsSemanticChangeDetection(TypedDict, total=False):
139+
"""
140+
Detect meaning-level changes to tracked page content, ignoring cosmetic or paraphrase-only differences. Which changes are meaningful is judged against the extract target's `instructions` (and `schema`, when provided).
141+
"""
142+
143+
type: Required[Literal["semantic"]]
144+
145+
confidence_threshold: float
146+
147+
148+
ChangeDetection: TypeAlias = Union[
149+
ChangeDetectionMonitorsExactChangeDetection, ChangeDetectionMonitorsSemanticChangeDetection
150+
]
151+
152+
153+
class Schedule(TypedDict, total=False):
154+
"""Run the monitor on a fixed interval defined by a frequency and a unit, e.g.
155+
156+
every 6 hours or every 2 days. The total interval (frequency × unit) must be between 10 minutes and 1 year.
157+
"""
158+
159+
frequency: Required[int]
160+
"""Number of units between runs.
161+
162+
The resulting interval (frequency × unit) must be at least 10 minutes and at
163+
most 1 year (e.g. minimum 10 when unit is minutes; maximum 365 when unit is
164+
days).
165+
"""
166+
167+
type: Required[Literal["interval"]]
168+
169+
unit: Required[Literal["minutes", "hours", "days"]]
170+
171+
172172
class Webhook(TypedDict, total=False):
173173
url: Required[str]
174174
"""Webhook URL events are delivered to."""

‎src/context/dev/types/monitor_create_response.py‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,8 @@ class WebhookFailure(BaseModel):
251251

252252

253253
class MonitorCreateResponse(BaseModel):
254-
"""A web monitor.
255-
256-
`mode` is the constant `web`; behavior is described by `target` (page/sitemap/extract) and `change_detection` (exact/semantic).
254+
"""
255+
A newly created monitor plus `initial_run_id`, the id of the baseline run queued at creation.
257256
"""
258257

259258
id: str
@@ -263,6 +262,13 @@ class MonitorCreateResponse(BaseModel):
263262

264263
created_at: datetime
265264

265+
initial_run_id: Optional[str] = None
266+
"""
267+
The baseline run queued by this create call, or null if it could not be queued
268+
immediately (in which case the baseline runs on the next scheduled tick). Poll
269+
GET /monitors/{monitor_id}/runs/{run_id}.
270+
"""
271+
266272
mode: Literal["web"]
267273
"""Top-level monitor category.
268274

0 commit comments

Comments
 (0)