Mercurial > hg > orthanc
comparison OrthancServer/Sources/OrthancRestApi/OrthancRestSystem.cpp @ 4403:ad646ff506d0
cont openapi
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 23 Dec 2020 18:32:13 +0100 |
parents | 354ea95b294a |
children | a4518adede59 |
comparison
equal
deleted
inserted
replaced
4402:b651989194d3 | 4403:ad646ff506d0 |
---|---|
67 .SetAnswerField("DatabaseVersion", RestApiCallDocumentation::Type_Number, | 67 .SetAnswerField("DatabaseVersion", RestApiCallDocumentation::Type_Number, |
68 "Version of the database: https://book.orthanc-server.com/developers/db-versioning.html") | 68 "Version of the database: https://book.orthanc-server.com/developers/db-versioning.html") |
69 .SetAnswerField("IsHttpServerSecure", RestApiCallDocumentation::Type_Boolean, | 69 .SetAnswerField("IsHttpServerSecure", RestApiCallDocumentation::Type_Boolean, |
70 "Whether the REST API is properly secured (assuming no reverse proxy is in use): https://book.orthanc-server.com/faq/security.html#securing-the-http-server") | 70 "Whether the REST API is properly secured (assuming no reverse proxy is in use): https://book.orthanc-server.com/faq/security.html#securing-the-http-server") |
71 .SetAnswerField("StorageAreaPlugin", RestApiCallDocumentation::Type_String, | 71 .SetAnswerField("StorageAreaPlugin", RestApiCallDocumentation::Type_String, |
72 "Information about the installed storage area plugin (\"null\" if no such plugin is installed)") | 72 "Information about the installed storage area plugin (`null` if no such plugin is installed)") |
73 .SetAnswerField("DatabaseBackendPlugin", RestApiCallDocumentation::Type_String, | 73 .SetAnswerField("DatabaseBackendPlugin", RestApiCallDocumentation::Type_String, |
74 "Information about the installed database index plugin (\"null\" if no such plugin is installed)") | 74 "Information about the installed database index plugin (`null` if no such plugin is installed)") |
75 .SetAnswerField("DicomAet", RestApiCallDocumentation::Type_String, "The DICOM AET of Orthanc") | 75 .SetAnswerField("DicomAet", RestApiCallDocumentation::Type_String, "The DICOM AET of Orthanc") |
76 .SetAnswerField("DicomPort", RestApiCallDocumentation::Type_Number, "The port to the DICOM server of Orthanc") | 76 .SetAnswerField("DicomPort", RestApiCallDocumentation::Type_Number, "The port to the DICOM server of Orthanc") |
77 .SetAnswerField("HttpPort", RestApiCallDocumentation::Type_Number, "The port to the HTTP server of Orthanc") | 77 .SetAnswerField("HttpPort", RestApiCallDocumentation::Type_Number, "The port to the HTTP server of Orthanc") |
78 .SetAnswerField("Name", RestApiCallDocumentation::Type_String, | 78 .SetAnswerField("Name", RestApiCallDocumentation::Type_String, |
79 "The name of the Orthanc server, cf. the \"Name\" configuration option") | 79 "The name of the Orthanc server, cf. the `Name` configuration option") |
80 .SetAnswerField("PluginsEnabled", RestApiCallDocumentation::Type_Boolean, | 80 .SetAnswerField("PluginsEnabled", RestApiCallDocumentation::Type_Boolean, |
81 "Whether Orthanc was built with support for plugins") | 81 "Whether Orthanc was built with support for plugins") |
82 .SetHttpGetSample("https://demo.orthanc-server.com/system", true); | 82 .SetHttpGetSample("https://demo.orthanc-server.com/system", true); |
83 return; | 83 return; |
84 } | 84 } |
129 { | 129 { |
130 if (call.IsDocumentation()) | 130 if (call.IsDocumentation()) |
131 { | 131 { |
132 call.GetDocumentation() | 132 call.GetDocumentation() |
133 .SetTag("System") | 133 .SetTag("System") |
134 .SetSummary("Get statistics") | 134 .SetSummary("Get database statistics") |
135 .SetDescription("Get some statistics about Orthanc") | 135 .SetDescription("Get statistics related to the database of Orthanc") |
136 .SetAnswerField("CountInstances", RestApiCallDocumentation::Type_Number, "Number of DICOM instances stored in Orthanc") | 136 .SetAnswerField("CountInstances", RestApiCallDocumentation::Type_Number, "Number of DICOM instances stored in Orthanc") |
137 .SetAnswerField("CountSeries", RestApiCallDocumentation::Type_Number, "Number of DICOM series stored in Orthanc") | 137 .SetAnswerField("CountSeries", RestApiCallDocumentation::Type_Number, "Number of DICOM series stored in Orthanc") |
138 .SetAnswerField("CountStudies", RestApiCallDocumentation::Type_Number, "Number of DICOM studies stored in Orthanc") | 138 .SetAnswerField("CountStudies", RestApiCallDocumentation::Type_Number, "Number of DICOM studies stored in Orthanc") |
139 .SetAnswerField("CountPatients", RestApiCallDocumentation::Type_Number, "Number of patients stored in Orthanc") | 139 .SetAnswerField("CountPatients", RestApiCallDocumentation::Type_Number, "Number of patients stored in Orthanc") |
140 .SetAnswerField("TotalDiskSize", RestApiCallDocumentation::Type_String, "Size of the storage area (in bytes)") | 140 .SetAnswerField("TotalDiskSize", RestApiCallDocumentation::Type_String, "Size of the storage area (in bytes)") |
141 .SetAnswerField("TotalDiskSizeMB", RestApiCallDocumentation::Type_Number, "Size of the storage area (in megabytes)") | 141 .SetAnswerField("TotalDiskSizeMB", RestApiCallDocumentation::Type_Number, "Size of the storage area (in megabytes)") |
142 .SetAnswerField("TotalUncompressedSize", RestApiCallDocumentation::Type_String, "Total size of all the files once uncompressed (in bytes). This corresponds to \"TotalDiskSize\" if no compression is enabled, cf. \"StorageCompression\" configuration option") | 142 .SetAnswerField("TotalUncompressedSize", RestApiCallDocumentation::Type_String, "Total size of all the files once uncompressed (in bytes). This corresponds to `TotalDiskSize` if no compression is enabled, cf. `StorageCompression` configuration option") |
143 .SetAnswerField("TotalUncompressedSizeMB", RestApiCallDocumentation::Type_Number, "Total size of all the files once uncompressed (in megabytes)") | 143 .SetAnswerField("TotalUncompressedSizeMB", RestApiCallDocumentation::Type_Number, "Total size of all the files once uncompressed (in megabytes)") |
144 .SetHttpGetSample("https://demo.orthanc-server.com/statistics", true); | 144 .SetHttpGetSample("https://demo.orthanc-server.com/statistics", true); |
145 return; | 145 return; |
146 } | 146 } |
147 | 147 |
171 call.GetDocumentation() | 171 call.GetDocumentation() |
172 .SetTag("System") | 172 .SetTag("System") |
173 .SetSummary("Generate an identifier") | 173 .SetSummary("Generate an identifier") |
174 .SetDescription("Generate a random DICOM identifier") | 174 .SetDescription("Generate a random DICOM identifier") |
175 .SetHttpGetArgument("level", RestApiCallDocumentation::Type_String, | 175 .SetHttpGetArgument("level", RestApiCallDocumentation::Type_String, |
176 "Type of DICOM resource among: \"patient\", \"study\", \"series\" or \"instance\"") | 176 "Type of DICOM resource among: `patient`, `study`, `series` or `instance`", true) |
177 .AddAnswerType(MimeType_PlainText, "The generated identifier"); | 177 .AddAnswerType(MimeType_PlainText, "The generated identifier"); |
178 return; | 178 return; |
179 } | 179 } |
180 | 180 |
181 std::string level = call.GetArgument("level", ""); | 181 std::string level = call.GetArgument("level", ""); |
203 { | 203 { |
204 call.GetDocumentation() | 204 call.GetDocumentation() |
205 .SetTag("System") | 205 .SetTag("System") |
206 .SetSummary("Execute Lua script") | 206 .SetSummary("Execute Lua script") |
207 .SetDescription("Execute the provided Lua script by the Orthanc server. This is very insecure for " | 207 .SetDescription("Execute the provided Lua script by the Orthanc server. This is very insecure for " |
208 "Orthanc servers that are remotely accessible, cf. configuration option \"ExecuteLuaEnabled\"") | 208 "Orthanc servers that are remotely accessible, cf. configuration option `ExecuteLuaEnabled`") |
209 .AddRequestType(MimeType_PlainText, "The Lua script to be executed") | 209 .AddRequestType(MimeType_PlainText, "The Lua script to be executed") |
210 .AddAnswerType(MimeType_PlainText, "Output of the Lua script"); | 210 .AddAnswerType(MimeType_PlainText, "Output of the Lua script"); |
211 return; | 211 return; |
212 } | 212 } |
213 | 213 |
251 } | 251 } |
252 | 252 |
253 | 253 |
254 static void GetDicomConformanceStatement(RestApiGetCall& call) | 254 static void GetDicomConformanceStatement(RestApiGetCall& call) |
255 { | 255 { |
256 if (call.IsDocumentation()) | |
257 { | |
258 call.GetDocumentation() | |
259 .SetTag("System") | |
260 .SetSummary("Get DICOM conformance") | |
261 .SetDescription("Get the DICOM conformance statement of Orthanc") | |
262 .AddAnswerType(MimeType_PlainText, "The DICOM conformance statement"); | |
263 return; | |
264 } | |
265 | |
256 std::string statement; | 266 std::string statement; |
257 GetFileResource(statement, ServerResources::DICOM_CONFORMANCE_STATEMENT); | 267 GetFileResource(statement, ServerResources::DICOM_CONFORMANCE_STATEMENT); |
258 call.GetOutput().AnswerBuffer(statement, MimeType_PlainText); | 268 call.GetOutput().AnswerBuffer(statement, MimeType_PlainText); |
259 } | 269 } |
260 | 270 |
261 | 271 |
262 static void GetDefaultEncoding(RestApiGetCall& call) | 272 static void GetDefaultEncoding(RestApiGetCall& call) |
263 { | 273 { |
274 if (call.IsDocumentation()) | |
275 { | |
276 call.GetDocumentation() | |
277 .SetTag("System") | |
278 .SetSummary("Get default encoding") | |
279 .SetDescription("Get the default encoding that is used by Orthanc if parsing " | |
280 "a DICOM instance without the `SpecificCharacterEncoding` tag, or during C-FIND. " | |
281 "This corresponds to the configuration option `DefaultEncoding`.") | |
282 .AddAnswerType(MimeType_PlainText, "The name of the encoding"); | |
283 return; | |
284 } | |
285 | |
264 Encoding encoding = GetDefaultDicomEncoding(); | 286 Encoding encoding = GetDefaultDicomEncoding(); |
265 call.GetOutput().AnswerBuffer(EnumerationToString(encoding), MimeType_PlainText); | 287 call.GetOutput().AnswerBuffer(EnumerationToString(encoding), MimeType_PlainText); |
266 } | 288 } |
267 | 289 |
268 | 290 |
269 static void SetDefaultEncoding(RestApiPutCall& call) | 291 static void SetDefaultEncoding(RestApiPutCall& call) |
270 { | 292 { |
293 if (call.IsDocumentation()) | |
294 { | |
295 call.GetDocumentation() | |
296 .SetTag("System") | |
297 .SetSummary("Set default encoding") | |
298 .SetDescription("Change the default encoding that is used by Orthanc if parsing " | |
299 "a DICOM instance without the `SpecificCharacterEncoding` tag, or during C-FIND. " | |
300 "This corresponds to the configuration option `DefaultEncoding`.") | |
301 .AddRequestType(MimeType_PlainText, "The name of the encoding. Check out configuration " | |
302 "option `DefaultEncoding` for the allowed values."); | |
303 return; | |
304 } | |
305 | |
271 std::string body; | 306 std::string body; |
272 call.BodyToString(body); | 307 call.BodyToString(body); |
273 | 308 |
274 Encoding encoding = StringToEncoding(body.c_str()); | 309 Encoding encoding = StringToEncoding(body.c_str()); |
275 | 310 |
506 { | 541 { |
507 if (call.IsDocumentation()) | 542 if (call.IsDocumentation()) |
508 { | 543 { |
509 call.GetDocumentation() | 544 call.GetDocumentation() |
510 .SetTag("System") | 545 .SetTag("System") |
511 .SetSummary("Get metrics") | 546 .SetSummary("Get usage metrics") |
512 .SetDescription("Get metrics in the Prometheus file format") | 547 .SetDescription("Get usage metrics of Orthanc in the Prometheus file format (OpenMetrics)") |
513 .SetHttpGetSample("https://demo.orthanc-server.com/tools/metrics-prometheus", false); | 548 .SetHttpGetSample("https://demo.orthanc-server.com/tools/metrics-prometheus", false); |
514 return; | 549 return; |
515 } | 550 } |
516 | 551 |
517 #if ORTHANC_ENABLE_PLUGINS == 1 | 552 #if ORTHANC_ENABLE_PLUGINS == 1 |
549 } | 584 } |
550 | 585 |
551 | 586 |
552 static void GetMetricsEnabled(RestApiGetCall& call) | 587 static void GetMetricsEnabled(RestApiGetCall& call) |
553 { | 588 { |
589 if (call.IsDocumentation()) | |
590 { | |
591 call.GetDocumentation() | |
592 .SetTag("System") | |
593 .SetSummary("Are metrics collected?") | |
594 .SetDescription("Returns a Boolean specifying whether Prometheus metrics " | |
595 "are collected and exposed at `/tools/metrics-prometheus`") | |
596 .AddAnswerType(MimeType_PlainText, "`1` if metrics are collected, `0` if metrics are disabled"); | |
597 return; | |
598 } | |
599 | |
554 bool enabled = OrthancRestApi::GetContext(call).GetMetricsRegistry().IsEnabled(); | 600 bool enabled = OrthancRestApi::GetContext(call).GetMetricsRegistry().IsEnabled(); |
555 call.GetOutput().AnswerBuffer(enabled ? "1" : "0", MimeType_PlainText); | 601 call.GetOutput().AnswerBuffer(enabled ? "1" : "0", MimeType_PlainText); |
556 } | 602 } |
557 | 603 |
558 | 604 |
559 static void PutMetricsEnabled(RestApiPutCall& call) | 605 static void PutMetricsEnabled(RestApiPutCall& call) |
560 { | 606 { |
607 if (call.IsDocumentation()) | |
608 { | |
609 call.GetDocumentation() | |
610 .SetTag("System") | |
611 .SetSummary("Enable collection of metrics") | |
612 .SetDescription("Enable or disable the collection and publication of metrics at `/tools/metrics-prometheus`") | |
613 .AddRequestType(MimeType_PlainText, "`1` if metrics are collected, `0` if metrics are disabled"); | |
614 return; | |
615 } | |
616 | |
561 bool enabled; | 617 bool enabled; |
562 | 618 |
563 std::string body; | 619 std::string body; |
564 call.BodyToString(body); | 620 call.BodyToString(body); |
565 | 621 |
589 { | 645 { |
590 call.GetDocumentation() | 646 call.GetDocumentation() |
591 .SetTag("Logs") | 647 .SetTag("Logs") |
592 .SetSummary("Get main log level") | 648 .SetSummary("Get main log level") |
593 .SetDescription("Get the main log level of Orthanc") | 649 .SetDescription("Get the main log level of Orthanc") |
594 .AddAnswerType(MimeType_PlainText, "Possible values: \"default\", \"verbose\" or \"trace\""); | 650 .AddAnswerType(MimeType_PlainText, "Possible values: `default`, `verbose` or `trace`"); |
595 return; | 651 return; |
596 } | 652 } |
597 | 653 |
598 const std::string s = EnumerationToString(GetGlobalVerbosity()); | 654 const std::string s = EnumerationToString(GetGlobalVerbosity()); |
599 call.GetOutput().AnswerBuffer(s, MimeType_PlainText); | 655 call.GetOutput().AnswerBuffer(s, MimeType_PlainText); |
606 { | 662 { |
607 call.GetDocumentation() | 663 call.GetDocumentation() |
608 .SetTag("Logs") | 664 .SetTag("Logs") |
609 .SetSummary("Set main log level") | 665 .SetSummary("Set main log level") |
610 .SetDescription("Set the main log level of Orthanc") | 666 .SetDescription("Set the main log level of Orthanc") |
611 .AddRequestType(MimeType_PlainText, "Possible values: \"default\", \"verbose\" or \"trace\""); | 667 .AddRequestType(MimeType_PlainText, "Possible values: `default`, `verbose` or `trace`"); |
612 return; | 668 return; |
613 } | 669 } |
614 | 670 |
615 std::string body; | 671 std::string body; |
616 call.BodyToString(body); | 672 call.BodyToString(body); |
647 if (call.IsDocumentation()) | 703 if (call.IsDocumentation()) |
648 { | 704 { |
649 std::string category = Logging::GetCategoryName(GetCategory(call)); | 705 std::string category = Logging::GetCategoryName(GetCategory(call)); |
650 call.GetDocumentation() | 706 call.GetDocumentation() |
651 .SetTag("Logs") | 707 .SetTag("Logs") |
652 .SetSummary("Get log level for \"" + category + "\"") | 708 .SetSummary("Get log level for `" + category + "`") |
653 .SetDescription("Get the log level of the log category \"" + category + "\"") | 709 .SetDescription("Get the log level of the log category `" + category + "`") |
654 .AddAnswerType(MimeType_PlainText, "Possible values: \"default\", \"verbose\" or \"trace\""); | 710 .AddAnswerType(MimeType_PlainText, "Possible values: `default`, `verbose` or `trace`"); |
655 return; | 711 return; |
656 } | 712 } |
657 | 713 |
658 const std::string s = EnumerationToString(GetCategoryVerbosity(GetCategory(call))); | 714 const std::string s = EnumerationToString(GetCategoryVerbosity(GetCategory(call))); |
659 call.GetOutput().AnswerBuffer(s, MimeType_PlainText); | 715 call.GetOutput().AnswerBuffer(s, MimeType_PlainText); |
665 if (call.IsDocumentation()) | 721 if (call.IsDocumentation()) |
666 { | 722 { |
667 std::string category = Logging::GetCategoryName(GetCategory(call)); | 723 std::string category = Logging::GetCategoryName(GetCategory(call)); |
668 call.GetDocumentation() | 724 call.GetDocumentation() |
669 .SetTag("Logs") | 725 .SetTag("Logs") |
670 .SetSummary("Set log level for \"" + category + "\"") | 726 .SetSummary("Set log level for `" + category + "`") |
671 .SetDescription("Set the log level of the log category \"" + category + "\"") | 727 .SetDescription("Set the log level of the log category `" + category + "`") |
672 .AddRequestType(MimeType_PlainText, "Possible values: \"default\", \"verbose\" or \"trace\""); | 728 .AddRequestType(MimeType_PlainText, "Possible values: `default`, `verbose` or `trace`"); |
673 return; | 729 return; |
674 } | 730 } |
675 | 731 |
676 std::string body; | 732 std::string body; |
677 call.BodyToString(body); | 733 call.BodyToString(body); |