{
  "repo": "tidbcloud/cost-provider",
  "binary": "cost-provider",
  "binary_path": "cmd",
  "surface_kind": "mixed_service",
  "type": "mixed_service",
  "services": [
    {
      "name": "CostProviderLifecycle",
      "package": "main",
      "methods": [
        {
          "name": "LoadFlags",
          "name_key": "Runtime CostProviderLifecycle.LoadFlags",
          "input": "--listen-address + --config-file + --log-level",
          "output": "addr + configPath + logLevel"
        },
        {
          "name": "ConfigureLogging",
          "name_key": "Runtime CostProviderLifecycle.ConfigureLogging",
          "input": "-log-level flag or default info",
          "output": "global zap log level configured"
        },
        {
          "name": "LoadConfig",
          "name_key": "Runtime CostProviderLifecycle.LoadConfig",
          "input": "INI file path from --config-file",
          "output": "viper config loaded from disk"
        },
        {
          "name": "InitializeManager",
          "name_key": "Runtime CostProviderLifecycle.InitializeManager",
          "input": "viper gcp.* + aws.* settings",
          "output": "*cost.Manager with gcp and aws providers registered"
        },
        {
          "name": "RegisterHTTPRoutes",
          "name_key": "Runtime CostProviderLifecycle.RegisterHTTPRoutes",
          "input": "gin.Engine",
          "output": "/ping, /version, and /api/v1/provider/cost handlers mounted"
        },
        {
          "name": "StartHTTPServer",
          "name_key": "Runtime CostProviderLifecycle.StartHTTPServer",
          "input": "listen address",
          "output": "gin HTTP server serving the registered routes"
        }
      ]
    },
    {
      "name": "CostProviderManager",
      "package": "pkg/cost",
      "methods": [
        {
          "name": "QueryBill",
          "name_key": "Runtime CostProviderManager.QueryBill",
          "input": "context + global.Request",
          "output": "combined []global.Item across all registered providers or the first provider-tagged error"
        },
        {
          "name": "RegisterProvider",
          "name_key": "Runtime CostProviderManager.RegisterProvider",
          "input": "provider key + ProviderClientInterface",
          "output": "provider inserted into the manager registry or conflict error"
        }
      ]
    },
    {
      "name": "CostProviderHTTP",
      "package": "api",
      "methods": [
        {
          "name": "POST /api/v1/provider/cost",
          "name_key": "HTTP POST /api/v1/provider/cost",
          "path": "/api/v1/provider/cost",
          "http_method": "POST",
          "input": "global.Request JSON body",
          "output": "global.Response containing aggregated provider bill data or validation/downstream error"
        },
        {
          "name": "GET /ping",
          "name_key": "HTTP GET /ping",
          "path": "/ping",
          "http_method": "GET",
          "input": "none",
          "output": "{\"message\":\"pong\"}"
        },
        {
          "name": "GET /version",
          "name_key": "HTTP GET /version",
          "path": "/version",
          "http_method": "GET",
          "input": "none",
          "output": "{\"version\": Version, \"gitHash\": GitHash}"
        }
      ]
    }
  ],
  "extensions": {
    "notes": [
      "The binary exposes one business handler plus two health/version handlers on a single Gin listener.",
      "The startup path always initializes both GCP and AWS provider clients before the HTTP server starts; if either provider initialization fails, the process panics and no partial provider mode exists.",
      "The request path itself only validates JSON and time fields before delegating to cost.Manager.QueryBill; the provider-specific SQL, auth, pagination, and classification branches live under the internal manager and provider clients.",
      "Project-level SQL filtering is conditional in both providers and only appears when request.ProjectID is non-empty.",
      "Data version v2 changes both SQL templates and resource subtype classification logic for AWS and GCP results."
    ]
  }
}
