Mercurial > hg > orthanc
annotate OrthancServer/Sources/OrthancRestApi/OrthancRestSystem.cpp @ 5039:28db9663fc2d
DicomSequencesMap + fix unit tests
author | Alain Mazy <am@osimis.io> |
---|---|
date | Mon, 27 Jun 2022 10:48:46 +0200 |
parents | c2ebc47f4f18 |
children | 7547c7dfd017 |
rev | line source |
---|---|
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
1900 | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
1288
6e7e5ed91c2d
upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1233
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
4870
43e613a7756b
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4831
diff
changeset
|
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium |
43e613a7756b
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4831
diff
changeset
|
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * This program is free software: you can redistribute it and/or |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * modify it under the terms of the GNU General Public License as |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * published by the Free Software Foundation, either version 3 of the |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * License, or (at your option) any later version. |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * This program is distributed in the hope that it will be useful, but |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * WITHOUT ANY WARRANTY; without even the implied warranty of |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * General Public License for more details. |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * You should have received a copy of the GNU General Public License |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 **/ |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 |
831
84513f2ee1f3
pch for unit tests and server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
824
diff
changeset
|
23 #include "../PrecompiledHeadersServer.h" |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 #include "OrthancRestApi.h" |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 |
4045 | 26 #include "../../../OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h" |
27 #include "../../../OrthancFramework/Sources/MetricsRegistry.h" | |
3097 | 28 #include "../../Plugins/Engine/OrthancPlugins.h" |
29 #include "../../Plugins/Engine/PluginsManager.h" | |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
30 #include "../OrthancConfiguration.h" |
4273
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4143
diff
changeset
|
31 #include "../OrthancInitialization.h" |
1437
02f5a3f5c0a0
access to the REST API from Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1434
diff
changeset
|
32 #include "../ServerContext.h" |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 |
4275
d7a50b7b8466
Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
34 #include <boost/algorithm/string/predicate.hpp> |
d7a50b7b8466
Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
35 |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 namespace Orthanc |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 // System information ------------------------------------------------------- |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 |
974 | 41 static void ServeRoot(RestApiGetCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 call.GetOutput().Redirect("app/explorer.html"); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 |
4461
22abc6851191
The DICOM meta-header and the transfer syntax are displayed at the "Instance" level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
46 static void ServeFavicon(RestApiGetCall& call) |
22abc6851191
The DICOM meta-header and the transfer syntax are displayed at the "Instance" level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
47 { |
22abc6851191
The DICOM meta-header and the transfer syntax are displayed at the "Instance" level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
48 call.GetOutput().Redirect("app/images/favicon.ico"); |
22abc6851191
The DICOM meta-header and the transfer syntax are displayed at the "Instance" level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
49 } |
4950
3778a0433dd3
new field 'MainDicomTags' in the /system response
Alain Mazy <am@osimis.io>
parents:
4892
diff
changeset
|
50 |
3778a0433dd3
new field 'MainDicomTags' in the /system response
Alain Mazy <am@osimis.io>
parents:
4892
diff
changeset
|
51 static void GetMainDicomTagsConfiguration(Json::Value& result) |
3778a0433dd3
new field 'MainDicomTags' in the /system response
Alain Mazy <am@osimis.io>
parents:
4892
diff
changeset
|
52 { |
3778a0433dd3
new field 'MainDicomTags' in the /system response
Alain Mazy <am@osimis.io>
parents:
4892
diff
changeset
|
53 Json::Value v; |
3778a0433dd3
new field 'MainDicomTags' in the /system response
Alain Mazy <am@osimis.io>
parents:
4892
diff
changeset
|
54 |
4961 | 55 result["Patient"] = DicomMap::GetMainDicomTagsSignature(ResourceType_Patient); |
56 result["Study"] = DicomMap::GetMainDicomTagsSignature(ResourceType_Study); | |
57 result["Series"] = DicomMap::GetMainDicomTagsSignature(ResourceType_Series); | |
58 result["Instance"] = DicomMap::GetMainDicomTagsSignature(ResourceType_Instance); | |
4950
3778a0433dd3
new field 'MainDicomTags' in the /system response
Alain Mazy <am@osimis.io>
parents:
4892
diff
changeset
|
59 } |
3778a0433dd3
new field 'MainDicomTags' in the /system response
Alain Mazy <am@osimis.io>
parents:
4892
diff
changeset
|
60 |
974 | 61 static void GetSystemInformation(RestApiGetCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 { |
4628
5fabef29c4ff
added new primitive "hasRevisionsSupport" in database SDK, added "CheckRevisions" to URI "/system"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4474
diff
changeset
|
63 static const char* const API_VERSION = "ApiVersion"; |
5fabef29c4ff
added new primitive "hasRevisionsSupport" in database SDK, added "CheckRevisions" to URI "/system"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4474
diff
changeset
|
64 static const char* const CHECK_REVISIONS = "CheckRevisions"; |
5fabef29c4ff
added new primitive "hasRevisionsSupport" in database SDK, added "CheckRevisions" to URI "/system"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4474
diff
changeset
|
65 static const char* const DATABASE_BACKEND_PLUGIN = "DatabaseBackendPlugin"; |
5fabef29c4ff
added new primitive "hasRevisionsSupport" in database SDK, added "CheckRevisions" to URI "/system"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4474
diff
changeset
|
66 static const char* const DATABASE_VERSION = "DatabaseVersion"; |
5024
c2ebc47f4f18
wip: adding DelayedDeletion plugin
Alain Mazy <am@osimis.io>
parents:
4988
diff
changeset
|
67 static const char* const DATABASE_SERVER_IDENTIFIER = "DatabaseServerIdentifier"; |
4628
5fabef29c4ff
added new primitive "hasRevisionsSupport" in database SDK, added "CheckRevisions" to URI "/system"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4474
diff
changeset
|
68 static const char* const DICOM_AET = "DicomAet"; |
5fabef29c4ff
added new primitive "hasRevisionsSupport" in database SDK, added "CheckRevisions" to URI "/system"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4474
diff
changeset
|
69 static const char* const DICOM_PORT = "DicomPort"; |
5fabef29c4ff
added new primitive "hasRevisionsSupport" in database SDK, added "CheckRevisions" to URI "/system"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4474
diff
changeset
|
70 static const char* const HTTP_PORT = "HttpPort"; |
5fabef29c4ff
added new primitive "hasRevisionsSupport" in database SDK, added "CheckRevisions" to URI "/system"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4474
diff
changeset
|
71 static const char* const IS_HTTP_SERVER_SECURE = "IsHttpServerSecure"; |
5fabef29c4ff
added new primitive "hasRevisionsSupport" in database SDK, added "CheckRevisions" to URI "/system"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4474
diff
changeset
|
72 static const char* const NAME = "Name"; |
5fabef29c4ff
added new primitive "hasRevisionsSupport" in database SDK, added "CheckRevisions" to URI "/system"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4474
diff
changeset
|
73 static const char* const PLUGINS_ENABLED = "PluginsEnabled"; |
5fabef29c4ff
added new primitive "hasRevisionsSupport" in database SDK, added "CheckRevisions" to URI "/system"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4474
diff
changeset
|
74 static const char* const STORAGE_AREA_PLUGIN = "StorageAreaPlugin"; |
5fabef29c4ff
added new primitive "hasRevisionsSupport" in database SDK, added "CheckRevisions" to URI "/system"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4474
diff
changeset
|
75 static const char* const VERSION = "Version"; |
4950
3778a0433dd3
new field 'MainDicomTags' in the /system response
Alain Mazy <am@osimis.io>
parents:
4892
diff
changeset
|
76 static const char* const MAIN_DICOM_TAGS = "MainDicomTags"; |
4979
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
77 static const char* const STORAGE_COMPRESSION = "StorageCompression"; |
4988
8fba26292a9f
Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents:
4979
diff
changeset
|
78 static const char* const OVERWRITE_INSTANCES = "OverwriteInstances"; |
8fba26292a9f
Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents:
4979
diff
changeset
|
79 static const char* const INGEST_TRANSCODING = "IngestTranscoding"; |
4628
5fabef29c4ff
added new primitive "hasRevisionsSupport" in database SDK, added "CheckRevisions" to URI "/system"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4474
diff
changeset
|
80 |
4401
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
81 if (call.IsDocumentation()) |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
82 { |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
83 call.GetDocumentation() |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
84 .SetTag("System") |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
85 .SetSummary("Get system information") |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
86 .SetDescription("Get system information about Orthanc") |
4628
5fabef29c4ff
added new primitive "hasRevisionsSupport" in database SDK, added "CheckRevisions" to URI "/system"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4474
diff
changeset
|
87 .SetAnswerField(API_VERSION, RestApiCallDocumentation::Type_Number, "Version of the REST API") |
5fabef29c4ff
added new primitive "hasRevisionsSupport" in database SDK, added "CheckRevisions" to URI "/system"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4474
diff
changeset
|
88 .SetAnswerField(VERSION, RestApiCallDocumentation::Type_String, "Version of Orthanc") |
5fabef29c4ff
added new primitive "hasRevisionsSupport" in database SDK, added "CheckRevisions" to URI "/system"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4474
diff
changeset
|
89 .SetAnswerField(DATABASE_VERSION, RestApiCallDocumentation::Type_Number, |
4401
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
90 "Version of the database: https://book.orthanc-server.com/developers/db-versioning.html") |
5024
c2ebc47f4f18
wip: adding DelayedDeletion plugin
Alain Mazy <am@osimis.io>
parents:
4988
diff
changeset
|
91 .SetAnswerField(DATABASE_SERVER_IDENTIFIER, RestApiCallDocumentation::Type_String, |
c2ebc47f4f18
wip: adding DelayedDeletion plugin
Alain Mazy <am@osimis.io>
parents:
4988
diff
changeset
|
92 "ID of the server in the database (when running multiple Orthanc on the same DB)") |
4628
5fabef29c4ff
added new primitive "hasRevisionsSupport" in database SDK, added "CheckRevisions" to URI "/system"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4474
diff
changeset
|
93 .SetAnswerField(IS_HTTP_SERVER_SECURE, RestApiCallDocumentation::Type_Boolean, |
4401
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
94 "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") |
4628
5fabef29c4ff
added new primitive "hasRevisionsSupport" in database SDK, added "CheckRevisions" to URI "/system"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4474
diff
changeset
|
95 .SetAnswerField(STORAGE_AREA_PLUGIN, RestApiCallDocumentation::Type_String, |
4403 | 96 "Information about the installed storage area plugin (`null` if no such plugin is installed)") |
4628
5fabef29c4ff
added new primitive "hasRevisionsSupport" in database SDK, added "CheckRevisions" to URI "/system"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4474
diff
changeset
|
97 .SetAnswerField(DATABASE_BACKEND_PLUGIN, RestApiCallDocumentation::Type_String, |
4403 | 98 "Information about the installed database index plugin (`null` if no such plugin is installed)") |
4628
5fabef29c4ff
added new primitive "hasRevisionsSupport" in database SDK, added "CheckRevisions" to URI "/system"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4474
diff
changeset
|
99 .SetAnswerField(DICOM_AET, RestApiCallDocumentation::Type_String, "The DICOM AET of Orthanc") |
5fabef29c4ff
added new primitive "hasRevisionsSupport" in database SDK, added "CheckRevisions" to URI "/system"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4474
diff
changeset
|
100 .SetAnswerField(DICOM_PORT, RestApiCallDocumentation::Type_Number, "The port to the DICOM server of Orthanc") |
5fabef29c4ff
added new primitive "hasRevisionsSupport" in database SDK, added "CheckRevisions" to URI "/system"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4474
diff
changeset
|
101 .SetAnswerField(HTTP_PORT, RestApiCallDocumentation::Type_Number, "The port to the HTTP server of Orthanc") |
5fabef29c4ff
added new primitive "hasRevisionsSupport" in database SDK, added "CheckRevisions" to URI "/system"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4474
diff
changeset
|
102 .SetAnswerField(NAME, RestApiCallDocumentation::Type_String, |
4403 | 103 "The name of the Orthanc server, cf. the `Name` configuration option") |
4628
5fabef29c4ff
added new primitive "hasRevisionsSupport" in database SDK, added "CheckRevisions" to URI "/system"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4474
diff
changeset
|
104 .SetAnswerField(PLUGINS_ENABLED, RestApiCallDocumentation::Type_Boolean, |
4401
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
105 "Whether Orthanc was built with support for plugins") |
4628
5fabef29c4ff
added new primitive "hasRevisionsSupport" in database SDK, added "CheckRevisions" to URI "/system"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4474
diff
changeset
|
106 .SetAnswerField(CHECK_REVISIONS, RestApiCallDocumentation::Type_Boolean, |
5fabef29c4ff
added new primitive "hasRevisionsSupport" in database SDK, added "CheckRevisions" to URI "/system"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4474
diff
changeset
|
107 "Whether Orthanc handle revisions of metadata and attachments to deal with multiple writers (new in Orthanc 1.9.2)") |
4950
3778a0433dd3
new field 'MainDicomTags' in the /system response
Alain Mazy <am@osimis.io>
parents:
4892
diff
changeset
|
108 .SetAnswerField(MAIN_DICOM_TAGS, RestApiCallDocumentation::Type_JsonObject, |
3778a0433dd3
new field 'MainDicomTags' in the /system response
Alain Mazy <am@osimis.io>
parents:
4892
diff
changeset
|
109 "The list of MainDicomTags saved in DB for each resource level (new in Orthanc 1.11.0)") |
4979
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
110 .SetAnswerField(STORAGE_COMPRESSION, RestApiCallDocumentation::Type_Boolean, |
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
111 "Whether storage compression is enabled (new in Orthanc 1.11.0)") |
4988
8fba26292a9f
Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents:
4979
diff
changeset
|
112 .SetAnswerField(OVERWRITE_INSTANCES, RestApiCallDocumentation::Type_Boolean, |
8fba26292a9f
Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents:
4979
diff
changeset
|
113 "Whether instances are overwritten when re-ingested (new in Orthanc 1.11.0)") |
8fba26292a9f
Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents:
4979
diff
changeset
|
114 .SetAnswerField(INGEST_TRANSCODING, RestApiCallDocumentation::Type_String, |
8fba26292a9f
Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents:
4979
diff
changeset
|
115 "Whether instances are transcoded when ingested into Orthanc (`""` if no transcoding is performed) (new in Orthanc 1.11.0)") |
4401
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
116 .SetHttpGetSample("https://demo.orthanc-server.com/system", true); |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
117 return; |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
118 } |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
119 |
3533
2090ec6a83a5
create a default user if none is provided, while issuing a warning in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3526
diff
changeset
|
120 ServerContext& context = OrthancRestApi::GetContext(call); |
2090ec6a83a5
create a default user if none is provided, while issuing a warning in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3526
diff
changeset
|
121 |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
122 Json::Value result = Json::objectValue; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
123 |
4628
5fabef29c4ff
added new primitive "hasRevisionsSupport" in database SDK, added "CheckRevisions" to URI "/system"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4474
diff
changeset
|
124 result[API_VERSION] = ORTHANC_API_VERSION; |
5fabef29c4ff
added new primitive "hasRevisionsSupport" in database SDK, added "CheckRevisions" to URI "/system"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4474
diff
changeset
|
125 result[VERSION] = ORTHANC_VERSION; |
5fabef29c4ff
added new primitive "hasRevisionsSupport" in database SDK, added "CheckRevisions" to URI "/system"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4474
diff
changeset
|
126 result[DATABASE_VERSION] = OrthancRestApi::GetIndex(call).GetDatabaseVersion(); |
5fabef29c4ff
added new primitive "hasRevisionsSupport" in database SDK, added "CheckRevisions" to URI "/system"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4474
diff
changeset
|
127 result[IS_HTTP_SERVER_SECURE] = context.IsHttpServerSecure(); // New in Orthanc 1.5.8 |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
128 |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
129 { |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
130 OrthancConfiguration::ReaderLock lock; |
4628
5fabef29c4ff
added new primitive "hasRevisionsSupport" in database SDK, added "CheckRevisions" to URI "/system"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4474
diff
changeset
|
131 result[DICOM_AET] = lock.GetConfiguration().GetOrthancAET(); |
5fabef29c4ff
added new primitive "hasRevisionsSupport" in database SDK, added "CheckRevisions" to URI "/system"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4474
diff
changeset
|
132 result[DICOM_PORT] = lock.GetConfiguration().GetUnsignedIntegerParameter(DICOM_PORT, 4242); |
5fabef29c4ff
added new primitive "hasRevisionsSupport" in database SDK, added "CheckRevisions" to URI "/system"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4474
diff
changeset
|
133 result[HTTP_PORT] = lock.GetConfiguration().GetUnsignedIntegerParameter(HTTP_PORT, 8042); |
5fabef29c4ff
added new primitive "hasRevisionsSupport" in database SDK, added "CheckRevisions" to URI "/system"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4474
diff
changeset
|
134 result[NAME] = lock.GetConfiguration().GetStringParameter(NAME, ""); |
5fabef29c4ff
added new primitive "hasRevisionsSupport" in database SDK, added "CheckRevisions" to URI "/system"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4474
diff
changeset
|
135 result[CHECK_REVISIONS] = lock.GetConfiguration().GetBooleanParameter(CHECK_REVISIONS, false); // New in Orthanc 1.9.2 |
4979
f316413027fd
renamed DbOptizer into Housekeeper + add Scheduler & triggers
Alain Mazy <am@osimis.io>
parents:
4961
diff
changeset
|
136 result[STORAGE_COMPRESSION] = lock.GetConfiguration().GetBooleanParameter(STORAGE_COMPRESSION, false); // New in Orthanc 1.11.0 |
4988
8fba26292a9f
Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents:
4979
diff
changeset
|
137 result[OVERWRITE_INSTANCES] = lock.GetConfiguration().GetBooleanParameter(OVERWRITE_INSTANCES, false); // New in Orthanc 1.11.0 |
8fba26292a9f
Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents:
4979
diff
changeset
|
138 result[INGEST_TRANSCODING] = lock.GetConfiguration().GetStringParameter(INGEST_TRANSCODING, ""); // New in Orthanc 1.11.0 |
5024
c2ebc47f4f18
wip: adding DelayedDeletion plugin
Alain Mazy <am@osimis.io>
parents:
4988
diff
changeset
|
139 result[DATABASE_SERVER_IDENTIFIER] = lock.GetConfiguration().GetDatabaseServerIdentifier(); |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
140 } |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
141 |
4628
5fabef29c4ff
added new primitive "hasRevisionsSupport" in database SDK, added "CheckRevisions" to URI "/system"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4474
diff
changeset
|
142 result[STORAGE_AREA_PLUGIN] = Json::nullValue; |
5fabef29c4ff
added new primitive "hasRevisionsSupport" in database SDK, added "CheckRevisions" to URI "/system"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4474
diff
changeset
|
143 result[DATABASE_BACKEND_PLUGIN] = Json::nullValue; |
1630
ffd23c0104af
"/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1597
diff
changeset
|
144 |
2136
dd609a99d39a
uniformization of the macro naming
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2069
diff
changeset
|
145 #if ORTHANC_ENABLE_PLUGINS == 1 |
4628
5fabef29c4ff
added new primitive "hasRevisionsSupport" in database SDK, added "CheckRevisions" to URI "/system"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4474
diff
changeset
|
146 result[PLUGINS_ENABLED] = true; |
3533
2090ec6a83a5
create a default user if none is provided, while issuing a warning in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3526
diff
changeset
|
147 const OrthancPlugins& plugins = context.GetPlugins(); |
1630
ffd23c0104af
"/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1597
diff
changeset
|
148 |
ffd23c0104af
"/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1597
diff
changeset
|
149 if (plugins.HasStorageArea()) |
ffd23c0104af
"/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1597
diff
changeset
|
150 { |
1631 | 151 std::string p = plugins.GetStorageAreaLibrary().GetPath(); |
4628
5fabef29c4ff
added new primitive "hasRevisionsSupport" in database SDK, added "CheckRevisions" to URI "/system"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4474
diff
changeset
|
152 result[STORAGE_AREA_PLUGIN] = boost::filesystem::canonical(p).string(); |
1630
ffd23c0104af
"/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1597
diff
changeset
|
153 } |
ffd23c0104af
"/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1597
diff
changeset
|
154 |
ffd23c0104af
"/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1597
diff
changeset
|
155 if (plugins.HasDatabaseBackend()) |
ffd23c0104af
"/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1597
diff
changeset
|
156 { |
1631 | 157 std::string p = plugins.GetDatabaseBackendLibrary().GetPath(); |
4628
5fabef29c4ff
added new primitive "hasRevisionsSupport" in database SDK, added "CheckRevisions" to URI "/system"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4474
diff
changeset
|
158 result[DATABASE_BACKEND_PLUGIN] = boost::filesystem::canonical(p).string(); |
1630
ffd23c0104af
"/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1597
diff
changeset
|
159 } |
1632
eb8fbcf008b5
fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1631
diff
changeset
|
160 #else |
4628
5fabef29c4ff
added new primitive "hasRevisionsSupport" in database SDK, added "CheckRevisions" to URI "/system"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4474
diff
changeset
|
161 result[PLUGINS_ENABLED] = false; |
1632
eb8fbcf008b5
fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1631
diff
changeset
|
162 #endif |
1630
ffd23c0104af
"/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1597
diff
changeset
|
163 |
4950
3778a0433dd3
new field 'MainDicomTags' in the /system response
Alain Mazy <am@osimis.io>
parents:
4892
diff
changeset
|
164 result[MAIN_DICOM_TAGS] = Json::objectValue; |
3778a0433dd3
new field 'MainDicomTags' in the /system response
Alain Mazy <am@osimis.io>
parents:
4892
diff
changeset
|
165 GetMainDicomTagsConfiguration(result[MAIN_DICOM_TAGS]); |
3778a0433dd3
new field 'MainDicomTags' in the /system response
Alain Mazy <am@osimis.io>
parents:
4892
diff
changeset
|
166 |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
167 call.GetOutput().AnswerJson(result); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
168 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
169 |
974 | 170 static void GetStatistics(RestApiGetCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
171 { |
4401
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
172 if (call.IsDocumentation()) |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
173 { |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
174 call.GetDocumentation() |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
175 .SetTag("System") |
4403 | 176 .SetSummary("Get database statistics") |
177 .SetDescription("Get statistics related to the database of Orthanc") | |
4401
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
178 .SetAnswerField("CountInstances", RestApiCallDocumentation::Type_Number, "Number of DICOM instances stored in Orthanc") |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
179 .SetAnswerField("CountSeries", RestApiCallDocumentation::Type_Number, "Number of DICOM series stored in Orthanc") |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
180 .SetAnswerField("CountStudies", RestApiCallDocumentation::Type_Number, "Number of DICOM studies stored in Orthanc") |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
181 .SetAnswerField("CountPatients", RestApiCallDocumentation::Type_Number, "Number of patients stored in Orthanc") |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
182 .SetAnswerField("TotalDiskSize", RestApiCallDocumentation::Type_String, "Size of the storage area (in bytes)") |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
183 .SetAnswerField("TotalDiskSizeMB", RestApiCallDocumentation::Type_Number, "Size of the storage area (in megabytes)") |
4403 | 184 .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") |
4401
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
185 .SetAnswerField("TotalUncompressedSizeMB", RestApiCallDocumentation::Type_Number, "Total size of all the files once uncompressed (in megabytes)") |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
186 .SetHttpGetSample("https://demo.orthanc-server.com/statistics", true); |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
187 return; |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
188 } |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
189 |
3174
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
190 static const uint64_t MEGA_BYTES = 1024 * 1024; |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
191 |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
192 uint64_t diskSize, uncompressedSize, countPatients, countStudies, countSeries, countInstances; |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
193 OrthancRestApi::GetIndex(call).GetGlobalStatistics(diskSize, uncompressedSize, countPatients, |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
194 countStudies, countSeries, countInstances); |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
195 |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
196 Json::Value result = Json::objectValue; |
3174
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
197 result["TotalDiskSize"] = boost::lexical_cast<std::string>(diskSize); |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
198 result["TotalUncompressedSize"] = boost::lexical_cast<std::string>(uncompressedSize); |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
199 result["TotalDiskSizeMB"] = static_cast<unsigned int>(diskSize / MEGA_BYTES); |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
200 result["TotalUncompressedSizeMB"] = static_cast<unsigned int>(uncompressedSize / MEGA_BYTES); |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
201 result["CountPatients"] = static_cast<unsigned int>(countPatients); |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
202 result["CountStudies"] = static_cast<unsigned int>(countStudies); |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
203 result["CountSeries"] = static_cast<unsigned int>(countSeries); |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
204 result["CountInstances"] = static_cast<unsigned int>(countInstances); |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
205 |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
206 call.GetOutput().AnswerJson(result); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
207 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
208 |
974 | 209 static void GenerateUid(RestApiGetCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
210 { |
4401
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
211 if (call.IsDocumentation()) |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
212 { |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
213 call.GetDocumentation() |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
214 .SetTag("System") |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
215 .SetSummary("Generate an identifier") |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
216 .SetDescription("Generate a random DICOM identifier") |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
217 .SetHttpGetArgument("level", RestApiCallDocumentation::Type_String, |
4403 | 218 "Type of DICOM resource among: `patient`, `study`, `series` or `instance`", true) |
4401
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
219 .AddAnswerType(MimeType_PlainText, "The generated identifier"); |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
220 return; |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
221 } |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
222 |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
223 std::string level = call.GetArgument("level", ""); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
224 if (level == "patient") |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
225 { |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
226 call.GetOutput().AnswerBuffer(FromDcmtkBridge::GenerateUniqueIdentifier(ResourceType_Patient), MimeType_PlainText); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
227 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
228 else if (level == "study") |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
229 { |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
230 call.GetOutput().AnswerBuffer(FromDcmtkBridge::GenerateUniqueIdentifier(ResourceType_Study), MimeType_PlainText); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
231 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
232 else if (level == "series") |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
233 { |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
234 call.GetOutput().AnswerBuffer(FromDcmtkBridge::GenerateUniqueIdentifier(ResourceType_Series), MimeType_PlainText); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
235 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
236 else if (level == "instance") |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
237 { |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
238 call.GetOutput().AnswerBuffer(FromDcmtkBridge::GenerateUniqueIdentifier(ResourceType_Instance), MimeType_PlainText); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
239 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
240 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
241 |
974 | 242 static void ExecuteScript(RestApiPostCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
243 { |
4401
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
244 if (call.IsDocumentation()) |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
245 { |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
246 call.GetDocumentation() |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
247 .SetTag("System") |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
248 .SetSummary("Execute Lua script") |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
249 .SetDescription("Execute the provided Lua script by the Orthanc server. This is very insecure for " |
4403 | 250 "Orthanc servers that are remotely accessible, cf. configuration option `ExecuteLuaEnabled`") |
4401
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
251 .AddRequestType(MimeType_PlainText, "The Lua script to be executed") |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
252 .AddAnswerType(MimeType_PlainText, "Output of the Lua script"); |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
253 return; |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
254 } |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
255 |
3535
41365091a41e
display a security warning in the logs at startup when ExecuteLuaEnabled is true
Alain Mazy <alain@mazy.be>
parents:
3534
diff
changeset
|
256 ServerContext& context = OrthancRestApi::GetContext(call); |
3526
f07352e0375c
new configuration option ExecuteLuaEnabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3401
diff
changeset
|
257 |
3535
41365091a41e
display a security warning in the logs at startup when ExecuteLuaEnabled is true
Alain Mazy <alain@mazy.be>
parents:
3534
diff
changeset
|
258 if (!context.IsExecuteLuaEnabled()) |
41365091a41e
display a security warning in the logs at startup when ExecuteLuaEnabled is true
Alain Mazy <alain@mazy.be>
parents:
3534
diff
changeset
|
259 { |
41365091a41e
display a security warning in the logs at startup when ExecuteLuaEnabled is true
Alain Mazy <alain@mazy.be>
parents:
3534
diff
changeset
|
260 LOG(ERROR) << "The URI /tools/execute-script is disallowed for security, " |
41365091a41e
display a security warning in the logs at startup when ExecuteLuaEnabled is true
Alain Mazy <alain@mazy.be>
parents:
3534
diff
changeset
|
261 << "check your configuration file"; |
41365091a41e
display a security warning in the logs at startup when ExecuteLuaEnabled is true
Alain Mazy <alain@mazy.be>
parents:
3534
diff
changeset
|
262 call.GetOutput().SignalError(HttpStatus_403_Forbidden); |
41365091a41e
display a security warning in the logs at startup when ExecuteLuaEnabled is true
Alain Mazy <alain@mazy.be>
parents:
3534
diff
changeset
|
263 return; |
3526
f07352e0375c
new configuration option ExecuteLuaEnabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3401
diff
changeset
|
264 } |
f07352e0375c
new configuration option ExecuteLuaEnabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3401
diff
changeset
|
265 |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
266 std::string result; |
1446
8dc80ba768aa
refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1437
diff
changeset
|
267 std::string command; |
8dc80ba768aa
refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1437
diff
changeset
|
268 call.BodyToString(command); |
8dc80ba768aa
refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1437
diff
changeset
|
269 |
996
cf52f3bcb2b3
clarification of Lua classes wrt multithreading
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
974
diff
changeset
|
270 { |
2617
912a767911b0
back to a single Lua context
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2616
diff
changeset
|
271 LuaScripting::Lock lock(context.GetLuaScripting()); |
2616
2f3007bf0708
event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2612
diff
changeset
|
272 lock.GetLua().Execute(result, command); |
996
cf52f3bcb2b3
clarification of Lua classes wrt multithreading
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
974
diff
changeset
|
273 } |
cf52f3bcb2b3
clarification of Lua classes wrt multithreading
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
974
diff
changeset
|
274 |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
275 call.GetOutput().AnswerBuffer(result, MimeType_PlainText); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
276 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
277 |
2475
8cc3ca64a534
Orthanc now uses UTC (universal time) instead of local time in its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
278 template <bool UTC> |
974 | 279 static void GetNowIsoString(RestApiGetCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
280 { |
4401
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
281 if (call.IsDocumentation()) |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
282 { |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
283 std::string type(UTC ? "UTC" : "local"); |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
284 call.GetDocumentation() |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
285 .SetTag("System") |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
286 .SetSummary("Get " + type + " time") |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
287 .AddAnswerType(MimeType_PlainText, "The " + type + " time") |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
288 .SetHttpGetSample("https://demo.orthanc-server.com" + call.FlattenUri(), false); |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
289 return; |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
290 } |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
291 |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
292 call.GetOutput().AnswerBuffer(SystemToolbox::GetNowIsoString(UTC), MimeType_PlainText); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
293 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
294 |
1073
01414536c930
complete DICOM conformance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
996
diff
changeset
|
295 |
01414536c930
complete DICOM conformance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
996
diff
changeset
|
296 static void GetDicomConformanceStatement(RestApiGetCall& call) |
01414536c930
complete DICOM conformance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
996
diff
changeset
|
297 { |
4403 | 298 if (call.IsDocumentation()) |
299 { | |
300 call.GetDocumentation() | |
301 .SetTag("System") | |
302 .SetSummary("Get DICOM conformance") | |
303 .SetDescription("Get the DICOM conformance statement of Orthanc") | |
304 .AddAnswerType(MimeType_PlainText, "The DICOM conformance statement"); | |
305 return; | |
306 } | |
307 | |
1073
01414536c930
complete DICOM conformance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
996
diff
changeset
|
308 std::string statement; |
4031
e3b3af80732d
ServerResources, and moving EmbeddedResourceHttpHandler from Core to OrthancServer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3672
diff
changeset
|
309 GetFileResource(statement, ServerResources::DICOM_CONFORMANCE_STATEMENT); |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
310 call.GetOutput().AnswerBuffer(statement, MimeType_PlainText); |
1073
01414536c930
complete DICOM conformance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
996
diff
changeset
|
311 } |
01414536c930
complete DICOM conformance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
996
diff
changeset
|
312 |
01414536c930
complete DICOM conformance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
996
diff
changeset
|
313 |
2573
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
314 static void GetDefaultEncoding(RestApiGetCall& call) |
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
315 { |
4403 | 316 if (call.IsDocumentation()) |
317 { | |
318 call.GetDocumentation() | |
319 .SetTag("System") | |
320 .SetSummary("Get default encoding") | |
321 .SetDescription("Get the default encoding that is used by Orthanc if parsing " | |
322 "a DICOM instance without the `SpecificCharacterEncoding` tag, or during C-FIND. " | |
323 "This corresponds to the configuration option `DefaultEncoding`.") | |
324 .AddAnswerType(MimeType_PlainText, "The name of the encoding"); | |
325 return; | |
326 } | |
327 | |
2573
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
328 Encoding encoding = GetDefaultDicomEncoding(); |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
329 call.GetOutput().AnswerBuffer(EnumerationToString(encoding), MimeType_PlainText); |
2573
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
330 } |
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
331 |
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
332 |
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
333 static void SetDefaultEncoding(RestApiPutCall& call) |
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
334 { |
4403 | 335 if (call.IsDocumentation()) |
336 { | |
337 call.GetDocumentation() | |
338 .SetTag("System") | |
339 .SetSummary("Set default encoding") | |
340 .SetDescription("Change the default encoding that is used by Orthanc if parsing " | |
341 "a DICOM instance without the `SpecificCharacterEncoding` tag, or during C-FIND. " | |
342 "This corresponds to the configuration option `DefaultEncoding`.") | |
343 .AddRequestType(MimeType_PlainText, "The name of the encoding. Check out configuration " | |
344 "option `DefaultEncoding` for the allowed values."); | |
345 return; | |
346 } | |
347 | |
3401 | 348 std::string body; |
349 call.BodyToString(body); | |
350 | |
351 Encoding encoding = StringToEncoding(body.c_str()); | |
2573
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
352 |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
353 { |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
354 OrthancConfiguration::WriterLock lock; |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
355 lock.GetConfiguration().SetDefaultEncoding(encoding); |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
356 } |
2573
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
357 |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
358 call.GetOutput().AnswerBuffer(EnumerationToString(encoding), MimeType_PlainText); |
2573
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
359 } |
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
360 |
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
361 |
4473
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
362 static void AnswerAcceptedTransferSyntaxes(RestApiCall& call) |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
363 { |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
364 std::set<DicomTransferSyntax> syntaxes; |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
365 OrthancRestApi::GetContext(call).GetAcceptedTransferSyntaxes(syntaxes); |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
366 |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
367 Json::Value json = Json::arrayValue; |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
368 for (std::set<DicomTransferSyntax>::const_iterator |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
369 syntax = syntaxes.begin(); syntax != syntaxes.end(); ++syntax) |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
370 { |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
371 json.append(GetTransferSyntaxUid(*syntax)); |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
372 } |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
373 |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
374 call.GetOutput().AnswerJson(json); |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
375 } |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
376 |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
377 |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
378 static void GetAcceptedTransferSyntaxes(RestApiGetCall& call) |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
379 { |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
380 if (call.IsDocumentation()) |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
381 { |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
382 call.GetDocumentation() |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
383 .SetTag("System") |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
384 .SetSummary("Get accepted transfer syntaxes") |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
385 .SetDescription("Get the list of UIDs of the DICOM transfer syntaxes that are accepted " |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
386 "by Orthanc C-STORE SCP. This corresponds to the configuration options " |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
387 "`AcceptedTransferSyntaxes` and `XXXTransferSyntaxAccepted`.") |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
388 .AddAnswerType(MimeType_Json, "JSON array containing the transfer syntax UIDs"); |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
389 return; |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
390 } |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
391 |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
392 AnswerAcceptedTransferSyntaxes(call); |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
393 } |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
394 |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
395 |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
396 static void SetAcceptedTransferSyntaxes(RestApiPutCall& call) |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
397 { |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
398 if (call.IsDocumentation()) |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
399 { |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
400 call.GetDocumentation() |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
401 .SetTag("System") |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
402 .SetSummary("Set accepted transfer syntaxes") |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
403 .SetDescription("Set the DICOM transfer syntaxes that accepted by Orthanc C-STORE SCP") |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
404 .AddRequestType(MimeType_PlainText, "UID of the transfer syntax to be accepted. " |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
405 "Wildcards `?` and `*` are accepted.") |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
406 .AddRequestType(MimeType_Json, "JSON array containing a list of transfer syntax " |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
407 "UIDs to be accepted. Wildcards `?` and `*` are accepted.") |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
408 .AddAnswerType(MimeType_Json, "JSON array containing the now-accepted transfer syntax UIDs"); |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
409 return; |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
410 } |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
411 |
4474
f8c1d94363b6
new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4473
diff
changeset
|
412 std::set<DicomTransferSyntax> syntaxes; |
4473
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
413 |
4474
f8c1d94363b6
new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4473
diff
changeset
|
414 Json::Value json; |
f8c1d94363b6
new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4473
diff
changeset
|
415 if (call.ParseJsonRequest(json)) |
f8c1d94363b6
new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4473
diff
changeset
|
416 { |
f8c1d94363b6
new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4473
diff
changeset
|
417 OrthancConfiguration::ParseAcceptedTransferSyntaxes(syntaxes, json); |
f8c1d94363b6
new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4473
diff
changeset
|
418 } |
f8c1d94363b6
new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4473
diff
changeset
|
419 else |
f8c1d94363b6
new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4473
diff
changeset
|
420 { |
f8c1d94363b6
new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4473
diff
changeset
|
421 std::string body; |
f8c1d94363b6
new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4473
diff
changeset
|
422 call.BodyToString(body); |
f8c1d94363b6
new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4473
diff
changeset
|
423 OrthancConfiguration::ParseAcceptedTransferSyntaxes(syntaxes, body); |
f8c1d94363b6
new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4473
diff
changeset
|
424 } |
f8c1d94363b6
new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4473
diff
changeset
|
425 |
4473
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
426 OrthancRestApi::GetContext(call).SetAcceptedTransferSyntaxes(syntaxes); |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
427 |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
428 AnswerAcceptedTransferSyntaxes(call); |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
429 } |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
430 |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
431 |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
432 static void GetUnknownSopClassAccepted(RestApiGetCall& call) |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
433 { |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
434 if (call.IsDocumentation()) |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
435 { |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
436 call.GetDocumentation() |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
437 .SetTag("System") |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
438 .SetSummary("Is unknown SOP class accepted?") |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
439 .SetDescription("Shall Orthanc C-STORE SCP accept DICOM instances with an unknown SOP class UID?") |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
440 .AddAnswerType(MimeType_PlainText, "`1` if accepted, `0` if not accepted"); |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
441 return; |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
442 } |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
443 |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
444 const bool accepted = OrthancRestApi::GetContext(call).IsUnknownSopClassAccepted(); |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
445 call.GetOutput().AnswerBuffer(accepted ? "1" : "0", MimeType_PlainText); |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
446 } |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
447 |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
448 |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
449 static void SetUnknownSopClassAccepted(RestApiPutCall& call) |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
450 { |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
451 if (call.IsDocumentation()) |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
452 { |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
453 call.GetDocumentation() |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
454 .SetTag("System") |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
455 .SetSummary("Set unknown SOP class accepted") |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
456 .SetDescription("Set whether Orthanc C-STORE SCP should accept DICOM instances with an unknown SOP class UID") |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
457 .AddRequestType(MimeType_PlainText, "`1` if accepted, `0` if not accepted"); |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
458 return; |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
459 } |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
460 |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
461 OrthancRestApi::GetContext(call).SetUnknownSopClassAccepted(call.ParseBooleanBody()); |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
462 call.GetOutput().AnswerBuffer("", MimeType_PlainText); |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
463 } |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
464 |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
465 |
2573
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
466 |
1232
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
467 // Plugins information ------------------------------------------------------ |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
468 |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
469 static void ListPlugins(RestApiGetCall& call) |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
470 { |
4417
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
471 if (call.IsDocumentation()) |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
472 { |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
473 call.GetDocumentation() |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
474 .SetTag("System") |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
475 .SetSummary("List plugins") |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
476 .SetDescription("List all the installed plugins") |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
477 .AddAnswerType(MimeType_Json, "JSON array containing the identifiers of the installed plugins") |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
478 .SetHttpGetSample("https://demo.orthanc-server.com/plugins", true); |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
479 return; |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
480 } |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
481 |
1232
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
482 Json::Value v = Json::arrayValue; |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
483 |
1233 | 484 v.append("explorer.js"); |
485 | |
1232
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
486 if (OrthancRestApi::GetContext(call).HasPlugins()) |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
487 { |
2136
dd609a99d39a
uniformization of the macro naming
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2069
diff
changeset
|
488 #if ORTHANC_ENABLE_PLUGINS == 1 |
1232
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
489 std::list<std::string> plugins; |
1434
f9cd40166269
refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
490 OrthancRestApi::GetContext(call).GetPlugins().GetManager().ListPlugins(plugins); |
1232
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
491 |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
492 for (std::list<std::string>::const_iterator |
1303 | 493 it = plugins.begin(); it != plugins.end(); ++it) |
1232
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
494 { |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
495 v.append(*it); |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
496 } |
1632
eb8fbcf008b5
fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1631
diff
changeset
|
497 #endif |
1232
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
498 } |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
499 |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
500 call.GetOutput().AnswerJson(v); |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
501 } |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
502 |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
503 |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
504 static void GetPlugin(RestApiGetCall& call) |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
505 { |
4417
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
506 if (call.IsDocumentation()) |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
507 { |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
508 call.GetDocumentation() |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
509 .SetTag("System") |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
510 .SetSummary("Get plugin") |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
511 .SetDescription("Get system information about the plugin whose identifier is provided in the URL") |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
512 .SetUriArgument("id", "Identifier of the job of interest") |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
513 .AddAnswerType(MimeType_Json, "JSON object containing information about the plugin") |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
514 .SetHttpGetSample("https://demo.orthanc-server.com/plugins/dicom-web", true); |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
515 return; |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
516 } |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
517 |
1232
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
518 if (!OrthancRestApi::GetContext(call).HasPlugins()) |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
519 { |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
520 return; |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
521 } |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
522 |
2136
dd609a99d39a
uniformization of the macro naming
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2069
diff
changeset
|
523 #if ORTHANC_ENABLE_PLUGINS == 1 |
1434
f9cd40166269
refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
524 const PluginsManager& manager = OrthancRestApi::GetContext(call).GetPlugins().GetManager(); |
1232
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
525 std::string id = call.GetUriComponent("id", ""); |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
526 |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
527 if (manager.HasPlugin(id)) |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
528 { |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
529 Json::Value v = Json::objectValue; |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
530 v["ID"] = id; |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
531 v["Version"] = manager.GetPluginVersion(id); |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
532 |
1434
f9cd40166269
refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
533 const OrthancPlugins& plugins = OrthancRestApi::GetContext(call).GetPlugins(); |
1232
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
534 const char *c = plugins.GetProperty(id.c_str(), _OrthancPluginProperty_RootUri); |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
535 if (c != NULL) |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
536 { |
1597
415dfd1d1c61
Improvements to the sample "ServeFolders" plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
537 std::string root = c; |
415dfd1d1c61
Improvements to the sample "ServeFolders" plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
538 if (!root.empty()) |
415dfd1d1c61
Improvements to the sample "ServeFolders" plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
539 { |
415dfd1d1c61
Improvements to the sample "ServeFolders" plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
540 // Turn the root URI into a URI relative to "/app/explorer.js" |
415dfd1d1c61
Improvements to the sample "ServeFolders" plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
541 if (root[0] == '/') |
415dfd1d1c61
Improvements to the sample "ServeFolders" plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
542 { |
415dfd1d1c61
Improvements to the sample "ServeFolders" plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
543 root = ".." + root; |
415dfd1d1c61
Improvements to the sample "ServeFolders" plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
544 } |
415dfd1d1c61
Improvements to the sample "ServeFolders" plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
545 |
415dfd1d1c61
Improvements to the sample "ServeFolders" plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
546 v["RootUri"] = root; |
415dfd1d1c61
Improvements to the sample "ServeFolders" plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
547 } |
1232
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
548 } |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
549 |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
550 c = plugins.GetProperty(id.c_str(), _OrthancPluginProperty_Description); |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
551 if (c != NULL) |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
552 { |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
553 v["Description"] = c; |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
554 } |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
555 |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
556 c = plugins.GetProperty(id.c_str(), _OrthancPluginProperty_OrthancExplorer); |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
557 v["ExtendsOrthancExplorer"] = (c != NULL); |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
558 |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
559 call.GetOutput().AnswerJson(v); |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
560 } |
1632
eb8fbcf008b5
fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1631
diff
changeset
|
561 #endif |
1232
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
562 } |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
563 |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
564 |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
565 static void GetOrthancExplorerPlugins(RestApiGetCall& call) |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
566 { |
4418 | 567 if (call.IsDocumentation()) |
568 { | |
569 call.GetDocumentation() | |
570 .SetTag("System") | |
571 .SetSummary("JavaScript extensions to Orthanc Explorer") | |
572 .SetDescription("Get the JavaScript extensions that are installed by all the plugins using the " | |
573 "`OrthancPluginExtendOrthancExplorer()` function of the plugin SDK. " | |
574 "This route is for internal use of Orthanc Explorer.") | |
575 .AddAnswerType(MimeType_JavaScript, "The JavaScript extensions"); | |
576 return; | |
577 } | |
578 | |
1232
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
579 std::string s = "// Extensions to Orthanc Explorer by the registered plugins\n\n"; |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
580 |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
581 if (OrthancRestApi::GetContext(call).HasPlugins()) |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
582 { |
2136
dd609a99d39a
uniformization of the macro naming
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2069
diff
changeset
|
583 #if ORTHANC_ENABLE_PLUGINS == 1 |
1434
f9cd40166269
refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
584 const OrthancPlugins& plugins = OrthancRestApi::GetContext(call).GetPlugins(); |
f9cd40166269
refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
585 const PluginsManager& manager = plugins.GetManager(); |
1232
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
586 |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
587 std::list<std::string> lst; |
1434
f9cd40166269
refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
588 manager.ListPlugins(lst); |
1232
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
589 |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
590 for (std::list<std::string>::const_iterator |
1303 | 591 it = lst.begin(); it != lst.end(); ++it) |
1232
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
592 { |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
593 const char* tmp = plugins.GetProperty(it->c_str(), _OrthancPluginProperty_OrthancExplorer); |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
594 if (tmp != NULL) |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
595 { |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
596 s += "/**\n * From plugin: " + *it + " (version " + manager.GetPluginVersion(*it) + ")\n **/\n\n"; |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
597 s += std::string(tmp) + "\n\n"; |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
598 } |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
599 } |
1632
eb8fbcf008b5
fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1631
diff
changeset
|
600 #endif |
1232
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
601 } |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
602 |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
603 call.GetOutput().AnswerBuffer(s, MimeType_JavaScript); |
1232
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
604 } |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
605 |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
606 |
2202
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2140
diff
changeset
|
607 |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2140
diff
changeset
|
608 |
2573
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
609 // Jobs information ------------------------------------------------------ |
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
610 |
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
611 static void ListJobs(RestApiGetCall& call) |
2202
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2140
diff
changeset
|
612 { |
4417
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
613 if (call.IsDocumentation()) |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
614 { |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
615 call.GetDocumentation() |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
616 .SetTag("Jobs") |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
617 .SetSummary("List jobs") |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
618 .SetDescription("List all the available jobs") |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
619 .SetHttpGetArgument("expand", RestApiCallDocumentation::Type_String, |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
620 "If present, retrieve detailed information about the individual jobs", false) |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
621 .AddAnswerType(MimeType_Json, "JSON array containing either the jobs identifiers, or detailed information " |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
622 "about the reported jobs (if `expand` argument is provided)") |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
623 .SetTruncatedJsonHttpGetSample("https://demo.orthanc-server.com/jobs", 3); |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
624 return; |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
625 } |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
626 |
2573
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
627 bool expand = call.HasArgument("expand"); |
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
628 |
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
629 Json::Value v = Json::arrayValue; |
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
630 |
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
631 std::set<std::string> jobs; |
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
632 OrthancRestApi::GetContext(call).GetJobsEngine().GetRegistry().ListJobs(jobs); |
2202
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2140
diff
changeset
|
633 |
2573
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
634 for (std::set<std::string>::const_iterator it = jobs.begin(); |
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
635 it != jobs.end(); ++it) |
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
636 { |
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
637 if (expand) |
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
638 { |
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
639 JobInfo info; |
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
640 if (OrthancRestApi::GetContext(call).GetJobsEngine().GetRegistry().GetJobInfo(info, *it)) |
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
641 { |
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
642 Json::Value tmp; |
2647
73d7d95dd75e
removal of internal job information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2617
diff
changeset
|
643 info.Format(tmp); |
2573
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
644 v.append(tmp); |
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
645 } |
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
646 } |
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
647 else |
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
648 { |
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
649 v.append(*it); |
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
650 } |
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
651 } |
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
652 |
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
653 call.GetOutput().AnswerJson(v); |
2202
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2140
diff
changeset
|
654 } |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2140
diff
changeset
|
655 |
2573
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
656 static void GetJobInfo(RestApiGetCall& call) |
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
657 { |
4417
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
658 if (call.IsDocumentation()) |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
659 { |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
660 Json::Value sample; |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
661 sample["CompletionTime"] = "20201227T161842.520129"; |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
662 sample["Content"]["ArchiveSizeMB"] = 22; |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
663 sample["Content"]["Description"] = "REST API"; |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
664 sample["Content"]["InstancesCount"] = 232; |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
665 sample["Content"]["UncompressedSizeMB"] = 64; |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
666 sample["CreationTime"] = "20201227T161836.428311"; |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
667 sample["EffectiveRuntime"] = 6.0810000000000004; |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
668 sample["ErrorCode"] = 0; |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
669 sample["ErrorDescription"] = "Success"; |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
670 sample["ID"] = "645ecb02-7c0e-4465-b767-df873222dcfb"; |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
671 sample["Priority"] = 0; |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
672 sample["Progress"] = 100; |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
673 sample["State"] = "Success"; |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
674 sample["Timestamp"] = "20201228T160340.253201"; |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
675 sample["Type"] = "Media"; |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
676 |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
677 call.GetDocumentation() |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
678 .SetTag("Jobs") |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
679 .SetSummary("Get job") |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
680 .SetDescription("Retrieve detailed information about the job whose identifier is provided in the URL: " |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
681 "https://book.orthanc-server.com/users/advanced-rest.html#jobs") |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
682 .SetUriArgument("id", "Identifier of the job of interest") |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
683 .AddAnswerType(MimeType_Json, "JSON object detailing the job") |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
684 .SetSample(sample); |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
685 return; |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
686 } |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
687 |
2573
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
688 std::string id = call.GetUriComponent("id", ""); |
2202
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2140
diff
changeset
|
689 |
2573
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
690 JobInfo info; |
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
691 if (OrthancRestApi::GetContext(call).GetJobsEngine().GetRegistry().GetJobInfo(info, id)) |
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
692 { |
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
693 Json::Value json; |
2647
73d7d95dd75e
removal of internal job information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2617
diff
changeset
|
694 info.Format(json); |
2573
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
695 call.GetOutput().AnswerJson(json); |
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
696 } |
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
697 } |
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
698 |
2582
b3da733d984c
job actions in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2573
diff
changeset
|
699 |
2976
cb5d75143da0
Asynchronous generation of ZIP archives and DICOM medias
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2940
diff
changeset
|
700 static void GetJobOutput(RestApiGetCall& call) |
cb5d75143da0
Asynchronous generation of ZIP archives and DICOM medias
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2940
diff
changeset
|
701 { |
4417
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
702 if (call.IsDocumentation()) |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
703 { |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
704 call.GetDocumentation() |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
705 .SetTag("Jobs") |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
706 .SetSummary("Get job output") |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
707 .SetDescription("Retrieve some output produced by a job. As of Orthanc 1.8.2, only the jobs that generate a " |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
708 "DICOMDIR media or a ZIP archive provide such an output (with `key` equals to `archive`).") |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
709 .SetUriArgument("id", "Identifier of the job of interest") |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
710 .SetUriArgument("key", "Name of the output of interest") |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
711 .AddAnswerType(MimeType_Binary, "Content of the output of the job"); |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
712 return; |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
713 } |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
714 |
2976
cb5d75143da0
Asynchronous generation of ZIP archives and DICOM medias
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2940
diff
changeset
|
715 std::string job = call.GetUriComponent("id", ""); |
cb5d75143da0
Asynchronous generation of ZIP archives and DICOM medias
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2940
diff
changeset
|
716 std::string key = call.GetUriComponent("key", ""); |
cb5d75143da0
Asynchronous generation of ZIP archives and DICOM medias
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2940
diff
changeset
|
717 |
cb5d75143da0
Asynchronous generation of ZIP archives and DICOM medias
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2940
diff
changeset
|
718 std::string value; |
cb5d75143da0
Asynchronous generation of ZIP archives and DICOM medias
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2940
diff
changeset
|
719 MimeType mime; |
4805
0a38000b086d
Archive jobs response now contains a header Content-Disposition:filename='archive.zip'
Alain Mazy <am@osimis.io>
parents:
4730
diff
changeset
|
720 std::string filename; |
2976
cb5d75143da0
Asynchronous generation of ZIP archives and DICOM medias
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2940
diff
changeset
|
721 |
cb5d75143da0
Asynchronous generation of ZIP archives and DICOM medias
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2940
diff
changeset
|
722 if (OrthancRestApi::GetContext(call).GetJobsEngine(). |
4805
0a38000b086d
Archive jobs response now contains a header Content-Disposition:filename='archive.zip'
Alain Mazy <am@osimis.io>
parents:
4730
diff
changeset
|
723 GetRegistry().GetJobOutput(value, mime, filename, job, key)) |
2976
cb5d75143da0
Asynchronous generation of ZIP archives and DICOM medias
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2940
diff
changeset
|
724 { |
4805
0a38000b086d
Archive jobs response now contains a header Content-Disposition:filename='archive.zip'
Alain Mazy <am@osimis.io>
parents:
4730
diff
changeset
|
725 if (!filename.empty()) |
0a38000b086d
Archive jobs response now contains a header Content-Disposition:filename='archive.zip'
Alain Mazy <am@osimis.io>
parents:
4730
diff
changeset
|
726 { |
0a38000b086d
Archive jobs response now contains a header Content-Disposition:filename='archive.zip'
Alain Mazy <am@osimis.io>
parents:
4730
diff
changeset
|
727 call.GetOutput().SetContentFilename(filename.c_str()); |
0a38000b086d
Archive jobs response now contains a header Content-Disposition:filename='archive.zip'
Alain Mazy <am@osimis.io>
parents:
4730
diff
changeset
|
728 } |
0a38000b086d
Archive jobs response now contains a header Content-Disposition:filename='archive.zip'
Alain Mazy <am@osimis.io>
parents:
4730
diff
changeset
|
729 |
2976
cb5d75143da0
Asynchronous generation of ZIP archives and DICOM medias
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2940
diff
changeset
|
730 call.GetOutput().AnswerBuffer(value, mime); |
cb5d75143da0
Asynchronous generation of ZIP archives and DICOM medias
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2940
diff
changeset
|
731 } |
cb5d75143da0
Asynchronous generation of ZIP archives and DICOM medias
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2940
diff
changeset
|
732 else |
cb5d75143da0
Asynchronous generation of ZIP archives and DICOM medias
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2940
diff
changeset
|
733 { |
cb5d75143da0
Asynchronous generation of ZIP archives and DICOM medias
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2940
diff
changeset
|
734 throw OrthancException(ErrorCode_InexistentItem, |
cb5d75143da0
Asynchronous generation of ZIP archives and DICOM medias
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2940
diff
changeset
|
735 "Job has no such output: " + key); |
cb5d75143da0
Asynchronous generation of ZIP archives and DICOM medias
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2940
diff
changeset
|
736 } |
cb5d75143da0
Asynchronous generation of ZIP archives and DICOM medias
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2940
diff
changeset
|
737 } |
cb5d75143da0
Asynchronous generation of ZIP archives and DICOM medias
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2940
diff
changeset
|
738 |
cb5d75143da0
Asynchronous generation of ZIP archives and DICOM medias
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2940
diff
changeset
|
739 |
2582
b3da733d984c
job actions in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2573
diff
changeset
|
740 enum JobAction |
b3da733d984c
job actions in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2573
diff
changeset
|
741 { |
b3da733d984c
job actions in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2573
diff
changeset
|
742 JobAction_Cancel, |
b3da733d984c
job actions in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2573
diff
changeset
|
743 JobAction_Pause, |
b3da733d984c
job actions in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2573
diff
changeset
|
744 JobAction_Resubmit, |
b3da733d984c
job actions in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2573
diff
changeset
|
745 JobAction_Resume |
b3da733d984c
job actions in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2573
diff
changeset
|
746 }; |
b3da733d984c
job actions in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2573
diff
changeset
|
747 |
b3da733d984c
job actions in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2573
diff
changeset
|
748 template <JobAction action> |
b3da733d984c
job actions in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2573
diff
changeset
|
749 static void ApplyJobAction(RestApiPostCall& call) |
2573
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
750 { |
4417
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
751 if (call.IsDocumentation()) |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
752 { |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
753 std::string verb; |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
754 switch (action) |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
755 { |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
756 case JobAction_Cancel: |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
757 verb = "Cancel"; |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
758 break; |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
759 |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
760 case JobAction_Pause: |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
761 verb = "Pause"; |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
762 break; |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
763 |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
764 case JobAction_Resubmit: |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
765 verb = "Resubmit"; |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
766 break; |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
767 |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
768 case JobAction_Resume: |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
769 verb = "Resume"; |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
770 break; |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
771 |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
772 default: |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
773 throw OrthancException(ErrorCode_InternalError); |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
774 } |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
775 |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
776 call.GetDocumentation() |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
777 .SetTag("Jobs") |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
778 .SetSummary(verb + " job") |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
779 .SetDescription(verb + " the job whose identifier is provided in the URL. Check out the " |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
780 "Orthanc Book for more information about the state machine applicable to jobs: " |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
781 "https://book.orthanc-server.com/users/advanced-rest.html#jobs") |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
782 .SetUriArgument("id", "Identifier of the job of interest") |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
783 .AddAnswerType(MimeType_Json, "Empty JSON object in the case of a success"); |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
784 return; |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
785 } |
a4518adede59
openapi for plugins and jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4403
diff
changeset
|
786 |
2573
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
787 std::string id = call.GetUriComponent("id", ""); |
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
788 |
2582
b3da733d984c
job actions in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2573
diff
changeset
|
789 bool ok = false; |
b3da733d984c
job actions in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2573
diff
changeset
|
790 |
b3da733d984c
job actions in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2573
diff
changeset
|
791 switch (action) |
b3da733d984c
job actions in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2573
diff
changeset
|
792 { |
b3da733d984c
job actions in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2573
diff
changeset
|
793 case JobAction_Cancel: |
b3da733d984c
job actions in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2573
diff
changeset
|
794 ok = OrthancRestApi::GetContext(call).GetJobsEngine().GetRegistry().Cancel(id); |
b3da733d984c
job actions in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2573
diff
changeset
|
795 break; |
b3da733d984c
job actions in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2573
diff
changeset
|
796 |
b3da733d984c
job actions in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2573
diff
changeset
|
797 case JobAction_Pause: |
b3da733d984c
job actions in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2573
diff
changeset
|
798 ok = OrthancRestApi::GetContext(call).GetJobsEngine().GetRegistry().Pause(id); |
b3da733d984c
job actions in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2573
diff
changeset
|
799 break; |
b3da733d984c
job actions in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2573
diff
changeset
|
800 |
b3da733d984c
job actions in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2573
diff
changeset
|
801 case JobAction_Resubmit: |
b3da733d984c
job actions in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2573
diff
changeset
|
802 ok = OrthancRestApi::GetContext(call).GetJobsEngine().GetRegistry().Resubmit(id); |
b3da733d984c
job actions in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2573
diff
changeset
|
803 break; |
b3da733d984c
job actions in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2573
diff
changeset
|
804 |
b3da733d984c
job actions in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2573
diff
changeset
|
805 case JobAction_Resume: |
b3da733d984c
job actions in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2573
diff
changeset
|
806 ok = OrthancRestApi::GetContext(call).GetJobsEngine().GetRegistry().Resume(id); |
b3da733d984c
job actions in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2573
diff
changeset
|
807 break; |
b3da733d984c
job actions in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2573
diff
changeset
|
808 |
b3da733d984c
job actions in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2573
diff
changeset
|
809 default: |
b3da733d984c
job actions in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2573
diff
changeset
|
810 throw OrthancException(ErrorCode_InternalError); |
b3da733d984c
job actions in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2573
diff
changeset
|
811 } |
b3da733d984c
job actions in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2573
diff
changeset
|
812 |
b3da733d984c
job actions in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2573
diff
changeset
|
813 if (ok) |
2573
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
814 { |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
815 call.GetOutput().AnswerBuffer("{}", MimeType_Json); |
2573
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
816 } |
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
817 } |
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
818 |
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
819 |
3174
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
820 static void GetMetricsPrometheus(RestApiGetCall& call) |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
821 { |
4401
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
822 if (call.IsDocumentation()) |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
823 { |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
824 call.GetDocumentation() |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
825 .SetTag("System") |
4403 | 826 .SetSummary("Get usage metrics") |
4424
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4418
diff
changeset
|
827 .SetDescription("Get usage metrics of Orthanc in the Prometheus file format (OpenMetrics): " |
83371ccdfe80
openapi documentation is now completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4418
diff
changeset
|
828 "https://book.orthanc-server.com/users/advanced-rest.html#instrumentation-with-prometheus") |
4401
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
829 .SetHttpGetSample("https://demo.orthanc-server.com/tools/metrics-prometheus", false); |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
830 return; |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
831 } |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
832 |
3179
fca730c267d7
New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3177
diff
changeset
|
833 #if ORTHANC_ENABLE_PLUGINS == 1 |
fca730c267d7
New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3177
diff
changeset
|
834 OrthancRestApi::GetContext(call).GetPlugins().RefreshMetrics(); |
fca730c267d7
New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3177
diff
changeset
|
835 #endif |
fca730c267d7
New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3177
diff
changeset
|
836 |
3177
053e72ff9fc5
new metrics: orthanc_jobs_[pending|running|completed]
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
837 static const float MEGA_BYTES = 1024 * 1024; |
3174
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
838 |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
839 ServerContext& context = OrthancRestApi::GetContext(call); |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
840 |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
841 uint64_t diskSize, uncompressedSize, countPatients, countStudies, countSeries, countInstances; |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
842 context.GetIndex().GetGlobalStatistics(diskSize, uncompressedSize, countPatients, |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
843 countStudies, countSeries, countInstances); |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
844 |
3179
fca730c267d7
New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3177
diff
changeset
|
845 unsigned int jobsPending, jobsRunning, jobsSuccess, jobsFailed; |
fca730c267d7
New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3177
diff
changeset
|
846 context.GetJobsEngine().GetRegistry().GetStatistics(jobsPending, jobsRunning, jobsSuccess, jobsFailed); |
3177
053e72ff9fc5
new metrics: orthanc_jobs_[pending|running|completed]
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
847 |
053e72ff9fc5
new metrics: orthanc_jobs_[pending|running|completed]
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
848 MetricsRegistry& registry = context.GetMetricsRegistry(); |
053e72ff9fc5
new metrics: orthanc_jobs_[pending|running|completed]
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
849 registry.SetValue("orthanc_disk_size_mb", static_cast<float>(diskSize) / MEGA_BYTES); |
053e72ff9fc5
new metrics: orthanc_jobs_[pending|running|completed]
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
850 registry.SetValue("orthanc_uncompressed_size_mb", static_cast<float>(diskSize) / MEGA_BYTES); |
3174
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
851 registry.SetValue("orthanc_count_patients", static_cast<unsigned int>(countPatients)); |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
852 registry.SetValue("orthanc_count_studies", static_cast<unsigned int>(countStudies)); |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
853 registry.SetValue("orthanc_count_series", static_cast<unsigned int>(countSeries)); |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
854 registry.SetValue("orthanc_count_instances", static_cast<unsigned int>(countInstances)); |
3177
053e72ff9fc5
new metrics: orthanc_jobs_[pending|running|completed]
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
855 registry.SetValue("orthanc_jobs_pending", jobsPending); |
053e72ff9fc5
new metrics: orthanc_jobs_[pending|running|completed]
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
856 registry.SetValue("orthanc_jobs_running", jobsRunning); |
3179
fca730c267d7
New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3177
diff
changeset
|
857 registry.SetValue("orthanc_jobs_completed", jobsSuccess + jobsFailed); |
fca730c267d7
New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3177
diff
changeset
|
858 registry.SetValue("orthanc_jobs_success", jobsSuccess); |
fca730c267d7
New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3177
diff
changeset
|
859 registry.SetValue("orthanc_jobs_failed", jobsFailed); |
3174
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
860 |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
861 std::string s; |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
862 registry.ExportPrometheusText(s); |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
863 |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
864 call.GetOutput().AnswerBuffer(s, MimeType_PrometheusText); |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
865 } |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
866 |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
867 |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
868 static void GetMetricsEnabled(RestApiGetCall& call) |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
869 { |
4403 | 870 if (call.IsDocumentation()) |
871 { | |
872 call.GetDocumentation() | |
873 .SetTag("System") | |
874 .SetSummary("Are metrics collected?") | |
875 .SetDescription("Returns a Boolean specifying whether Prometheus metrics " | |
876 "are collected and exposed at `/tools/metrics-prometheus`") | |
877 .AddAnswerType(MimeType_PlainText, "`1` if metrics are collected, `0` if metrics are disabled"); | |
878 return; | |
879 } | |
880 | |
3174
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
881 bool enabled = OrthancRestApi::GetContext(call).GetMetricsRegistry().IsEnabled(); |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
882 call.GetOutput().AnswerBuffer(enabled ? "1" : "0", MimeType_PlainText); |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
883 } |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
884 |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
885 |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
886 static void PutMetricsEnabled(RestApiPutCall& call) |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
887 { |
4403 | 888 if (call.IsDocumentation()) |
889 { | |
890 call.GetDocumentation() | |
891 .SetTag("System") | |
892 .SetSummary("Enable collection of metrics") | |
893 .SetDescription("Enable or disable the collection and publication of metrics at `/tools/metrics-prometheus`") | |
894 .AddRequestType(MimeType_PlainText, "`1` if metrics are collected, `0` if metrics are disabled"); | |
895 return; | |
896 } | |
897 | |
4473
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
898 const bool enabled = call.ParseBooleanBody(); |
3174
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
899 |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
900 // Success |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
901 OrthancRestApi::GetContext(call).GetMetricsRegistry().SetEnabled(enabled); |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
902 call.GetOutput().AnswerBuffer("", MimeType_PlainText); |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
903 } |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
904 |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
905 |
3672
ea8c1c0e81eb
Fix issue #65 (Logging improvements)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
906 static void GetLogLevel(RestApiGetCall& call) |
ea8c1c0e81eb
Fix issue #65 (Logging improvements)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
907 { |
4401
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
908 if (call.IsDocumentation()) |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
909 { |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
910 call.GetDocumentation() |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
911 .SetTag("Logs") |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
912 .SetSummary("Get main log level") |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
913 .SetDescription("Get the main log level of Orthanc") |
4403 | 914 .AddAnswerType(MimeType_PlainText, "Possible values: `default`, `verbose` or `trace`"); |
4401
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
915 return; |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
916 } |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
917 |
4273
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4143
diff
changeset
|
918 const std::string s = EnumerationToString(GetGlobalVerbosity()); |
3672
ea8c1c0e81eb
Fix issue #65 (Logging improvements)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
919 call.GetOutput().AnswerBuffer(s, MimeType_PlainText); |
ea8c1c0e81eb
Fix issue #65 (Logging improvements)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
920 } |
ea8c1c0e81eb
Fix issue #65 (Logging improvements)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
921 |
ea8c1c0e81eb
Fix issue #65 (Logging improvements)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
922 |
ea8c1c0e81eb
Fix issue #65 (Logging improvements)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
923 static void PutLogLevel(RestApiPutCall& call) |
ea8c1c0e81eb
Fix issue #65 (Logging improvements)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
924 { |
4401
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
925 if (call.IsDocumentation()) |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
926 { |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
927 call.GetDocumentation() |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
928 .SetTag("Logs") |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
929 .SetSummary("Set main log level") |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
930 .SetDescription("Set the main log level of Orthanc") |
4403 | 931 .AddRequestType(MimeType_PlainText, "Possible values: `default`, `verbose` or `trace`"); |
4401
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
932 return; |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
933 } |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
934 |
3672
ea8c1c0e81eb
Fix issue #65 (Logging improvements)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
935 std::string body; |
ea8c1c0e81eb
Fix issue #65 (Logging improvements)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
936 call.BodyToString(body); |
ea8c1c0e81eb
Fix issue #65 (Logging improvements)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
937 |
4273
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4143
diff
changeset
|
938 SetGlobalVerbosity(StringToVerbosity(body)); |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4143
diff
changeset
|
939 |
3672
ea8c1c0e81eb
Fix issue #65 (Logging improvements)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
940 // Success |
ea8c1c0e81eb
Fix issue #65 (Logging improvements)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
941 LOG(WARNING) << "REST API call has switched the log level to: " << body; |
ea8c1c0e81eb
Fix issue #65 (Logging improvements)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
942 call.GetOutput().AnswerBuffer("", MimeType_PlainText); |
ea8c1c0e81eb
Fix issue #65 (Logging improvements)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
943 } |
ea8c1c0e81eb
Fix issue #65 (Logging improvements)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
944 |
ea8c1c0e81eb
Fix issue #65 (Logging improvements)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
945 |
4275
d7a50b7b8466
Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
946 static Logging::LogCategory GetCategory(const RestApiCall& call) |
d7a50b7b8466
Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
947 { |
d7a50b7b8466
Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
948 static const std::string PREFIX = "log-level-"; |
d7a50b7b8466
Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
949 |
d7a50b7b8466
Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
950 if (call.GetFullUri().size() == 2 && |
d7a50b7b8466
Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
951 call.GetFullUri() [0] == "tools" && |
d7a50b7b8466
Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
952 boost::starts_with(call.GetFullUri() [1], PREFIX)) |
d7a50b7b8466
Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
953 { |
d7a50b7b8466
Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
954 Logging::LogCategory category; |
d7a50b7b8466
Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
955 if (Logging::LookupCategory(category, call.GetFullUri() [1].substr(PREFIX.size()))) |
d7a50b7b8466
Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
956 { |
d7a50b7b8466
Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
957 return category; |
d7a50b7b8466
Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
958 } |
d7a50b7b8466
Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
959 } |
d7a50b7b8466
Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
960 |
d7a50b7b8466
Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
961 throw OrthancException(ErrorCode_InternalError); |
d7a50b7b8466
Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
962 } |
d7a50b7b8466
Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
963 |
d7a50b7b8466
Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
964 |
d7a50b7b8466
Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
965 static void GetLogLevelCategory(RestApiGetCall& call) |
d7a50b7b8466
Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
966 { |
4401
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
967 if (call.IsDocumentation()) |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
968 { |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
969 std::string category = Logging::GetCategoryName(GetCategory(call)); |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
970 call.GetDocumentation() |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
971 .SetTag("Logs") |
4403 | 972 .SetSummary("Get log level for `" + category + "`") |
973 .SetDescription("Get the log level of the log category `" + category + "`") | |
974 .AddAnswerType(MimeType_PlainText, "Possible values: `default`, `verbose` or `trace`"); | |
4401
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
975 return; |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
976 } |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
977 |
4275
d7a50b7b8466
Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
978 const std::string s = EnumerationToString(GetCategoryVerbosity(GetCategory(call))); |
d7a50b7b8466
Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
979 call.GetOutput().AnswerBuffer(s, MimeType_PlainText); |
d7a50b7b8466
Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
980 } |
d7a50b7b8466
Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
981 |
d7a50b7b8466
Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
982 |
d7a50b7b8466
Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
983 static void PutLogLevelCategory(RestApiPutCall& call) |
d7a50b7b8466
Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
984 { |
4401
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
985 if (call.IsDocumentation()) |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
986 { |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
987 std::string category = Logging::GetCategoryName(GetCategory(call)); |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
988 call.GetDocumentation() |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
989 .SetTag("Logs") |
4403 | 990 .SetSummary("Set log level for `" + category + "`") |
991 .SetDescription("Set the log level of the log category `" + category + "`") | |
992 .AddRequestType(MimeType_PlainText, "Possible values: `default`, `verbose` or `trace`"); | |
4401
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
993 return; |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
994 } |
354ea95b294a
documenting system calls
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4379
diff
changeset
|
995 |
4275
d7a50b7b8466
Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
996 std::string body; |
d7a50b7b8466
Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
997 call.BodyToString(body); |
d7a50b7b8466
Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
998 |
d7a50b7b8466
Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
999 Verbosity verbosity = StringToVerbosity(body); |
d7a50b7b8466
Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
1000 Logging::LogCategory category = GetCategory(call); |
d7a50b7b8466
Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
1001 SetCategoryVerbosity(category, verbosity); |
d7a50b7b8466
Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
1002 |
d7a50b7b8466
Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
1003 // Success |
d7a50b7b8466
Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
1004 LOG(WARNING) << "REST API call has switched the log level of category \"" |
d7a50b7b8466
Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
1005 << Logging::GetCategoryName(category) << "\" to \"" |
d7a50b7b8466
Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
1006 << EnumerationToString(verbosity) << "\""; |
d7a50b7b8466
Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
1007 call.GetOutput().AnswerBuffer("", MimeType_PlainText); |
d7a50b7b8466
Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
1008 } |
d7a50b7b8466
Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
1009 |
d7a50b7b8466
Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
1010 |
4378
9e2fc6911ac8
adding option to disable orthance explorer when http server is enabled
Andrew Wallis <andrew.wallis@varian.com>>
parents:
4275
diff
changeset
|
1011 void OrthancRestApi::RegisterSystem(bool orthancExplorerEnabled) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1012 { |
4378
9e2fc6911ac8
adding option to disable orthance explorer when http server is enabled
Andrew Wallis <andrew.wallis@varian.com>>
parents:
4275
diff
changeset
|
1013 if (orthancExplorerEnabled) |
9e2fc6911ac8
adding option to disable orthance explorer when http server is enabled
Andrew Wallis <andrew.wallis@varian.com>>
parents:
4275
diff
changeset
|
1014 { |
9e2fc6911ac8
adding option to disable orthance explorer when http server is enabled
Andrew Wallis <andrew.wallis@varian.com>>
parents:
4275
diff
changeset
|
1015 Register("/", ServeRoot); |
4461
22abc6851191
The DICOM meta-header and the transfer syntax are displayed at the "Instance" level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1016 Register("/favicon.ico", ServeFavicon); // New in Orthanc 1.9.0 |
4378
9e2fc6911ac8
adding option to disable orthance explorer when http server is enabled
Andrew Wallis <andrew.wallis@varian.com>>
parents:
4275
diff
changeset
|
1017 } |
4379
85b5b0e1bac9
added NEWS about "OrthancExplorerEnabled" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4378
diff
changeset
|
1018 |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1019 Register("/system", GetSystemInformation); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1020 Register("/statistics", GetStatistics); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1021 Register("/tools/generate-uid", GenerateUid); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1022 Register("/tools/execute-script", ExecuteScript); |
2475
8cc3ca64a534
Orthanc now uses UTC (universal time) instead of local time in its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
1023 Register("/tools/now", GetNowIsoString<true>); |
8cc3ca64a534
Orthanc now uses UTC (universal time) instead of local time in its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
1024 Register("/tools/now-local", GetNowIsoString<false>); |
1073
01414536c930
complete DICOM conformance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
996
diff
changeset
|
1025 Register("/tools/dicom-conformance", GetDicomConformanceStatement); |
2202
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2140
diff
changeset
|
1026 Register("/tools/default-encoding", GetDefaultEncoding); |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2140
diff
changeset
|
1027 Register("/tools/default-encoding", SetDefaultEncoding); |
3174
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
1028 Register("/tools/metrics", GetMetricsEnabled); |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
1029 Register("/tools/metrics", PutMetricsEnabled); |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
1030 Register("/tools/metrics-prometheus", GetMetricsPrometheus); |
3672
ea8c1c0e81eb
Fix issue #65 (Logging improvements)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
1031 Register("/tools/log-level", GetLogLevel); |
ea8c1c0e81eb
Fix issue #65 (Logging improvements)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
1032 Register("/tools/log-level", PutLogLevel); |
1232
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
1033 |
4275
d7a50b7b8466
Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
1034 for (size_t i = 0; i < Logging::GetCategoriesCount(); i++) |
d7a50b7b8466
Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
1035 { |
d7a50b7b8466
Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
1036 const std::string name(Logging::GetCategoryName(i)); |
d7a50b7b8466
Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
1037 Register("/tools/log-level-" + name, GetLogLevelCategory); |
d7a50b7b8466
Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
1038 Register("/tools/log-level-" + name, PutLogLevelCategory); |
d7a50b7b8466
Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
1039 } |
d7a50b7b8466
Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
1040 |
1232
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
1041 Register("/plugins", ListPlugins); |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
1042 Register("/plugins/{id}", GetPlugin); |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1218
diff
changeset
|
1043 Register("/plugins/explorer.js", GetOrthancExplorerPlugins); |
2573
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
1044 |
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
1045 Register("/jobs", ListJobs); |
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
1046 Register("/jobs/{id}", GetJobInfo); |
2582
b3da733d984c
job actions in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2573
diff
changeset
|
1047 Register("/jobs/{id}/cancel", ApplyJobAction<JobAction_Cancel>); |
b3da733d984c
job actions in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2573
diff
changeset
|
1048 Register("/jobs/{id}/pause", ApplyJobAction<JobAction_Pause>); |
b3da733d984c
job actions in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2573
diff
changeset
|
1049 Register("/jobs/{id}/resubmit", ApplyJobAction<JobAction_Resubmit>); |
b3da733d984c
job actions in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2573
diff
changeset
|
1050 Register("/jobs/{id}/resume", ApplyJobAction<JobAction_Resume>); |
2976
cb5d75143da0
Asynchronous generation of ZIP archives and DICOM medias
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2940
diff
changeset
|
1051 Register("/jobs/{id}/{key}", GetJobOutput); |
4473
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
1052 |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
1053 // New in Orthanc 1.9.0 |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
1054 Register("/tools/accepted-transfer-syntaxes", GetAcceptedTransferSyntaxes); |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
1055 Register("/tools/accepted-transfer-syntaxes", SetAcceptedTransferSyntaxes); |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
1056 Register("/tools/unknown-sop-class-accepted", GetUnknownSopClassAccepted); |
68f52897c119
new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4461
diff
changeset
|
1057 Register("/tools/unknown-sop-class-accepted", SetUnknownSopClassAccepted); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1058 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1059 } |