Skip to content

Commit 789eb86

Browse files
feat(api): api update
1 parent f80c306 commit 789eb86

13 files changed

Lines changed: 572 additions & 2713 deletions

‎.stats.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 36
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-8667763c416101820f5086c97d542bf13bb3bb12b57f5f604da671d9dcea0599.yml
3-
openapi_spec_hash: e33db883d584bc8573897391f3edb105
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-66a3bf68b47ba61c9b61406d36f614a079ff752b8964a8df8062e485391d5598.yml
3+
openapi_spec_hash: b17d6cfe3710dd0605078f3907a1a419
44
config_hash: 7ec4851ee8d93177947e95df5ae897b5

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

Lines changed: 155 additions & 461 deletions
Large diffs are not rendered by default.

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

Lines changed: 47 additions & 215 deletions
Original file line numberDiff line numberDiff line change
@@ -9,122 +9,48 @@
99

1010
__all__ = [
1111
"MonitorCreateParams",
12-
"MonitorsCreatePageExactMonitorRequest",
13-
"MonitorsCreatePageExactMonitorRequestChangeDetection",
14-
"MonitorsCreatePageExactMonitorRequestSchedule",
15-
"MonitorsCreatePageExactMonitorRequestTarget",
16-
"MonitorsCreatePageExactMonitorRequestWebhook",
17-
"MonitorsCreateSitemapExactMonitorRequest",
18-
"MonitorsCreateSitemapExactMonitorRequestChangeDetection",
19-
"MonitorsCreateSitemapExactMonitorRequestSchedule",
20-
"MonitorsCreateSitemapExactMonitorRequestTarget",
21-
"MonitorsCreateSitemapExactMonitorRequestWebhook",
22-
"MonitorsCreatePageSemanticMonitorRequest",
23-
"MonitorsCreatePageSemanticMonitorRequestChangeDetection",
24-
"MonitorsCreatePageSemanticMonitorRequestSchedule",
25-
"MonitorsCreatePageSemanticMonitorRequestTarget",
26-
"MonitorsCreatePageSemanticMonitorRequestWebhook",
27-
"MonitorsCreateExtractSemanticMonitorRequest",
28-
"MonitorsCreateExtractSemanticMonitorRequestChangeDetection",
29-
"MonitorsCreateExtractSemanticMonitorRequestSchedule",
30-
"MonitorsCreateExtractSemanticMonitorRequestTarget",
31-
"MonitorsCreateExtractSemanticMonitorRequestWebhook",
12+
"ChangeDetection",
13+
"ChangeDetectionMonitorsExactChangeDetection",
14+
"ChangeDetectionMonitorsSemanticChangeDetection",
15+
"Schedule",
16+
"Target",
17+
"TargetMonitorsPageTarget",
18+
"TargetMonitorsSitemapTarget",
19+
"TargetMonitorsExtractTarget",
20+
"Webhook",
3221
]
3322

3423

35-
class MonitorsCreatePageExactMonitorRequest(TypedDict, total=False):
36-
change_detection: Required[MonitorsCreatePageExactMonitorRequestChangeDetection]
37-
"""Detect exact changes.
38-
39-
For page targets, this means visible text diffs. For sitemap targets, this means
40-
URL additions and removals.
41-
"""
24+
class MonitorCreateParams(TypedDict, total=False):
25+
change_detection: Required[ChangeDetection]
26+
"""Discriminated union describing how changes are detected."""
4227

4328
name: Required[str]
4429

45-
schedule: Required[MonitorsCreatePageExactMonitorRequestSchedule]
30+
schedule: Required[Schedule]
4631
"""Run the monitor on a fixed interval defined by a frequency and a unit, e.g.
4732
4833
every 6 hours or every 2 days. The total interval (frequency × unit) must be
4934
between 10 minutes and 1 year.
5035
"""
5136

52-
target: Required[MonitorsCreatePageExactMonitorRequestTarget]
53-
54-
tags: SequenceNotStr[str]
55-
"""User-defined tags for grouping and filtering monitors and their changes."""
56-
57-
webhook: Optional[MonitorsCreatePageExactMonitorRequestWebhook]
58-
59-
60-
class MonitorsCreatePageExactMonitorRequestChangeDetection(TypedDict, total=False):
61-
"""Detect exact changes.
62-
63-
For page targets, this means visible text diffs. For sitemap targets, this means URL additions and removals.
64-
"""
65-
66-
type: Required[Literal["exact"]]
67-
68-
69-
class MonitorsCreatePageExactMonitorRequestSchedule(TypedDict, total=False):
70-
"""Run the monitor on a fixed interval defined by a frequency and a unit, e.g.
71-
72-
every 6 hours or every 2 days. The total interval (frequency × unit) must be between 10 minutes and 1 year.
73-
"""
74-
75-
frequency: Required[int]
76-
"""Number of units between runs.
77-
78-
The resulting interval (frequency × unit) must be at least 10 minutes and at
79-
most 1 year (e.g. minimum 10 when unit is minutes; maximum 365 when unit is
80-
days).
81-
"""
82-
83-
type: Required[Literal["interval"]]
84-
85-
unit: Required[Literal["minutes", "hours", "days"]]
86-
87-
88-
class MonitorsCreatePageExactMonitorRequestTarget(TypedDict, total=False):
89-
type: Required[Literal["page"]]
90-
91-
url: Required[str]
92-
93-
normalize_whitespace: bool
94-
"""Normalize whitespace before comparing or analyzing text."""
95-
96-
97-
class MonitorsCreatePageExactMonitorRequestWebhook(TypedDict, total=False):
98-
url: Required[str]
99-
"""Webhook URL called when a change is detected."""
100-
101-
102-
class MonitorsCreateSitemapExactMonitorRequest(TypedDict, total=False):
103-
change_detection: Required[MonitorsCreateSitemapExactMonitorRequestChangeDetection]
104-
"""Detect exact changes.
105-
106-
For page targets, this means visible text diffs. For sitemap targets, this means
107-
URL additions and removals.
108-
"""
109-
110-
name: Required[str]
37+
target: Required[Target]
38+
"""Discriminated union describing what the monitor watches."""
11139

112-
schedule: Required[MonitorsCreateSitemapExactMonitorRequestSchedule]
113-
"""Run the monitor on a fixed interval defined by a frequency and a unit, e.g.
40+
mode: Literal["web"]
41+
"""Top-level monitor category.
11442
115-
every 6 hours or every 2 days. The total interval (frequency × unit) must be
116-
between 10 minutes and 1 year.
43+
Always `web` today; the concrete behavior is described by `target` and
44+
`change_detection`.
11745
"""
11846

119-
target: Required[MonitorsCreateSitemapExactMonitorRequestTarget]
120-
12147
tags: SequenceNotStr[str]
12248
"""User-defined tags for grouping and filtering monitors and their changes."""
12349

124-
webhook: Optional[MonitorsCreateSitemapExactMonitorRequestWebhook]
50+
webhook: Optional[Webhook]
12551

12652

127-
class MonitorsCreateSitemapExactMonitorRequestChangeDetection(TypedDict, total=False):
53+
class ChangeDetectionMonitorsExactChangeDetection(TypedDict, total=False):
12854
"""Detect exact changes.
12955
13056
For page targets, this means visible text diffs. For sitemap targets, this means URL additions and removals.
@@ -133,67 +59,7 @@ class MonitorsCreateSitemapExactMonitorRequestChangeDetection(TypedDict, total=F
13359
type: Required[Literal["exact"]]
13460

13561

136-
class MonitorsCreateSitemapExactMonitorRequestSchedule(TypedDict, total=False):
137-
"""Run the monitor on a fixed interval defined by a frequency and a unit, e.g.
138-
139-
every 6 hours or every 2 days. The total interval (frequency × unit) must be between 10 minutes and 1 year.
140-
"""
141-
142-
frequency: Required[int]
143-
"""Number of units between runs.
144-
145-
The resulting interval (frequency × unit) must be at least 10 minutes and at
146-
most 1 year (e.g. minimum 10 when unit is minutes; maximum 365 when unit is
147-
days).
148-
"""
149-
150-
type: Required[Literal["interval"]]
151-
152-
unit: Required[Literal["minutes", "hours", "days"]]
153-
154-
155-
class MonitorsCreateSitemapExactMonitorRequestTarget(TypedDict, total=False):
156-
type: Required[Literal["sitemap"]]
157-
158-
url: Required[str]
159-
"""Sitemap URL to monitor."""
160-
161-
exclude: SequenceNotStr[str]
162-
"""URL path patterns to exclude."""
163-
164-
include: SequenceNotStr[str]
165-
"""URL path patterns to include."""
166-
167-
max_urls: int
168-
169-
170-
class MonitorsCreateSitemapExactMonitorRequestWebhook(TypedDict, total=False):
171-
url: Required[str]
172-
"""Webhook URL called when a change is detected."""
173-
174-
175-
class MonitorsCreatePageSemanticMonitorRequest(TypedDict, total=False):
176-
change_detection: Required[MonitorsCreatePageSemanticMonitorRequestChangeDetection]
177-
"""Detect meaning-level changes that match a natural language query."""
178-
179-
name: Required[str]
180-
181-
schedule: Required[MonitorsCreatePageSemanticMonitorRequestSchedule]
182-
"""Run the monitor on a fixed interval defined by a frequency and a unit, e.g.
183-
184-
every 6 hours or every 2 days. The total interval (frequency × unit) must be
185-
between 10 minutes and 1 year.
186-
"""
187-
188-
target: Required[MonitorsCreatePageSemanticMonitorRequestTarget]
189-
190-
tags: SequenceNotStr[str]
191-
"""User-defined tags for grouping and filtering monitors and their changes."""
192-
193-
webhook: Optional[MonitorsCreatePageSemanticMonitorRequestWebhook]
194-
195-
196-
class MonitorsCreatePageSemanticMonitorRequestChangeDetection(TypedDict, total=False):
62+
class ChangeDetectionMonitorsSemanticChangeDetection(TypedDict, total=False):
19763
"""Detect meaning-level changes that match a natural language query."""
19864

19965
query: Required[str]
@@ -203,7 +69,12 @@ class MonitorsCreatePageSemanticMonitorRequestChangeDetection(TypedDict, total=F
20369
confidence_threshold: float
20470

20571

206-
class MonitorsCreatePageSemanticMonitorRequestSchedule(TypedDict, total=False):
72+
ChangeDetection: TypeAlias = Union[
73+
ChangeDetectionMonitorsExactChangeDetection, ChangeDetectionMonitorsSemanticChangeDetection
74+
]
75+
76+
77+
class Schedule(TypedDict, total=False):
20778
"""Run the monitor on a fixed interval defined by a frequency and a unit, e.g.
20879
20980
every 6 hours or every 2 days. The total interval (frequency × unit) must be between 10 minutes and 1 year.
@@ -222,7 +93,9 @@ class MonitorsCreatePageSemanticMonitorRequestSchedule(TypedDict, total=False):
22293
unit: Required[Literal["minutes", "hours", "days"]]
22394

22495

225-
class MonitorsCreatePageSemanticMonitorRequestTarget(TypedDict, total=False):
96+
class TargetMonitorsPageTarget(TypedDict, total=False):
97+
"""Watch a single web page."""
98+
22699
type: Required[Literal["page"]]
227100

228101
url: Required[str]
@@ -231,62 +104,26 @@ class MonitorsCreatePageSemanticMonitorRequestTarget(TypedDict, total=False):
231104
"""Normalize whitespace before comparing or analyzing text."""
232105

233106

234-
class MonitorsCreatePageSemanticMonitorRequestWebhook(TypedDict, total=False):
235-
url: Required[str]
236-
"""Webhook URL called when a change is detected."""
237-
238-
239-
class MonitorsCreateExtractSemanticMonitorRequest(TypedDict, total=False):
240-
change_detection: Required[MonitorsCreateExtractSemanticMonitorRequestChangeDetection]
241-
"""Detect meaning-level changes that match a natural language query."""
242-
243-
name: Required[str]
244-
245-
schedule: Required[MonitorsCreateExtractSemanticMonitorRequestSchedule]
246-
"""Run the monitor on a fixed interval defined by a frequency and a unit, e.g.
247-
248-
every 6 hours or every 2 days. The total interval (frequency × unit) must be
249-
between 10 minutes and 1 year.
250-
"""
251-
252-
target: Required[MonitorsCreateExtractSemanticMonitorRequestTarget]
253-
254-
tags: SequenceNotStr[str]
255-
"""User-defined tags for grouping and filtering monitors and their changes."""
107+
class TargetMonitorsSitemapTarget(TypedDict, total=False):
108+
"""Watch a sitemap for URL additions and removals."""
256109

257-
webhook: Optional[MonitorsCreateExtractSemanticMonitorRequestWebhook]
258-
259-
260-
class MonitorsCreateExtractSemanticMonitorRequestChangeDetection(TypedDict, total=False):
261-
"""Detect meaning-level changes that match a natural language query."""
262-
263-
query: Required[str]
264-
265-
type: Required[Literal["semantic"]]
266-
267-
confidence_threshold: float
268-
269-
270-
class MonitorsCreateExtractSemanticMonitorRequestSchedule(TypedDict, total=False):
271-
"""Run the monitor on a fixed interval defined by a frequency and a unit, e.g.
110+
type: Required[Literal["sitemap"]]
272111

273-
every 6 hours or every 2 days. The total interval (frequency × unit) must be between 10 minutes and 1 year.
274-
"""
112+
url: Required[str]
113+
"""Sitemap URL to monitor."""
275114

276-
frequency: Required[int]
277-
"""Number of units between runs.
115+
exclude: SequenceNotStr[str]
116+
"""URL path patterns to exclude."""
278117

279-
The resulting interval (frequency × unit) must be at least 10 minutes and at
280-
most 1 year (e.g. minimum 10 when unit is minutes; maximum 365 when unit is
281-
days).
282-
"""
118+
include: SequenceNotStr[str]
119+
"""URL path patterns to include."""
283120

284-
type: Required[Literal["interval"]]
121+
max_urls: int
285122

286-
unit: Required[Literal["minutes", "hours", "days"]]
287123

124+
class TargetMonitorsExtractTarget(TypedDict, total=False):
125+
"""Watch a site's extracted structured data."""
288126

289-
class MonitorsCreateExtractSemanticMonitorRequestTarget(TypedDict, total=False):
290127
type: Required[Literal["extract"]]
291128

292129
url: Required[str]
@@ -310,14 +147,9 @@ class MonitorsCreateExtractSemanticMonitorRequestTarget(TypedDict, total=False):
310147
"""
311148

312149

313-
class MonitorsCreateExtractSemanticMonitorRequestWebhook(TypedDict, total=False):
314-
url: Required[str]
315-
"""Webhook URL called when a change is detected."""
150+
Target: TypeAlias = Union[TargetMonitorsPageTarget, TargetMonitorsSitemapTarget, TargetMonitorsExtractTarget]
316151

317152

318-
MonitorCreateParams: TypeAlias = Union[
319-
MonitorsCreatePageExactMonitorRequest,
320-
MonitorsCreateSitemapExactMonitorRequest,
321-
MonitorsCreatePageSemanticMonitorRequest,
322-
MonitorsCreateExtractSemanticMonitorRequest,
323-
]
153+
class Webhook(TypedDict, total=False):
154+
url: Required[str]
155+
"""Webhook URL called when a change is detected."""

0 commit comments

Comments
 (0)