# HG changeset patch # User amazy # Date 1512474208 -3600 # Node ID 67c01a6f151ea7cdf27997621ee3d6c4f6c1775c # Parent e11483be3f3ba83296c8e387aaa5685f58b66e06 added ?expand argument to /peers and /modalities routes diff -r e11483be3f3b -r 67c01a6f151e NEWS --- a/NEWS Thu Nov 30 10:26:56 2017 +0100 +++ b/NEWS Tue Dec 05 12:43:28 2017 +0100 @@ -1,6 +1,11 @@ Pending changes in the mainline =============================== +REST API +-------- + +* added ?expand argument to /peers and /modalities routes + Version 1.3.1 (2017-11-29) ========================== diff -r e11483be3f3b -r 67c01a6f151e OrthancServer/OrthancRestApi/OrthancRestModalities.cpp --- 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); + } }