{
  "repo": "tidbcloud/auditservice",
  "binary": "api",
  "binary_path": "cmd/api/main.go",
  "surface_kind": "mixed_service",
  "type": "mixed_service",
  "extensions": {
    "notes": [
      "The API binary exposes three auth models on the same server: user routes under /api/v1/audit, ops AK/SK routes under /api/v1/ops-audit, and OpenAPI routes under /v1beta1/auditLogs.",
      "Only GET /v1beta1/auditLogs is currently registered from open_api.go; the checkStatus/enable/disable handlers exist in code but are not mounted.",
      "PUT /api/v1/audit/{org_id}/settings writes the org setting and also emits an auditlog SDK event via Submit()."
    ]
  },
  "services": [
    {
      "name": "AuditApiLifecycle",
      "package": "main",
      "methods": [
        {
          "name": "Startup",
          "name_key": "AuditApiLifecycle.Startup",
          "input": "config path flag + environment variables",
          "output": "loaded remote config, initialized DB and service clients, and running HTTP API server",
          "type": "local"
        },
        {
          "name": "LoadRemoteConfig",
          "name_key": "AuditApiLifecycle.LoadRemoteConfig",
          "input": "oneconfig-account/config.yaml",
          "output": "viper-backed remote config plus background watcher",
          "type": "local"
        },
        {
          "name": "InitializeDB",
          "name_key": "AuditApiLifecycle.InitializeDB",
          "input": "DB_DSN env var",
          "output": "gorm DB handle without migrations",
          "type": "local"
        },
        {
          "name": "InitializeAuditService",
          "name_key": "AuditApiLifecycle.InitializeAuditService",
          "input": "account_svc_addr + cm_svc_addr + acl_svc_addr",
          "output": "AuditSvc backed by account, cluster-management, acl, and dao clients",
          "type": "local"
        },
        {
          "name": "StartHTTPServer",
          "name_key": "AuditApiLifecycle.StartHTTPServer",
          "input": "tiinf config file path",
          "output": "running gin/tiinf API server with user, ops, and openapi routes",
          "type": "local"
        }
      ]
    },
    {
      "name": "AuditApiHTTP",
      "type": "http",
      "methods": [
        {
          "name": "GET /healthz",
          "name_key": "HTTP GET /healthz",
          "input": "none",
          "output": "pong",
          "path": "/healthz",
          "type": "http"
        },
        {
          "name": "GET /ping",
          "name_key": "HTTP GET /ping",
          "input": "none",
          "output": "pong",
          "path": "/ping",
          "type": "http"
        },
        {
          "name": "GET /api/v1/audit/event_types",
          "name_key": "HTTP GET /api/v1/audit/event_types",
          "input": "none",
          "output": "event type mapping",
          "path": "/api/v1/audit/event_types",
          "type": "http"
        },
        {
          "name": "GET /api/v1/audit/{org_id}/settings",
          "name_key": "HTTP GET /api/v1/audit/{org_id}/settings",
          "input": "org_id path + authenticated user context",
          "output": "current audit-log status for the org",
          "path": "/api/v1/audit/:org_id/settings",
          "type": "http"
        },
        {
          "name": "PUT /api/v1/audit/{org_id}/settings",
          "name_key": "HTTP PUT /api/v1/audit/{org_id}/settings",
          "input": "org_id path + UpdateSettingsReq JSON + authenticated user context",
          "output": "HTTP 200 after persisting the new setting and submitting an audit event",
          "path": "/api/v1/audit/:org_id/settings",
          "type": "http"
        },
        {
          "name": "GET /api/v1/audit/{org_id}/audit_logs",
          "name_key": "HTTP GET /api/v1/audit/{org_id}/audit_logs",
          "input": "org_id path + QueryAuditLogFilter query + authenticated user context",
          "output": "paginated audit log records",
          "path": "/api/v1/audit/:org_id/audit_logs",
          "type": "http"
        },
        {
          "name": "GET /api/v1/audit/{org_id}/audit_logs/export",
          "name_key": "HTTP GET /api/v1/audit/{org_id}/audit_logs/export",
          "input": "org_id path + ExportAuditLogReq query + authenticated user context",
          "output": "JSON or CSV attachment",
          "path": "/api/v1/audit/:org_id/audit_logs/export",
          "type": "http"
        },
        {
          "name": "GET /api/v1/ops-audit/event_types",
          "name_key": "HTTP GET /api/v1/ops-audit/event_types",
          "input": "ops AK/SK signed request",
          "output": "event type mapping",
          "path": "/api/v1/ops-audit/event_types",
          "type": "http"
        },
        {
          "name": "GET /api/v1/ops-audit/{org_id}/settings",
          "name_key": "HTTP GET /api/v1/ops-audit/{org_id}/settings",
          "input": "org_id path + ops AK/SK signed request",
          "output": "current audit-log status for the org",
          "path": "/api/v1/ops-audit/:org_id/settings",
          "type": "http"
        },
        {
          "name": "GET /api/v1/ops-audit/{org_id}/audit_logs",
          "name_key": "HTTP GET /api/v1/ops-audit/{org_id}/audit_logs",
          "input": "org_id path + QueryAuditLogFilter query + ops AK/SK signed request",
          "output": "paginated audit log records",
          "path": "/api/v1/ops-audit/:org_id/audit_logs",
          "type": "http"
        },
        {
          "name": "GET /api/v1/ops-audit/{org_id}/audit_logs/export",
          "name_key": "HTTP GET /api/v1/ops-audit/{org_id}/audit_logs/export",
          "input": "org_id path + ExportAuditLogReq query + ops AK/SK signed request",
          "output": "JSON or CSV attachment",
          "path": "/api/v1/ops-audit/:org_id/audit_logs/export",
          "type": "http"
        },
        {
          "name": "GET /v1beta1/auditLogs",
          "name_key": "HTTP GET /v1beta1/auditLogs",
          "input": "OpenAPI query params + authenticated API key identity",
          "output": "v1beta1 audit log list with nextPageToken",
          "path": "/v1beta1/auditLogs",
          "type": "http"
        }
      ]
    }
  ]
}
