-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathdata_sources.py
More file actions
42 lines (34 loc) · 1.2 KB
/
data_sources.py
File metadata and controls
42 lines (34 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import logging
from typing import Dict
from fastapi import APIRouter, Depends, Query
from feast.api.registry.rest.rest_utils import grpc_call, parse_tags
from feast.protos.feast.registry import RegistryServer_pb2
logger = logging.getLogger(__name__)
def get_data_source_router(grpc_handler) -> APIRouter:
router = APIRouter()
@router.get("/data_sources")
def list_data_sources(
project: str = Query(...),
allow_cache: bool = Query(default=True),
tags: Dict[str, str] = Depends(parse_tags),
):
req = RegistryServer_pb2.ListDataSourcesRequest(
project=project,
allow_cache=allow_cache,
tags=tags,
)
response = grpc_call(grpc_handler.ListDataSources, req)
return {"data_sources": response.get("dataSources", [])}
@router.get("/data_sources/{name}")
def get_data_source(
name: str,
project: str = Query(...),
allow_cache: bool = Query(default=True),
):
req = RegistryServer_pb2.GetDataSourceRequest(
name=name,
project=project,
allow_cache=allow_cache,
)
return grpc_call(grpc_handler.GetDataSource, req)
return router