File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change 22import os
33
44import click
5+ import requests
6+ from yarl import URL
7+
8+ from dandi .consts import known_instances
9+ from dandi .utils import ServerInfo
510
611from .. import get_logger
712
813lgr = get_logger ()
914
15+
16+ def get_server_info (dandi_id : str ) -> ServerInfo :
17+ """
18+ Get server info from a particular DANDI instance
19+
20+ Parameters
21+ ----------
22+ dandi_id : str
23+ The ID specifying the particular known DANDI instance to query for server info.
24+ This is a key in the `dandi.consts.known_instances` dictionary.
25+
26+ Returns
27+ -------
28+ ServerInfo
29+ An object representing the server information responded by the DANDI instance.
30+
31+ Raises
32+ ------
33+ valueError
34+ If the provided `dandi_id` is not a valid key in the
35+ `dandi.consts.known_instances` dictionary.
36+ """
37+ if dandi_id not in known_instances :
38+ raise ValueError (f"Unknown DANDI instance: { dandi_id } " )
39+
40+ info_url = str (URL (known_instances [dandi_id ].api ) / "info/" )
41+ resp = requests .get (info_url )
42+ resp .raise_for_status ()
43+ return ServerInfo .model_validate (resp .json ())
44+
45+
1046# Aux common functionality
1147
1248
You can’t perform that action at this time.
0 commit comments