|
34 | 34 | from typing import Any |
35 | 35 |
|
36 | 36 | import uvicorn |
| 37 | +from dp_sdk.ocf import dp |
37 | 38 | from fastapi import FastAPI, status |
38 | 39 | from fastapi.middleware.cors import CORSMiddleware |
39 | 40 | from fastapi.openapi.utils import get_openapi |
| 41 | +from grpclib.client import Channel |
40 | 42 | from pydantic import BaseModel |
41 | 43 | from pyhocon import ConfigFactory |
42 | 44 | from starlette.responses import FileResponse |
43 | 45 | from starlette.staticfiles import StaticFiles |
44 | 46 |
|
45 | | -from quartz_api.internal.backends import DummyClient, QuartzClient |
| 47 | +from quartz_api.internal.backends import DataPlatformClient, DummyClient, QuartzClient |
46 | 48 | from quartz_api.internal.middleware import audit, auth |
47 | 49 | from quartz_api.internal.models import DatabaseInterface, get_db_client |
48 | 50 | from quartz_api.internal.service import regions, sites |
@@ -156,6 +158,14 @@ def redoc_html() -> FileResponse: |
156 | 158 | case "dummydb": |
157 | 159 | db_instance = DummyClient() |
158 | 160 | log.warning("disabled backend. NOT recommended for production") |
| 161 | + case "dataplatform": |
| 162 | + |
| 163 | + channel = Channel( |
| 164 | + host=conf.get_string("backend.dataplatform.host"), |
| 165 | + port=conf.get_int("backend.dataplatform.port"), |
| 166 | + ) |
| 167 | + client = dp.DataPlatformDataServiceStub(channel=channel) |
| 168 | + db_instance = DataPlatformClient.from_dp(dp_client=client) |
159 | 169 | case _: |
160 | 170 | raise ValueError( |
161 | 171 | "Unknown backend. " |
|
0 commit comments