: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 care_quality_commission import source (#66725)
Tom Owers07f09fc336a1
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/SOURCES.md b/products/warehouse_sources/backend/temporal/data_imports/sources/SOURCES.mdindex b0bd2137ecb1..c8220cfed819 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/SOURCES.md+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/SOURCES.md@@ -42,218 +42,219 @@ the row lists both.## Implemented sources-| Source | Comm method | Primary library | Tracked transport |-| ------------------- | --------------------------- | --------------------------------------------------------------- | --------------------------- |-| adroll | HTTP | requests | ✅ |-| agilecrm | HTTP | requests | ✅ |-| aircall | HTTP | requests | ✅ |-| airtable | HTTP | requests | ✅ |-| algolia | HTTP | requests | ✅ |-| amazon_ads | HTTP | requests | ✅ |-| amplitude | HTTP | requests | ✅ |-| apify_dataset | HTTP | requests | ✅ |-| apollo | HTTP | requests | ✅ |-| appsflyer | HTTP (CSV reports) | requests | ✅ |-| asana | HTTP | requests | ✅ |-| ashby | HTTP | requests | ✅ |-| attentive | HTTP (webhook-first) | requests (webhook management) | ✅ |-| attio | HTTP | requests + `rest_source.RESTClient` | ✅ |-| aviationstack | HTTP | requests | ✅ |-| azure_devops | HTTP | requests | ✅ |-| bamboohr | HTTP | requests | ✅ |-| beamer | HTTP | requests | ✅ |-| bigmailer | HTTP | requests | ✅ |-| bigquery | HTTP + gRPC | google-cloud-bigquery + bigquery-storage | ✅ (HTTP + gRPC) |-| bing_ads | HTTP (vendor SDK, SOAP) | bingads SDK | ⚠️ |-| blogger | HTTP | requests | ✅ |-| braintree | HTTP (GraphQL) | requests | ✅ |-| braze | HTTP | requests | ✅ |-| breezometer | HTTP | requests | ✅ |-| brevo | HTTP | requests | ✅ |-| brex | HTTP | requests | ✅ |-| bugsnag | HTTP | requests | ✅ |-| buildbetter | HTTP | requests | ✅ |-| buildkite | HTTP | requests | ✅ |-| calendly | HTTP | requests | ✅ |-| campaign_monitor | HTTP | requests | ✅ |-| campayn | HTTP | requests | ✅ |-| canny | HTTP | requests | ✅ |-| chargebee | HTTP | requests + `rest_source.RESTClient` | ✅ |-| chargedesk | HTTP | requests | ✅ |-| checkout_com | HTTP | requests | ✅ |-| churnkey | HTTP | requests | ✅ |-| coda | HTTP | requests | ✅ |-| coin_api | HTTP | requests | ✅ |-| coingecko | HTTP | requests | ✅ |-| coinmarketcap | HTTP | requests + `rest_source.RESTClient` | ✅ |-| commercetools | HTTP | requests | ✅ |-| confluence | HTTP | requests | ✅ |-| chartmogul | HTTP | requests | ✅ |-| circleci | HTTP | requests | ✅ |-| cimis | HTTP | requests | ✅ |-| cloudflare | HTTP | requests | ✅ |-| clari | HTTP | requests | ✅ |-| clerk | HTTP | requests + `rest_source.RESTClient` | ✅ |-| clickhouse | DB protocol (HTTP-based) | clickhouse-connect / clickhouse-driver | ➖ |-| clickup | HTTP | requests | ✅ |-| clockify | HTTP | requests | ✅ |-| close | HTTP | requests + `rest_source.RESTClient` | ✅ |-| convertkit | HTTP | requests | ✅ |-| convex | HTTP | requests | ✅ |-| copper | HTTP | requests | ✅ |-| coupa | HTTP | requests | ✅ |-| crunchbase | HTTP | requests | ✅ |-| culture_amp | HTTP | requests | ✅ |-| customer_io | HTTP + Webhook | requests + `WebhookSourceManager` | ✅ (App API) / ➖ (webhook) |-| datadog | HTTP | requests | ✅ |-| deel | HTTP | requests | ✅ |-| delighted | HTTP | requests | ✅ |-| dixa | HTTP | requests | ✅ |-| docuseal | HTTP | requests | ✅ |-| doit | HTTP | requests | ✅ |-| drip | HTTP | requests | ✅ |-| e_conomic | HTTP | requests | ✅ |-| easypost | HTTP | requests | ✅ |-| easypromos | HTTP | requests | ✅ |-| freshdesk | HTTP | requests | ✅ |-| freshsales | HTTP | requests | ✅ |-| elasticemail | HTTP | requests | ✅ |-| elasticsearch | HTTP | requests | ✅ |-| emailoctopus | HTTP | requests | ✅ |-| eventbrite | HTTP | requests | ✅ |-| everhour | HTTP | requests | ✅ |-| factorial | HTTP | requests + `rest_source.RESTClient` | ✅ |-| fillout | HTTP | requests + `rest_source.RESTClient` | ✅ |-| financial_modelling | HTTP | requests | ✅ |-| finnhub | HTTP | requests | ✅ |-| finnworlds | HTTP | requests | ✅ |-| fleetio | HTTP | requests | ✅ |-| front | HTTP | requests | ✅ |-| fullstory | HTTP | requests | ✅ |-| github | HTTP + Webhook | requests + `WebhookSourceManager` | ✅ (pull) / ➖ (webhook) |-| giphy | HTTP | requests | ✅ |-| gitlab | HTTP | requests | ✅ |-| gladly | HTTP | requests | ✅ |-| gocardless | HTTP | requests | ✅ |-| gong | HTTP | requests | ✅ |-| google_ads | gRPC | google-ads (googleads.client) | ✅ |-| google_analytics | HTTP | requests (`AuthorizedSession` + `TrackedHTTPAdapter`) | ✅ |-| google_sheets | HTTP (vendor SDK) | gspread | ✅ |-| granola | HTTP | requests | ✅ |-| gorgias | HTTP | requests | ✅ |-| greenhouse | HTTP | requests | ✅ |-| guru | HTTP | requests | ✅ |-| hibob | HTTP | requests | ✅ |-| hubspot | HTTP | requests | ✅ |-| incident_io | HTTP | requests | ✅ |-| intercom | HTTP | requests + `rest_source.RESTClient` | ✅ |-| iterable | HTTP | requests | ✅ |-| jira | HTTP | requests | ✅ |-| jotform | HTTP | requests | ✅ |-| klaviyo | HTTP | requests | ✅ |-| lago | HTTP | requests | ✅ |-| launchdarkly | HTTP | requests | ✅ |-| kustomer | HTTP | requests | ✅ |-| lattice | HTTP | requests | ✅ |-| lemlist | HTTP | requests | ✅ |-| lightspeed_retail | HTTP | requests | ✅ |-| linear | HTTP | requests | ✅ |-| lever | HTTP | requests | ✅ |-| linkedin_ads | HTTP (vendor SDK, RESTli) | linkedin-api (RestliClient) | ⚠️ |-| lob | HTTP | requests | ✅ |-| mailchimp | HTTP | requests + `rest_source.RESTClient` | ✅ |-| mailerlite | HTTP | requests | ✅ |-| mailersend | HTTP | requests | ✅ |-| mailgun | HTTP | requests | ✅ |-| mailjet | HTTP | requests | ✅ |-| matomo | HTTP | requests | ✅ |-| meta_ads | HTTP | requests | ✅ |-| metabase | HTTP | requests | ✅ |-| mixpanel | HTTP | requests | ✅ |-| mollie | HTTP | requests | ✅ |-| monday | HTTP (GraphQL) | requests | ✅ |-| mongodb | DB protocol | pymongo | ➖ |-| mssql | DB protocol | pyodbc / pymssql | ➖ |-| mux | HTTP | requests | ✅ |-| mysql | DB protocol | pymysql | ➖ |-| okta | HTTP | requests | ✅ |-| notion | HTTP | requests | ✅ |-| omnisend | HTTP | requests | ✅ |-| orb | HTTP | requests + `rest_source.RESTClient` | ✅ |-| openweather | HTTP | requests | ✅ |-| ortto | HTTP | requests | ✅ |-| oura | HTTP | requests | ✅ |-| outbrain | HTTP | requests | ✅ |-| paddle | HTTP | requests | ✅ |-| optimizely | HTTP | requests | ✅ |-| pagerduty | HTTP | requests | ✅ |-| pandadoc | HTTP | requests | ✅ |-| paystack | HTTP | requests + `rest_source.RESTClient` | ✅ |-| pendo | HTTP | requests | ✅ |-| personio | HTTP | requests | ✅ |-| pingdom | HTTP | requests | ✅ |-| pinterest_ads | HTTP | requests | ✅ |-| pipedrive | HTTP | requests | ✅ |-| plain | HTTP | requests | ✅ |-| plausible | HTTP | requests | ✅ |-| polar | HTTP | requests | ✅ |-| plaid | HTTP | requests | ✅ |-| postgres | DB protocol | psycopg | ➖ |-| postmark | HTTP | requests | ✅ |-| productboard | HTTP | requests | ✅ |-| pylon | HTTP | requests | ✅ |-| recurly | HTTP | requests + `rest_source.RESTClient` | ✅ |-| ramp | HTTP | requests | ✅ |-| recharge | HTTP | requests | ✅ |-| reddit_ads | HTTP | requests + `rest_source.RESTClient` | ✅ |-| redshift | DB protocol | psycopg (Postgres-compatible) | ➖ |-| resend | HTTP | requests | ✅ |-| revenuecat | HTTP + Webhook | requests + `WebhookSourceManager` | ✅ (pull) / ➖ (webhook) |-| rippling | HTTP | requests | ✅ |-| rollbar | HTTP | requests | ✅ |-| rootly | HTTP | requests | ✅ |-| salesforce | HTTP | requests + `rest_source.RESTClient` | ✅ |-| salesloft | HTTP | requests | ✅ |-| segment | HTTP | requests | ✅ |-| sendgrid | HTTP | requests | ✅ |-| sentry | HTTP | requests + `rest_source.RESTClient` | ✅ |-| servicenow | HTTP | requests | ✅ |-| shipstation | HTTP | requests | ✅ |-| shopify | HTTP | requests | ✅ |-| shortcut | HTTP | requests | ✅ |-| slack | HTTP | requests + `rest_source.RESTClient` | ✅ |-| smartsheet | HTTP | requests | ✅ |-| snapchat_ads | HTTP | requests + `rest_source.RESTClient` | ✅ |-| snowflake | DB protocol | snowflake-connector-python | ➖ |-| sparkpost | HTTP | requests | ✅ |-| square | HTTP | requests | ✅ |-| squarespace | HTTP | requests | ✅ |-| statuspage | HTTP | requests | ✅ |-| stripe | HTTP (vendor SDK) + Webhook | stripe (StripeClient + RequestsClient) + `WebhookSourceManager` | ✅ (pull) / ➖ (webhook) |-| supabase | DB protocol | psycopg (delegates to PostgresSource) | ➖ |-| surveymonkey | HTTP | requests | ✅ |-| taboola | HTTP | requests | ✅ |-| teamwork | HTTP | requests | ✅ |-| temporalio | gRPC (vendor SDK) | temporalio (`Client`, Rust core via `temporalio.bridge`) | ⚠️ |-| thinkific | HTTP | requests | ✅ |-| tiktok_ads | HTTP | requests + `rest_source.RESTClient` | ✅ |-| tmdb | HTTP | requests | ✅ |-| todoist | HTTP | requests | ✅ |-| trello | HTTP | requests | ✅ |-| twilio | HTTP | requests | ✅ |-| typeform | HTTP | requests + `rest_source.RESTClient` | ✅ |-| vercel | HTTP | requests | ✅ |-| vitally | HTTP | requests + `rest_source.RESTClient` | ✅ |-| webflow | HTTP | requests | ✅ |-| woocommerce | HTTP | requests + `rest_source.RESTClient` | ✅ |-| wordpress | HTTP | requests | ✅ |-| workable | HTTP | requests | ✅ |-| workos | HTTP | requests + `rest_source.RESTClient` | ✅ |-| wrike | HTTP | requests | ✅ |-| zendesk | HTTP | requests + `rest_source.RESTClient` | ✅ |-| zendesk_sell | HTTP | requests | ✅ |-| zoom | HTTP | requests | ✅ |-| zuora | HTTP | requests | ✅ |+| Source | Comm method | Primary library | Tracked transport |+| ----------------------- | --------------------------- | --------------------------------------------------------------- | --------------------------- |+| adroll | HTTP | requests | ✅ |+| agilecrm | HTTP | requests | ✅ |+| aircall | HTTP | requests | ✅ |+| airtable | HTTP | requests | ✅ |+| algolia | HTTP | requests | ✅ |+| amazon_ads | HTTP | requests | ✅ |+| amplitude | HTTP | requests | ✅ |+| apify_dataset | HTTP | requests | ✅ |+| apollo | HTTP | requests | ✅ |+| appsflyer | HTTP (CSV reports) | requests | ✅ |+| asana | HTTP | requests | ✅ |+| ashby | HTTP | requests | ✅ |+| attentive | HTTP (webhook-first) | requests (webhook management) | ✅ |+| attio | HTTP | requests + `rest_source.RESTClient` | ✅ |+| aviationstack | HTTP | requests | ✅ |+| azure_devops | HTTP | requests | ✅ |+| bamboohr | HTTP | requests | ✅ |+| beamer | HTTP | requests | ✅ |+| bigmailer | HTTP | requests | ✅ |+| bigquery | HTTP + gRPC | google-cloud-bigquery + bigquery-storage | ✅ (HTTP + gRPC) |+| bing_ads | HTTP (vendor SDK, SOAP) | bingads SDK | ⚠️ |+| blogger | HTTP | requests | ✅ |+| braintree | HTTP (GraphQL) | requests | ✅ |+| braze | HTTP | requests | ✅ |+| breezometer | HTTP | requests | ✅ |+| brevo | HTTP | requests | ✅ |+| brex | HTTP | requests | ✅ |+| bugsnag | HTTP | requests | ✅ |+| buildbetter | HTTP | requests | ✅ |+| buildkite | HTTP | requests | ✅ |+| calendly | HTTP | requests | ✅ |+| campaign_monitor | HTTP | requests | ✅ |+| campayn | HTTP | requests | ✅ |+| canny | HTTP | requests | ✅ |+| care_quality_commission | HTTP | requests | ✅ |+| chargebee | HTTP | requests + `rest_source.RESTClient` | ✅ |+| chargedesk | HTTP | requests | ✅ |+| checkout_com | HTTP | requests | ✅ |+| churnkey | HTTP | requests | ✅ |+| coda | HTTP | requests | ✅ |+| coin_api | HTTP | requests | ✅ |+| coingecko | HTTP | requests | ✅ |+| coinmarketcap | HTTP | requests + `rest_source.RESTClient` | ✅ |+| commercetools | HTTP | requests | ✅ |+| confluence | HTTP | requests | ✅ |+| chartmogul | HTTP | requests | ✅ |+| circleci | HTTP | requests | ✅ |+| cimis | HTTP | requests | ✅ |+| cloudflare | HTTP | requests | ✅ |+| clari | HTTP | requests | ✅ |+| clerk | HTTP | requests + `rest_source.RESTClient` | ✅ |+| clickhouse | DB protocol (HTTP-based) | clickhouse-connect / clickhouse-driver | ➖ |+| clickup | HTTP | requests | ✅ |+| clockify | HTTP | requests | ✅ |+| close | HTTP | requests + `rest_source.RESTClient` | ✅ |+| convertkit | HTTP | requests | ✅ |+| convex | HTTP | requests | ✅ |+| copper | HTTP | requests | ✅ |+| coupa | HTTP | requests | ✅ |+| crunchbase | HTTP | requests | ✅ |+| culture_amp | HTTP | requests | ✅ |+| customer_io | HTTP + Webhook | requests + `WebhookSourceManager` | ✅ (App API) / ➖ (webhook) |+| datadog | HTTP | requests | ✅ |+| deel | HTTP | requests | ✅ |+| delighted | HTTP | requests | ✅ |+| dixa | HTTP | requests | ✅ |+| docuseal | HTTP | requests | ✅ |+| doit | HTTP | requests | ✅ |+| drip | HTTP | requests | ✅ |+| e_conomic | HTTP | requests | ✅ |+| easypost | HTTP | requests | ✅ |+| easypromos | HTTP | requests | ✅ |+| freshdesk | HTTP | requests | ✅ |+| freshsales | HTTP | requests | ✅ |+| elasticemail | HTTP | requests | ✅ |+| elasticsearch | HTTP | requests | ✅ |+| emailoctopus | HTTP | requests | ✅ |+| eventbrite | HTTP | requests | ✅ |+| everhour | HTTP | requests | ✅ |+| factorial | HTTP | requests + `rest_source.RESTClient` | ✅ |+| fillout | HTTP | requests + `rest_source.RESTClient` | ✅ |+| financial_modelling | HTTP | requests | ✅ |+| finnhub | HTTP | requests | ✅ |+| finnworlds | HTTP | requests | ✅ |+| fleetio | HTTP | requests | ✅ |+| front | HTTP | requests | ✅ |+| fullstory | HTTP | requests | ✅ |+| github | HTTP + Webhook | requests + `WebhookSourceManager` | ✅ (pull) / ➖ (webhook) |+| giphy | HTTP | requests | ✅ |+| gitlab | HTTP | requests | ✅ |+| gladly | HTTP | requests | ✅ |+| gocardless | HTTP | requests | ✅ |+| gong | HTTP | requests | ✅ |+| google_ads | gRPC | google-ads (googleads.client) | ✅ |+| google_analytics | HTTP | requests (`AuthorizedSession` + `TrackedHTTPAdapter`) | ✅ |+| google_sheets | HTTP (vendor SDK) | gspread | ✅ |+| granola | HTTP | requests | ✅ |+| gorgias | HTTP | requests | ✅ |+| greenhouse | HTTP | requests | ✅ |+| guru | HTTP | requests | ✅ |+| hibob | HTTP | requests | ✅ |+| hubspot | HTTP | requests | ✅ |+| incident_io | HTTP | requests | ✅ |+| intercom | HTTP | requests + `rest_source.RESTClient` | ✅ |+| iterable | HTTP | requests | ✅ |+| jira | HTTP | requests | ✅ |+| jotform | HTTP | requests | ✅ |+| klaviyo | HTTP | requests | ✅ |+| lago | HTTP | requests | ✅ |+| launchdarkly | HTTP | requests | ✅ |+| kustomer | HTTP | requests | ✅ |+| lattice | HTTP | requests | ✅ |+| lemlist | HTTP | requests | ✅ |+| lightspeed_retail | HTTP | requests | ✅ |+| linear | HTTP | requests | ✅ |+| lever | HTTP | requests | ✅ |+| linkedin_ads | HTTP (vendor SDK, RESTli) | linkedin-api (RestliClient) | ⚠️ |+| lob | HTTP | requests | ✅ |+| mailchimp | HTTP | requests + `rest_source.RESTClient` | ✅ |+| mailerlite | HTTP | requests | ✅ |+| mailersend | HTTP | requests | ✅ |+| mailgun | HTTP | requests | ✅ |+| mailjet | HTTP | requests | ✅ |+| matomo | HTTP | requests | ✅ |+| meta_ads | HTTP | requests | ✅ |+| metabase | HTTP | requests | ✅ |+| mixpanel | HTTP | requests | ✅ |+| mollie | HTTP | requests | ✅ |+| monday | HTTP (GraphQL) | requests | ✅ |+| mongodb | DB protocol | pymongo | ➖ |+| mssql | DB protocol | pyodbc / pymssql | ➖ |+| mux | HTTP | requests | ✅ |+| mysql | DB protocol | pymysql | ➖ |+| okta | HTTP | requests | ✅ |+| notion | HTTP | requests | ✅ |+| omnisend | HTTP | requests | ✅ |+| orb | HTTP | requests + `rest_source.RESTClient` | ✅ |+| openweather | HTTP | requests | ✅ |+| ortto | HTTP | requests | ✅ |+| oura | HTTP | requests | ✅ |+| outbrain | HTTP | requests | ✅ |+| paddle | HTTP | requests | ✅ |+| optimizely | HTTP | requests | ✅ |+| pagerduty | HTTP | requests | ✅ |+| pandadoc | HTTP | requests | ✅ |+| paystack | HTTP | requests + `rest_source.RESTClient` | ✅ |+| pendo | HTTP | requests | ✅ |+| personio | HTTP | requests | ✅ |+| pingdom | HTTP | requests | ✅ |+| pinterest_ads | HTTP | requests | ✅ |+| pipedrive | HTTP | requests | ✅ |+| plain | HTTP | requests | ✅ |+| plausible | HTTP | requests | ✅ |+| polar | HTTP | requests | ✅ |+| plaid | HTTP | requests | ✅ |+| postgres | DB protocol | psycopg | ➖ |+| postmark | HTTP | requests | ✅ |+| productboard | HTTP | requests | ✅ |+| pylon | HTTP | requests | ✅ |+| recurly | HTTP | requests + `rest_source.RESTClient` | ✅ |+| ramp | HTTP | requests | ✅ |+| recharge | HTTP | requests | ✅ |+| reddit_ads | HTTP | requests + `rest_source.RESTClient` | ✅ |+| redshift | DB protocol | psycopg (Postgres-compatible) | ➖ |+| resend | HTTP | requests | ✅ |+| revenuecat | HTTP + Webhook | requests + `WebhookSourceManager` | ✅ (pull) / ➖ (webhook) |+| rippling | HTTP | requests | ✅ |+| rollbar | HTTP | requests | ✅ |+| rootly | HTTP | requests | ✅ |+| salesforce | HTTP | requests + `rest_source.RESTClient` | ✅ |+| salesloft | HTTP | requests | ✅ |+| segment | HTTP | requests | ✅ |+| sendgrid | HTTP | requests | ✅ |+| sentry | HTTP | requests + `rest_source.RESTClient` | ✅ |+| servicenow | HTTP | requests | ✅ |+| shipstation | HTTP | requests | ✅ |+| shopify | HTTP | requests | ✅ |+| shortcut | HTTP | requests | ✅ |+| slack | HTTP | requests + `rest_source.RESTClient` | ✅ |+| smartsheet | HTTP | requests | ✅ |+| snapchat_ads | HTTP | requests + `rest_source.RESTClient` | ✅ |+| snowflake | DB protocol | snowflake-connector-python | ➖ |+| sparkpost | HTTP | requests | ✅ |+| square | HTTP | requests | ✅ |+| squarespace | HTTP | requests | ✅ |+| statuspage | HTTP | requests | ✅ |+| stripe | HTTP (vendor SDK) + Webhook | stripe (StripeClient + RequestsClient) + `WebhookSourceManager` | ✅ (pull) / ➖ (webhook) |+| supabase | DB protocol | psycopg (delegates to PostgresSource) | ➖ |+| surveymonkey | HTTP | requests | ✅ |+| taboola | HTTP | requests | ✅ |+| teamwork | HTTP | requests | ✅ |+| temporalio | gRPC (vendor SDK) | temporalio (`Client`, Rust core via `temporalio.bridge`) | ⚠️ |+| thinkific | HTTP | requests | ✅ |+| tiktok_ads | HTTP | requests + `rest_source.RESTClient` | ✅ |+| tmdb | HTTP | requests | ✅ |+| todoist | HTTP | requests | ✅ |+| trello | HTTP | requests | ✅ |+| twilio | HTTP | requests | ✅ |+| typeform | HTTP | requests + `rest_source.RESTClient` | ✅ |+| vercel | HTTP | requests | ✅ |+| vitally | HTTP | requests + `rest_source.RESTClient` | ✅ |+| webflow | HTTP | requests | ✅ |+| woocommerce | HTTP | requests + `rest_source.RESTClient` | ✅ |+| wordpress | HTTP | requests | ✅ |+| workable | HTTP | requests | ✅ |+| workos | HTTP | requests + `rest_source.RESTClient` | ✅ |+| wrike | HTTP | requests | ✅ |+| zendesk | HTTP | requests + `rest_source.RESTClient` | ✅ |+| zendesk_sell | HTTP | requests | ✅ |+| zoom | HTTP | requests | ✅ |+| zuora | HTTP | requests | ✅ |### Notes on partially-tracked sources@@ -337,7 +338,6 @@ doesn't conflict with concurrent PRs.- campaign_manager_360- capsule_crm- captain_data-- care_quality_commission- cart_com- castor_edc- chameleondiff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/care_quality_commission/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/care_quality_commission/canonical_descriptions.pynew file mode 100644index 000000000000..dba317b4d219--- /dev/null+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/care_quality_commission/canonical_descriptions.py@@ -0,0 +1,82 @@+from products.warehouse_sources.backend.temporal.data_imports.sources.common.canonical_descriptions import (+ CanonicalDescriptions,+)++# Descriptions sourced from the CQC Syndication API documentation+# (https://api.cqc.org.uk and the CQC developer portal at api-portal.service.cqc.org.uk).+CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {+ "providers": {+ "description": "Organisations registered with the Care Quality Commission to provide regulated health or social care in England. One row per provider, with its registration details, contact information, and the regulated activities and service types it is registered for.",+ "docs_url": "https://api.cqc.org.uk",+ "columns": {+ "providerId": "Unique CQC identifier for the provider.",+ "name": "Registered name of the provider organisation.",+ "alsoKnownAs": "Trading or alternative name the provider is also known by.",+ "providerType": "Type of provider (e.g. Organisation, Partnership, Individual).",+ "ownershipType": "Ownership category of the provider (e.g. Organisation, Individual).",+ "organisationType": "CQC organisation classification for the provider.",+ "registrationStatus": "Current CQC registration status (e.g. Registered, Deregistered).",+ "registrationDate": "Date the provider first registered with CQC.",+ "deregistrationDate": "Date the provider deregistered, if applicable.",+ "companiesHouseNumber": "Companies House registration number, where the provider is a company.",+ "charityNumber": "Charity Commission number, where the provider is a charity.",+ "postalAddressLine1": "First line of the provider's registered postal address.",+ "postalAddressLine2": "Second line of the provider's registered postal address.",+ "postalAddressTownCity": "Town or city of the provider's registered postal address.",+ "postalAddressCounty": "County of the provider's registered postal address.",+ "postalCode": "Postcode of the provider's registered postal address.",+ "region": "CQC region the provider is located in.",+ "uprn": "Unique Property Reference Number for the provider's address.",+ "onspdLatitude": "Latitude of the provider's address (ONS Postcode Directory).",+ "onspdLongitude": "Longitude of the provider's address (ONS Postcode Directory).",+ "mainPhoneNumber": "Primary contact phone number for the provider.",+ "website": "Provider's website URL.",+ "constituency": "UK parliamentary constituency of the provider's address.",+ "localAuthority": "Local authority covering the provider's address.",+ "lastInspection": "Details of the provider's most recent inspection.",+ "currentRatings": "The provider's current CQC ratings, where rated.",+ "regulatedActivities": "Regulated activities the provider is registered to carry out.",+ "inspectionCategories": "CQC inspection categories applicable to the provider.",+ "inspectionAreas": "Inspection areas associated with the provider.",+ "locationIds": "CQC identifiers of the locations operated by this provider.",+ },+ },+ "locations": {+ "description": "Individual care locations (care homes, hospitals, clinics, GP practices, and other services) registered with the Care Quality Commission. One row per location, with its address, the provider that operates it, the regulated activities and service types delivered there, and its latest CQC ratings and inspection details.",+ "docs_url": "https://api.cqc.org.uk",+ "columns": {+ "locationId": "Unique CQC identifier for the location.",+ "providerId": "CQC identifier of the provider that operates this location.",+ "name": "Registered name of the location.",+ "alsoKnownAs": "Trading or alternative name the location is also known by.",+ "type": "Type of location (e.g. Social Care Org, NHS Healthcare Organisation).",+ "organisationType": "CQC organisation classification for the location.",+ "registrationStatus": "Current CQC registration status (e.g. Registered, Deregistered).",+ "registrationDate": "Date the location first registered with CQC.",+ "deregistrationDate": "Date the location deregistered, if applicable.",+ "dormancy": "Whether the location is currently dormant (not operating).",+ "numberOfBeds": "Number of registered beds at the location, where applicable.",+ "careHome": "Whether the location is a care home.",+ "postalAddressLine1": "First line of the location's address.",+ "postalAddressLine2": "Second line of the location's address.",+ "postalAddressTownCity": "Town or city of the location's address.",+ "postalAddressCounty": "County of the location's address.",+ "postalCode": "Postcode of the location's address.",+ "region": "CQC region the location is in.",+ "uprn": "Unique Property Reference Number for the location's address.",+ "onspdLatitude": "Latitude of the location's address (ONS Postcode Directory).",+ "onspdLongitude": "Longitude of the location's address (ONS Postcode Directory).",+ "mainPhoneNumber": "Primary contact phone number for the location.",+ "website": "Location's website URL.",+ "constituency": "UK parliamentary constituency of the location's address.",+ "localAuthority": "Local authority covering the location's address.",+ "lastInspection": "Details of the location's most recent inspection.",+ "currentRatings": "The location's current CQC ratings (overall and per key question), where rated.",+ "regulatedActivities": "Regulated activities carried out at the location.",+ "gacServiceTypes": "General activity classification service types delivered at the location.",+ "specialisms": "Care specialisms offered at the location.",+ "inspectionCategories": "CQC inspection categories applicable to the location.",+ "relationships": "Relationships between this location and others (e.g. predecessor/successor).",+ },+ },+}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/care_quality_commission/care_quality_commission.py b/products/warehouse_sources/backend/temporal/data_imports/sources/care_quality_commission/care_quality_commission.pynew file mode 100644index 000000000000..b80cbd5ceeef--- /dev/null+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/care_quality_commission/care_quality_commission.py@@ -0,0 +1,220 @@+"""Care Quality Commission (CQC) Syndication API transport.++The CQC Syndication API (https://api.cqc.org.uk/public/v1) exposes the UK regulator's data on+health and social care providers and locations. Two list endpoints (`/providers`, `/locations`)+return thin summary records (id + name) with page-number pagination; the rich record — addresses,+registration dates, organisation/service types, regulated activities, specialisms, and latest+ratings — only comes from the per-id detail endpoints (`/providers/{id}`, `/locations/{id}`). So+each stream pages the list and fans out one detail call per id.++Authentication is a single subscription/primary key (obtained from the CQC developer portal at+api-portal.service.cqc.org.uk) sent as the `Ocp-Apim-Subscription-Key` header. A `partnerCode`+query param is recommended on every request — clients sending it get the 2000 req/min tier; without+it requests are throttled harder and 429 more readily.++Incremental sync: the API only surfaces change detection via `/changes/provider` and+`/changes/location` (which return changed ids for a `startTimestamp`/`endTimestamp` window). Those+would require fanning out to detail per changed id, but — critically — the detail records carry no+stable "last modified" timestamp we can anchor the pipeline's incremental watermark to. Without a+row-level cursor field the watermark can't advance correctly, so both streams ship full-refresh+only. Full refresh is resumable at list-page granularity so a long fan-out survives heartbeat+timeouts.+"""++import math+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 products.warehouse_sources.backend.temporal.data_imports.pipelines.pipeline.batcher import Batcher+from products.warehouse_sources.backend.temporal.data_imports.pipelines.pipeline.typings import SourceResponse+from products.warehouse_sources.backend.temporal.data_imports.sources.care_quality_commission.settings import (+ CQC_ENDPOINTS,+ CQCEndpointConfig,+)+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++CQC_BASE_URL = "https://api.cqc.org.uk/public/v1"++# Records per list page. The detail fan-out dominates request volume, so this only trades off list+# round-trips; a few hundred keeps each resumable page a sensible unit of work.+LIST_PAGE_SIZE = 500+++class CQCRetryableError(Exception):+ pass+++class CQCResumeConfig:+ # Next list page to fetch. On resume we re-fetch this page (and re-fan-out its detail); merge+ # dedupes the re-pulled rows on the primary key.+ page: int = 1+++def _get_headers(api_key: str) -> dict[str, str]:+ return {+ "Ocp-Apim-Subscription-Key": api_key,+ "Accept": "application/json",+ "User-Agent": "PostHog-DataWarehouse",+ }+++def _build_url(path: str, params: dict[str, Any]) -> str:+ url = f"{CQC_BASE_URL}{path}"+ filtered = {key: value for key, value in params.items() if value is not None and value != ""}+ if not filtered:+ return url+ return f"{url}?{urlencode(filtered)}"+++@retry(+ retry=retry_if_exception_type((CQCRetryableError, requests.ReadTimeout, requests.ConnectionError)),+ stop=stop_after_attempt(5),+ wait=wait_exponential_jitter(initial=1, max=60),+ reraise=True,+)+def _fetch(session: requests.Session, url: str, headers: dict[str, str], logger: FilteringBoundLogger) -> dict:+ response = session.get(url, headers=headers, timeout=60)++ # 429 (rate limited) and 5xx are transient — back off and retry.+ if response.status_code == 429 or response.status_code >= 500:+ raise CQCRetryableError(f"CQC API error (retryable): status={response.status_code}, url={url}")++ if not response.ok:+ logger.error(f"CQC API error: status={response.status_code}, body={response.text}, url={url}")+ response.raise_for_status()++ return response.json()+++def validate_credentials(api_key: str, partner_code: str | None) -> bool:+ # A single cheap probe of the providers list confirms the subscription key is genuine without+ # depending on any particular record existing.+ url = _build_url("/providers", {"page": 1, "perPage": 1, "partnerCode": partner_code})+ try:+ # `redact_values` scrubs the subscription key from logged URLs and captured HTTP samples;+ # `allow_redirects=False` stops a 30x from forwarding the credentialed header off-host.+ session = make_tracked_session(redact_values=(api_key,), allow_redirects=False)+ response = session.get(url, headers=_get_headers(api_key), timeout=30)+ return response.status_code == 200+ except Exception:+ return False+++def _iter_detail_rows(+ session: requests.Session,+ config: CQCEndpointConfig,+ headers: dict[str, str],+ partner_code: str | None,+ logger: FilteringBoundLogger,+ batcher: Batcher,+ resumable_source_manager: ResumableSourceManager[CQCResumeConfig],+ start_page: int,+) -> Iterator[Any]:+ page = start_page+ while True:+ list_data = _fetch(+ session,+ _build_url(config.list_path, {"page": page, "perPage": LIST_PAGE_SIZE, "partnerCode": partner_code}),+ headers,+ logger,+ )++ items = list_data.get(config.list_data_key, [])+ if not items:+ break++ # If totalPages is missing or smaller than the page we just fetched, don't trust it to+ # terminate — fall back to the empty-items check above, which is the safe loop terminator.+ total_pages = list_data.get("totalPages")+ if total_pages is None or total_pages < page:+ total_pages = math.inf++ for item in items:+ # Direct access: a list record missing its id field is an API contract violation worth+ # surfacing as a KeyError rather than silently skipping the row.+ record_id = item[config.id_field]++ detail = _fetch(+ session,+ _build_url(config.detail_path.format(id=record_id), {"partnerCode": partner_code}),+ headers,+ logger,+ )+ batcher.batch(detail)++ if batcher.should_yield():+ yield batcher.get_table()+ # Save AFTER yielding so a crash re-fetches the current page rather than skipping+ # rows; merge dedupes the re-pulled records on the primary key.+ resumable_source_manager.save_state(CQCResumeConfig(page=page))++ if page >= total_pages:+ break++ page += 1+ # Advance the bookmark so a crash between pages resumes on the next page.+ resumable_source_manager.save_state(CQCResumeConfig(page=page))+++def get_rows(+ api_key: str,+ partner_code: str | None,+ endpoint: str,+ logger: FilteringBoundLogger,+ resumable_source_manager: ResumableSourceManager[CQCResumeConfig],+) -> Iterator[Any]:+ config = CQC_ENDPOINTS[endpoint]+ headers = _get_headers(api_key)+ batcher = Batcher(logger=logger, chunk_size=2000, chunk_size_bytes=100 * 1024 * 1024)+ # One session reused across every list page and detail call so urllib3 keeps the connection+ # alive instead of re-handshaking per request. `redact_values` scrubs the subscription key+ # from logged URLs and captured HTTP samples; `allow_redirects=False` stops a 30x from+ # forwarding the credentialed header off-host.+ session = make_tracked_session(redact_values=(api_key,), allow_redirects=False)++ resume = resumable_source_manager.load_state() if resumable_source_manager.can_resume() else None+ start_page = resume.page if resume is not None else 1+ if resume is not None:+ logger.debug(f"CQC: resuming {endpoint} from page {start_page}")++ yield from _iter_detail_rows(+ session, config, headers, partner_code, logger, batcher, resumable_source_manager, start_page+ )++ if batcher.should_yield(include_incomplete_chunk=True):+ yield batcher.get_table()+++def care_quality_commission_source(+ api_key: str,+ partner_code: str | None,+ endpoint: str,+ logger: FilteringBoundLogger,+ resumable_source_manager: ResumableSourceManager[CQCResumeConfig],+) -> SourceResponse:+ config = CQC_ENDPOINTS[endpoint]++ return SourceResponse(+ name=endpoint,+ items=lambda: get_rows(+ api_key=api_key,+ partner_code=partner_code,+ endpoint=endpoint,+ logger=logger,+ resumable_source_manager=resumable_source_manager,+ ),+ primary_keys=config.primary_keys,+ partition_count=1,+ partition_size=1,+ 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,+ )diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/care_quality_commission/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/care_quality_commission/settings.pynew file mode 100644index 000000000000..141bc51b29c4--- /dev/null+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/care_quality_commission/settings.py@@ -0,0 +1,58 @@+from dataclasses import dataclass, field+from typing import Optional++from products.warehouse_sources.backend.types import IncrementalField+++@dataclass+class CQCEndpointConfig:+ name: str+ # List endpoint returning summary records + pagination metadata (e.g. "/providers").+ list_path: str+ # Key under which the list endpoint nests its records (e.g. "providers").+ list_data_key: str+ # Per-record id field on the summary record (e.g. "providerId").+ id_field: str+ # Detail endpoint template fetched per id for the full record (e.g. "/providers/{id}").+ detail_path: str+ # Required, no default: each endpoint has its own key (providerId vs locationId), so a generic+ # default would silently mis-key any future endpoint that forgot to set it.+ primary_keys: list[str]+ # Stable date field used for datetime partitioning. `registrationDate` is the date the+ # provider/location first registered with CQC — it never changes once set, unlike rating+ # or inspection dates which move on every re-inspection.+ partition_key: Optional[str] = "registrationDate"+ incremental_fields: list[IncrementalField] = field(default_factory=list)+ should_sync_default: bool = True+++CQC_ENDPOINTS: dict[str, CQCEndpointConfig] = {+ "providers": CQCEndpointConfig(+ name="providers",+ list_path="/providers",+ list_data_key="providers",+ id_field="providerId",+ detail_path="/providers/{id}",+ primary_keys=["providerId"],+ ),+ "locations": CQCEndpointConfig(+ name="locations",+ list_path="/locations",+ list_data_key="locations",+ id_field="locationId",+ detail_path="/locations/{id}",+ primary_keys=["locationId"],+ ),+}++ENDPOINTS = tuple(CQC_ENDPOINTS.keys())++# Both endpoints ship full-refresh only. The CQC API exposes change detection solely through the+# dedicated /changes/provider and /changes/location endpoints, which return changed ids for a+# timestamp window — but the per-record detail returned by /providers/{id} and /locations/{id}+# carries no stable "last modified" column to anchor the pipeline's incremental watermark to, so a+# reliable server-side incremental cursor isn't available. See the module docstring in+# care_quality_commission.py for the full rationale.+INCREMENTAL_FIELDS: dict[str, list[IncrementalField]] = {+ name: config.incremental_fields for name, config in CQC_ENDPOINTS.items()+}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/care_quality_commission/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/care_quality_commission/source.pyindex 07dd564e654b..e200807084f5 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/care_quality_commission/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/care_quality_commission/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.care_quality_commission.care_quality_commission import (+ CQCResumeConfig,+ care_quality_commission_source,+ validate_credentials as validate_cqc_credentials,+)+from products.warehouse_sources.backend.temporal.data_imports.sources.care_quality_commission.settings import (+ CQC_ENDPOINTS,+ ENDPOINTS,+ INCREMENTAL_FIELDS,+)+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 SourceSchemafrom products.warehouse_sources.backend.temporal.data_imports.sources.generated_configs import (CareQualityCommissionSourceConfig,)@@ -15,7 +37,9 @@ from products.warehouse_sources.backend.types import ExternalDataSourceType@SourceRegistry.register-class CareQualityCommissionSource(SimpleSource[CareQualityCommissionSourceConfig]):+class CareQualityCommissionSource(ResumableSource[CareQualityCommissionSourceConfig, CQCResumeConfig]):+ lists_tables_without_credentials = True # static endpoint catalog — safe for public docs+@propertydef source_type(self) -> ExternalDataSourceType:return ExternalDataSourceType.CAREQUALITYCOMMISSION@@ -26,7 +50,100 @@ class CareQualityCommissionSource(SimpleSource[CareQualityCommissionSourceConfigname=SchemaExternalDataSourceType.CARE_QUALITY_COMMISSION,category=DataWarehouseSourceCategory.ANALYTICS,label="Care Quality Commission",+ releaseStatus=ReleaseStatus.ALPHA,+ caption="""Enter your CQC Syndication API subscription key to pull UK health and social care provider and location data into the PostHog Data warehouse.++Create a subscription key from the [CQC developer portal](https://api-portal.service.cqc.org.uk) — subscribe to the Syndication API product and copy its primary key.++The `partner code` is optional but recommended: requests sent with a partner code are allowed up to 2000 requests/minute, while requests without one are throttled harder. Request a partner code from CQC if you don't have one.""",iconPath="/static/services/care_quality_commission.png",- fields=cast(list[FieldType], []),- unreleasedSource=True,+ docsUrl="https://posthog.com/docs/cdp/sources/care-quality-commission",+ fields=cast(+ list[FieldType],+ [+ SourceFieldInputConfig(+ name="api_key",+ label="Subscription key",+ type=SourceFieldInputConfigType.PASSWORD,+ required=True,+ placeholder="Your CQC primary subscription key",+ secret=True,+ ),+ SourceFieldInputConfig(+ name="partner_code",+ label="Partner code (optional)",+ type=SourceFieldInputConfigType.TEXT,+ required=False,+ placeholder="Your CQC partner code",+ secret=False,+ ),+ ],+ ),+ )++ def get_canonical_descriptions(self) -> CanonicalDescriptions:+ from products.warehouse_sources.backend.temporal.data_imports.sources.care_quality_commission.canonical_descriptions import (+ CANONICAL_DESCRIPTIONS,+ )++ return CANONICAL_DESCRIPTIONS++ def get_non_retryable_errors(self) -> dict[str, str | None]:+ return {+ # An invalid or unsubscribed subscription key surfaces as a requests HTTPError when+ # `_fetch` calls `raise_for_status()`. Retrying can never satisfy a credential problem,+ # so stop the sync. Match the stable status text and base host, not the per-request path.+ "401 Client Error: Unauthorized for url: https://api.cqc.org.uk": "Your CQC subscription key is invalid. Create a new key from the CQC developer portal and reconnect.",+ "403 Client Error: Forbidden for url: https://api.cqc.org.uk": "Your CQC subscription key is not authorized for the Syndication API. Subscribe to the Syndication API product in the CQC developer portal, then reconnect.",+ }++ def get_schemas(+ self,+ config: CareQualityCommissionSourceConfig,+ team_id: int,+ with_counts: bool = False,+ names: list[str] | None = None,+ force_refresh: bool = False,+ ) -> list[SourceSchema]:+ def _build_schema(endpoint: str) -> SourceSchema:+ endpoint_config = CQC_ENDPOINTS[endpoint]+ return SourceSchema(+ name=endpoint,+ # Full refresh only — no reliable server-side incremental cursor (see settings.py).+ supports_incremental=False,+ supports_append=False,+ incremental_fields=INCREMENTAL_FIELDS.get(endpoint, []),+ should_sync_default=endpoint_config.should_sync_default,+ detected_primary_keys=endpoint_config.primary_keys,+ )++ schemas = [_build_schema(endpoint) for endpoint in 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: CareQualityCommissionSourceConfig, team_id: int, schema_name: Optional[str] = None+ ) -> tuple[bool, str | None]:+ if validate_cqc_credentials(config.api_key, config.partner_code):+ return True, None++ return False, "Invalid CQC subscription key"++ def get_resumable_source_manager(self, inputs: SourceInputs) -> ResumableSourceManager[CQCResumeConfig]:+ return ResumableSourceManager[CQCResumeConfig](inputs, CQCResumeConfig)++ def source_for_pipeline(+ self,+ config: CareQualityCommissionSourceConfig,+ resumable_source_manager: ResumableSourceManager[CQCResumeConfig],+ inputs: SourceInputs,+ ) -> SourceResponse:+ return care_quality_commission_source(+ api_key=config.api_key,+ partner_code=config.partner_code,+ endpoint=inputs.schema_name,+ logger=inputs.logger,+ resumable_source_manager=resumable_source_manager,)diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/care_quality_commission/tests/test_care_quality_commission.py b/products/warehouse_sources/backend/temporal/data_imports/sources/care_quality_commission/tests/test_care_quality_commission.pynew file mode 100644index 000000000000..ee51c0c505f9--- /dev/null+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/care_quality_commission/tests/test_care_quality_commission.py@@ -0,0 +1,261 @@+from typing import Any++import pytest+from unittest.mock import MagicMock, patch++import requests+from parameterized import parameterized++from products.warehouse_sources.backend.temporal.data_imports.sources.care_quality_commission import (+ care_quality_commission as cqc,+)+from products.warehouse_sources.backend.temporal.data_imports.sources.care_quality_commission.care_quality_commission import (+ CQC_BASE_URL,+ CQCResumeConfig,+ _build_url,+ _fetch,+ _get_headers,+ care_quality_commission_source,+ get_rows,+)+from products.warehouse_sources.backend.temporal.data_imports.sources.care_quality_commission.settings import (+ CQC_ENDPOINTS,+)+++class _FakeResumableManager:+ def __init__(self, state: CQCResumeConfig | None = None) -> None:+ self._state = state+ self.saved: list[CQCResumeConfig] = []++ def can_resume(self) -> bool:+ return self._state is not None++ def load_state(self) -> CQCResumeConfig | None:+ return self._state++ def save_state(self, data: CQCResumeConfig) -> None:+ self.saved.append(data)+++class TestGetHeaders:+ def test_uses_subscription_key_header(self) -> None:+ headers = _get_headers("my-key")+ # CQC authenticates with the Azure API Management subscription-key header, not a bearer token.+ assert headers["Ocp-Apim-Subscription-Key"] == "my-key"+ assert headers["Accept"] == "application/json"+++class TestBuildUrl:+ def test_includes_partner_code_and_pagination(self) -> None:+ url = _build_url("/providers", {"page": 1, "perPage": 500, "partnerCode": "PC"})+ assert url == f"{CQC_BASE_URL}/providers?page=1&perPage=500&partnerCode=PC"++ def test_omits_none_and_empty_params(self) -> None:+ # A missing partner code must not leak through as `partnerCode=None` / `partnerCode=`.+ url = _build_url("/providers", {"page": 1, "partnerCode": None, "extra": ""})+ assert url == f"{CQC_BASE_URL}/providers?page=1"++ def test_no_params(self) -> None:+ assert _build_url("/providers/1-123", {}) == f"{CQC_BASE_URL}/providers/1-123"+++class TestFetch:+ @parameterized.expand([("rate_limited", 429), ("server_error", 500), ("bad_gateway", 503)])+ def test_retryable_status_raises_retryable_error(self, _name: str, status: int) -> None:+ response = MagicMock()+ response.status_code = status+ session = MagicMock()+ session.get.return_value = response+ # Skip tenacity's backoff sleeps so the 5 retries don't slow the test.+ _fetch.retry.sleep = lambda _s: None # type: ignore[attr-defined]+ with pytest.raises(cqc.CQCRetryableError):+ _fetch(session, "http://x", {}, MagicMock())++ @parameterized.expand([("unauthorized", 401), ("forbidden", 403), ("not_found", 404)])+ def test_client_error_raises_for_status(self, _name: str, status: int) -> None:+ response = MagicMock()+ response.status_code = status+ response.ok = False+ response.raise_for_status.side_effect = requests.HTTPError(f"{status} error", response=response)+ session = MagicMock()+ session.get.return_value = response+ with pytest.raises(requests.HTTPError):+ _fetch(session, "http://x", {}, MagicMock())++ def test_success_returns_json(self) -> None:+ response = MagicMock()+ response.status_code = 200+ response.ok = True+ response.json.return_value = {"providers": []}+ session = MagicMock()+ session.get.return_value = response+ assert _fetch(session, "http://x", {}, MagicMock()) == {"providers": []}+++def _collect(+ manager: _FakeResumableManager,+ monkeypatch: Any,+ pages: dict[str, Any],+ endpoint: str = "providers",+ partner_code: str | None = "PC",+) -> list[dict]:+ def fake_fetch(session: Any, url: str, headers: dict[str, str], logger: Any) -> dict:+ result = pages[url]+ if isinstance(result, Exception):+ raise result+ return result++ monkeypatch.setattr(cqc, "_fetch", fake_fetch)+ monkeypatch.setattr(cqc, "make_tracked_session", lambda **kwargs: MagicMock())++ rows: list[dict] = []+ for table in get_rows(+ api_key="key",+ partner_code=partner_code,+ endpoint=endpoint,+ logger=MagicMock(),+ resumable_source_manager=manager, # type: ignore[arg-type]+ ):+ rows.extend(table.to_pylist())+ return rows+++class TestGetRowsFanOut:+ def test_fans_out_list_to_detail_records(self, monkeypatch: Any) -> None:+ pages = {+ f"{CQC_BASE_URL}/providers?page=1&perPage=500&partnerCode=PC": {+ "providers": [{"providerId": "1-A"}, {"providerId": "1-B"}],+ "totalPages": 1,+ },+ f"{CQC_BASE_URL}/providers/1-A?partnerCode=PC": {"providerId": "1-A", "name": "Alpha"},+ f"{CQC_BASE_URL}/providers/1-B?partnerCode=PC": {"providerId": "1-B", "name": "Bravo"},+ }+ rows = _collect(_FakeResumableManager(), monkeypatch, pages)+ assert rows == [+ {"providerId": "1-A", "name": "Alpha"},+ {"providerId": "1-B", "name": "Bravo"},+ ]++ def test_locations_endpoint_uses_location_paths(self, monkeypatch: Any) -> None:+ pages = {+ f"{CQC_BASE_URL}/locations?page=1&perPage=500&partnerCode=PC": {+ "locations": [{"locationId": "1-L"}],+ "totalPages": 1,+ },+ f"{CQC_BASE_URL}/locations/1-L?partnerCode=PC": {"locationId": "1-L", "name": "Loc"},+ }+ rows = _collect(_FakeResumableManager(), monkeypatch, pages, endpoint="locations")+ assert rows == [{"locationId": "1-L", "name": "Loc"}]++ def test_paginates_across_pages(self, monkeypatch: Any) -> None:+ pages = {+ f"{CQC_BASE_URL}/providers?page=1&perPage=500&partnerCode=PC": {+ "providers": [{"providerId": "1-A"}],+ "totalPages": 2,+ },+ f"{CQC_BASE_URL}/providers/1-A?partnerCode=PC": {"providerId": "1-A"},+ f"{CQC_BASE_URL}/providers?page=2&perPage=500&partnerCode=PC": {+ "providers": [{"providerId": "1-B"}],+ "totalPages": 2,+ },+ f"{CQC_BASE_URL}/providers/1-B?partnerCode=PC": {"providerId": "1-B"},+ }+ manager = _FakeResumableManager()+ rows = _collect(manager, monkeypatch, pages)+ assert rows == [{"providerId": "1-A"}, {"providerId": "1-B"}]+ # The bookmark advances to page 2 after page 1 completes so a crash resumes mid-stream.+ assert CQCResumeConfig(page=2) in manager.saved++ def test_paginates_when_total_pages_missing(self, monkeypatch: Any) -> None:+ # The API omits totalPages: don't trust the fallback to terminate after page 1 — keep+ # paging until an empty page is returned.+ pages = {+ f"{CQC_BASE_URL}/providers?page=1&perPage=500&partnerCode=PC": {+ "providers": [{"providerId": "1-A"}],+ },+ f"{CQC_BASE_URL}/providers/1-A?partnerCode=PC": {"providerId": "1-A"},+ f"{CQC_BASE_URL}/providers?page=2&perPage=500&partnerCode=PC": {+ "providers": [{"providerId": "1-B"}],+ },+ f"{CQC_BASE_URL}/providers/1-B?partnerCode=PC": {"providerId": "1-B"},+ f"{CQC_BASE_URL}/providers?page=3&perPage=500&partnerCode=PC": {"providers": []},+ }+ rows = _collect(_FakeResumableManager(), monkeypatch, pages)+ assert rows == [{"providerId": "1-A"}, {"providerId": "1-B"}]++ def test_empty_page_terminates(self, monkeypatch: Any) -> None:+ pages = {+ f"{CQC_BASE_URL}/providers?page=1&perPage=500&partnerCode=PC": {"providers": [], "totalPages": 5},+ }+ assert _collect(_FakeResumableManager(), monkeypatch, pages) == []++ def test_record_without_id_raises(self, monkeypatch: Any) -> None:+ # A list record missing its id field is an API contract violation — fail fast with a+ # KeyError rather than silently dropping the row.+ pages = {+ f"{CQC_BASE_URL}/providers?page=1&perPage=500&partnerCode=PC": {+ "providers": [{"name": "no id"}],+ "totalPages": 1,+ },+ }+ with pytest.raises(KeyError):+ _collect(_FakeResumableManager(), monkeypatch, pages)++ def test_resume_skips_already_synced_pages(self, monkeypatch: Any) -> None:+ # Saved state says page 2; page 1 must not be fetched again.+ pages = {+ f"{CQC_BASE_URL}/providers?page=2&perPage=500&partnerCode=PC": {+ "providers": [{"providerId": "1-B"}],+ "totalPages": 2,+ },+ f"{CQC_BASE_URL}/providers/1-B?partnerCode=PC": {"providerId": "1-B"},+ }+ manager = _FakeResumableManager(CQCResumeConfig(page=2))+ rows = _collect(manager, monkeypatch, pages)+ assert rows == [{"providerId": "1-B"}]++ def test_omits_partner_code_when_absent(self, monkeypatch: Any) -> None:+ pages = {+ f"{CQC_BASE_URL}/providers?page=1&perPage=500": {+ "providers": [{"providerId": "1-A"}],+ "totalPages": 1,+ },+ f"{CQC_BASE_URL}/providers/1-A": {"providerId": "1-A"},+ }+ rows = _collect(_FakeResumableManager(), monkeypatch, pages, partner_code=None)+ assert rows == [{"providerId": "1-A"}]+++class TestSourceResponse:+ @parameterized.expand([("providers", ["providerId"]), ("locations", ["locationId"])])+ def test_response_shape(self, endpoint: str, expected_keys: list[str]) -> None:+ response = care_quality_commission_source(+ api_key="key",+ partner_code="PC",+ endpoint=endpoint,+ logger=MagicMock(),+ resumable_source_manager=MagicMock(),+ )+ assert response.name == endpoint+ assert response.primary_keys == expected_keys+ # Partition on the stable registration date so partitions never rewrite.+ assert response.partition_mode == "datetime"+ assert response.partition_keys == [CQC_ENDPOINTS[endpoint].partition_key]+++class TestValidateCredentials:+ @parameterized.expand([("ok", 200, True), ("unauthorized", 401, False), ("forbidden", 403, False)])+ def test_status_mapping(self, _name: str, status: int, expected: bool) -> None:+ response = MagicMock()+ response.status_code = status+ session = MagicMock()+ session.get.return_value = response+ with patch.object(cqc, "make_tracked_session", lambda **kwargs: session):+ assert cqc.validate_credentials("key", "PC") is expected++ def test_network_error_is_invalid(self) -> None:+ session = MagicMock()+ session.get.side_effect = requests.ConnectionError("boom")+ with patch.object(cqc, "make_tracked_session", lambda **kwargs: session):+ assert cqc.validate_credentials("key", "PC") is Falsediff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/care_quality_commission/tests/test_care_quality_commission_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/care_quality_commission/tests/test_care_quality_commission_source.pynew file mode 100644index 000000000000..86bd210c1196--- /dev/null+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/care_quality_commission/tests/test_care_quality_commission_source.py@@ -0,0 +1,167 @@+from typing import Any++from unittest.mock import MagicMock++from parameterized import parameterized++from posthog.schema import DataWarehouseSourceCategory, ReleaseStatus++from products.warehouse_sources.backend.temporal.data_imports.sources.care_quality_commission import (+ source as cqc_source,+)+from products.warehouse_sources.backend.temporal.data_imports.sources.care_quality_commission.care_quality_commission import (+ CQCResumeConfig,+)+from products.warehouse_sources.backend.temporal.data_imports.sources.care_quality_commission.source import (+ CareQualityCommissionSource,+)+from products.warehouse_sources.backend.temporal.data_imports.sources.common.resumable import ResumableSourceManager+from products.warehouse_sources.backend.types import ExternalDataSourceType+++def _config(api_key: str = "key", partner_code: str | None = "PC") -> Any:+ config = MagicMock()+ config.api_key = api_key+ config.partner_code = partner_code+ return config+++class TestSourceConfig:+ def test_source_type(self) -> None:+ assert CareQualityCommissionSource().source_type == ExternalDataSourceType.CAREQUALITYCOMMISSION++ def test_config_metadata(self) -> None:+ config = CareQualityCommissionSource().get_source_config+ assert config.label == "Care Quality Commission"+ assert config.category == DataWarehouseSourceCategory.ANALYTICS+ assert config.releaseStatus == ReleaseStatus.ALPHA+ # docsUrl slug must match the published doc filename so the website doesn't 404.+ assert config.docsUrl == "https://posthog.com/docs/cdp/sources/care-quality-commission"+ assert config.unreleasedSource is None++ def test_fields(self) -> None:+ fields: dict[str, Any] = {f.name: f for f in CareQualityCommissionSource().get_source_config.fields}+ assert set(fields) == {"api_key", "partner_code"}+ # The subscription key is the secret; the partner code is an optional throttling hint.+ assert fields["api_key"].required is True+ assert fields["api_key"].secret is True+ assert fields["partner_code"].required is False+++class TestGetSchemas:+ def test_returns_both_streams_as_full_refresh(self) -> None:+ schemas = {s.name: s for s in CareQualityCommissionSource().get_schemas(MagicMock(), team_id=1)}+ assert set(schemas) == {"providers", "locations"}+ for schema in schemas.values():+ assert schema.supports_incremental is False+ assert schema.supports_append is False+ assert schema.incremental_fields == []++ @parameterized.expand([("providers", ["providerId"]), ("locations", ["locationId"])])+ def test_primary_keys(self, endpoint: str, expected_keys: list[str]) -> None:+ schemas = {s.name: s for s in CareQualityCommissionSource().get_schemas(MagicMock(), team_id=1)}+ assert schemas[endpoint].detected_primary_keys == expected_keys++ def test_names_filter(self) -> None:+ schemas = CareQualityCommissionSource().get_schemas(MagicMock(), team_id=1, names=["locations"])+ assert [s.name for s in schemas] == ["locations"]+++class TestDocumentedTables:+ def test_lists_tables_without_credentials(self) -> None:+ # The endpoint catalog is static (no I/O), so the public docs can render the table list.+ assert CareQualityCommissionSource.lists_tables_without_credentials is True++ def test_documented_tables_carry_descriptions_and_keys(self) -> None:+ tables = {t["name"]: t for t in CareQualityCommissionSource().get_documented_tables()}+ assert set(tables) == {"providers", "locations"}+ assert tables["providers"]["primary_keys"] == ["providerId"]+ assert tables["providers"]["sync_methods"] == ["Full refresh"]+ assert tables["providers"]["description"]+++class TestValidateCredentials:+ def test_valid(self, monkeypatch: Any) -> None:+ monkeypatch.setattr(cqc_source, "validate_cqc_credentials", lambda api_key, partner_code: True)+ ok, error = CareQualityCommissionSource().validate_credentials(_config(), team_id=1)+ assert ok is True+ assert error is None++ def test_invalid(self, monkeypatch: Any) -> None:+ monkeypatch.setattr(cqc_source, "validate_cqc_credentials", lambda api_key, partner_code: False)+ ok, error = CareQualityCommissionSource().validate_credentials(_config(), team_id=1)+ assert ok is False+ assert error is not None++ def test_passes_partner_code_through(self, monkeypatch: Any) -> None:+ seen: dict[str, Any] = {}++ def fake_validate(api_key: str, partner_code: str | None) -> bool:+ seen["api_key"] = api_key+ seen["partner_code"] = partner_code+ return True++ monkeypatch.setattr(cqc_source, "validate_cqc_credentials", fake_validate)+ CareQualityCommissionSource().validate_credentials(_config(api_key="k", partner_code="P1"), team_id=1)+ assert seen == {"api_key": "k", "partner_code": "P1"}+++class TestNonRetryableErrors:+ @parameterized.expand(+ [+ (+ "unauthorized",+ "401 Client Error: Unauthorized for url: https://api.cqc.org.uk/public/v1/providers/1-123",+ ),+ ("forbidden", "403 Client Error: Forbidden for url: https://api.cqc.org.uk/public/v1/locations"),+ ]+ )+ def test_credential_errors_are_non_retryable(self, _name: str, observed_error: str) -> None:+ non_retryable = CareQualityCommissionSource().get_non_retryable_errors()+ assert any(key in observed_error for key in non_retryable)++ @parameterized.expand(+ [+ (+ "server_error",+ "500 Server Error: Internal Server Error for url: https://api.cqc.org.uk/public/v1/providers",+ ),+ ("rate_limited", "429 Client Error: Too Many Requests for url: https://api.cqc.org.uk/public/v1/providers"),+ ("read_timeout", "HTTPSConnectionPool(host='api.cqc.org.uk', port=443): Read timed out."),+ ]+ )+ def test_transient_errors_remain_retryable(self, _name: str, other_error: str) -> None:+ non_retryable = CareQualityCommissionSource().get_non_retryable_errors()+ assert not any(key in other_error for key in non_retryable)+++class TestResumableSourceManager:+ def test_returns_manager_bound_to_resume_config(self) -> None:+ inputs = MagicMock()+ manager = CareQualityCommissionSource().get_resumable_source_manager(inputs)+ assert isinstance(manager, ResumableSourceManager)+ assert manager._data_class is CQCResumeConfig+++class TestSourceForPipeline:+ def test_plumbs_arguments(self, monkeypatch: Any) -> None:+ captured: dict[str, Any] = {}++ def fake_source(**kwargs: Any) -> str:+ captured.update(kwargs)+ return "response"++ monkeypatch.setattr(cqc_source, "care_quality_commission_source", fake_source)++ inputs = MagicMock()+ inputs.schema_name = "providers"+ manager = MagicMock()+ result: Any = CareQualityCommissionSource().source_for_pipeline(+ _config(api_key="k", partner_code="P1"), manager, inputs+ )++ assert result == "response"+ assert captured["api_key"] == "k"+ assert captured["partner_code"] == "P1"+ assert captured["endpoint"] == "providers"+ assert captured["resumable_source_manager"] is managerdiff --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 616e38c604bd..809abee65c46 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@@ -577,7 +577,8 @@ class CaptainDataSourceConfig(config.Config):@config.configclass CareQualityCommissionSourceConfig(config.Config):- pass+ api_key: str+ partner_code: str | None = None@config.config