changeset 4338:1263e727d048

give access to the configuration of one single peer or modality
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 03 Dec 2020 10:43:31 +0100
parents 7707fa761b71
children fc5caed6f940
files NEWS OrthancServer/Sources/OrthancRestApi/OrthancRestModalities.cpp
diffstat 2 files changed, 39 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Wed Dec 02 11:01:59 2020 +0100
+++ b/NEWS	Thu Dec 03 10:43:31 2020 +0100
@@ -11,7 +11,10 @@
 REST API
 --------
 
+* API version upgraded to 9
 * "/tools/log-level-*": Dynamically access and/or change the verbosity of logging categories
+* "/peers/{id}/configuration": Get the configuration of one peer (cf. "/peers?expand")
+* "/modalities/{id}/configuration": Get the configuration of one modality (cf. "/modalities?expand")
 
 Maintenance
 -----------
--- a/OrthancServer/Sources/OrthancRestApi/OrthancRestModalities.cpp	Wed Dec 02 11:01:59 2020 +0100
+++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestModalities.cpp	Thu Dec 03 10:43:31 2020 +0100
@@ -1200,6 +1200,25 @@
     }
   }
 
+  static void GetPeerConfiguration(RestApiGetCall& call)
+  {
+    OrthancConfiguration::ReaderLock lock;
+    const std::string peer = call.GetUriComponent("id", "");
+
+    WebServiceParameters info;  
+    if (lock.GetConfiguration().LookupOrthancPeer(info, peer))
+    {
+      Json::Value answer;
+      info.FormatPublic(answer);
+      call.GetOutput().AnswerJson(answer);
+    }
+    else
+    {
+      throw OrthancException(ErrorCode_UnknownResource,
+                             "No peer with symbolic name: " + peer);
+    }
+  }
+
   // DICOM bridge -------------------------------------------------------------
 
   static bool IsExistingModality(const OrthancRestApi::SetOfStrings& modalities,
@@ -1294,6 +1313,21 @@
   }
 
 
+  static void GetModalityConfiguration(RestApiGetCall& call)
+  {
+    const std::string modality = call.GetUriComponent("id", "");
+
+    Json::Value answer;
+
+    {
+      OrthancConfiguration::ReaderLock lock;
+      lock.GetConfiguration().GetModalityUsingSymbolicName(modality).Serialize(answer, true /* force advanced format */);
+    }
+    
+    call.GetOutput().AnswerJson(answer);
+  }
+
+
   static void UpdatePeer(RestApiPutCall& call)
   {
     ServerContext& context = OrthancRestApi::GetContext(call);
@@ -1616,6 +1650,7 @@
     Register("/modalities/{id}/store", DicomStore);
     Register("/modalities/{id}/store-straight", DicomStoreStraight);  // New in 1.6.1
     Register("/modalities/{id}/move", DicomMove);
+    Register("/modalities/{id}/configuration", GetModalityConfiguration);  // New in 1.8.1
 
     // For Query/Retrieve
     Register("/modalities/{id}/query", DicomQuery);
@@ -1643,6 +1678,7 @@
     Register("/peers/{id}", DeletePeer);
     Register("/peers/{id}/store", PeerStore);
     Register("/peers/{id}/system", PeerSystem);
+    Register("/peers/{id}/configuration", GetPeerConfiguration);  // New in 1.8.1
 
     Register("/modalities/{id}/find-worklist", DicomFindWorklist);