Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(rootly): add statuses, alert events and incident events tables (#128425)

Tom Owers4678b2b979b9
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md
index 9823a4edc8b1..bef70508ad25 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md
@@ -10433,10 +10433,10 @@ Today (16): `action_items`, `alerts`, `causes`, `environments`, `escalation_poli
Diffed against: <https://docs.rootly.com/api-reference>
-- [ ] `incident_events (list-incident-events)` — the incident timeline, the core state/transition history for MTTA and MTTR analysis (high)
-- [ ] `statuses (list-statuses)` — lookup table resolving the status IDs on incidents we already sync (high)
-- [ ] `shifts (list-shifts)` — actual on-call shift records, the basis of on-call load and fairness reporting (high)
-- [ ] `alert_events (list-alert-events)` — alert lifecycle history (ack, escalate, resolve) for the alerts we already sync (high)
+- [x] `incident_events (list-incident-events)` — the incident timeline, the core state/transition history for MTTA and MTTR analysis (high) → `incident_events` (full refresh, fan-out over `incidents`)
+- [x] `statuses (list-statuses)` — lookup table resolving the status IDs on incidents we already sync (high) → `statuses` (full refresh)
+- [ ] `shifts (list-shifts)` — actual on-call shift records, the basis of on-call load and fairness reporting (high); skipped: shifts are computed for a `from`/`to` window that defaults to the next month, with no timestamps to sync on and no documented window limit for past shifts
+- [x] `alert_events (list-alert-events)` — alert lifecycle history (ack, escalate, resolve) for the alerts we already sync (high) → `alert_events` (incremental on `created_at`, from the flat `GET /v1/alert_events` feed)
- [ ] `incident_roles (list-incident-roles)` — lookup resolving role assignments on incidents (commander, comms lead) (high)
- [ ] `on_calls (list-on-calls)` — who was on call for a given schedule and window (medium)
- [ ] `schedule_rotations (list-schedule-rotations)` — resolves the schedules table into rotation structure (medium)
diff --git a/products/warehouse_sources/sources/rootly/canonical_descriptions.py b/products/warehouse_sources/sources/rootly/canonical_descriptions.py
index e329bedff031..4f81725849b6 100644
--- a/products/warehouse_sources/sources/rootly/canonical_descriptions.py
+++ b/products/warehouse_sources/sources/rootly/canonical_descriptions.py
@@ -175,4 +175,46 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"name": "Name of the cause.",
},
},
+ "statuses": {
+ "description": "Custom incident lifecycle statuses defined in the Rootly organization.",
+ "docs_url": "https://docs.rootly.com/api-reference/statuses/list-statuses",
+ "columns": {
+ "id": "Unique identifier for the status.",
+ "name": "Name of the status.",
+ "slug": "URL-safe identifier derived from the status name.",
+ "description": "Description of the status.",
+ "color": "Display color of the status.",
+ "enabled": "Whether the status is enabled.",
+ "created_at": "When the status was created.",
+ "updated_at": "When the status was last updated.",
+ },
+ },
+ "alert_events": {
+ "description": "Lifecycle events of alerts, such as notifications, pages, acknowledgements, escalations, and resolutions.",
+ "docs_url": "https://docs.rootly.com/api-reference/alertevents/list-alert-events-across-alerts",
+ "columns": {
+ "id": "Unique identifier for the alert event.",
+ "alert_id": "ID of the alert the event belongs to.",
+ "kind": "Category of the event (e.g. notification, action, status_update, note).",
+ "action": "What happened (e.g. paged, acknowledged, escalated, resolved).",
+ "source": "Source of the event.",
+ "user_id": "ID of the user who wrote the note, for note events.",
+ "details": "Note message, for note events.",
+ "created_at": "When the event was created.",
+ "updated_at": "When the event was last updated.",
+ },
+ },
+ "incident_events": {
+ "description": "Timeline events of incidents, one row per event on an incident's timeline.",
+ "docs_url": "https://docs.rootly.com/api-reference/incidentevents/list-incident-events",
+ "columns": {
+ "id": "Unique identifier for the incident event.",
+ "incident_id": "ID of the incident the event belongs to.",
+ "event": "Summary of the incident event.",
+ "visibility": "Visibility of the event (internal or external).",
+ "occurred_at": "When the event occurred.",
+ "created_at": "When the event was created.",
+ "updated_at": "When the event was last updated.",
+ },
+ },
}
diff --git a/products/warehouse_sources/sources/rootly/rootly.py b/products/warehouse_sources/sources/rootly/rootly.py
index 2226a57b4c57..4a8d9275bf5b 100644
--- a/products/warehouse_sources/sources/rootly/rootly.py
+++ b/products/warehouse_sources/sources/rootly/rootly.py
@@ -1,14 +1,19 @@
import dataclasses
from datetime import UTC, date, datetime
-from typing import Any, Optional
+from typing import Any, Optional, cast
from urllib.parse import urlencode
from products.warehouse_sources.sources.rootly.settings import ROOTLY_ENDPOINTS, RootlyEndpointConfig
from products.warehouse_sources.sources.sdk import (
+ ClientConfig,
+ Endpoint,
+ JSONResponseCursorPaginator,
JSONResponsePaginator,
+ Resource,
RESTAPIConfig,
ResumableSourceManager,
SourceResponse,
+ build_dependent_resource,
make_tracked_session,
rest_api_resource,
validate_via_probe,
@@ -24,6 +29,13 @@ class RootlyResumeConfig:
# Full next-page URL from the JSON:API `links.next` field. It already carries the page,
# sort, and filter params, so following it preserves the incremental window on every page.
next_url: str | None = None
+ # `meta.next_cursor` for cursor-paginated feeds; the original params are re-sent with it.
+ cursor: str | None = None
+ # Fan-out endpoints resume by parent: the parent paths already fully synced, the parent in
+ # progress, and that parent's paginator state.
+ completed: list[str] | None = None
+ current: str | None = None
+ child_state: dict[str, Any] | None = None
def _accept_headers() -> dict[str, str]:
@@ -98,6 +110,9 @@ def probe_credentials(api_key: str, endpoint: str | None = None) -> int | None:
"""Cheap probe of a Rootly collection. Returns the HTTP status code, or None on a connection
failure. Probes the given endpoint's path when set, else a generic, cheap collection."""
config = ROOTLY_ENDPOINTS.get(endpoint) if endpoint else None
+ if config is not None and config.fanout is not None:
+ # A child path needs a parent id; access to the parent collection is the same scope check.
+ config = ROOTLY_ENDPOINTS[config.fanout.parent_name]
path = config.path if config else "/users"
url = _build_url(f"{ROOTLY_BASE_URL}{path}", {"page[size]": 1})
_ok, status = validate_via_probe(
@@ -108,42 +123,64 @@ def probe_credentials(api_key: str, endpoint: str | None = None) -> int | None:
return status
-def rootly_source(
+def _client_config(api_key: str) -> ClientConfig:
+ return {
+ "base_url": ROOTLY_BASE_URL,
+ "headers": _accept_headers(),
+ # Auth (Bearer) goes through the framework auth config so its value is redacted from logs.
+ "auth": {"type": "bearer", "token": api_key},
+ # Rootly is JSON:API — the next page URL lives in the response body under `links.next`.
+ "paginator": JSONResponsePaginator(next_url_path="links.next"),
+ }
+
+
+def _make_source_response(config: RootlyEndpointConfig, resource: Resource) -> SourceResponse:
+ return SourceResponse(
+ name=config.name,
+ items=lambda: resource,
+ primary_keys=config.primary_keys,
+ partition_count=1,
+ partition_size=1,
+ partition_mode="datetime" if config.partition_key else None,
+ partition_format="week" if config.partition_key else None,
+ partition_keys=[config.partition_key] if config.partition_key else None,
+ column_hints=resource.column_hints,
+ )
+
+
+def _top_level_source(
+ config: RootlyEndpointConfig,
api_key: str,
- endpoint: str,
team_id: int,
job_id: str,
resumable_source_manager: ResumableSourceManager[RootlyResumeConfig],
- should_use_incremental_field: bool = False,
- db_incremental_field_last_value: Optional[Any] = None,
- incremental_field: str | None = None,
+ should_use_incremental_field: bool,
+ db_incremental_field_last_value: Optional[Any],
+ incremental_field: str | None,
) -> SourceResponse:
- config = ROOTLY_ENDPOINTS[endpoint]
-
params = _build_initial_params(
config, should_use_incremental_field, db_incremental_field_last_value, incremental_field
)
+ endpoint_config: Endpoint = {
+ "path": config.path,
+ "params": params,
+ # A 200 body without `data` is treated as an empty page (JSON:API always carries
+ # `data`), matching the old `data.get("data", [])` — so no data_selector_required.
+ "data_selector": "data",
+ }
+ if config.pagination == "cursor":
+ endpoint_config["paginator"] = JSONResponseCursorPaginator(
+ cursor_path="meta.next_cursor", cursor_param="page[after]"
+ )
+
rest_config: RESTAPIConfig = {
- "client": {
- "base_url": ROOTLY_BASE_URL,
- "headers": _accept_headers(),
- # Auth (Bearer) goes through the framework auth config so its value is redacted from logs.
- "auth": {"type": "bearer", "token": api_key},
- # Rootly is JSON:API — the next page URL lives in the response body under `links.next`.
- "paginator": JSONResponsePaginator(next_url_path="links.next"),
- },
+ "client": _client_config(api_key),
"resource_defaults": {},
"resources": [
{
- "name": endpoint,
- "endpoint": {
- "path": config.path,
- "params": params,
- # A 200 body without `data` is treated as an empty page (JSON:API always carries
- # `data`), matching the old `data.get("data", [])` — so no data_selector_required.
- "data_selector": "data",
- },
+ "name": config.name,
+ "endpoint": endpoint_config,
# Rootly is JSON:API — hoist each item's `attributes` into the row root.
"data_map": _flatten_item,
}
@@ -155,12 +192,16 @@ def rootly_source(
resume = resumable_source_manager.load_state()
if resume is not None and resume.next_url:
initial_paginator_state = {"next_url": resume.next_url}
+ elif resume is not None and resume.cursor:
+ initial_paginator_state = {"cursor": resume.cursor}
def save_checkpoint(state: Optional[dict[str, Any]]) -> None:
# Persist only while a next page remains; the checkpoint lands AFTER a page is yielded so a
# crash re-yields the last page (merge dedupes on the primary key) rather than skipping it.
if state and state.get("next_url"):
resumable_source_manager.save_state(RootlyResumeConfig(next_url=state["next_url"]))
+ elif state and state.get("cursor"):
+ resumable_source_manager.save_state(RootlyResumeConfig(cursor=state["cursor"]))
resource = rest_api_resource(
rest_config,
@@ -173,14 +214,83 @@ def rootly_source(
initial_paginator_state=initial_paginator_state,
)
- return SourceResponse(
- name=endpoint,
- items=lambda: resource,
- primary_keys=config.primary_keys,
- partition_count=1,
- partition_size=1,
- partition_mode="datetime" if config.partition_key else None,
- partition_format="week" if config.partition_key else None,
- partition_keys=[config.partition_key] if config.partition_key else None,
- column_hints=resource.column_hints,
+ return _make_source_response(config, resource)
+
+
+def _fanout_source(
+ config: RootlyEndpointConfig,
+ api_key: str,
+ team_id: int,
+ job_id: str,
+ resumable_source_manager: ResumableSourceManager[RootlyResumeConfig],
+) -> SourceResponse:
+ assert config.fanout is not None
+
+ initial_state: Optional[dict[str, Any]] = None
+ if resumable_source_manager.can_resume():
+ resume = resumable_source_manager.load_state()
+ if resume is not None and (resume.completed or resume.current):
+ initial_state = {
+ "completed": resume.completed or [],
+ "current": resume.current,
+ "child_state": resume.child_state,
+ }
+
+ def save_checkpoint(state: Optional[dict[str, Any]]) -> None:
+ if state is not None:
+ resumable_source_manager.save_state(
+ RootlyResumeConfig(
+ completed=state.get("completed"),
+ current=state.get("current"),
+ child_state=state.get("child_state"),
+ )
+ )
+
+ resource = cast(
+ Resource,
+ build_dependent_resource(
+ endpoint_configs=ROOTLY_ENDPOINTS,
+ child_endpoint=config.name,
+ fanout=config.fanout,
+ client_config=_client_config(api_key),
+ path_format_values={},
+ team_id=team_id,
+ job_id=job_id,
+ # Fan-out children have no server-side time filter, so they always sync as full refresh.
+ db_incremental_field_last_value=None,
+ parent_endpoint_extra={"data_selector": "data"},
+ child_endpoint_extra={"data_selector": "data"},
+ page_size_param="page[size]",
+ resume_hook=save_checkpoint,
+ initial_paginator_state=initial_state,
+ ),
+ )
+ # The parent id is injected before this map runs, so it survives the `attributes` hoist.
+ return _make_source_response(config, resource.add_map(_flatten_item))
+
+
+def rootly_source(
+ api_key: str,
+ endpoint: str,
+ team_id: int,
+ job_id: str,
+ resumable_source_manager: ResumableSourceManager[RootlyResumeConfig],
+ should_use_incremental_field: bool = False,
+ db_incremental_field_last_value: Optional[Any] = None,
+ incremental_field: str | None = None,
+) -> SourceResponse:
+ config = ROOTLY_ENDPOINTS[endpoint]
+
+ if config.fanout is not None:
+ return _fanout_source(config, api_key, team_id, job_id, resumable_source_manager)
+
+ return _top_level_source(
+ config,
+ api_key,
+ team_id,
+ job_id,
+ resumable_source_manager,
+ should_use_incremental_field,
+ db_incremental_field_last_value,
+ incremental_field,
)
diff --git a/products/warehouse_sources/sources/rootly/settings.py b/products/warehouse_sources/sources/rootly/settings.py
index 78ccf5d71645..8caac361d151 100644
--- a/products/warehouse_sources/sources/rootly/settings.py
+++ b/products/warehouse_sources/sources/rootly/settings.py
@@ -1,7 +1,7 @@
from dataclasses import dataclass, field
-from typing import Optional
+from typing import Literal, Optional
-from products.warehouse_sources.sources.sdk import IncrementalField, IncrementalFieldType
+from products.warehouse_sources.sources.sdk import DependentEndpointConfig, IncrementalField, IncrementalFieldType
def _timestamp_field(name: str) -> IncrementalField:
@@ -32,6 +32,12 @@ class RootlyEndpointConfig:
primary_keys: list[str] = field(default_factory=lambda: ["id"])
should_sync_default: bool = True
page_size: int = 100
+ # "links_next" follows the JSON:API `links.next` URL. "cursor" sends `meta.next_cursor` back as
+ # `page[after]`, for feeds that return no `links`.
+ pagination: Literal["links_next", "cursor"] = "links_next"
+ # Set for endpoints that are only reachable under a parent resource (one request series per parent).
+ fanout: Optional[DependentEndpointConfig] = None
+ default_incremental_field: Optional[str] = None
# Endpoint catalog. Paths are relative to https://api.rootly.com/v1. The set mirrors the streams a
@@ -72,6 +78,34 @@ ROOTLY_ENDPOINTS: dict[str, RootlyEndpointConfig] = {
incremental_fields=_UPDATED_THEN_CREATED,
should_sync_default=False,
),
+ # The flat event feed across all alerts. It filters and sorts only on `created_at`, and caps
+ # `page[size]` at 50. High volume, so off by default.
+ "alert_events": RootlyEndpointConfig(
+ name="alert_events",
+ path="/alert_events",
+ supports_incremental=True,
+ incremental_fields=[_timestamp_field("created_at")],
+ pagination="cursor",
+ page_size=50,
+ should_sync_default=False,
+ ),
+ # Rootly lists incident timeline events only per incident and with no time filter, so this
+ # fans out over every incident on each sync. Off by default because of the request volume.
+ "incident_events": RootlyEndpointConfig(
+ name="incident_events",
+ path="/incidents/{incident_id}/events",
+ fanout=DependentEndpointConfig(
+ parent_name="incidents",
+ resolve_param="incident_id",
+ resolve_field="id",
+ include_from_parent=["id"],
+ parent_field_renames={"id": "incident_id"},
+ # An incident deleted between the parent listing and its child fetch must not fail the sync.
+ child_response_actions=[{"status_code": 404, "action": "ignore"}],
+ ),
+ primary_keys=["incident_id", "id"],
+ should_sync_default=False,
+ ),
# Configuration / reference resources — small and slowly-changing, so full refresh each sync.
"users": RootlyEndpointConfig(name="users", path="/users"),
"teams": RootlyEndpointConfig(name="teams", path="/teams"),
@@ -80,6 +114,7 @@ ROOTLY_ENDPOINTS: dict[str, RootlyEndpointConfig] = {
"schedules": RootlyEndpointConfig(name="schedules", path="/schedules"),
"escalation_policies": RootlyEndpointConfig(name="escalation_policies", path="/escalation_policies"),
"workflows": RootlyEndpointConfig(name="workflows", path="/workflows"),
+ "statuses": RootlyEndpointConfig(name="statuses", path="/statuses"),
# Small enumeration resources whose timestamp columns we haven't confirmed against the live API.
# Partitioning a handful of rows buys nothing, so don't risk partitioning on an absent field.
"environments": RootlyEndpointConfig(name="environments", path="/environments", partition_key=None),
@@ -96,5 +131,5 @@ INCREMENTAL_FIELDS: dict[str, list[IncrementalField]] = {
name: config.incremental_fields for name, config in ROOTLY_ENDPOINTS.items() if config.incremental_fields
}
-# Per-endpoint default sync flag; only pulses (the high-volume activity timeline) is off by default.
+# Per-endpoint default sync flag; the high-volume timeline and event endpoints are off by default.
SHOULD_SYNC_DEFAULT: dict[str, bool] = {name: config.should_sync_default for name, config in ROOTLY_ENDPOINTS.items()}
diff --git a/products/warehouse_sources/sources/rootly/tests/test_rootly.py b/products/warehouse_sources/sources/rootly/tests/test_rootly.py
index a224fec943ef..7549adc750c7 100644
--- a/products/warehouse_sources/sources/rootly/tests/test_rootly.py
+++ b/products/warehouse_sources/sources/rootly/tests/test_rootly.py
@@ -6,13 +6,19 @@ from parameterized import parameterized
from products.warehouse_sources.sources.rootly._config import RootlySourceConfig
from products.warehouse_sources.sources.rootly.rootly import (
ROOTLY_BASE_URL,
+ RootlyResumeConfig,
_build_url,
_clamp_future_value_to_now,
_format_incremental_value,
probe_credentials,
)
from products.warehouse_sources.sources.rootly.source import RootlySource
-from products.warehouse_sources.sources.sdk.testing import ScriptedResponse, SourceDriver, scripted_network
+from products.warehouse_sources.sources.sdk.testing import (
+ RecordedRequest,
+ ScriptedResponse,
+ SourceDriver,
+ scripted_network,
+)
def _response(
@@ -24,6 +30,10 @@ def _response(
return ScriptedResponse(json=body)
+def _feed_response(items: list[dict[str, Any]], next_cursor: str | None) -> ScriptedResponse:
+ return ScriptedResponse(json={"data": items, "meta": {"next_cursor": next_cursor}})
+
+
def _driver() -> SourceDriver:
return SourceDriver(RootlySource(), RootlySourceConfig(api_key="rootly_test"))
@@ -112,6 +122,13 @@ class TestIncrementalParams:
datetime(2026, 3, 4),
{"page[size]": "100"},
),
+ (
+ "cursor_feed_sorts_and_filters_on_created_at",
+ "alert_events",
+ True,
+ datetime(2026, 3, 4, 2, 58, 14, tzinfo=UTC),
+ {"page[size]": "50", "sort": "created_at", "filter[created_at][gt]": "2026-03-04T02:58:14+00:00"},
+ ),
(
"full_refresh_endpoint_never_sorts_or_filters",
"users",
@@ -131,15 +148,106 @@ class TestIncrementalParams:
) -> None:
inputs: dict[str, Any] = {"db_incremental_field_last_value": last_value}
if should_use_incremental_field:
- inputs["incremental_field"] = "updated_at"
+ inputs["incremental_field"] = "created_at" if endpoint == "alert_events" else "updated_at"
result = _driver().run(endpoint, [_response([{"id": "1", "attributes": {}}])], **inputs)
assert {name: values[0] for name, values in result.queries[0].items()} == expected_params
+class TestCursorFeed:
+ def test_walks_next_cursor_and_keeps_the_incremental_window(self) -> None:
+ result = _driver().run(
+ "alert_events",
+ [
+ _feed_response([{"id": "e1", "type": "alert_events", "attributes": {"action": "paged"}}], "c2"),
+ _feed_response([{"id": "e2", "type": "alert_events", "attributes": {"action": "resolved"}}], None),
+ ],
+ incremental_field="created_at",
+ db_incremental_field_last_value=datetime(2026, 3, 4, tzinfo=UTC),
+ )
+
+ assert result.raised is None
+ assert [(row["id"], row["action"]) for row in result.rows] == [("e1", "paged"), ("e2", "resolved")]
+ assert result.paths == ["/v1/alert_events", "/v1/alert_events"]
+ assert result.params("page[after]") == [None, "c2"]
+ assert result.params("filter[created_at][gt]") == ["2026-03-04T00:00:00+00:00"] * 2
+ assert result.params("sort") == ["created_at"] * 2
+ assert result.saved_states == [RootlyResumeConfig(cursor="c2")]
+
+ def test_resumes_from_saved_cursor(self) -> None:
+ result = _driver().run(
+ "alert_events",
+ [_feed_response([{"id": "e9", "attributes": {}}], None)],
+ resume_state=RootlyResumeConfig(cursor="c9"),
+ )
+
+ assert result.raised is None
+ assert [row["id"] for row in result.rows] == ["e9"]
+ assert result.params("page[after]") == ["c9"]
+
+
+def _incident_events_script(request: RecordedRequest) -> ScriptedResponse:
+ second_page = f"{ROOTLY_BASE_URL}/incidents/inc-1/events?page%5Bnumber%5D=2"
+ if request.path == "/v1/incidents":
+ return _response([{"id": "inc-1", "type": "incidents"}, {"id": "inc-2", "type": "incidents"}])
+ if request.path == "/v1/incidents/inc-1/events" and request.param("page[number]") == "2":
+ return _response([{"id": "ev-2", "type": "incident_events", "attributes": {"event": "Mitigated"}}])
+ if request.path == "/v1/incidents/inc-1/events":
+ return _response(
+ [{"id": "ev-1", "type": "incident_events", "attributes": {"event": "Started"}}], next_url=second_page
+ )
+ if request.path == "/v1/incidents/inc-2/events":
+ return ScriptedResponse(status=404, json={"errors": [{"title": "Not found", "status": "404"}]})
+ raise AssertionError(f"unexpected request {request.url}")
+
+
+class TestIncidentEventsFanout:
+ def test_fans_out_over_incidents_and_tags_rows_with_the_incident(self) -> None:
+ result = _driver().run("incident_events", _incident_events_script)
+
+ assert result.raised is None
+ assert result.rows == [
+ {"id": "ev-1", "type": "incident_events", "event": "Started", "incident_id": "inc-1"},
+ {"id": "ev-2", "type": "incident_events", "event": "Mitigated", "incident_id": "inc-1"},
+ ]
+ assert result.paths == [
+ "/v1/incidents",
+ "/v1/incidents/inc-1/events",
+ "/v1/incidents/inc-1/events",
+ "/v1/incidents/inc-2/events",
+ ]
+ assert result.response is not None
+ assert result.response.primary_keys == ["incident_id", "id"]
+
+ def test_resume_skips_incidents_already_synced(self) -> None:
+ result = _driver().run(
+ "incident_events",
+ _incident_events_script,
+ resume_state=RootlyResumeConfig(completed=["/incidents/inc-1/events"]),
+ )
+
+ assert result.raised is None
+ assert result.rows == []
+ assert result.paths == ["/v1/incidents", "/v1/incidents/inc-2/events"]
+
+
class TestProbeCredentials:
@parameterized.expand([("ok", 200), ("unauthorized", 401), ("forbidden", 403)])
def test_returns_status_code(self, _name: str, status_code: int) -> None:
with scripted_network([ScriptedResponse(status=status_code)]):
assert probe_credentials("rootly_test", "incidents") == status_code
+
+ @parameterized.expand(
+ [
+ ("top_level_endpoint", "statuses", "/v1/statuses"),
+ # The child path needs an incident id, so the scope check probes the parent collection.
+ ("fanout_endpoint_probes_parent", "incident_events", "/v1/incidents"),
+ ("no_endpoint", None, "/v1/users"),
+ ]
+ )
+ def test_probes_a_concrete_collection(self, _name: str, endpoint: str | None, expected_path: str) -> None:
+ with scripted_network([ScriptedResponse(status=200)]) as network:
+ assert probe_credentials("rootly_test", endpoint) == 200
+
+ assert [request.path for request in network.requests_log] == [expected_path]