: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(data-warehouse): implement ezofficeinventory import source (#66745)
Tom Owers06a9b51f8f5e
diff --git a/frontend/public/services/ezofficeinventory.svg b/frontend/public/services/ezofficeinventory.svgnew file mode 100644index 000000000000..97ad471168c3--- /dev/null+++ b/frontend/public/services/ezofficeinventory.svg@@ -0,0 +1,10 @@+<?xml version="1.0" encoding="UTF-8"?>+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="250px" height="250px" viewBox="0 0 250 250" version="1.1">+<g id="surface1">+<path style=" stroke:none;fill-rule:nonzero;fill:rgb(0%,43.137255%,78.039216%);fill-opacity:1;" d="M 138.667969 250.167969 C 92.445312 250.167969 46.304688 250.167969 0.167969 250.167969 C 0.167969 166.832031 0.167969 83.5 0.167969 0.167969 C 83.5 0.167969 166.832031 0.167969 250.167969 0.167969 C 250.167969 83.5 250.167969 166.832031 250.167969 250.167969 C 213.027344 250.167969 175.890625 250.167969 138.667969 250.167969 M 175.675781 91.667969 C 159.507812 91.667969 143.339844 91.667969 127.171875 91.667969 C 127.003906 91.667969 126.839844 91.683594 126.582031 91.683594 C 126.566406 91.738281 126.550781 91.789062 126.523438 91.992188 C 126.523438 95.847656 126.523438 99.699219 126.523438 103.675781 C 137.152344 103.675781 147.699219 103.675781 158.335938 103.675781 C 158.144531 103.96875 158.039062 104.132812 157.929688 104.289062 C 147.265625 119.621094 136.59375 134.953125 125.949219 150.296875 C 125.660156 150.714844 125.496094 151.304688 125.484375 151.820312 C 125.433594 153.984375 125.460938 156.152344 125.460938 158.316406 C 125.460938 158.972656 125.460938 159.628906 125.460938 160.289062 C 142.636719 160.289062 159.703125 160.289062 176.785156 160.289062 C 176.785156 156.234375 176.785156 152.226562 176.785156 148.144531 C 165.5625 148.144531 154.386719 148.144531 143.082031 148.144531 C 143.308594 147.792969 143.457031 147.542969 143.625 147.304688 C 146.132812 143.710938 148.648438 140.125 151.152344 136.53125 C 154.511719 131.707031 157.847656 126.867188 161.214844 122.050781 C 165.980469 115.238281 170.769531 108.4375 175.53125 101.621094 C 175.753906 101.300781 175.957031 100.878906 175.960938 100.503906 C 175.992188 97.617188 175.96875 94.730469 175.980469 91.75 C 175.929688 91.730469 175.878906 91.710938 175.675781 91.667969 M 91.582031 103.640625 C 99.019531 103.640625 106.453125 103.640625 113.929688 103.640625 C 113.929688 99.613281 113.929688 95.683594 113.929688 91.71875 C 100.777344 91.71875 87.660156 91.71875 74.554688 91.71875 C 74.554688 114.613281 74.554688 137.453125 74.554688 160.273438 C 87.789062 160.273438 100.964844 160.273438 114.105469 160.273438 C 114.105469 156.203125 114.105469 152.191406 114.105469 148.117188 C 105.71875 148.117188 97.398438 148.117188 89.0625 148.117188 C 89.0625 142.179688 89.0625 136.304688 89.0625 130.34375 C 92.988281 130.34375 96.867188 130.34375 100.75 130.34375 C 104.628906 130.34375 108.507812 130.34375 112.417969 130.34375 C 112.417969 126.402344 112.417969 122.554688 112.417969 118.617188 C 108.492188 118.617188 104.609375 118.617188 100.730469 118.617188 C 96.851562 118.617188 92.972656 118.617188 89.0625 118.617188 C 89.0625 113.582031 89.0625 108.652344 89.0625 103.640625 C 89.875 103.640625 90.648438 103.640625 91.582031 103.640625 Z M 91.582031 103.640625 "/>+<path style=" stroke:none;fill-rule:nonzero;fill:rgb(100%,100%,100%);fill-opacity:1;" d="M 126.671875 91.691406 C 126.839844 91.683594 127.003906 91.667969 127.171875 91.667969 C 143.339844 91.667969 159.507812 91.667969 175.769531 91.710938 C 175.886719 91.789062 175.921875 91.820312 175.964844 91.839844 C 175.96875 94.730469 175.992188 97.617188 175.960938 100.503906 C 175.957031 100.878906 175.753906 101.300781 175.53125 101.621094 C 170.769531 108.4375 165.980469 115.238281 161.214844 122.050781 C 157.847656 126.867188 154.511719 131.707031 151.152344 136.53125 C 148.648438 140.125 146.132812 143.710938 143.625 147.304688 C 143.457031 147.542969 143.308594 147.792969 143.082031 148.144531 C 154.386719 148.144531 165.5625 148.144531 176.785156 148.144531 C 176.785156 152.226562 176.785156 156.234375 176.785156 160.289062 C 159.703125 160.289062 142.636719 160.289062 125.460938 160.289062 C 125.460938 159.628906 125.460938 158.972656 125.460938 158.316406 C 125.460938 156.152344 125.433594 153.984375 125.484375 151.820312 C 125.496094 151.304688 125.660156 150.714844 125.949219 150.296875 C 136.59375 134.953125 147.265625 119.621094 157.929688 104.289062 C 158.039062 104.132812 158.144531 103.96875 158.335938 103.675781 C 147.699219 103.675781 137.152344 103.675781 126.523438 103.675781 C 126.523438 99.699219 126.523438 95.847656 126.558594 91.898438 C 126.625 91.769531 126.652344 91.730469 126.671875 91.691406 Z M 126.671875 91.691406 "/>+<path style=" stroke:none;fill-rule:nonzero;fill:rgb(100%,100%,100%);fill-opacity:1;" d="M 91.5 103.640625 C 90.648438 103.640625 89.875 103.640625 89.0625 103.640625 C 89.0625 108.652344 89.0625 113.582031 89.0625 118.617188 C 92.972656 118.617188 96.851562 118.617188 100.730469 118.617188 C 104.609375 118.617188 108.492188 118.617188 112.417969 118.617188 C 112.417969 122.554688 112.417969 126.402344 112.417969 130.34375 C 108.507812 130.34375 104.628906 130.34375 100.75 130.34375 C 96.867188 130.34375 92.988281 130.34375 89.0625 130.34375 C 89.0625 136.304688 89.0625 142.179688 89.0625 148.117188 C 97.398438 148.117188 105.71875 148.117188 114.105469 148.117188 C 114.105469 152.191406 114.105469 156.203125 114.105469 160.273438 C 100.964844 160.273438 87.789062 160.273438 74.554688 160.273438 C 74.554688 137.453125 74.554688 114.613281 74.554688 91.71875 C 87.660156 91.71875 100.777344 91.71875 113.929688 91.71875 C 113.929688 95.683594 113.929688 99.613281 113.929688 103.640625 C 106.453125 103.640625 99.019531 103.640625 91.5 103.640625 Z M 91.5 103.640625 "/>+<path style=" stroke:none;fill-rule:nonzero;fill:rgb(76.862745%,86.666667%,94.901961%);fill-opacity:1;" d="M 126.628906 91.6875 C 126.652344 91.730469 126.625 91.769531 126.566406 91.820312 C 126.550781 91.789062 126.566406 91.738281 126.628906 91.6875 Z M 126.628906 91.6875 "/>+<path style=" stroke:none;fill-rule:nonzero;fill:rgb(76.862745%,86.666667%,94.901961%);fill-opacity:1;" d="M 175.972656 91.796875 C 175.921875 91.820312 175.886719 91.789062 175.847656 91.71875 C 175.878906 91.710938 175.929688 91.730469 175.972656 91.796875 Z M 175.972656 91.796875 "/>+</g>+</svg>diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/SOURCES.md b/products/warehouse_sources/backend/temporal/data_imports/sources/SOURCES.mdindex f6a5d33cf263..386724c72cdb 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/SOURCES.md+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/SOURCES.md@@ -139,6 +139,7 @@ the row lists both.| eventee | HTTP | requests | ✅ || everhour | HTTP | requests | ✅ || exchange_rates_api | HTTP | requests | ✅ |+| ezofficeinventory | HTTP | requests | ✅ || factorial | HTTP | requests + `rest_source.RESTClient` | ✅ || fillout | HTTP | requests + `rest_source.RESTClient` | ✅ || financial_modelling | HTTP | requests | ✅ |@@ -391,7 +392,6 @@ doesn't conflict with concurrent PRs.- encharge- eventzilla- expensify-- ezofficeinventory- facebook_pages- fastbill- fastlydiff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/ezofficeinventory/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/ezofficeinventory/canonical_descriptions.pynew file mode 100644index 000000000000..06c900f8a5c6--- /dev/null+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/ezofficeinventory/canonical_descriptions.py@@ -0,0 +1,123 @@+from products.warehouse_sources.backend.temporal.data_imports.sources.common.canonical_descriptions import (+ CanonicalDescriptions,+)++_DOCS_URL = "https://ezo.io/ezofficeinventory/developers/"++CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {+ "assets": {+ "description": "Fixed (trackable) assets — individually identified items that are checked in and out.",+ "docs_url": _DOCS_URL,+ "columns": {+ "identifier": "Unique identifier (sequence number) for the asset.",+ "name": "Display name of the asset.",+ "state": "Current lifecycle state of the asset (e.g. available, checked out, in service).",+ "group_id": "Identifier of the asset group the asset belongs to.",+ "location_id": "Identifier of the location the asset is currently at.",+ "created_at": "Timestamp when the asset was created.",+ "updated_at": "Timestamp when the asset was last updated.",+ },+ },+ "inventories": {+ "description": "Inventory (volatile) items tracked by quantity rather than as individually identified units.",+ "docs_url": _DOCS_URL,+ "columns": {+ "identifier": "Unique identifier for the inventory item.",+ "name": "Display name of the inventory item.",+ "created_at": "Timestamp when the inventory item was created.",+ "updated_at": "Timestamp when the inventory item was last updated.",+ },+ },+ "asset_stocks": {+ "description": "Asset stock — quantity-tracked items that share a single asset definition across many units.",+ "docs_url": _DOCS_URL,+ "columns": {+ "identifier": "Unique identifier for the asset stock item.",+ "name": "Display name of the asset stock item.",+ "created_at": "Timestamp when the asset stock item was created.",+ "updated_at": "Timestamp when the asset stock item was last updated.",+ },+ },+ "checked_out_assets": {+ "description": "Fixed assets currently checked out, returned by the asset filter endpoint with status=checked_out.",+ "docs_url": _DOCS_URL,+ "columns": {+ "identifier": "Unique identifier (sequence number) for the asset.",+ "name": "Display name of the asset.",+ "created_at": "Timestamp when the asset was created.",+ },+ },+ "members": {+ "description": "People in the account — employees and other users who can check items in and out.",+ "docs_url": _DOCS_URL,+ "columns": {+ "id": "Unique identifier for the member.",+ "email": "Member's email address.",+ "employee_identification_number": "Employee identification number.",+ "status": "Member status (e.g. active, inactive).",+ "created_at": "Timestamp when the member was created.",+ },+ },+ "locations": {+ "description": "Physical locations where assets and inventory are stored or used.",+ "docs_url": _DOCS_URL,+ "columns": {+ "id": "Unique identifier for the location.",+ "name": "Display name of the location.",+ "city": "City the location is in.",+ "country": "Country the location is in.",+ "created_at": "Timestamp when the location was created.",+ },+ },+ "groups": {+ "description": "Asset groups used to categorize assets.",+ "docs_url": _DOCS_URL,+ "columns": {+ "id": "Unique identifier for the group.",+ "name": "Display name of the group.",+ "created_at": "Timestamp when the group was created.",+ },+ },+ "subgroups": {+ "description": "Subgroups nested under asset groups for finer categorization.",+ "docs_url": _DOCS_URL,+ "columns": {+ "id": "Unique identifier for the subgroup.",+ "name": "Display name of the subgroup.",+ "created_at": "Timestamp when the subgroup was created.",+ },+ },+ "vendors": {+ "description": "Vendors that supply assets, inventory, and services.",+ "docs_url": _DOCS_URL,+ "columns": {+ "id": "Unique identifier for the vendor.",+ "name": "Display name of the vendor.",+ "created_at": "Timestamp when the vendor was created.",+ },+ },+ "labels": {+ "description": "Print label templates configured for assets.",+ "docs_url": _DOCS_URL,+ "columns": {+ "id": "Unique identifier for the label template.",+ "name": "Display name of the label template.",+ },+ },+ "custom_fields": {+ "description": "Custom attributes (fields) defined for assets in the account.",+ "docs_url": _DOCS_URL,+ "columns": {+ "id": "Unique identifier for the custom field.",+ "name": "Display name of the custom field.",+ },+ },+ "purchase_orders": {+ "description": "Purchase orders raised for procuring assets and inventory.",+ "docs_url": _DOCS_URL,+ "columns": {+ "id": "Unique identifier for the purchase order.",+ "created_at": "Timestamp when the purchase order was created.",+ },+ },+}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/ezofficeinventory/ezofficeinventory.com.mdx b/products/warehouse_sources/backend/temporal/data_imports/sources/ezofficeinventory/ezofficeinventory.com.mdxnew file mode 100644index 000000000000..efc4f8dea778--- /dev/null+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/ezofficeinventory/ezofficeinventory.com.mdx@@ -0,0 +1,73 @@+---+title: Linking EZOfficeInventory as a source+sidebar: Docs+showTitle: true+availability: { free: full, selfServe: full, enterprise: full }+sourceId: EZOfficeInventory+---++<!--+This is the user-facing source doc. It belongs in the posthog.com repo at+contents/docs/cdp/sources/ezofficeinventory.md (served at /docs/cdp/sources/ezofficeinventory).+It is staged here because no posthog.com checkout was available when the source was implemented —+move it into posthog.com and delete it from this repo. See the /documenting-warehouse-sources skill.+-->++import SourceSetupIntro from '../_snippets/source-setup-intro.mdx'+import SyncModes from '../_snippets/sync-modes.mdx'+import TroubleshootingLink from '../_snippets/dw-troubleshooting-link.mdx'+import AlphaRelease from '../_snippets/alpha-release.mdx'++<AlphaRelease />++[EZOfficeInventory](https://ezo.io/ezofficeinventory/) (now branded EZO) is a cloud asset and+inventory management platform. Linking it as a source syncs your assets, inventory, members,+locations, and related records into PostHog so you can join asset and inventory data with the rest of+your warehouse.++## Prerequisites++Before connecting, you need:++- An EZOfficeInventory account with **API access enabled**. API access is off by default — the account+ owner enables it in **Settings → Integrations → API Integration**.+- A company **access token**, generated on that same settings page. The token is sent in the `token`+ HTTP header over HTTPS on every request, so keep it secret and regenerate it if it is compromised.+- Your account **subdomain** — the `<subdomain>` in `https://<subdomain>.ezofficeinventory.com`.++## Adding a data source++<SourceSetupIntro />++You'll need to provide:++- **Subdomain**: your EZOfficeInventory subdomain (the part before `.ezofficeinventory.com`).+- **Access token**: the company access token from **Settings → Integrations → API Integration**.++## Sync modes++<SyncModes />++EZOfficeInventory's API does not expose a general server-side `updated_after`/`created_after` cursor on+its listing endpoints, so every table syncs via **full refresh** — each sync re-reads the full table and+replaces the warehouse copy. The connector paginates politely within EZOfficeInventory's fair-use rate+limit (~60 requests/minute) and backs off automatically on rate-limit responses.++## Configuration++<SourceParameters />++## Supported tables++<SourceTables />++## Troubleshooting++- **Invalid credentials on connect**: confirm API access is enabled in **Settings → Integrations → API+ Integration**, that the access token is current, and that the subdomain is correct (no+ `https://` prefix or `.ezofficeinventory.com` suffix).+- **Syncs are slow on large accounts**: EZOfficeInventory enforces a fair-use limit of roughly 60+ requests per minute (lower on trial accounts). The connector throttles to stay within it, so large+ asset or inventory tables can take a while on the first sync.++<TroubleshootingLink />diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/ezofficeinventory/ezofficeinventory.py b/products/warehouse_sources/backend/temporal/data_imports/sources/ezofficeinventory/ezofficeinventory.pynew file mode 100644index 000000000000..7e58d55ddb54--- /dev/null+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/ezofficeinventory/ezofficeinventory.py@@ -0,0 +1,182 @@+import re+import dataclasses+from collections.abc import Iterator+from typing import Any+from urllib.parse import urlencode++import requests+from structlog.types import FilteringBoundLogger+from tenacity import retry, retry_if_exception_type, stop_after_attempt, wait_exponential_jitter+from urllib3.util.retry import Retry++from products.warehouse_sources.backend.temporal.data_imports.pipelines.pipeline.typings import SourceResponse+from products.warehouse_sources.backend.temporal.data_imports.sources.common.http import make_tracked_session+from products.warehouse_sources.backend.temporal.data_imports.sources.common.resumable import ResumableSourceManager+from products.warehouse_sources.backend.temporal.data_imports.sources.ezofficeinventory.settings import (+ EZOFFICEINVENTORY_ENDPOINTS,+ EZOfficeInventoryEndpointConfig,+)++# EZOfficeInventory enforces a per-account hostname, so only the subdomain label is user-supplied.+# Restricting it to host-safe characters keeps the request pinned to *.ezofficeinventory.com.+SUBDOMAIN_REGEX = re.compile(r"^[a-zA-Z0-9-]+$")++REQUEST_TIMEOUT_SECONDS = 60+++class EZOfficeInventoryRetryableError(Exception):+ """Raised for transient API responses (429 / 5xx) so tenacity retries them."""+++class EZOfficeInventoryResumeConfig:+ # Next page (1-indexed) to fetch when resuming an interrupted sync.+ next_page: int+++def base_url(subdomain: str) -> str:+ return f"https://{subdomain}.ezofficeinventory.com"+++def _headers(api_key: str) -> dict[str, str]:+ return {"token": api_key, "Accept": "application/json"}+++def _extract_items(data: dict[str, Any], config: EZOfficeInventoryEndpointConfig) -> list[dict[str, Any]]:+ """Pull the record list out of the response, unwrapping single-key item objects where needed."""+ items = data.get(config.data_selector) or []+ if not isinstance(items, list):+ return []+ if config.unwrap_key:+ unwrapped = []+ for item in items:+ if isinstance(item, dict) and config.unwrap_key in item:+ unwrapped.append(item[config.unwrap_key])+ else:+ unwrapped.append(item)+ return unwrapped+ return items+++@retry(+ retry=retry_if_exception_type((EZOfficeInventoryRetryableError, requests.ReadTimeout, requests.ConnectionError)),+ stop=stop_after_attempt(6),+ wait=wait_exponential_jitter(initial=2, max=70),+ reraise=True,+)+def _fetch_page(session: requests.Session, url: str, logger: FilteringBoundLogger) -> dict[str, Any]:+ response = session.get(url, timeout=REQUEST_TIMEOUT_SECONDS)++ # Fair-use limit is ~60 req/min; the API returns 429 with a Retry-After header. Treat 429 and+ # 5xx as transient and let tenacity back off (max ~70s covers a full rate-limit window reset).+ if response.status_code == 429 or response.status_code >= 500:+ raise EZOfficeInventoryRetryableError(+ f"EZOfficeInventory API error (retryable): status={response.status_code}, url={url}"+ )++ if not response.ok:+ logger.error(f"EZOfficeInventory API error: status={response.status_code}, body={response.text}, url={url}")+ response.raise_for_status()++ return response.json()+++def _build_url(subdomain: str, config: EZOfficeInventoryEndpointConfig, page: int) -> str:+ params: dict[str, Any] = dict(config.extra_params)+ params["page"] = page+ return f"{base_url(subdomain)}/{config.path}?{urlencode(params)}"+++def get_rows(+ api_key: str,+ subdomain: str,+ endpoint: str,+ logger: FilteringBoundLogger,+ resumable_source_manager: ResumableSourceManager[EZOfficeInventoryResumeConfig],+) -> Iterator[list[dict[str, Any]]]:+ config = EZOFFICEINVENTORY_ENDPOINTS[endpoint]+ headers = _headers(api_key)+ # One session reused across pages so urllib3 keeps the connection alive.+ # Redirects are pinned off so the user-supplied token can't be replayed to a+ # cross-host redirect target (SSRF / credential-exfiltration defense-in-depth).+ # urllib3 retries are disabled so tenacity (on `_fetch_page`) is the single retry+ # layer — otherwise 429/5xx would be retried by both, compounding the backoff.+ session = make_tracked_session(+ headers=headers, redact_values=(api_key,), allow_redirects=False, retry=Retry(total=0)+ )++ resume = resumable_source_manager.load_state() if resumable_source_manager.can_resume() else None+ page = resume.next_page if resume else 1++ while True:+ data = _fetch_page(session, _build_url(subdomain, config, page), logger)+ items = _extract_items(data, config)+ if not items:+ break++ yield items++ total_pages = data.get("total_pages")+ has_more = total_pages is None or page < total_pages+ if not has_more:+ break++ # Checkpoint AFTER yielding so a crash re-fetches the page we just emitted rather than+ # skipping it — merge dedupes the re-yielded rows on the primary key.+ page += 1+ resumable_source_manager.save_state(EZOfficeInventoryResumeConfig(next_page=page))+++def ezofficeinventory_source(+ api_key: str,+ subdomain: str,+ endpoint: str,+ logger: FilteringBoundLogger,+ resumable_source_manager: ResumableSourceManager[EZOfficeInventoryResumeConfig],+) -> SourceResponse:+ config = EZOFFICEINVENTORY_ENDPOINTS[endpoint]++ return SourceResponse(+ name=endpoint,+ items=lambda: get_rows(+ api_key=api_key,+ subdomain=subdomain,+ endpoint=endpoint,+ logger=logger,+ resumable_source_manager=resumable_source_manager,+ ),+ primary_keys=config.primary_keys,+ partition_mode="datetime" if config.partition_key else None,+ partition_format="month" if config.partition_key else None,+ partition_keys=[config.partition_key] if config.partition_key else None,+ )+++def validate_credentials(api_key: str, subdomain: str) -> tuple[bool, str | None]:+ """Return (is_valid, error_message). A non-None message overrides the generic+ "invalid credentials" error so transient failures (e.g. rate limiting) aren't+ misreported as bad credentials."""+ if not SUBDOMAIN_REGEX.match(subdomain):+ return False, None+ try:+ response = make_tracked_session(+ headers=_headers(api_key), redact_values=(api_key,), allow_redirects=False, retry=Retry(total=0)+ ).get(+ f"{base_url(subdomain)}/assets.api?page=1",+ timeout=10,+ )+ except Exception:+ return False, None++ if response.status_code == 200:+ return True, None++ # The fair-use cap is ~60 req/min; a 429 here means we couldn't verify the token, not that it's+ # wrong. Surface that distinctly so the user isn't told their credentials are invalid.+ if response.status_code == 429:+ return (+ False,+ "EZOfficeInventory rate limit reached while validating credentials. Please wait a minute and try again.",+ )++ return False, Nonediff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/ezofficeinventory/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/ezofficeinventory/settings.pynew file mode 100644index 000000000000..59cb0ff38f92--- /dev/null+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/ezofficeinventory/settings.py@@ -0,0 +1,121 @@+from dataclasses import dataclass, field+from typing import Optional++from products.warehouse_sources.backend.types import IncrementalField+++@dataclass+class EZOfficeInventoryEndpointConfig:+ name: str+ # Path relative to https://<subdomain>.ezofficeinventory.com (no leading slash).+ path: str+ # Top-level key in the JSON response that holds the list of records.+ data_selector: str+ # Some list endpoints wrap each record in a single-key object (e.g. groups returns+ # `{"groups": [{"group": {...}}]}`); set this to the inner key to unwrap it.+ unwrap_key: Optional[str] = None+ primary_keys: list[str] = field(default_factory=lambda: ["id"])+ # Stable creation timestamp used for datetime partitioning. Never an `updated_at`-style+ # field — partitions must not rewrite on every sync. None disables partitioning.+ partition_key: Optional[str] = None+ # Extra static query params (e.g. the `status=checked_out` filter on /assets/filter.api).+ extra_params: dict[str, str] = field(default_factory=dict)+ should_sync_default: bool = True+++# EZOfficeInventory exposes no general server-side `updated_after`/`created_after` cursor on its+# core listing endpoints, and its per-asset history endpoints only paginate (no server-side date+# filter — the date bound applied by other connectors is purely client-side). Every endpoint here+# is therefore full refresh; see SOURCES.md / the source docstring for the incremental-sync note.+EZOFFICEINVENTORY_ENDPOINTS: dict[str, EZOfficeInventoryEndpointConfig] = {+ "assets": EZOfficeInventoryEndpointConfig(+ name="assets",+ path="assets.api",+ data_selector="assets",+ primary_keys=["identifier"],+ partition_key="created_at",+ ),+ "inventories": EZOfficeInventoryEndpointConfig(+ name="inventories",+ path="inventory.api",+ data_selector="volatile_assets",+ primary_keys=["identifier"],+ partition_key="created_at",+ ),+ "asset_stocks": EZOfficeInventoryEndpointConfig(+ name="asset_stocks",+ path="stock_assets.api",+ data_selector="stock_assets",+ primary_keys=["identifier"],+ partition_key="created_at",+ ),+ "checked_out_assets": EZOfficeInventoryEndpointConfig(+ name="checked_out_assets",+ path="assets/filter.api",+ data_selector="assets",+ primary_keys=["identifier"],+ partition_key="created_at",+ extra_params={"status": "checked_out"},+ ),+ "members": EZOfficeInventoryEndpointConfig(+ name="members",+ path="members.api",+ data_selector="members",+ primary_keys=["id"],+ partition_key="created_at",+ ),+ "locations": EZOfficeInventoryEndpointConfig(+ name="locations",+ path="locations/get_line_item_locations.api",+ data_selector="locations",+ primary_keys=["id"],+ partition_key="created_at",+ ),+ "groups": EZOfficeInventoryEndpointConfig(+ name="groups",+ path="assets/classification_view.api",+ data_selector="groups",+ unwrap_key="group",+ primary_keys=["id"],+ partition_key="created_at",+ ),+ "subgroups": EZOfficeInventoryEndpointConfig(+ name="subgroups",+ path="groups/get_sub_groups.api",+ data_selector="sub_groups",+ primary_keys=["id"],+ partition_key="created_at",+ ),+ "vendors": EZOfficeInventoryEndpointConfig(+ name="vendors",+ path="assets/vendors.api",+ data_selector="vendors",+ unwrap_key="vendor",+ primary_keys=["id"],+ partition_key="created_at",+ ),+ "labels": EZOfficeInventoryEndpointConfig(+ name="labels",+ path="print_label_templates.api",+ data_selector="print_label_templates",+ primary_keys=["id"],+ ),+ "custom_fields": EZOfficeInventoryEndpointConfig(+ name="custom_fields",+ path="assets/custom_attributes.api",+ data_selector="custom_attributes",+ primary_keys=["id"],+ ),+ "purchase_orders": EZOfficeInventoryEndpointConfig(+ name="purchase_orders",+ path="purchase_orders.api",+ data_selector="purchase_orders",+ primary_keys=["id"],+ partition_key="created_at",+ ),+}++ENDPOINTS = tuple(EZOFFICEINVENTORY_ENDPOINTS.keys())++# Every endpoint is full refresh — no server-side timestamp filter is available.+INCREMENTAL_FIELDS: dict[str, list[IncrementalField]] = {}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/ezofficeinventory/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/ezofficeinventory/source.pyindex 777373632d59..bb180e768001 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/ezofficeinventory/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/ezofficeinventory/source.py@@ -1,13 +1,35 @@-from typing import cast+from typing import Optional, castfrom posthog.schema import (DataWarehouseSourceCategory,ExternalDataSourceType as SchemaExternalDataSourceType,+ ReleaseStatus,SourceConfig,+ SourceFieldInputConfig,+ SourceFieldInputConfigType,)-from products.warehouse_sources.backend.temporal.data_imports.sources.common.base import FieldType, SimpleSource+from products.warehouse_sources.backend.temporal.data_imports.pipelines.pipeline.typings import (+ SourceInputs,+ SourceResponse,+)+from products.warehouse_sources.backend.temporal.data_imports.sources.common.base import FieldType, ResumableSource+from products.warehouse_sources.backend.temporal.data_imports.sources.common.canonical_descriptions import (+ CanonicalDescriptions,+)from products.warehouse_sources.backend.temporal.data_imports.sources.common.registry import SourceRegistry+from products.warehouse_sources.backend.temporal.data_imports.sources.common.resumable import ResumableSourceManager+from products.warehouse_sources.backend.temporal.data_imports.sources.common.schema import SourceSchema+from products.warehouse_sources.backend.temporal.data_imports.sources.ezofficeinventory.ezofficeinventory import (+ EZOfficeInventoryResumeConfig,+ ezofficeinventory_source,+ validate_credentials as validate_ezofficeinventory_credentials,+)+from products.warehouse_sources.backend.temporal.data_imports.sources.ezofficeinventory.settings import (+ ENDPOINTS,+ EZOFFICEINVENTORY_ENDPOINTS,+ INCREMENTAL_FIELDS,+)from products.warehouse_sources.backend.temporal.data_imports.sources.generated_configs import (EZOfficeInventorySourceConfig,)@@ -15,18 +37,127 @@ from products.warehouse_sources.backend.types import ExternalDataSourceType@SourceRegistry.register-class EZOfficeInventorySource(SimpleSource[EZOfficeInventorySourceConfig]):+class EZOfficeInventorySource(ResumableSource[EZOfficeInventorySourceConfig, EZOfficeInventoryResumeConfig]):+ # `get_schemas` iterates a static endpoint catalog with no I/O, so the table list is safe to+ # render in public docs without credentials.+ lists_tables_without_credentials = True+@propertydef source_type(self) -> ExternalDataSourceType:return ExternalDataSourceType.EZOFFICEINVENTORY+ @property+ def connection_host_fields(self) -> list[str]:+ # The access token is sent to <subdomain>.ezofficeinventory.com, so retargeting the+ # subdomain must re-require the token.+ return ["subdomain"]++ def get_non_retryable_errors(self) -> dict[str, str | None]:+ return {+ "401 Client Error: Unauthorized for url": "Your EZOfficeInventory access token is invalid or expired. Please generate a new token and reconnect.",+ "403 Client Error: Forbidden for url": "Your EZOfficeInventory access token does not have the required permissions, or API access is disabled for the account.",+ "Unauthorized for url": "Your EZOfficeInventory access token is invalid or expired. Please generate a new token and reconnect.",+ }++ def get_canonical_descriptions(self) -> CanonicalDescriptions:+ from products.warehouse_sources.backend.temporal.data_imports.sources.ezofficeinventory.canonical_descriptions import (+ CANONICAL_DESCRIPTIONS,+ )++ return CANONICAL_DESCRIPTIONS++ def get_schemas(+ self,+ config: EZOfficeInventorySourceConfig,+ team_id: int,+ with_counts: bool = False,+ names: list[str] | None = None,+ force_refresh: bool = False,+ ) -> list[SourceSchema]:+ schemas = [+ SourceSchema(+ name=endpoint,+ supports_incremental=INCREMENTAL_FIELDS.get(endpoint) is not None,+ supports_append=INCREMENTAL_FIELDS.get(endpoint) is not None,+ incremental_fields=INCREMENTAL_FIELDS.get(endpoint, []),+ detected_primary_keys=EZOFFICEINVENTORY_ENDPOINTS[endpoint].primary_keys,+ should_sync_default=EZOFFICEINVENTORY_ENDPOINTS[endpoint].should_sync_default,+ )+ for endpoint in list(ENDPOINTS)+ ]++ if names is not None:+ names_set = set(names)+ schemas = [s for s in schemas if s.name in names_set]++ return schemas++ def validate_credentials(+ self, config: EZOfficeInventorySourceConfig, team_id: int, schema_name: Optional[str] = None+ ) -> tuple[bool, str | None]:+ is_valid, error_message = validate_ezofficeinventory_credentials(config.api_key, config.subdomain)+ if is_valid:+ return True, None++ return (+ False,+ error_message+ or "Invalid EZOfficeInventory credentials. Check the subdomain and access token, and that API access is enabled in Settings.",+ )++ def get_resumable_source_manager(+ self, inputs: SourceInputs+ ) -> ResumableSourceManager[EZOfficeInventoryResumeConfig]:+ return ResumableSourceManager[EZOfficeInventoryResumeConfig](inputs, EZOfficeInventoryResumeConfig)++ def source_for_pipeline(+ self,+ config: EZOfficeInventorySourceConfig,+ resumable_source_manager: ResumableSourceManager[EZOfficeInventoryResumeConfig],+ inputs: SourceInputs,+ ) -> SourceResponse:+ return ezofficeinventory_source(+ api_key=config.api_key,+ subdomain=config.subdomain,+ endpoint=inputs.schema_name,+ logger=inputs.logger,+ resumable_source_manager=resumable_source_manager,+ )+@propertydef get_source_config(self) -> SourceConfig:return SourceConfig(name=SchemaExternalDataSourceType.EZ_OFFICE_INVENTORY,category=DataWarehouseSourceCategory.PRODUCTIVITY,label="EZOfficeInventory",- iconPath="/static/services/ezofficeinventory.png",- fields=cast(list[FieldType], []),+ caption=(+ "Enter your EZOfficeInventory subdomain and access token. Enable API access in "+ "**Settings → Integrations → API Integration** and generate a token there. All tables "+ "sync via full refresh — the API exposes no general server-side `updated_after` cursor."+ ),+ docsUrl="https://posthog.com/docs/cdp/sources/ezofficeinventory",+ iconPath="/static/services/ezofficeinventory.svg",+ releaseStatus=ReleaseStatus.ALPHA,unreleasedSource=True,+ fields=cast(+ list[FieldType],+ [+ SourceFieldInputConfig(+ name="subdomain",+ label="Subdomain",+ type=SourceFieldInputConfigType.TEXT,+ required=True,+ placeholder="your-company",+ secret=False,+ ),+ SourceFieldInputConfig(+ name="api_key",+ label="Access token",+ type=SourceFieldInputConfigType.PASSWORD,+ required=True,+ placeholder="",+ secret=True,+ ),+ ],+ ),)diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/ezofficeinventory/tests/test_ezofficeinventory.py b/products/warehouse_sources/backend/temporal/data_imports/sources/ezofficeinventory/tests/test_ezofficeinventory.pynew file mode 100644index 000000000000..f32a63d00763--- /dev/null+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/ezofficeinventory/tests/test_ezofficeinventory.py@@ -0,0 +1,264 @@+import json+from typing import Any++import pytest+from unittest.mock import MagicMock, patch++from requests import Response++from products.warehouse_sources.backend.temporal.data_imports.sources.ezofficeinventory import ezofficeinventory+from products.warehouse_sources.backend.temporal.data_imports.sources.ezofficeinventory.ezofficeinventory import (+ EZOfficeInventoryResumeConfig,+ _build_url,+ _extract_items,+ ezofficeinventory_source,+ get_rows,+ validate_credentials,+)+from products.warehouse_sources.backend.temporal.data_imports.sources.ezofficeinventory.settings import (+ EZOFFICEINVENTORY_ENDPOINTS,+)++_MODULE = "products.warehouse_sources.backend.temporal.data_imports.sources.ezofficeinventory.ezofficeinventory"+++def _http_response(body: dict[str, Any], status_code: int = 200) -> Response:+ resp = Response()+ resp.status_code = status_code+ resp._content = json.dumps(body).encode()+ resp.headers["Content-Type"] = "application/json"+ return resp+++def _manager(*, can_resume: bool = False, state: EZOfficeInventoryResumeConfig | None = None) -> MagicMock:+ manager = MagicMock()+ manager.can_resume.return_value = can_resume+ manager.load_state.return_value = state+ return manager+++class TestExtractItems:+ def test_simple_selector(self) -> None:+ config = EZOFFICEINVENTORY_ENDPOINTS["assets"]+ assert _extract_items({"assets": [{"identifier": 1}, {"identifier": 2}]}, config) == [+ {"identifier": 1},+ {"identifier": 2},+ ]++ @pytest.mark.parametrize(+ ("endpoint", "body", "expected"),+ [+ ("groups", {"groups": [{"group": {"id": 1}}, {"group": {"id": 2}}]}, [{"id": 1}, {"id": 2}]),+ ("vendors", {"vendors": [{"vendor": {"id": 9}}]}, [{"id": 9}]),+ ],+ )+ def test_unwraps_single_key_items(self, endpoint: str, body: dict[str, Any], expected: list[dict]) -> None:+ assert _extract_items(body, EZOFFICEINVENTORY_ENDPOINTS[endpoint]) == expected++ def test_unwrap_falls_back_when_inner_key_absent(self) -> None:+ # A row already shaped like the unwrapped object is passed through untouched.+ config = EZOFFICEINVENTORY_ENDPOINTS["groups"]+ assert _extract_items({"groups": [{"id": 5}]}, config) == [{"id": 5}]++ @pytest.mark.parametrize("body", [{}, {"assets": None}, {"assets": "not-a-list"}, {"other": [1]}])+ def test_missing_or_malformed_selector_returns_empty(self, body: dict[str, Any]) -> None:+ assert _extract_items(body, EZOFFICEINVENTORY_ENDPOINTS["assets"]) == []+++class TestBuildUrl:+ def test_includes_page_and_extra_params(self) -> None:+ url = _build_url("acme", EZOFFICEINVENTORY_ENDPOINTS["checked_out_assets"], 3)+ assert url == "https://acme.ezofficeinventory.com/assets/filter.api?status=checked_out&page=3"++ def test_plain_endpoint_only_has_page(self) -> None:+ url = _build_url("acme", EZOFFICEINVENTORY_ENDPOINTS["assets"], 1)+ assert url == "https://acme.ezofficeinventory.com/assets.api?page=1"+++class TestGetRows:+ def _drive(+ self, endpoint: str, manager: MagicMock, responses: list[Response]+ ) -> tuple[list[list[dict]], list[str]]:+ requested_urls: list[str] = []+ response_iter = iter(responses)++ def fake_get(url: str, **_kwargs: Any) -> Response:+ requested_urls.append(url)+ return next(response_iter)++ session = MagicMock()+ session.get.side_effect = fake_get++ with patch(f"{_MODULE}.make_tracked_session", return_value=session):+ batches = list(+ get_rows(+ api_key="tok",+ subdomain="acme",+ endpoint=endpoint,+ logger=MagicMock(),+ resumable_source_manager=manager,+ )+ )+ return batches, requested_urls++ def test_sync_session_disables_redirects_and_urllib3_retries(self) -> None:+ manager = _manager()+ session = MagicMock()+ session.get.return_value = _http_response({"assets": []})+ with patch(f"{_MODULE}.make_tracked_session", return_value=session) as mocked:+ list(+ get_rows(+ api_key="tok",+ subdomain="acme",+ endpoint="assets",+ logger=MagicMock(),+ resumable_source_manager=manager,+ )+ )+ assert mocked.call_args.kwargs["allow_redirects"] is False+ # urllib3 retries off so tenacity is the only retry layer (no compounded backoff).+ assert mocked.call_args.kwargs["retry"].total == 0++ def test_paginates_until_total_pages(self) -> None:+ manager = _manager()+ responses = [+ _http_response({"assets": [{"identifier": 1}], "total_pages": 2}),+ _http_response({"assets": [{"identifier": 2}], "total_pages": 2}),+ ]+ batches, urls = self._drive("assets", manager, responses)++ assert batches == [[{"identifier": 1}], [{"identifier": 2}]]+ assert urls == [+ "https://acme.ezofficeinventory.com/assets.api?page=1",+ "https://acme.ezofficeinventory.com/assets.api?page=2",+ ]+ # State is saved once (after page 1), pointing at page 2 — never after the terminal page.+ manager.save_state.assert_called_once_with(EZOfficeInventoryResumeConfig(next_page=2))++ def test_stops_on_empty_page_when_total_pages_absent(self) -> None:+ manager = _manager()+ responses = [+ _http_response({"assets": [{"identifier": 1}]}),+ _http_response({"assets": []}),+ ]+ batches, urls = self._drive("assets", manager, responses)++ assert batches == [[{"identifier": 1}]]+ assert len(urls) == 2+ manager.save_state.assert_called_once_with(EZOfficeInventoryResumeConfig(next_page=2))++ def test_first_page_empty_yields_nothing(self) -> None:+ manager = _manager()+ batches, urls = self._drive("assets", manager, [_http_response({"assets": []})])++ assert batches == []+ assert urls == ["https://acme.ezofficeinventory.com/assets.api?page=1"]+ manager.save_state.assert_not_called()++ def test_resumes_from_saved_page(self) -> None:+ manager = _manager(can_resume=True, state=EZOfficeInventoryResumeConfig(next_page=3))+ responses = [_http_response({"assets": [{"identifier": 30}], "total_pages": 3})]+ batches, urls = self._drive("assets", manager, responses)++ assert batches == [[{"identifier": 30}]]+ # Picks up at page 3 (the saved cursor), not page 1.+ assert urls == ["https://acme.ezofficeinventory.com/assets.api?page=3"]+ manager.save_state.assert_not_called()+++class TestValidateCredentials:+ @pytest.mark.parametrize("bad_subdomain", ["", "has space", "bad/slash", "a.b", "http://x"])+ def test_rejects_unsafe_subdomain_without_network(self, bad_subdomain: str) -> None:+ with patch(f"{_MODULE}.make_tracked_session") as mocked:+ assert validate_credentials("tok", bad_subdomain) == (False, None)+ mocked.assert_not_called()++ @pytest.mark.parametrize(+ ("status_code", "expected"),+ [(200, True), (401, False), (403, False), (500, False)],+ )+ def test_maps_status_code(self, status_code: int, expected: bool) -> None:+ session = MagicMock()+ session.get.return_value = _http_response({}, status_code=status_code)+ with patch(f"{_MODULE}.make_tracked_session", return_value=session):+ is_valid, _ = validate_credentials("tok", "acme")+ assert is_valid is expected++ def test_rate_limit_returns_specific_message(self) -> None:+ session = MagicMock()+ session.get.return_value = _http_response({}, status_code=429)+ with patch(f"{_MODULE}.make_tracked_session", return_value=session):+ is_valid, error = validate_credentials("tok", "acme")+ assert is_valid is False+ assert error is not None+ assert "rate limit" in error.lower()++ def test_validation_session_disables_redirects_and_urllib3_retries(self) -> None:+ session = MagicMock()+ session.get.return_value = _http_response({}, status_code=200)+ with patch(f"{_MODULE}.make_tracked_session", return_value=session) as mocked:+ validate_credentials("tok", "acme")+ assert mocked.call_args.kwargs["allow_redirects"] is False+ # Single-shot validation handles status codes itself; urllib3 retries stay off.+ assert mocked.call_args.kwargs["retry"].total == 0++ def test_network_error_is_false(self) -> None:+ session = MagicMock()+ session.get.side_effect = Exception("boom")+ with patch(f"{_MODULE}.make_tracked_session", return_value=session):+ assert validate_credentials("tok", "acme") == (False, None)+++class TestSourceResponse:+ def test_partitioned_endpoint_sets_datetime_partitioning(self) -> None:+ response = ezofficeinventory_source(+ api_key="tok",+ subdomain="acme",+ endpoint="assets",+ logger=MagicMock(),+ resumable_source_manager=_manager(),+ )+ assert response.name == "assets"+ assert response.primary_keys == ["identifier"]+ assert response.partition_mode == "datetime"+ assert response.partition_keys == ["created_at"]+ assert response.partition_format == "month"++ def test_unpartitioned_endpoint_has_no_partitioning(self) -> None:+ response = ezofficeinventory_source(+ api_key="tok",+ subdomain="acme",+ endpoint="labels",+ logger=MagicMock(),+ resumable_source_manager=_manager(),+ )+ assert response.primary_keys == ["id"]+ assert response.partition_mode is None+ assert response.partition_keys is None+++class TestRetryableFetch:+ @pytest.mark.parametrize("status_code", [429, 500, 503])+ def test_retryable_status_raises_then_succeeds(self, status_code: int) -> None:+ # The first response is retryable; tenacity retries and the second succeeds.+ session = MagicMock()+ session.get.side_effect = [+ _http_response({}, status_code=status_code),+ _http_response({"assets": [{"identifier": 1}], "total_pages": 1}),+ ]+ # Skip tenacity's real backoff sleep so the test stays fast.+ with (+ patch.object(ezofficeinventory._fetch_page.retry, "sleep"), # type: ignore[attr-defined]+ patch(f"{_MODULE}.make_tracked_session", return_value=session),+ ):+ batches = list(+ get_rows(+ api_key="tok",+ subdomain="acme",+ endpoint="assets",+ logger=MagicMock(),+ resumable_source_manager=_manager(),+ )+ )+ assert batches == [[{"identifier": 1}]]+ assert session.get.call_count == 2diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/ezofficeinventory/tests/test_ezofficeinventory_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/ezofficeinventory/tests/test_ezofficeinventory_source.pynew file mode 100644index 000000000000..1b06da1dadbf--- /dev/null+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/ezofficeinventory/tests/test_ezofficeinventory_source.py@@ -0,0 +1,131 @@+from typing import cast++import pytest+from unittest.mock import MagicMock, patch++from posthog.schema import DataWarehouseSourceCategory, ReleaseStatus, SourceFieldInputConfig++from products.warehouse_sources.backend.temporal.data_imports.sources.ezofficeinventory.ezofficeinventory import (+ EZOfficeInventoryResumeConfig,+)+from products.warehouse_sources.backend.temporal.data_imports.sources.ezofficeinventory.settings import ENDPOINTS+from products.warehouse_sources.backend.temporal.data_imports.sources.ezofficeinventory.source import (+ EZOfficeInventorySource,+)+from products.warehouse_sources.backend.temporal.data_imports.sources.generated_configs import (+ EZOfficeInventorySourceConfig,+)+from products.warehouse_sources.backend.types import ExternalDataSourceType++_MODULE = "products.warehouse_sources.backend.temporal.data_imports.sources.ezofficeinventory.source"+++def _config() -> EZOfficeInventorySourceConfig:+ return cast(EZOfficeInventorySourceConfig, EZOfficeInventorySourceConfig(subdomain="acme", api_key="tok"))+++class TestSourceConfig:+ def test_source_type(self) -> None:+ assert EZOfficeInventorySource().source_type == ExternalDataSourceType.EZOFFICEINVENTORY++ def test_get_source_config_fields(self) -> None:+ config = EZOfficeInventorySource().get_source_config+ fields = {f.name: cast(SourceFieldInputConfig, f) for f in config.fields}+ assert set(fields) == {"subdomain", "api_key"}+ # The token is the only secret; the subdomain is a plain connection host field.+ assert fields["api_key"].secret is True+ assert fields["subdomain"].secret is False+ assert fields["api_key"].required is True+ assert fields["subdomain"].required is True++ def test_get_source_config_metadata(self) -> None:+ config = EZOfficeInventorySource().get_source_config+ assert config.category == DataWarehouseSourceCategory.PRODUCTIVITY+ assert config.releaseStatus == ReleaseStatus.ALPHA+ assert config.docsUrl == "https://posthog.com/docs/cdp/sources/ezofficeinventory"++ def test_connection_host_fields_include_subdomain(self) -> None:+ # Retargeting the subdomain must re-require the stored token.+ assert EZOfficeInventorySource().connection_host_fields == ["subdomain"]+++class TestGetSchemas:+ def test_returns_all_endpoints_full_refresh(self) -> None:+ schemas = EZOfficeInventorySource().get_schemas(_config(), team_id=1)+ assert {s.name for s in schemas} == set(ENDPOINTS)+ # EZOfficeInventory exposes no server-side cursor — every table is full refresh.+ assert all(not s.supports_incremental for s in schemas)+ assert all(not s.supports_append for s in schemas)++ def test_primary_keys_are_endpoint_specific(self) -> None:+ schemas = {s.name: s for s in EZOfficeInventorySource().get_schemas(_config(), team_id=1)}+ assert schemas["assets"].detected_primary_keys == ["identifier"]+ assert schemas["members"].detected_primary_keys == ["id"]++ def test_names_filter(self) -> None:+ schemas = EZOfficeInventorySource().get_schemas(_config(), team_id=1, names=["assets", "members"])+ assert {s.name for s in schemas} == {"assets", "members"}++ def test_documented_tables_render_without_credentials(self) -> None:+ source = EZOfficeInventorySource()+ assert source.lists_tables_without_credentials is True+ tables = source.get_documented_tables()+ assert {t["name"] for t in tables} == set(ENDPOINTS)+ # Curated descriptions flow through from canonical_descriptions.py.+ assets = next(t for t in tables if t["name"] == "assets")+ assert assets["description"]+ assert assets["sync_methods"] == ["Full refresh"]+++class TestValidateCredentials:+ @pytest.mark.parametrize(+ ("transport_result", "expected_ok"),+ [((True, None), True), ((False, None), False)],+ )+ def test_delegates_to_transport(self, transport_result: tuple[bool, str | None], expected_ok: bool) -> None:+ with patch(f"{_MODULE}.validate_ezofficeinventory_credentials", return_value=transport_result) as mocked:+ ok, error = EZOfficeInventorySource().validate_credentials(_config(), team_id=1)+ mocked.assert_called_once_with("tok", "acme")+ assert ok is expected_ok+ assert (error is None) is expected_ok++ def test_surfaces_transport_error_message(self) -> None:+ with patch(+ f"{_MODULE}.validate_ezofficeinventory_credentials",+ return_value=(False, "EZOfficeInventory rate limit reached while validating credentials."),+ ):+ ok, error = EZOfficeInventorySource().validate_credentials(_config(), team_id=1)+ assert ok is False+ assert error == "EZOfficeInventory rate limit reached while validating credentials."+++class TestNonRetryableErrors:+ def test_auth_errors_are_non_retryable(self) -> None:+ errors = EZOfficeInventorySource().get_non_retryable_errors()+ assert any("401" in key for key in errors)+ assert any("403" in key for key in errors)+++class TestResumableWiring:+ def test_get_resumable_source_manager_binds_data_class(self) -> None:+ inputs = MagicMock()+ inputs.logger = MagicMock()+ manager = EZOfficeInventorySource().get_resumable_source_manager(inputs)+ assert manager._data_class is EZOfficeInventoryResumeConfig++ def test_source_for_pipeline_plumbs_arguments(self) -> None:+ inputs = MagicMock()+ inputs.schema_name = "members"+ inputs.logger = MagicMock()+ manager = MagicMock()++ with patch(f"{_MODULE}.ezofficeinventory_source") as mocked:+ EZOfficeInventorySource().source_for_pipeline(_config(), manager, inputs)++ mocked.assert_called_once_with(+ api_key="tok",+ subdomain="acme",+ endpoint="members",+ logger=inputs.logger,+ resumable_source_manager=manager,+ )diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs.py b/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs.pyindex 7a48804f0072..9006cf8baac7 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs.py@@ -1030,7 +1030,8 @@ class EConomicSourceConfig(config.Config):@config.configclass EZOfficeInventorySourceConfig(config.Config):- pass+ subdomain: str+ api_key: str@config.config