version: 1

# BigQuery extract source (ADR 0017) for the warehouse-layer cloud_tenants table. We OWN this
# extract: it `bq extract`s gcp-digital-bi(.dwh_cloud_platform).cloud_tenants to Parquet in a GCS
# bucket we own and owns the GCS-snapshot `source` contract for the objects it writes. The transform
# layer snapshots cloud_tenants instead of re-porting the GA4 -> cloud_users -> cloud_tenants chain
# (ADR 0019); only its scalar columns are consumed downstream, but the whole table is exported.
#
# Run: provision setup/grunt/cloud_tenants (bucket + reader SA), then generate-contracts ->
# extract-run, and load the resulting manifest with gcs_bulk_load (sources/cloud_tenants).
# `bq`/`gcloud` authenticate via ambient gcloud auth; there is no DSN to store.

source:
  name: cloud_tenants
  project: REPLACE-WITH-GCP-PROJECT          # e.g. gcp-digital-bi (prod) or gcp-digital-bi-dev
  dataset: dwh_cloud_platform
  domain: cloud_platform
  owner: data-platform
  secrets_file: secrets.env
  watermark_candidates:
    - updated_timestamp
    - created_timestamp
  # BigQuery enforces no primary keys; the snapshot declares them per table so the loader can
  # do raw-snapshot dedup detection (ADR 0017).
  primary_keys:
    cloud_tenants: [tenant_id]

tables:
  include:
    - cloud_tenants
  exclude: []
  require_primary_key: true

gcs:
  # `bq extract` requires the export bucket location to match the source dataset location.
  bucket: REPLACE-WITH-EXPORT-BUCKET
  location: us-west2
  snapshot_prefix: snapshots/source=cloud_tenants
  manifest_prefix: manifests/source=cloud_tenants
  runtime_log_prefix: logs/source=cloud_tenants

export:
  compression: ZSTD

freshness:
  degraded_after_hours: 30
  blocked_after_hours: 48

retention:
  gcs_snapshots_days: 7
  manifests_days: 365

governance:
  classifications:
    - customer_data
  classification_patterns:
    customer_data: "tenant|email|name|company|country|domain"

contracts:
  output_dir: contracts/generated
