Skip to content

Commit a2650d4

Browse files
feat(api): api update
1 parent c15ed56 commit a2650d4

15 files changed

Lines changed: 209 additions & 20 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-c7625b4a7beb9e7d9827f3b836e6539cbc5f26b6754891d4352716e38cdecd73.yml
3-
openapi_spec_hash: cbee9cf164cc6704a6febb4d9737e83e
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-09b6020939995033719a53b988fb00bdb20c42d87070975a8d6b469fa18128fb.yml
3+
openapi_spec_hash: ba3e471937a679e2c45c0b9a115fca5c
44
config_hash: 7ec4851ee8d93177947e95df5ae897b5

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

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,12 @@ def list(
267267
search_type: `prefix` for as-you-type prefix matching (default), `exact` for full-token
268268
matching.
269269
270+
status: Monitor lifecycle status. `failed` means the most recent run failed (see the
271+
monitor's `last_error`); failed monitors keep running on schedule and flip back
272+
to `active` on the next successful run. Monitors are auto-`paused` after
273+
repeated consecutive failures or insufficient-credit skips; resume by PATCHing
274+
status to `active`.
275+
270276
tag: Filter to items that have this tag.
271277
272278
tags: Comma-separated list of tags to filter by (matches monitors having any of them).
@@ -399,7 +405,7 @@ def list_account_runs(
399405
*,
400406
cursor: str | Omit = omit,
401407
limit: int | Omit = omit,
402-
status: Literal["queued", "running", "completed", "failed"] | Omit = omit,
408+
status: Literal["queued", "running", "completed", "failed", "skipped"] | Omit = omit,
403409
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
404410
# The extra values given here take precedence over values defined on the client or passed to this method.
405411
extra_headers: Headers | None = None,
@@ -411,6 +417,9 @@ def list_account_runs(
411417
Returns an account-wide feed of monitor runs across all monitors.
412418
413419
Args:
420+
status: Lifecycle status of a run. `skipped` runs never executed — see `skip_reason`
421+
(insufficient credits, monitor paused, or superseded by a concurrent run).
422+
414423
extra_headers: Send extra headers
415424
416425
extra_query: Add additional query parameters to the request
@@ -497,18 +506,22 @@ def list_runs(
497506
*,
498507
cursor: str | Omit = omit,
499508
limit: int | Omit = omit,
500-
status: Literal["queued", "running", "completed", "failed"] | Omit = omit,
509+
status: Literal["queued", "running", "completed", "failed", "skipped"] | Omit = omit,
501510
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
502511
# The extra values given here take precedence over values defined on the client or passed to this method.
503512
extra_headers: Headers | None = None,
504513
extra_query: Query | None = None,
505514
extra_body: Body | None = None,
506515
timeout: float | httpx.Timeout | None | NotGiven = not_given,
507516
) -> MonitorListRunsResponse:
508-
"""
509-
List monitor runs
517+
"""List monitor runs
510518
511519
Args:
520+
status: Lifecycle status of a run.
521+
522+
`skipped` runs never executed — see `skip_reason`
523+
(insufficient credits, monitor paused, or superseded by a concurrent run).
524+
512525
extra_headers: Send extra headers
513526
514527
extra_query: Add additional query parameters to the request
@@ -831,6 +844,12 @@ async def list(
831844
search_type: `prefix` for as-you-type prefix matching (default), `exact` for full-token
832845
matching.
833846
847+
status: Monitor lifecycle status. `failed` means the most recent run failed (see the
848+
monitor's `last_error`); failed monitors keep running on schedule and flip back
849+
to `active` on the next successful run. Monitors are auto-`paused` after
850+
repeated consecutive failures or insufficient-credit skips; resume by PATCHing
851+
status to `active`.
852+
834853
tag: Filter to items that have this tag.
835854
836855
tags: Comma-separated list of tags to filter by (matches monitors having any of them).
@@ -963,7 +982,7 @@ async def list_account_runs(
963982
*,
964983
cursor: str | Omit = omit,
965984
limit: int | Omit = omit,
966-
status: Literal["queued", "running", "completed", "failed"] | Omit = omit,
985+
status: Literal["queued", "running", "completed", "failed", "skipped"] | Omit = omit,
967986
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
968987
# The extra values given here take precedence over values defined on the client or passed to this method.
969988
extra_headers: Headers | None = None,
@@ -975,6 +994,9 @@ async def list_account_runs(
975994
Returns an account-wide feed of monitor runs across all monitors.
976995
977996
Args:
997+
status: Lifecycle status of a run. `skipped` runs never executed — see `skip_reason`
998+
(insufficient credits, monitor paused, or superseded by a concurrent run).
999+
9781000
extra_headers: Send extra headers
9791001
9801002
extra_query: Add additional query parameters to the request
@@ -1061,18 +1083,22 @@ async def list_runs(
10611083
*,
10621084
cursor: str | Omit = omit,
10631085
limit: int | Omit = omit,
1064-
status: Literal["queued", "running", "completed", "failed"] | Omit = omit,
1086+
status: Literal["queued", "running", "completed", "failed", "skipped"] | Omit = omit,
10651087
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
10661088
# The extra values given here take precedence over values defined on the client or passed to this method.
10671089
extra_headers: Headers | None = None,
10681090
extra_query: Query | None = None,
10691091
extra_body: Body | None = None,
10701092
timeout: float | httpx.Timeout | None | NotGiven = not_given,
10711093
) -> MonitorListRunsResponse:
1072-
"""
1073-
List monitor runs
1094+
"""List monitor runs
10741095
10751096
Args:
1097+
status: Lifecycle status of a run.
1098+
1099+
`skipped` runs never executed — see `skip_reason`
1100+
(insufficient credits, monitor paused, or superseded by a concurrent run).
1101+
10761102
extra_headers: Send extra headers
10771103
10781104
extra_query: Add additional query parameters to the request

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,10 @@ class TargetMonitorsPageTarget(TypedDict, total=False):
105105

106106

107107
class TargetMonitorsSitemapTarget(TypedDict, total=False):
108-
"""Watch a sitemap for URL additions and removals."""
108+
"""Watch a sitemap for URL additions and removals.
109+
110+
Crawled URLs are normalized (lowercased host, no trailing slash/fragment) and scoped to the monitored site and its subdomains before comparison. A new URL set must be observed on two consecutive runs before a change is reported, suppressing one-run crawl flaps.
111+
"""
109112

110113
type: Required[Literal["sitemap"]]
111114

@@ -119,6 +122,7 @@ class TargetMonitorsSitemapTarget(TypedDict, total=False):
119122
"""URL path patterns to include."""
120123

121124
max_urls: int
125+
"""Maximum number of sitemap URLs to track (capped at 10,000)."""
122126

123127

124128
class TargetMonitorsExtractTarget(TypedDict, total=False):

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

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"TargetMonitorsPageTarget",
2020
"TargetMonitorsSitemapTarget",
2121
"TargetMonitorsExtractTarget",
22+
"LastError",
2223
"Webhook",
2324
]
2425

@@ -79,7 +80,10 @@ class TargetMonitorsPageTarget(BaseModel):
7980

8081

8182
class TargetMonitorsSitemapTarget(BaseModel):
82-
"""Watch a sitemap for URL additions and removals."""
83+
"""Watch a sitemap for URL additions and removals.
84+
85+
Crawled URLs are normalized (lowercased host, no trailing slash/fragment) and scoped to the monitored site and its subdomains before comparison. A new URL set must be observed on two consecutive runs before a change is reported, suppressing one-run crawl flaps.
86+
"""
8387

8488
type: Literal["sitemap"]
8589

@@ -93,6 +97,7 @@ class TargetMonitorsSitemapTarget(BaseModel):
9397
"""URL path patterns to include."""
9498

9599
max_urls: Optional[int] = None
100+
"""Maximum number of sitemap URLs to track (capped at 10,000)."""
96101

97102

98103
class TargetMonitorsExtractTarget(BaseModel):
@@ -127,6 +132,14 @@ class TargetMonitorsExtractTarget(BaseModel):
127132
]
128133

129134

135+
class LastError(BaseModel):
136+
"""Error from the most recent failed run; null when the last run succeeded."""
137+
138+
code: str
139+
140+
message: str
141+
142+
130143
class Webhook(BaseModel):
131144
url: str
132145
"""Webhook URL called when a change is detected."""
@@ -171,6 +184,13 @@ class MonitorCreateResponse(BaseModel):
171184
"""
172185

173186
status: Literal["active", "paused", "failed"]
187+
"""Monitor lifecycle status.
188+
189+
`failed` means the most recent run failed (see the monitor's `last_error`);
190+
failed monitors keep running on schedule and flip back to `active` on the next
191+
successful run. Monitors are auto-`paused` after repeated consecutive failures
192+
or insufficient-credit skips; resume by PATCHing status to `active`.
193+
"""
174194

175195
target: Target
176196
"""Discriminated union describing what the monitor watches."""
@@ -179,8 +199,14 @@ class MonitorCreateResponse(BaseModel):
179199

180200
last_change_at: Optional[datetime] = None
181201

202+
last_error: Optional[LastError] = None
203+
"""Error from the most recent failed run; null when the last run succeeded."""
204+
182205
last_run_at: Optional[datetime] = None
183206

207+
next_run_at: Optional[datetime] = None
208+
"""When the next scheduled run is due."""
209+
184210
tags: Optional[List[str]] = None
185211
"""User-defined tags for grouping and filtering monitors and their changes."""
186212

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,9 @@ class MonitorListAccountRunsParams(TypedDict, total=False):
1212

1313
limit: int
1414

15-
status: Literal["queued", "running", "completed", "failed"]
15+
status: Literal["queued", "running", "completed", "failed", "skipped"]
16+
"""Lifecycle status of a run.
17+
18+
`skipped` runs never executed — see `skip_reason` (insufficient credits, monitor
19+
paused, or superseded by a concurrent run).
20+
"""

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,20 @@ class Data(BaseModel):
2828

2929
change_detection_type: Literal["exact", "semantic"]
3030

31+
credits_charged: int
32+
"""Credits charged for this run (0 for skipped/failed runs)."""
33+
3134
monitor_id: str
3235

3336
run_type: Literal["baseline", "scheduled"]
3437
"""The first run after monitor creation is a baseline run."""
3538

36-
status: Literal["queued", "running", "completed", "failed"]
39+
status: Literal["queued", "running", "completed", "failed", "skipped"]
40+
"""Lifecycle status of a run.
41+
42+
`skipped` runs never executed — see `skip_reason` (insufficient credits, monitor
43+
paused, or superseded by a concurrent run).
44+
"""
3745

3846
target_type: Literal["page", "sitemap", "extract"]
3947

@@ -43,6 +51,9 @@ class Data(BaseModel):
4351

4452
error: Optional[DataError] = None
4553

54+
skip_reason: Optional[Literal["insufficient_credits", "monitor_paused", "superseded"]] = None
55+
"""Why a skipped run never executed; null unless status is `skipped`."""
56+
4657
started_at: Optional[datetime] = None
4758

4859

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ class MonitorListParams(TypedDict, total=False):
3333
"""
3434

3535
status: Literal["active", "paused", "failed"]
36+
"""Monitor lifecycle status.
37+
38+
`failed` means the most recent run failed (see the monitor's `last_error`);
39+
failed monitors keep running on schedule and flip back to `active` on the next
40+
successful run. Monitors are auto-`paused` after repeated consecutive failures
41+
or insufficient-credit skips; resume by PATCHing status to `active`.
42+
"""
3643

3744
tag: str
3845
"""Filter to items that have this tag."""

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

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"DataTargetMonitorsPageTarget",
2121
"DataTargetMonitorsSitemapTarget",
2222
"DataTargetMonitorsExtractTarget",
23+
"DataLastError",
2324
"DataWebhook",
2425
]
2526

@@ -80,7 +81,10 @@ class DataTargetMonitorsPageTarget(BaseModel):
8081

8182

8283
class DataTargetMonitorsSitemapTarget(BaseModel):
83-
"""Watch a sitemap for URL additions and removals."""
84+
"""Watch a sitemap for URL additions and removals.
85+
86+
Crawled URLs are normalized (lowercased host, no trailing slash/fragment) and scoped to the monitored site and its subdomains before comparison. A new URL set must be observed on two consecutive runs before a change is reported, suppressing one-run crawl flaps.
87+
"""
8488

8589
type: Literal["sitemap"]
8690

@@ -94,6 +98,7 @@ class DataTargetMonitorsSitemapTarget(BaseModel):
9498
"""URL path patterns to include."""
9599

96100
max_urls: Optional[int] = None
101+
"""Maximum number of sitemap URLs to track (capped at 10,000)."""
97102

98103

99104
class DataTargetMonitorsExtractTarget(BaseModel):
@@ -128,6 +133,14 @@ class DataTargetMonitorsExtractTarget(BaseModel):
128133
]
129134

130135

136+
class DataLastError(BaseModel):
137+
"""Error from the most recent failed run; null when the last run succeeded."""
138+
139+
code: str
140+
141+
message: str
142+
143+
131144
class DataWebhook(BaseModel):
132145
url: str
133146
"""Webhook URL called when a change is detected."""
@@ -172,6 +185,13 @@ class Data(BaseModel):
172185
"""
173186

174187
status: Literal["active", "paused", "failed"]
188+
"""Monitor lifecycle status.
189+
190+
`failed` means the most recent run failed (see the monitor's `last_error`);
191+
failed monitors keep running on schedule and flip back to `active` on the next
192+
successful run. Monitors are auto-`paused` after repeated consecutive failures
193+
or insufficient-credit skips; resume by PATCHing status to `active`.
194+
"""
175195

176196
target: DataTarget
177197
"""Discriminated union describing what the monitor watches."""
@@ -180,8 +200,14 @@ class Data(BaseModel):
180200

181201
last_change_at: Optional[datetime] = None
182202

203+
last_error: Optional[DataLastError] = None
204+
"""Error from the most recent failed run; null when the last run succeeded."""
205+
183206
last_run_at: Optional[datetime] = None
184207

208+
next_run_at: Optional[datetime] = None
209+
"""When the next scheduled run is due."""
210+
185211
tags: Optional[List[str]] = None
186212
"""User-defined tags for grouping and filtering monitors and their changes."""
187213

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,9 @@ class MonitorListRunsParams(TypedDict, total=False):
1212

1313
limit: int
1414

15-
status: Literal["queued", "running", "completed", "failed"]
15+
status: Literal["queued", "running", "completed", "failed", "skipped"]
16+
"""Lifecycle status of a run.
17+
18+
`skipped` runs never executed — see `skip_reason` (insufficient credits, monitor
19+
paused, or superseded by a concurrent run).
20+
"""

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,20 @@ class Data(BaseModel):
2828

2929
change_detection_type: Literal["exact", "semantic"]
3030

31+
credits_charged: int
32+
"""Credits charged for this run (0 for skipped/failed runs)."""
33+
3134
monitor_id: str
3235

3336
run_type: Literal["baseline", "scheduled"]
3437
"""The first run after monitor creation is a baseline run."""
3538

36-
status: Literal["queued", "running", "completed", "failed"]
39+
status: Literal["queued", "running", "completed", "failed", "skipped"]
40+
"""Lifecycle status of a run.
41+
42+
`skipped` runs never executed — see `skip_reason` (insufficient credits, monitor
43+
paused, or superseded by a concurrent run).
44+
"""
3745

3846
target_type: Literal["page", "sitemap", "extract"]
3947

@@ -43,6 +51,9 @@ class Data(BaseModel):
4351

4452
error: Optional[DataError] = None
4553

54+
skip_reason: Optional[Literal["insufficient_credits", "monitor_paused", "superseded"]] = None
55+
"""Why a skipped run never executed; null unless status is `skipped`."""
56+
4657
started_at: Optional[datetime] = None
4758

4859

0 commit comments

Comments
 (0)