comparison OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp @ 4413:22a1352a0823

cont openapi
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 28 Dec 2020 13:08:00 +0100
parents a6abe5f512db
children d928dfcacb4b
comparison
equal deleted inserted replaced
4412:68b96234fbd6 4413:22a1352a0823
1593 std::string r = GetResourceTypeText(t, false /* plural */, false /* upper case */); 1593 std::string r = GetResourceTypeText(t, false /* plural */, false /* upper case */);
1594 call.GetDocumentation() 1594 call.GetDocumentation()
1595 .SetTag(GetResourceTypeText(t, true /* plural */, true /* upper case */)) 1595 .SetTag(GetResourceTypeText(t, true /* plural */, true /* upper case */))
1596 .SetSummary("Get size of attachment on disk") 1596 .SetSummary("Get size of attachment on disk")
1597 .SetDescription("Get the size of one attachment associated with the given " + r + ", as stored on the disk. " 1597 .SetDescription("Get the size of one attachment associated with the given " + r + ", as stored on the disk. "
1598 "This is different from `.../size` if `EnableStorage` is `true`.") 1598 "This is different from `.../size` iff `EnableStorage` is `true`.")
1599 .SetUriArgument("id", "Orthanc identifier of the " + r + " of interest") 1599 .SetUriArgument("id", "Orthanc identifier of the " + r + " of interest")
1600 .SetUriArgument("name", "The name of the attachment") 1600 .SetUriArgument("name", "The name of the attachment")
1601 .AddAnswerType(MimeType_PlainText, "The size of the attachment, as stored on the disk"); 1601 .AddAnswerType(MimeType_PlainText, "The size of the attachment, as stored on the disk");
1602 return; 1602 return;
1603 } 1603 }
1643 std::string r = GetResourceTypeText(t, false /* plural */, false /* upper case */); 1643 std::string r = GetResourceTypeText(t, false /* plural */, false /* upper case */);
1644 call.GetDocumentation() 1644 call.GetDocumentation()
1645 .SetTag(GetResourceTypeText(t, true /* plural */, true /* upper case */)) 1645 .SetTag(GetResourceTypeText(t, true /* plural */, true /* upper case */))
1646 .SetSummary("Get MD5 of attachment on disk") 1646 .SetSummary("Get MD5 of attachment on disk")
1647 .SetDescription("Get the MD5 hash of one attachment associated with the given " + r + ", as stored on the disk. " 1647 .SetDescription("Get the MD5 hash of one attachment associated with the given " + r + ", as stored on the disk. "
1648 "This is different from `.../md5` if `EnableStorage` is `true`.") 1648 "This is different from `.../md5` iff `EnableStorage` is `true`.")
1649 .SetUriArgument("id", "Orthanc identifier of the " + r + " of interest") 1649 .SetUriArgument("id", "Orthanc identifier of the " + r + " of interest")
1650 .SetUriArgument("name", "The name of the attachment") 1650 .SetUriArgument("name", "The name of the attachment")
1651 .AddAnswerType(MimeType_PlainText, "The MD5 of the attachment, as stored on the disk"); 1651 .AddAnswerType(MimeType_PlainText, "The MD5 of the attachment, as stored on the disk");
1652 return; 1652 return;
1653 } 1653 }
1750 } 1750 }
1751 1751
1752 1752
1753 static void DeleteAttachment(RestApiDeleteCall& call) 1753 static void DeleteAttachment(RestApiDeleteCall& call)
1754 { 1754 {
1755 if (call.IsDocumentation())
1756 {
1757 ResourceType t = StringToResourceType(call.GetFullUri()[0].c_str());
1758 std::string r = GetResourceTypeText(t, false /* plural */, false /* upper case */);
1759 call.GetDocumentation()
1760 .SetTag(GetResourceTypeText(t, true /* plural */, true /* upper case */))
1761 .SetSummary("Delete attachment")
1762 .SetDescription("Delete an attachment associated with the given DICOM " + r)
1763 .SetUriArgument("id", "Orthanc identifier of the " + r + " of interest")
1764 .SetUriArgument("name", "The name of the attachment");
1765 return;
1766 }
1767
1755 CheckValidResourceType(call); 1768 CheckValidResourceType(call);
1756 1769
1757 std::string publicId = call.GetUriComponent("id", ""); 1770 std::string publicId = call.GetUriComponent("id", "");
1758 std::string name = call.GetUriComponent("name", ""); 1771 std::string name = call.GetUriComponent("name", "");
1759 FileContentType contentType = StringToContentType(name); 1772 FileContentType contentType = StringToContentType(name);
1794 1807
1795 1808
1796 template <enum CompressionType compression> 1809 template <enum CompressionType compression>
1797 static void ChangeAttachmentCompression(RestApiPostCall& call) 1810 static void ChangeAttachmentCompression(RestApiPostCall& call)
1798 { 1811 {
1812 if (call.IsDocumentation())
1813 {
1814 ResourceType t = StringToResourceType(call.GetFullUri()[0].c_str());
1815 std::string r = GetResourceTypeText(t, false /* plural */, false /* upper case */);
1816 call.GetDocumentation()
1817 .SetTag(GetResourceTypeText(t, true /* plural */, true /* upper case */))
1818 .SetSummary(compression == CompressionType_None ? "Uncompress attachment" : "Compress attachment")
1819 .SetDescription("Change the compression scheme that is used to store an attachment.")
1820 .SetUriArgument("id", "Orthanc identifier of the " + r + " of interest")
1821 .SetUriArgument("name", "The name of the attachment");
1822 return;
1823 }
1824
1799 CheckValidResourceType(call); 1825 CheckValidResourceType(call);
1800 1826
1801 std::string publicId = call.GetUriComponent("id", ""); 1827 std::string publicId = call.GetUriComponent("id", "");
1802 std::string name = call.GetUriComponent("name", ""); 1828 std::string name = call.GetUriComponent("name", "");
1803 FileContentType contentType = StringToContentType(name); 1829 FileContentType contentType = StringToContentType(name);
1807 } 1833 }
1808 1834
1809 1835
1810 static void IsAttachmentCompressed(RestApiGetCall& call) 1836 static void IsAttachmentCompressed(RestApiGetCall& call)
1811 { 1837 {
1838 if (call.IsDocumentation())
1839 {
1840 ResourceType t = StringToResourceType(call.GetFullUri()[0].c_str());
1841 std::string r = GetResourceTypeText(t, false /* plural */, false /* upper case */);
1842 call.GetDocumentation()
1843 .SetTag(GetResourceTypeText(t, true /* plural */, true /* upper case */))
1844 .SetSummary("Is attachment compressed?")
1845 .SetDescription("Test whether the attachment has been stored as a compressed file on the disk.")
1846 .SetUriArgument("id", "Orthanc identifier of the " + r + " of interest")
1847 .SetUriArgument("name", "The name of the attachment")
1848 .AddAnswerType(MimeType_PlainText, "`0` if the attachment was stored uncompressed, `1` if it was compressed");
1849 return;
1850 }
1851
1812 FileInfo info; 1852 FileInfo info;
1813 if (GetAttachmentInfo(info, call)) 1853 if (GetAttachmentInfo(info, call))
1814 { 1854 {
1815 std::string answer = (info.GetCompressionType() == CompressionType_None) ? "0" : "1"; 1855 std::string answer = (info.GetCompressionType() == CompressionType_None) ? "0" : "1";
1816 call.GetOutput().AnswerBuffer(answer, MimeType_PlainText); 1856 call.GetOutput().AnswerBuffer(answer, MimeType_PlainText);