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(data-warehouse): add 4 missing tables to the Xmatters source (#118507)

Tom Owersb946da8d02e2
diff --git a/posthog/test/repo_invariants/dataclass_frozen_baseline.txt b/posthog/test/repo_invariants/dataclass_frozen_baseline.txt
index 45b28a669d9c..88baae31a2ab 100644
--- a/posthog/test/repo_invariants/dataclass_frozen_baseline.txt
+++ b/posthog/test/repo_invariants/dataclass_frozen_baseline.txt
@@ -1229,8 +1229,6 @@
1 products/warehouse_sources/backend/temporal/data_imports/sources/wufoo/wufoo.py
1 products/warehouse_sources/backend/temporal/data_imports/sources/xendit/settings.py
1 products/warehouse_sources/backend/temporal/data_imports/sources/xendit/xendit.py
-1 products/warehouse_sources/backend/temporal/data_imports/sources/xmatters/settings.py
-1 products/warehouse_sources/backend/temporal/data_imports/sources/xmatters/xmatters.py
1 products/warehouse_sources/backend/temporal/data_imports/sources/yousign/settings.py
1 products/warehouse_sources/backend/temporal/data_imports/sources/yousign/yousign.py
1 products/warehouse_sources/backend/temporal/data_imports/sources/zapier_supported_storage/settings.py
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 81d23e8984e0..f4516dfac47f 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
@@ -13332,10 +13332,10 @@ Today (9): `devices`, `dynamic_teams`, `events`, `groups`, `people`, `plans`, `r
Diffed against: <https://help.xmatters.com/xmapi/index.html>
-- [ ] `audits (GET /api/xm/1/audits)` — the notification, response and event audit records — the main analytical fact table for alerting (high)
-- [ ] `incidents (GET /api/xm/1/incidents, /incidents/{id}/timeline-entries)` — incident objects and their timeline; the headline object of xMatters incident management (high)
-- [ ] `group members (GET /api/xm/1/groups/{id}/members)` — membership lookup joining the people and groups we already sync (high)
-- [ ] `group shifts (GET /api/xm/1/groups/{id}/shifts)` — on-call rotation definitions; without them groups carry no schedule (high)
+- [x] `audits (GET /api/xm/1/audits)` — the notification, response and event audit records — the main analytical fact table for alerting (high)
+- [x] `incidents (GET /api/xm/1/incidents, /incidents/{id}/timeline-entries)` — incident objects and their timeline; the headline object of xMatters incident management (high)
+- [x] `group members (GET /api/xm/1/groups/{id}/members)` — membership lookup joining the people and groups we already sync (high)
+- [x] `group shifts (GET /api/xm/1/groups/{id}/shifts)` — on-call rotation definitions; without them groups carry no schedule (high)
- [ ] `on-call (GET /api/xm/1/on-call)` — who is on call over a timeframe, the vendor's headline query (high)
- [ ] `services (GET /api/xm/1/services)` — lookup resolving the service referenced by incidents and signals (high)
- [ ] `event user deliveries (GET /api/xm/1/events/{id}/user-deliveries)` — per-recipient delivery and response outcomes for each event (medium)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/xmatters/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/xmatters/canonical_descriptions.py
index 6629b5c878c0..8b04ff0bcdc4 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/xmatters/canonical_descriptions.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/xmatters/canonical_descriptions.py
@@ -129,4 +129,60 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
createdDate="Date and time the subscription was created.",
),
},
+ "incidents": {
+ "description": "An incident tracked by xMatters incident management, with its severity, status, and impacted services.",
+ "docs_url": "https://help.xmatters.com/xmapi/index.html#get-incidents",
+ "columns": _columns(
+ incidentIdentifier="The alpha-numeric incident number, for example INC-145.",
+ summary="The title of the incident.",
+ description="The description of the incident.",
+ severity="The severity of the incident (CRITICAL, HIGH, MEDIUM, LOW, MINIMAL).",
+ status="The status of the incident (OPEN, IN_PROGRESS, MITIGATED, RESOLVED, REJECTED).",
+ initiatedBy="The person, or the credentials, that created the incident.",
+ commander="The person responsible for the incident.",
+ requestId="The identifier returned from the request that triggered the incident.",
+ impactedServices="The services that the incident impacts.",
+ createdAt="Date and time the incident was created.",
+ updatedAt="Date and time the incident was last updated.",
+ ),
+ },
+ "audits": {
+ "description": "An audit record for an event: a status change, a comment, or a recipient's response to a notification.",
+ "docs_url": "https://help.xmatters.com/xmapi/index.html#get-event-audit-information",
+ "columns": {
+ "id": "Unique identifier (UUID) for the audit record.",
+ "event_id": "Identifier of the event that the audit record belongs to.",
+ "type": "The audit type, for example EVENT_CREATED, EVENT_ANNOTATED, or RESPONSE_RECEIVED.",
+ "at": "Date and time (UTC) the audit record was added to the event.",
+ "annotation": "For EVENT_ANNOTATED records, the comment and the person who made it.",
+ "response": "For RESPONSE_RECEIVED records, the response a recipient gave to a notification.",
+ "orderId": "Deprecated sequential identifier for the audit record.",
+ },
+ },
+ "group_members": {
+ "description": "A membership of a person, device, or group in an xMatters group.",
+ "docs_url": "https://help.xmatters.com/xmapi/index.html#get-group-members",
+ "columns": {
+ "group_id": "Identifier of the group.",
+ "member_id": "Identifier of the member (person, device, or group).",
+ "group": "Reference to the group.",
+ "member": "Reference to the member, including its recipient type.",
+ },
+ },
+ "group_shifts": {
+ "description": "An on-call shift in a group, with its schedule, recurrence, and rotation.",
+ "docs_url": "https://help.xmatters.com/xmapi/index.html#get-shifts",
+ "columns": _columns(
+ group_id="Identifier of the group that owns the shift.",
+ group="Reference to the group that owns the shift.",
+ name="The name of the shift.",
+ description="A description of the shift.",
+ start="The start time of the shift.",
+ end="The end time of the shift.",
+ created="Date and time the shift was created.",
+ timezone="The time zone the shift occurs in.",
+ recurrence="How the shift repeats.",
+ rotation="How members rotate through the shift.",
+ ),
+ },
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/xmatters/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/xmatters/settings.py
index ab7bc670ea33..e4f37087e461 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/xmatters/settings.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/xmatters/settings.py
@@ -1,13 +1,20 @@
from dataclasses import dataclass, field
from typing import Optional
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.fanout import (
+ DependentEndpointConfig,
+)
from products.warehouse_sources.backend.types import IncrementalField, IncrementalFieldType
+# xMatters caps `limit` at 1000; using the max reduces round-trips.
+PAGE_SIZE = 1000
-@dataclass
+
+@dataclass(frozen=True)
class XmattersEndpointConfig:
+ name: str
path: str # Path under the API base URL, e.g. "/events"
- primary_key: str = "id"
+ primary_keys: list[str] = field(default_factory=lambda: ["id"])
partition_key: Optional[str] = None # Stable datetime field used to partition (never a mutable field)
incremental_fields: list[IncrementalField] = field(default_factory=list)
# True only when the endpoint exposes a server-side time-window filter (`from`) on the
@@ -15,6 +22,10 @@ class XmattersEndpointConfig:
# required for safe incremental sync: the filter bounds the window and the ascending
# sort guarantees a stable watermark. Reference/config endpoints stay full-refresh.
supports_from: bool = False
+ # Set for per-parent endpoints; the parent is another endpoint in this catalog.
+ fanout: Optional[DependentEndpointConfig] = None
+ default_incremental_field: Optional[str] = None
+ page_size: int = PAGE_SIZE
_CREATED_INCREMENTAL: list[IncrementalField] = [
@@ -27,11 +38,22 @@ _CREATED_INCREMENTAL: list[IncrementalField] = [
]
-# Top-level list endpoints. xMatters also exposes per-parent resources (e.g. /audits requires
-# an eventId, /on-call and /shifts require a group), which need fan-out and are not included
-# here. Every list response is wrapped in a `data` array with `count`, `total`, and `links`.
+# Sent explicitly so the audit table does not depend on the API's default set of types.
+AUDIT_TYPES = (
+ "EVENT_ANNOTATED",
+ "EVENT_CREATED",
+ "EVENT_SUSPENDED",
+ "EVENT_RESUMED",
+ "EVENT_COMPLETED",
+ "EVENT_TERMINATED",
+ "RESPONSE_RECEIVED",
+)
+
+
+# Every list response is wrapped in a `data` array with `count`, `total`, and `links`.
XMATTERS_ENDPOINTS: dict[str, XmattersEndpointConfig] = {
"events": XmattersEndpointConfig(
+ name="events",
path="/events",
partition_key="created",
incremental_fields=_CREATED_INCREMENTAL,
@@ -42,29 +64,91 @@ XMATTERS_ENDPOINTS: dict[str, XmattersEndpointConfig] = {
supports_from=True,
),
"people": XmattersEndpointConfig(
+ name="people",
path="/people",
),
"groups": XmattersEndpointConfig(
+ name="groups",
path="/groups",
),
"devices": XmattersEndpointConfig(
+ name="devices",
path="/devices",
),
"sites": XmattersEndpointConfig(
+ name="sites",
path="/sites",
),
"roles": XmattersEndpointConfig(
+ name="roles",
path="/roles",
),
"dynamic_teams": XmattersEndpointConfig(
+ name="dynamic_teams",
path="/dynamic-teams",
),
"plans": XmattersEndpointConfig(
+ name="plans",
path="/plans",
),
"subscriptions": XmattersEndpointConfig(
+ name="subscriptions",
path="/subscriptions",
),
+ "incidents": XmattersEndpointConfig(
+ name="incidents",
+ path="/incidents",
+ # `from` filters on createdAt, but the sort order is undocumented and incidents change
+ # status after creation, so this stays full refresh.
+ partition_key="createdAt",
+ ),
+ "audits": XmattersEndpointConfig(
+ name="audits",
+ # /audits only answers for one event at a time, so it fans out over /events.
+ path="/audits?eventId={event_id}",
+ primary_keys=["event_id", "id"],
+ partition_key="at",
+ fanout=DependentEndpointConfig(
+ parent_name="events",
+ resolve_param="event_id",
+ resolve_field="id",
+ include_from_parent=["id"],
+ parent_field_renames={"id": "event_id"},
+ parent_params={"sortBy": "START_TIME", "sortOrder": "ASCENDING"},
+ child_params={"auditType": ",".join(AUDIT_TYPES), "sortOrder": "ASCENDING"},
+ child_response_actions=[{"status_code": 404, "action": "ignore"}],
+ ),
+ ),
+ "group_members": XmattersEndpointConfig(
+ name="group_members",
+ path="/groups/{group_id}/members",
+ primary_keys=["group_id", "member_id"],
+ fanout=DependentEndpointConfig(
+ parent_name="groups",
+ resolve_param="group_id",
+ resolve_field="id",
+ include_from_parent=["id"],
+ parent_field_renames={"id": "group_id"},
+ child_response_actions=[{"status_code": 404, "action": "ignore"}],
+ ),
+ ),
+ "group_shifts": XmattersEndpointConfig(
+ name="group_shifts",
+ path="/groups/{group_id}/shifts",
+ primary_keys=["group_id", "id"],
+ partition_key="created",
+ fanout=DependentEndpointConfig(
+ parent_name="groups",
+ resolve_param="group_id",
+ resolve_field="id",
+ include_from_parent=["id"],
+ parent_field_renames={"id": "group_id"},
+ # Only On-Call groups have shifts.
+ parent_params={"groupType": "ON_CALL"},
+ child_params={"embed": "rotation"},
+ child_response_actions=[{"status_code": 404, "action": "ignore"}],
+ ),
+ ),
}
ENDPOINTS = tuple(XMATTERS_ENDPOINTS.keys())
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/xmatters/tests/test_xmatters.py b/products/warehouse_sources/backend/temporal/data_imports/sources/xmatters/tests/test_xmatters.py
index 8e75b40ba765..c233b74f1b7c 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/xmatters/tests/test_xmatters.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/xmatters/tests/test_xmatters.py
@@ -7,6 +7,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.tes
ScriptedResponse,
SourceDriver,
always,
+ route,
scripted_network,
)
from products.warehouse_sources.backend.temporal.data_imports.sources.generated_configs.xmatters import (
@@ -89,6 +90,23 @@ class TestValidateCredentials:
assert ok is expected_ok
assert status == expected_status
+ @pytest.mark.parametrize(
+ "endpoint,expected_path",
+ [
+ (None, "/api/xm/1/people"),
+ ("incidents", "/api/xm/1/incidents"),
+ # A per-parent path has an unbound placeholder, so the probe goes to the parent listing.
+ ("audits", "/api/xm/1/events"),
+ ("group_members", "/api/xm/1/groups"),
+ ("group_shifts", "/api/xm/1/groups"),
+ ],
+ )
+ def test_probe_path(self, endpoint: Optional[str], expected_path: str) -> None:
+ with scripted_network(always(ScriptedResponse(json={"data": []}))) as network:
+ ok, _status, _error = validate_credentials("acme", "svc", "secret", endpoint)
+ assert ok is True
+ assert [request.path for request in network.requests_log] == [expected_path]
+
class TestPagination:
def test_advances_offset_and_sets_page_params(self) -> None:
@@ -126,3 +144,114 @@ class TestPagination:
assert request.param("from") == "2026-01-01T00:00:00+00:00"
assert request.param("sortBy") == "START_TIME"
assert request.param("sortOrder") == "ASCENDING"
+
+
+class TestFanout:
+ @pytest.mark.parametrize(
+ "endpoint,parent_path,child_path,parent_params,child_params,child_rows,expected_rows",
+ [
+ (
+ "audits",
+ "/events",
+ "/audits",
+ {"sortBy": "START_TIME", "sortOrder": "ASCENDING"},
+ {
+ "auditType": "EVENT_ANNOTATED,EVENT_CREATED,EVENT_SUSPENDED,EVENT_RESUMED,"
+ "EVENT_COMPLETED,EVENT_TERMINATED,RESPONSE_RECEIVED",
+ "sortOrder": "ASCENDING",
+ },
+ [{"id": "a-1", "type": "EVENT_CREATED", "at": "2026-02-01T10:00:00.000Z"}],
+ [{"id": "a-1", "event_id": "p-1"}],
+ ),
+ (
+ "group_members",
+ "/groups",
+ "/groups/p-1/members",
+ {},
+ {},
+ [{"group": {"id": "p-1"}, "member": {"id": "m-1", "recipientType": "PERSON"}}],
+ [{"group_id": "p-1", "member_id": "m-1"}],
+ ),
+ (
+ "group_shifts",
+ "/groups",
+ "/groups/p-1/shifts",
+ {"groupType": "ON_CALL"},
+ {"embed": "rotation"},
+ [{"id": "s-1", "name": "Weekdays", "created": "2026-02-01T10:00:00.000Z"}],
+ [{"id": "s-1", "group_id": "p-1"}],
+ ),
+ ],
+ )
+ def test_fans_out_over_parent_rows(
+ self,
+ endpoint: str,
+ parent_path: str,
+ child_path: str,
+ parent_params: dict[str, str],
+ child_params: dict[str, str],
+ child_rows: list[dict[str, Any]],
+ expected_rows: list[dict[str, Any]],
+ ) -> None:
+ script = route({child_path: [_response(child_rows)], parent_path: [_response([{"id": "p-1"}])]})
+ result = _driver().run(endpoint, script)
+
+ assert result.raised is None
+ assert [{key: row[key] for key in expected.keys()} for row, expected in zip(result.rows, expected_rows)] == (
+ expected_rows
+ )
+ assert len(result.rows) == len(expected_rows)
+ parent_request, child_request = result.requests
+ assert parent_request.path == f"/api/xm/1{parent_path}"
+ assert child_request.path == f"/api/xm/1{child_path}"
+ for name, value in parent_params.items():
+ assert parent_request.param(name) == value
+ for name, value in child_params.items():
+ assert child_request.param(name) == value
+ if endpoint == "audits":
+ assert child_request.param("eventId") == "p-1"
+
+ def test_fanout_saves_per_parent_progress(self) -> None:
+ script = route(
+ {
+ "/groups/g-1/members": [_response([{"group": {"id": "g-1"}, "member": {"id": "m-1"}}])],
+ "/groups/g-2/members": [_response([{"group": {"id": "g-2"}, "member": {"id": "m-2"}}])],
+ "/groups": [_response([{"id": "g-1"}, {"id": "g-2"}])],
+ }
+ )
+ result = _driver().run("group_members", script)
+
+ assert result.raised is None
+ assert result.saved_states
+ state = result.saved_states[-1].paginator_state
+ assert state is not None
+ assert "completed" in state
+
+ def test_child_404_for_a_deleted_parent_is_skipped(self) -> None:
+ script = route(
+ {
+ "/groups/gone/members": [ScriptedResponse(status=404, json={"code": 404, "reason": "Not Found"})],
+ "/groups/kept/members": [_response([{"group": {"id": "kept"}, "member": {"id": "m-1"}}])],
+ "/groups": [_response([{"id": "gone"}, {"id": "kept"}])],
+ }
+ )
+ result = _driver().run("group_members", script)
+
+ assert result.raised is None
+ assert [(row["group_id"], row["member_id"]) for row in result.rows] == [("kept", "m-1")]
+
+ def test_child_walks_pages_per_parent(self) -> None:
+ script = route(
+ {
+ "/groups/p-1/shifts": [
+ _response([{"id": "s-1"}], next_url="/api/xm/1/groups/p-1/shifts?offset=1000"),
+ _response([{"id": "s-2"}]),
+ ],
+ "/groups": [_response([{"id": "p-1"}])],
+ }
+ )
+ result = _driver().run("group_shifts", script)
+
+ assert result.raised is None
+ assert [row["id"] for row in result.rows] == ["s-1", "s-2"]
+ assert [r.param("offset") for r in result.requests if r.path.endswith("/shifts")] == ["0", str(PAGE_SIZE)]
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/xmatters/xmatters.py b/products/warehouse_sources/backend/temporal/data_imports/sources/xmatters/xmatters.py
index 1a659cf05c9e..2f46057e5028 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/xmatters/xmatters.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/xmatters/xmatters.py
@@ -2,7 +2,7 @@ import re
import base64
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 requests import Response
@@ -12,13 +12,19 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.res
RESTAPIConfig,
rest_api_resource,
)
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.fanout import (
+ build_dependent_resource,
+)
from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.paginators import (
OffsetPaginator,
)
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.resource import Resource
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.typing import ClientConfig
from products.warehouse_sources.backend.temporal.data_imports.sources.common.resumable import ResumableSourceManager
from products.warehouse_sources.backend.temporal.data_imports.sources.common.source_helpers import validate_via_probe
from products.warehouse_sources.backend.temporal.data_imports.sources.common.typings import SourceResponse
from products.warehouse_sources.backend.temporal.data_imports.sources.xmatters.settings import (
+ PAGE_SIZE,
XMATTERS_ENDPOINTS,
XmattersEndpointConfig,
)
@@ -30,13 +36,13 @@ BASE_URL_TEMPLATE = "https://{subdomain}.xmatters.com/api/xm/1"
# `@`, etc.) could redirect worker requests to an attacker-controlled host (SSRF).
SUBDOMAIN_REGEX = re.compile(r"^[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$")
-# xMatters caps `limit` at 1000; using the max reduces round-trips.
-PAGE_SIZE = 1000
-
[email protected](frozen=True)
class XmattersResumeConfig:
- offset: int
+ # Flat endpoints resume from `offset`; fan-out endpoints round-trip the framework's opaque
+ # per-parent checkpoint through `paginator_state`.
+ offset: int = 0
+ paginator_state: Optional[dict[str, Any]] = None
def is_valid_subdomain(subdomain: str) -> bool:
@@ -110,6 +116,11 @@ class XmattersPaginator(OffsetPaginator):
self._has_next_page = True
+def _normalize_group_member(item: dict[str, Any]) -> dict[str, Any]:
+ # Membership rows carry no id of their own; lift the nested member id so it can key the row.
+ return {**item, "member_id": item["member"]["id"]}
+
+
def _build_params(
config: XmattersEndpointConfig,
should_use_incremental_field: bool,
@@ -140,6 +151,9 @@ def validate_credentials(
endpoint).
"""
config = XMATTERS_ENDPOINTS.get(endpoint) if endpoint else None
+ if config and config.fanout:
+ # A per-parent path needs a parent id, so probe the parent listing instead.
+ config = XMATTERS_ENDPOINTS[config.fanout.parent_name]
path = config.path if config else "/people"
url = f"{_base_url(subdomain)}{path}?{urlencode({'limit': 1})}"
@@ -157,6 +171,60 @@ def validate_credentials(
return False, status, None
+def _fanout_source(
+ config: XmattersEndpointConfig,
+ client_config: ClientConfig,
+ team_id: int,
+ job_id: str,
+ resumable_source_manager: ResumableSourceManager[XmattersResumeConfig],
+) -> SourceResponse:
+ assert config.fanout is not None
+
+ initial_paginator_state: Optional[dict[str, Any]] = None
+ if resumable_source_manager.can_resume():
+ resume = resumable_source_manager.load_state()
+ if resume is not None:
+ initial_paginator_state = resume.paginator_state
+
+ def save_fanout_checkpoint(state: Optional[dict[str, Any]]) -> None:
+ if state:
+ resumable_source_manager.save_state(XmattersResumeConfig(paginator_state=dict(state)))
+
+ resource = cast(
+ Resource,
+ build_dependent_resource(
+ endpoint_configs=XMATTERS_ENDPOINTS,
+ child_endpoint=config.name,
+ fanout=config.fanout,
+ client_config=client_config,
+ path_format_values={},
+ team_id=team_id,
+ job_id=job_id,
+ # The per-parent endpoints have no server-side time filter, so they are full refresh.
+ db_incremental_field_last_value=None,
+ parent_endpoint_extra={"data_selector": "data"},
+ child_endpoint_extra={"data_selector": "data"},
+ resume_hook=save_fanout_checkpoint,
+ initial_paginator_state=initial_paginator_state,
+ ),
+ )
+ if config.name == "group_members":
+ resource = resource.add_map(_normalize_group_member)
+
+ return SourceResponse(
+ name=config.name,
+ items=lambda: resource,
+ primary_keys=config.primary_keys,
+ sort_mode="asc",
+ 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 xmatters_source(
subdomain: str,
username: str,
@@ -169,16 +237,20 @@ def xmatters_source(
db_incremental_field_last_value: Optional[Any] = None,
) -> SourceResponse:
config = XMATTERS_ENDPOINTS[endpoint]
+ client_config: ClientConfig = {
+ "base_url": _base_url(subdomain),
+ # Auth (HTTP Basic) is supplied via the framework auth config so the password is
+ # redacted from logs and raised error messages; only non-secret headers go here.
+ "headers": {"Accept": "application/json", "Content-Type": "application/json"},
+ "auth": {"type": "http_basic", "username": username, "password": password},
+ "paginator": XmattersPaginator(limit=PAGE_SIZE),
+ }
+
+ if config.fanout is not None:
+ return _fanout_source(config, client_config, team_id, job_id, resumable_source_manager)
rest_config: RESTAPIConfig = {
- "client": {
- "base_url": _base_url(subdomain),
- # Auth (HTTP Basic) is supplied via the framework auth config so the password is
- # redacted from logs and raised error messages; only non-secret headers go here.
- "headers": {"Accept": "application/json", "Content-Type": "application/json"},
- "auth": {"type": "http_basic", "username": username, "password": password},
- "paginator": XmattersPaginator(limit=PAGE_SIZE),
- },
+ "client": client_config,
"resource_defaults": {},
"resources": [
{
@@ -216,7 +288,7 @@ def xmatters_source(
return SourceResponse(
name=endpoint,
items=lambda: resource,
- primary_keys=[config.primary_key],
+ primary_keys=config.primary_keys,
# We request START_TIME ascending where a sort is available, and full-refresh endpoints
# replace wholesale, so ascending is correct everywhere.
sort_mode="asc",