Mercurial > hg > orthanc
comparison OrthancServer/Sources/OrthancRestApi/OrthancRestModalities.cpp @ 4418:9d6fa3da8f00
cont openapi
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 29 Dec 2020 10:24:17 +0100 |
parents | 189e48f4a92a |
children | cd96c807ca3d |
comparison
equal
deleted
inserted
replaced
4417:a4518adede59 | 4418:9d6fa3da8f00 |
---|---|
1145 return peers.find(id) != peers.end(); | 1145 return peers.find(id) != peers.end(); |
1146 } | 1146 } |
1147 | 1147 |
1148 static void ListPeers(RestApiGetCall& call) | 1148 static void ListPeers(RestApiGetCall& call) |
1149 { | 1149 { |
1150 if (call.IsDocumentation()) | |
1151 { | |
1152 call.GetDocumentation() | |
1153 .SetTag("Networking") | |
1154 .SetSummary("List Orthanc peers") | |
1155 .SetDescription("List all the Orthanc peers that are known to Orthanc. This corresponds either to the content of the " | |
1156 "`OrthancPeers` configuration option, or to the information stored in the database if " | |
1157 "`OrthancPeersInDatabase` is `true`.") | |
1158 .SetHttpGetArgument("expand", RestApiCallDocumentation::Type_String, | |
1159 "If present, retrieve detailed information about the individual Orthanc peers", false) | |
1160 .AddAnswerType(MimeType_Json, "JSON array containing either the identifiers of the peers, or detailed information " | |
1161 "about the peers (if `expand` argument is provided)"); | |
1162 return; | |
1163 } | |
1164 | |
1150 OrthancConfiguration::ReaderLock lock; | 1165 OrthancConfiguration::ReaderLock lock; |
1151 | 1166 |
1152 OrthancRestApi::SetOfStrings peers; | 1167 OrthancRestApi::SetOfStrings peers; |
1153 lock.GetConfiguration().GetListOfOrthancPeers(peers); | 1168 lock.GetConfiguration().GetListOfOrthancPeers(peers); |
1154 | 1169 |
1182 } | 1197 } |
1183 } | 1198 } |
1184 | 1199 |
1185 static void ListPeerOperations(RestApiGetCall& call) | 1200 static void ListPeerOperations(RestApiGetCall& call) |
1186 { | 1201 { |
1202 if (call.IsDocumentation()) | |
1203 { | |
1204 call.GetDocumentation() | |
1205 .SetTag("Networking") | |
1206 .SetSummary("List operations on peer") | |
1207 .SetDescription("List the operations that are available for an Orthanc peer.") | |
1208 .SetUriArgument("id", "Orthanc identifier of the peer of interest") | |
1209 .AddAnswerType(MimeType_Json, "List of the available operations"); | |
1210 return; | |
1211 } | |
1212 | |
1187 OrthancConfiguration::ReaderLock lock; | 1213 OrthancConfiguration::ReaderLock lock; |
1188 | 1214 |
1189 OrthancRestApi::SetOfStrings peers; | 1215 OrthancRestApi::SetOfStrings peers; |
1190 lock.GetConfiguration().GetListOfOrthancPeers(peers); | 1216 lock.GetConfiguration().GetListOfOrthancPeers(peers); |
1191 | 1217 |
1240 (call, job.release(), true /* synchronous by default */, request); | 1266 (call, job.release(), true /* synchronous by default */, request); |
1241 } | 1267 } |
1242 | 1268 |
1243 static void PeerSystem(RestApiGetCall& call) | 1269 static void PeerSystem(RestApiGetCall& call) |
1244 { | 1270 { |
1271 if (call.IsDocumentation()) | |
1272 { | |
1273 call.GetDocumentation() | |
1274 .SetTag("Networking") | |
1275 .SetSummary("Get peer system information") | |
1276 .SetDescription("Get system information about some Orthanc peer. This corresponds to doing a `GET` request " | |
1277 "against the `/system` URI of the remote peer. This route can be used to test connectivity.") | |
1278 .SetUriArgument("id", "Orthanc identifier of the peer of interest") | |
1279 .AddAnswerType(MimeType_Json, "System information about the peer"); | |
1280 return; | |
1281 } | |
1282 | |
1245 std::string remote = call.GetUriComponent("id", ""); | 1283 std::string remote = call.GetUriComponent("id", ""); |
1246 | 1284 |
1247 OrthancConfiguration::ReaderLock lock; | 1285 OrthancConfiguration::ReaderLock lock; |
1248 | 1286 |
1249 WebServiceParameters peer; | 1287 WebServiceParameters peer; |
1270 } | 1308 } |
1271 } | 1309 } |
1272 | 1310 |
1273 static void GetPeerConfiguration(RestApiGetCall& call) | 1311 static void GetPeerConfiguration(RestApiGetCall& call) |
1274 { | 1312 { |
1313 if (call.IsDocumentation()) | |
1314 { | |
1315 Json::Value sample; | |
1316 sample["HttpHeaders"] = Json::objectValue; | |
1317 sample["Password"] = Json::nullValue; | |
1318 sample["Pkcs11"] = false; | |
1319 sample["Url"] = "http://127.0.1.1:5000/"; | |
1320 sample["Username"] = "alice"; | |
1321 call.GetDocumentation() | |
1322 .SetTag("Networking") | |
1323 .SetSummary("Get peer configuration") | |
1324 .SetDescription("Get detailed information about the configuration of some Orthanc peer.") | |
1325 .SetUriArgument("id", "Orthanc identifier of the peer of interest") | |
1326 .AddAnswerType(MimeType_Json, "Configuration of the peer") | |
1327 .SetSample(sample); | |
1328 return; | |
1329 } | |
1330 | |
1275 OrthancConfiguration::ReaderLock lock; | 1331 OrthancConfiguration::ReaderLock lock; |
1276 const std::string peer = call.GetUriComponent("id", ""); | 1332 const std::string peer = call.GetUriComponent("id", ""); |
1277 | 1333 |
1278 WebServiceParameters info; | 1334 WebServiceParameters info; |
1279 if (lock.GetConfiguration().LookupOrthancPeer(info, peer)) | 1335 if (lock.GetConfiguration().LookupOrthancPeer(info, peer)) |
1297 return modalities.find(id) != modalities.end(); | 1353 return modalities.find(id) != modalities.end(); |
1298 } | 1354 } |
1299 | 1355 |
1300 static void ListModalities(RestApiGetCall& call) | 1356 static void ListModalities(RestApiGetCall& call) |
1301 { | 1357 { |
1358 if (call.IsDocumentation()) | |
1359 { | |
1360 call.GetDocumentation() | |
1361 .SetTag("Networking") | |
1362 .SetSummary("List DICOM modalities") | |
1363 .SetDescription("List all the DICOM modalities that are known to Orthanc. This corresponds either to the content of the " | |
1364 "`DicomModalities` configuration option, or to the information stored in the database if " | |
1365 "`DicomModalitiesInDatabase` is `true`.") | |
1366 .SetHttpGetArgument("expand", RestApiCallDocumentation::Type_String, | |
1367 "If present, retrieve detailed information about the individual DICOM modalities", false) | |
1368 .AddAnswerType(MimeType_Json, "JSON array containing either the identifiers of the modalities, or detailed information " | |
1369 "about the modalities (if `expand` argument is provided)"); | |
1370 return; | |
1371 } | |
1372 | |
1302 OrthancConfiguration::ReaderLock lock; | 1373 OrthancConfiguration::ReaderLock lock; |
1303 | 1374 |
1304 OrthancRestApi::SetOfStrings modalities; | 1375 OrthancRestApi::SetOfStrings modalities; |
1305 lock.GetConfiguration().GetListOfDicomModalities(modalities); | 1376 lock.GetConfiguration().GetListOfDicomModalities(modalities); |
1306 | 1377 |
1331 } | 1402 } |
1332 | 1403 |
1333 | 1404 |
1334 static void ListModalityOperations(RestApiGetCall& call) | 1405 static void ListModalityOperations(RestApiGetCall& call) |
1335 { | 1406 { |
1407 if (call.IsDocumentation()) | |
1408 { | |
1409 call.GetDocumentation() | |
1410 .SetTag("Networking") | |
1411 .SetSummary("List operations on modality") | |
1412 .SetDescription("List the operations that are available for a DICOM modality.") | |
1413 .SetUriArgument("id", "Orthanc identifier of the DICOM modality of interest") | |
1414 .AddAnswerType(MimeType_Json, "List of the available operations"); | |
1415 return; | |
1416 } | |
1417 | |
1336 OrthancConfiguration::ReaderLock lock; | 1418 OrthancConfiguration::ReaderLock lock; |
1337 | 1419 |
1338 OrthancRestApi::SetOfStrings modalities; | 1420 OrthancRestApi::SetOfStrings modalities; |
1339 lock.GetConfiguration().GetListOfDicomModalities(modalities); | 1421 lock.GetConfiguration().GetListOfDicomModalities(modalities); |
1340 | 1422 |
1372 } | 1454 } |
1373 | 1455 |
1374 | 1456 |
1375 static void DeleteModality(RestApiDeleteCall& call) | 1457 static void DeleteModality(RestApiDeleteCall& call) |
1376 { | 1458 { |
1459 if (call.IsDocumentation()) | |
1460 { | |
1461 call.GetDocumentation() | |
1462 .SetTag("Networking") | |
1463 .SetSummary("Delete DICOM modality") | |
1464 .SetDescription("Delete one DICOM modality. This change is permanent iff. `DicomModalitiesInDatabase` is `true`, " | |
1465 "otherwise it is lost at the next restart of Orthanc.") | |
1466 .SetUriArgument("id", "Orthanc identifier of the DICOM modality of interest"); | |
1467 return; | |
1468 } | |
1469 | |
1377 ServerContext& context = OrthancRestApi::GetContext(call); | 1470 ServerContext& context = OrthancRestApi::GetContext(call); |
1378 | 1471 |
1379 { | 1472 { |
1380 OrthancConfiguration::WriterLock lock; | 1473 OrthancConfiguration::WriterLock lock; |
1381 lock.GetConfiguration().RemoveModality(call.GetUriComponent("id", "")); | 1474 lock.GetConfiguration().RemoveModality(call.GetUriComponent("id", "")); |
1387 } | 1480 } |
1388 | 1481 |
1389 | 1482 |
1390 static void GetModalityConfiguration(RestApiGetCall& call) | 1483 static void GetModalityConfiguration(RestApiGetCall& call) |
1391 { | 1484 { |
1485 if (call.IsDocumentation()) | |
1486 { | |
1487 Json::Value sample; | |
1488 sample["AET"] = "ORTHANCTEST"; | |
1489 sample["AllowEcho"] = true; | |
1490 sample["AllowEventReport"] = true; | |
1491 sample["AllowFind"] = true; | |
1492 sample["AllowGet"] = true; | |
1493 sample["AllowMove"] = true; | |
1494 sample["AllowNAction"] = true; | |
1495 sample["AllowStore"] = true; | |
1496 sample["AllowTranscoding"] = true; | |
1497 sample["Host"] = "127.0.1.1"; | |
1498 sample["Manufacturer"] = "Generic"; | |
1499 sample["Port"] = 5001; | |
1500 call.GetDocumentation() | |
1501 .SetTag("Networking") | |
1502 .SetSummary("Get modality configuration") | |
1503 .SetDescription("Get detailed information about the configuration of some DICOM modality.") | |
1504 .SetUriArgument("id", "Orthanc identifier of the modality of interest") | |
1505 .AddAnswerType(MimeType_Json, "Configuration of the modality") | |
1506 .SetSample(sample); | |
1507 return; | |
1508 } | |
1509 | |
1392 const std::string modality = call.GetUriComponent("id", ""); | 1510 const std::string modality = call.GetUriComponent("id", ""); |
1393 | 1511 |
1394 Json::Value answer; | 1512 Json::Value answer; |
1395 | 1513 |
1396 { | 1514 { |
1424 } | 1542 } |
1425 | 1543 |
1426 | 1544 |
1427 static void DeletePeer(RestApiDeleteCall& call) | 1545 static void DeletePeer(RestApiDeleteCall& call) |
1428 { | 1546 { |
1547 if (call.IsDocumentation()) | |
1548 { | |
1549 call.GetDocumentation() | |
1550 .SetTag("Networking") | |
1551 .SetSummary("Delete Orthanc peer") | |
1552 .SetDescription("Delete one Orthanc peer. This change is permanent iff. `OrthancPeersInDatabase` is `true`, " | |
1553 "otherwise it is lost at the next restart of Orthanc.") | |
1554 .SetUriArgument("id", "Orthanc identifier of the Orthanc peer of interest"); | |
1555 return; | |
1556 } | |
1557 | |
1429 ServerContext& context = OrthancRestApi::GetContext(call); | 1558 ServerContext& context = OrthancRestApi::GetContext(call); |
1430 | 1559 |
1431 { | 1560 { |
1432 OrthancConfiguration::WriterLock lock; | 1561 OrthancConfiguration::WriterLock lock; |
1433 lock.GetConfiguration().RemovePeer(call.GetUriComponent("id", "")); | 1562 lock.GetConfiguration().RemovePeer(call.GetUriComponent("id", "")); |