: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.sdk import (
CanonicalDescriptions,
DataWarehouseSourceCategory,
ExternalDataSourceType,
FieldType,
ReleaseStatus,
SimpleSource,
SourceConfig,
SourceFieldInputConfig,
SourceFieldInputConfigType,
SourceInputs,
SourceRegistry,
SourceResponse,
SourceSchema,
detect,
)
from products.warehouse_sources.sources.vultr._config import VultrSourceConfig
from products.warehouse_sources.sources.vultr.settings import ENDPOINTS
from products.warehouse_sources.sources.vultr.vultr import (
validate_credentials as validate_vultr_credentials,
vultr_source,
)
@SourceRegistry.register
class VultrSource(SimpleSource[VultrSourceConfig]):
codebase_detection = detect(
env=("^VULTR_",),
npm=("@vultr/vultr-node",),
go=(
"github.com/vultr/govultr",
"github.com/crossplane-contrib/provider-vultr",
"github.com/vultr/cert-manager-webhook-vultr",
"github.com/vultr/docker-machine-driver-vultr",
"github.com/vultr/external-dns-vultr-webhook",
"github.com/vultr/packer-plugin-vultr",
"github.com/vultr/vultr-cli",
"github.com/vultr/vultr-cloud-controller-manager",
"github.com/vultr/vultr-cluster-autoscaler",
"github.com/vultr/vultr-csi",
),
)
# get_schemas is a static endpoint catalog with no I/O, so the table list is safe for public docs.
lists_tables_without_credentials = True
supported_versions = ("v2",)
default_version = "v2"
api_docs_url = "https://www.vultr.com/api/"
@property
def source_type(self) -> ExternalDataSourceType:
return ExternalDataSourceType.VULTR
def get_non_retryable_errors(self) -> dict[str, str | None]:
return {
"401 Client Error: Unauthorized for url": "Your Vultr API key is invalid or has been revoked. Generate a new key in the Vultr customer portal and reconnect.",
"403 Client Error: Forbidden for url": "Your Vultr API key is being blocked. Check the API key's IP access control list in the Vultr customer portal and reconnect.",
}
def get_canonical_descriptions(self) -> CanonicalDescriptions:
from products.warehouse_sources.sources.vultr.canonical_descriptions import CANONICAL_DESCRIPTIONS
return CANONICAL_DESCRIPTIONS
def get_schemas(
self,
config: VultrSourceConfig,
team_id: int,
with_counts: bool = False,
names: list[str] | None = None,
force_refresh: bool = False,
api_version: str | None = None,
) -> list[SourceSchema]:
# Every Vultr list endpoint is full-refresh: the API exposes no server-side timestamp filter.
schemas = [
SourceSchema(
name=endpoint,
supports_incremental=False,
supports_append=False,
incremental_fields=[],
)
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: VultrSourceConfig, team_id: int, schema_name: Optional[str] = None, api_version: str | None = None
) -> tuple[bool, str | None]:
return validate_vultr_credentials(config.api_key, schema_name)
def source_for_pipeline(self, config: VultrSourceConfig, inputs: SourceInputs) -> SourceResponse:
resource = vultr_source(
api_key=config.api_key,
endpoint=inputs.schema_name,
team_id=inputs.team_id,
job_id=inputs.job_id,
)
return SourceResponse(
name=resource.name,
items=lambda: resource,
primary_keys=ENDPOINTS[inputs.schema_name].primary_keys,
column_hints=resource.column_hints,
)
@property
def get_source_config(self) -> SourceConfig:
return SourceConfig(
name=ExternalDataSourceType.VULTR,
category=DataWarehouseSourceCategory.ENGINEERING___MONITORING,
label="Vultr",
caption=(
"Import your Vultr cloud infrastructure and billing data. Generate a personal access token "
"under **Account > API** in the [Vultr customer portal](https://my.vultr.com/settings/#settingsapi). "
"The token grants full account access; if API access is restricted, add PostHog's egress IPs to the "
"API key's access control list."
),
docsUrl="https://posthog.com/docs/cdp/sources/vultr",
iconPath="/static/services/vultr.svg",
keywords=["cloud", "infrastructure", "billing", "compute"],
releaseStatus=ReleaseStatus.BETA,
fields=cast(
list[FieldType],
[
SourceFieldInputConfig(
name="api_key",
label="API key",
type=SourceFieldInputConfigType.PASSWORD,
required=True,
placeholder="",
secret=True,
),
],
),
)