Skip to content

Commit

Permalink
implement and test search function
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanmi151 committed Jan 31, 2025
1 parent 7cac658 commit 4b62e8a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
14 changes: 11 additions & 3 deletions backend/maelstro/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
"""

from io import BytesIO
from typing import Annotated, Any
from fastapi import FastAPI, HTTPException, status, Request, Response, Header
from typing import Annotated, Any, Dict
from fastapi import FastAPI, HTTPException, status, Request, Response, Header, Form
from fastapi.responses import PlainTextResponse
from geonetwork import GnApi
from maelstro.config import ConfigError, app_config as config
from maelstro.metadata import Meta
from maelstro.core import CloneDataset
import json


app = FastAPI(root_path="/maelstro-backend")
Expand Down Expand Up @@ -100,6 +100,14 @@ def get_sources() -> list[dict[str, str]]:
def get_destinations() -> list[dict[str, str]]:
return config.get_destinations()

@app.post("/search/{src_name}")
def post_search(src_name: str, data: Dict[str, Any]) :
src_info = config.get_access_info(
is_src=True, is_geonetwork=True, instance_id=src_name
)
gn = GnApi(src_info["url"], src_info["auth"])

return gn.search(json.dumps(data))

@app.get("/sources/{src_name}/data/{uuid}/layers")
def get_layers(src_name: str, uuid: str) -> list[dict[str, str]]:
Expand Down
4 changes: 2 additions & 2 deletions backend/tests/test_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ destinations:
# nom de l'instance geOrchestra destination, telle qu'il apparaitra dans la UI
"CompoLocale":
geonetwork:
api_url: http://geonetwork:8080/geonetwork/srv/api
api_url: http://georchestra-127-0-0-1.nip.io/geonetwork/srv/api
login_env_var: LOCAL_LOGIN
password_env_var: LOCAL_LOGIN
password_env_var: LOCAL_PASSWORD
geoserver:
url: https://georchestra-127-0-0-1.nip.io/geoserver
"PlateformeProfessionnelle":
Expand Down
3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ services:
- georchestra_datadir:/etc/georchestra
environment:
MAELSTRO_CONFIG: /app/tests/test_config.yaml
LOCAL_LOGIN: admin
LOCAL_LOGIN: testadmin
LOCAL_PASSWORD: testadmin
healthcheck:
test: "health_check"
interval: 10s
Expand Down

0 comments on commit 4b62e8a

Please sign in to comment.