diff --git a/src/lsst/rsp/__init__.py b/src/lsst/rsp/__init__.py index be2e6b9..b263515 100644 --- a/src/lsst/rsp/__init__.py +++ b/src/lsst/rsp/__init__.py @@ -12,6 +12,7 @@ ) from .forwarder import Forwarder from .log import IPythonHandler, forward_lsst_log +from .service import get_datalink_result, get_siav2_service from .utils import ( format_bytes, get_access_token, @@ -40,10 +41,12 @@ "forward_lsst_log", "get_access_token", "get_catalog", + "get_datalink_result", "get_digest", "get_node", "get_pod", "get_tap_service", + "get_siav2_service", "get_obstap_service", "retrieve_query", "get_hostname", diff --git a/src/lsst/rsp/service.py b/src/lsst/rsp/service.py index c194a7d..466ebff 100644 --- a/src/lsst/rsp/service.py +++ b/src/lsst/rsp/service.py @@ -1,8 +1,17 @@ from pyvo.dal import SIA2Service +from pyvo.dal.adhoc import DatalinkResults +from pyvo.dal.sia2 import ObsCoreRecord from .utils import get_pyvo_auth, get_service_url +def get_datalink_result(result: ObsCoreRecord) -> DatalinkResults: + """Helper function to return the datalink part of the result.""" + return DatalinkResults.from_result_url( + result.getdataurl(), session=get_pyvo_auth() + ) + + def get_siav2_service(label: str) -> SIA2Service: """Return a configured SIA2Service object that is ready to use.""" if label != "staff": diff --git a/src/lsst/rsp/utils.py b/src/lsst/rsp/utils.py index a2a223b..b6cf32d 100644 --- a/src/lsst/rsp/utils.py +++ b/src/lsst/rsp/utils.py @@ -64,7 +64,7 @@ def get_service_url(name: str, env_name: Optional[str] = None) -> str: return url fqdn = os.getenv("EXTERNAL_INSTANCE_URL") or "" - path = os.getenv(f"{env_name}_ROUTE") or f"/api/{name}" + path = os.getenv(f"{env_name}_ROUTE") or f"api/{name}" return f"{fqdn}/{path}"