: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
from typing import Optional, cast
from products.warehouse_sources.sources.gleif._config import GleifSourceConfig
from products.warehouse_sources.sources.gleif.gleif import (
GleifResumeConfig,
gleif_source,
validate_credentials as validate_gleif_credentials,
)
from products.warehouse_sources.sources.gleif.settings import ENDPOINTS, INCREMENTAL_FIELDS
from products.warehouse_sources.sources.sdk import (
CanonicalDescriptions,
DataWarehouseSourceCategory,
ExternalDataSourceType,
FieldType,
ReleaseStatus,
ResumableSource,
ResumableSourceManager,
SourceConfig,
SourceInputs,
SourceRegistry,
SourceResponse,
SourceSchema,
build_endpoint_schemas,
detect,
)
@SourceRegistry.register
class GleifSource(ResumableSource[GleifSourceConfig, GleifResumeConfig]):
codebase_detection = detect(env=("^GLEIF_",))
lists_tables_without_credentials = True # static endpoint catalog — safe for public docs
api_docs_url = "https://www.gleif.org/en/lei-data/gleif-api"
@property
def source_type(self) -> ExternalDataSourceType:
return ExternalDataSourceType.GLEIF
def get_canonical_descriptions(self) -> CanonicalDescriptions:
from products.warehouse_sources.sources.gleif.canonical_descriptions import CANONICAL_DESCRIPTIONS
return CANONICAL_DESCRIPTIONS
def get_schemas(
self,
config: GleifSourceConfig,
team_id: int,
with_counts: bool = False,
names: list[str] | None = None,
force_refresh: bool = False,
api_version: str | None = None,
) -> list[SourceSchema]:
return build_endpoint_schemas(ENDPOINTS, INCREMENTAL_FIELDS, names)
def validate_credentials(
self,
config: GleifSourceConfig,
team_id: int,
schema_name: Optional[str] = None,
api_version: str | None = None,
) -> tuple[bool, str | None]:
if validate_gleif_credentials():
return True, None
return False, "Could not reach the GLEIF API. Please try again in a moment."
def get_resumable_source_manager(self, inputs: SourceInputs) -> ResumableSourceManager[GleifResumeConfig]:
return ResumableSourceManager[GleifResumeConfig](inputs, GleifResumeConfig)
def source_for_pipeline(
self,
config: GleifSourceConfig,
resumable_source_manager: ResumableSourceManager[GleifResumeConfig],
inputs: SourceInputs,
) -> SourceResponse:
return gleif_source(
endpoint=inputs.schema_name,
team_id=inputs.team_id,
job_id=inputs.job_id,
resumable_source_manager=resumable_source_manager,
should_use_incremental_field=inputs.should_use_incremental_field,
db_incremental_field_last_value=inputs.db_incremental_field_last_value
if inputs.should_use_incremental_field
else None,
)
@property
def get_source_config(self) -> SourceConfig:
return SourceConfig(
name=ExternalDataSourceType.GLEIF,
category=DataWarehouseSourceCategory.FINANCE___ACCOUNTING,
keywords=["lei", "legal entity identifier"],
label="GLEIF (Global Legal Entity Identifier Foundation)",
caption=(
"Import Legal Entity Identifier (LEI) reference data from GLEIF's free, public "
"registry. No API key or account is required."
),
iconPath="/static/services/gleif.png",
docsUrl="https://posthog.com/docs/cdp/sources/gleif",
releaseStatus=ReleaseStatus.BETA,
fields=cast(list[FieldType], []),
)