comparison OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp @ 4404:f34634916d8c

cont openapi
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 24 Dec 2020 08:59:45 +0100
parents ad646ff506d0
children 5466f336b09f
comparison
equal deleted inserted replaced
4403:ad646ff506d0 4404:f34634916d8c
170 .SetDescription("List the Orthanc identifiers of all the available DICOM " + resources) 170 .SetDescription("List the Orthanc identifiers of all the available DICOM " + resources)
171 .SetHttpGetArgument("limit", RestApiCallDocumentation::Type_Number, "Limit the number of results", false) 171 .SetHttpGetArgument("limit", RestApiCallDocumentation::Type_Number, "Limit the number of results", false)
172 .SetHttpGetArgument("since", RestApiCallDocumentation::Type_Number, "Show only the resources since the provided index", false) 172 .SetHttpGetArgument("since", RestApiCallDocumentation::Type_Number, "Show only the resources since the provided index", false)
173 .SetHttpGetArgument("expand", RestApiCallDocumentation::Type_String, 173 .SetHttpGetArgument("expand", RestApiCallDocumentation::Type_String,
174 "If present, retrieve detailed information about the individual " + resources, false) 174 "If present, retrieve detailed information about the individual " + resources, false)
175 .AddAnswerType(MimeType_Json, "JSON array containing either the Orthanc identifiers, or detailed information "
176 "about the reported " + resources + " (if `expand` argument is provided)")
175 .SetHttpGetSample("https://demo.orthanc-server.com/" + resources + "?since=0&limit=2", true); 177 .SetHttpGetSample("https://demo.orthanc-server.com/" + resources + "?since=0&limit=2", true);
176 return; 178 return;
177 } 179 }
178 180
179 ServerIndex& index = OrthancRestApi::GetIndex(call); 181 ServerIndex& index = OrthancRestApi::GetIndex(call);
236 238
237 const std::string resource = GetResourceTypeText(resourceType, false /* plural */, false /* lower case */); 239 const std::string resource = GetResourceTypeText(resourceType, false /* plural */, false /* lower case */);
238 call.GetDocumentation() 240 call.GetDocumentation()
239 .SetTag(GetResourceTypeText(resourceType, true /* plural */, true /* upper case */)) 241 .SetTag(GetResourceTypeText(resourceType, true /* plural */, true /* upper case */))
240 .SetSummary("Get information about some " + resource) 242 .SetSummary("Get information about some " + resource)
241 .SetDescription("Get information about the DICOM " + resource + " of interest whose Orthanc identifier is provided in the URL") 243 .SetDescription("Get detailed information about the DICOM " + resource + " of interest whose Orthanc identifier is provided in the URL")
242 .SetUriArgument("id", RestApiCallDocumentation::Type_String, "Orthanc identifier of the " + resource + " of interest") 244 .SetUriArgument("id", "Orthanc identifier of the " + resource + " of interest")
243 .SetHttpGetSample(sampleUrl, true); 245 .SetHttpGetSample(sampleUrl, true);
244 return; 246 return;
245 } 247 }
246 248
247 Json::Value result; 249 Json::Value result;
259 const std::string resource = GetResourceTypeText(resourceType, false /* plural */, false /* lower case */); 261 const std::string resource = GetResourceTypeText(resourceType, false /* plural */, false /* lower case */);
260 call.GetDocumentation() 262 call.GetDocumentation()
261 .SetTag(GetResourceTypeText(resourceType, true /* plural */, true /* upper case */)) 263 .SetTag(GetResourceTypeText(resourceType, true /* plural */, true /* upper case */))
262 .SetSummary("Delete some " + resource) 264 .SetSummary("Delete some " + resource)
263 .SetDescription("Delete the DICOM " + resource + " of interest whose Orthanc identifier is provided in the URL") 265 .SetDescription("Delete the DICOM " + resource + " of interest whose Orthanc identifier is provided in the URL")
264 .SetUriArgument("id", RestApiCallDocumentation::Type_String, "Orthanc identifier of the " + resource + " of interest"); 266 .SetUriArgument("id", "Orthanc identifier of the " + resource + " of interest");
265 return; 267 return;
266 } 268 }
267 269
268 Json::Value result; 270 Json::Value result;
269 if (OrthancRestApi::GetContext(call).DeleteResource(result, call.GetUriComponent("id", ""), resourceType)) 271 if (OrthancRestApi::GetContext(call).DeleteResource(result, call.GetUriComponent("id", ""), resourceType))
280 if (call.IsDocumentation()) 282 if (call.IsDocumentation())
281 { 283 {
282 call.GetDocumentation() 284 call.GetDocumentation()
283 .SetTag("Patients") 285 .SetTag("Patients")
284 .SetSummary("Is the patient protected against recycling?") 286 .SetSummary("Is the patient protected against recycling?")
285 .SetUriArgument("id", RestApiCallDocumentation::Type_String, "Orthanc identifier of the patient of interest") 287 .SetUriArgument("id", "Orthanc identifier of the patient of interest")
286 .AddAnswerType(MimeType_PlainText, "`1` if protected, `0` if not protected"); 288 .AddAnswerType(MimeType_PlainText, "`1` if protected, `0` if not protected");
287 return; 289 return;
288 } 290 }
289 291
290 std::string publicId = call.GetUriComponent("id", ""); 292 std::string publicId = call.GetUriComponent("id", "");
299 { 301 {
300 call.GetDocumentation() 302 call.GetDocumentation()
301 .SetTag("Patients") 303 .SetTag("Patients")
302 .SetSummary("Protect one patient against recycling") 304 .SetSummary("Protect one patient against recycling")
303 .SetDescription("Check out configuration options `MaximumStorageSize` and `MaximumPatientCount`") 305 .SetDescription("Check out configuration options `MaximumStorageSize` and `MaximumPatientCount`")
304 .SetUriArgument("id", RestApiCallDocumentation::Type_String, "Orthanc identifier of the patient of interest"); 306 .SetUriArgument("id", "Orthanc identifier of the patient of interest");
305 return; 307 return;
306 } 308 }
307 309
308 ServerContext& context = OrthancRestApi::GetContext(call); 310 ServerContext& context = OrthancRestApi::GetContext(call);
309 311
398 400
399 401
400 template <DicomToJsonFormat format> 402 template <DicomToJsonFormat format>
401 static void GetInstanceTags(RestApiGetCall& call) 403 static void GetInstanceTags(RestApiGetCall& call)
402 { 404 {
405 if (call.IsDocumentation())
406 {
407 if (format == DicomToJsonFormat_Human)
408 {
409 call.GetDocumentation()
410 .SetTag("Instances")
411 .SetSummary("Get human-readable tags")
412 .SetDescription("Get the DICOM tags in human-readable format")
413 .SetUriArgument("id", "Orthanc identifier of the DICOM instance of interest")
414 .AddAnswerType(MimeType_Json, "JSON object containing the DICOM tags and their associated value")
415 .SetHttpGetSample("https://demo.orthanc-server.com/instances/7c92ce8e-bbf67ed2-ffa3b8c1-a3b35d94-7ff3ae26/simplified-tags", true);
416 return;
417 }
418 else
419 {
420 throw OrthancException(ErrorCode_NotImplemented);
421 }
422 }
423
403 ServerContext& context = OrthancRestApi::GetContext(call); 424 ServerContext& context = OrthancRestApi::GetContext(call);
404 425
405 std::string publicId = call.GetUriComponent("id", ""); 426 std::string publicId = call.GetUriComponent("id", "");
406 427
407 std::set<DicomTag> ignoreTagLength; 428 std::set<DicomTag> ignoreTagLength;
426 } 447 }
427 448
428 449
429 static void GetInstanceTagsBis(RestApiGetCall& call) 450 static void GetInstanceTagsBis(RestApiGetCall& call)
430 { 451 {
452 if (call.IsDocumentation())
453 {
454 call.GetDocumentation()
455 .SetTag("Instances")
456 .SetSummary("Get DICOM tags")
457 .SetDescription("Get the DICOM tags in the specified format. By default, the `full` format is used, which "
458 "combines hexadecimal tags with human-readable description.")
459 .SetUriArgument("id", "Orthanc identifier of the DICOM instance of interest")
460 .SetHttpGetArgument("simplify", RestApiCallDocumentation::Type_String,
461 "If present, report the DICOM tags in human-readable format "
462 "(same as the `/instances/{id}/simplified-tags` route)", false)
463 .SetHttpGetArgument("short", RestApiCallDocumentation::Type_String,
464 "If present, report the DICOM tags indexed in hexadecimal format", false)
465 .AddAnswerType(MimeType_Json, "JSON object containing the DICOM tags and their associated value")
466 .SetHttpGetSample("https://demo.orthanc-server.com/instances/7c92ce8e-bbf67ed2-ffa3b8c1-a3b35d94-7ff3ae26/tags", true);
467 return;
468 }
469
431 switch (GetDicomFormat(call)) 470 switch (GetDicomFormat(call))
432 { 471 {
433 case DicomToJsonFormat_Human: 472 case DicomToJsonFormat_Human:
434 GetInstanceTags<DicomToJsonFormat_Human>(call); 473 GetInstanceTags<DicomToJsonFormat_Human>(call);
435 break; 474 break;
2059 } 2098 }
2060 2099
2061 2100
2062 static void GetInstanceHeader(RestApiGetCall& call) 2101 static void GetInstanceHeader(RestApiGetCall& call)
2063 { 2102 {
2103 if (call.IsDocumentation())
2104 {
2105 call.GetDocumentation()
2106 .SetTag("Instances")
2107 .SetSummary("Get DICOM meta-header")
2108 .SetDescription("Get the DICOM tags in the meta-header of the DICOM instance. By default, the `full` format is used, which "
2109 "combines hexadecimal tags with human-readable description.")
2110 .SetUriArgument("id", "Orthanc identifier of the DICOM instance of interest")
2111 .SetHttpGetArgument("simplify", RestApiCallDocumentation::Type_String,
2112 "If present, report the DICOM tags in human-readable format", false)
2113 .SetHttpGetArgument("short", RestApiCallDocumentation::Type_String,
2114 "If present, report the DICOM tags indexed in hexadecimal format", false)
2115 .AddAnswerType(MimeType_Json, "JSON object containing the DICOM tags and their associated value")
2116 .SetHttpGetSample("https://demo.orthanc-server.com/instances/7c92ce8e-bbf67ed2-ffa3b8c1-a3b35d94-7ff3ae26/header", true);
2117 return;
2118 }
2119
2064 ServerContext& context = OrthancRestApi::GetContext(call); 2120 ServerContext& context = OrthancRestApi::GetContext(call);
2065 2121
2066 std::string publicId = call.GetUriComponent("id", ""); 2122 std::string publicId = call.GetUriComponent("id", "");
2067 2123
2068 std::string dicomContent; 2124 std::string dicomContent;