Mercurial > hg > orthanc
diff OrthancServer/OrthancRestApi/OrthancRestModalities.cpp @ 2441:67c01a6f151e
added ?expand argument to /peers and /modalities routes
author | amazy |
---|---|
date | Tue, 05 Dec 2017 12:43:28 +0100 |
parents | 7284093111b0 |
children | 878b59270859 |
line wrap: on
line diff
--- a/OrthancServer/OrthancRestApi/OrthancRestModalities.cpp Thu Nov 30 10:26:56 2017 +0100 +++ b/OrthancServer/OrthancRestApi/OrthancRestModalities.cpp Tue Dec 05 12:43:28 2017 +0100 @@ -792,14 +792,37 @@ OrthancRestApi::SetOfStrings peers; Configuration::GetListOfOrthancPeers(peers); - Json::Value result = Json::arrayValue; - for (OrthancRestApi::SetOfStrings::const_iterator - it = peers.begin(); it != peers.end(); ++it) + if (call.HasArgument("expand")) { - result.append(*it); + Json::Value result = Json::objectValue; + for (OrthancRestApi::SetOfStrings::const_iterator + it = peers.begin(); it != peers.end(); ++it) + { + WebServiceParameters peer; + Configuration::GetOrthancPeer(peer, *it); + + Json::Value jsonPeer = Json::objectValue; + // only return the minimum information to identify the destination, do not include "security" information like passwords + jsonPeer["Url"] = peer.GetUrl(); + if (!peer.GetUsername().empty()) + { + jsonPeer["Username"] = peer.GetUsername(); + } + result[*it] = jsonPeer; + } + call.GetOutput().AnswerJson(result); } + else // if expand is not present, keep backward compatibility and return an array of peers + { + Json::Value result = Json::arrayValue; + for (OrthancRestApi::SetOfStrings::const_iterator + it = peers.begin(); it != peers.end(); ++it) + { + result.append(*it); + } - call.GetOutput().AnswerJson(result); + call.GetOutput().AnswerJson(result); + } } static void ListPeerOperations(RestApiGetCall& call) @@ -872,14 +895,29 @@ OrthancRestApi::SetOfStrings modalities; Configuration::GetListOfDicomModalities(modalities); - Json::Value result = Json::arrayValue; - for (OrthancRestApi::SetOfStrings::const_iterator - it = modalities.begin(); it != modalities.end(); ++it) + if (call.HasArgument("expand")) { - result.append(*it); + Json::Value result = Json::objectValue; + for (OrthancRestApi::SetOfStrings::const_iterator + it = modalities.begin(); it != modalities.end(); ++it) + { + Json::Value modality; + Configuration::GetModalityUsingSymbolicName(*it).ToJson(modality); + + result[*it] = modality; + } + call.GetOutput().AnswerJson(result); } - - call.GetOutput().AnswerJson(result); + else // if expand is not present, keep backward compatibility and return an array of modalities ids + { + Json::Value result = Json::arrayValue; + for (OrthancRestApi::SetOfStrings::const_iterator + it = modalities.begin(); it != modalities.end(); ++it) + { + result.append(*it); + } + call.GetOutput().AnswerJson(result); + } }