comparison OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp @ 4410:a6abe5f512db

cont openapi
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 25 Dec 2020 11:23:32 +0100
parents 5784a9eaf502
children 22a1352a0823
comparison
equal deleted inserted replaced
4409:5784a9eaf502 4410:a6abe5f512db
1591 { 1591 {
1592 ResourceType t = StringToResourceType(call.GetFullUri()[0].c_str()); 1592 ResourceType t = StringToResourceType(call.GetFullUri()[0].c_str());
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 the 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` if `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 on the disk"); 1601 .AddAnswerType(MimeType_PlainText, "The size of the attachment, as stored on the disk");
1602 return; 1602 return;
1603 } 1603 }
1604 1604
1605 FileInfo info; 1605 FileInfo info;
1606 if (GetAttachmentInfo(info, call)) 1606 if (GetAttachmentInfo(info, call))
1610 } 1610 }
1611 1611
1612 1612
1613 static void GetAttachmentMD5(RestApiGetCall& call) 1613 static void GetAttachmentMD5(RestApiGetCall& call)
1614 { 1614 {
1615 if (call.IsDocumentation())
1616 {
1617 ResourceType t = StringToResourceType(call.GetFullUri()[0].c_str());
1618 std::string r = GetResourceTypeText(t, false /* plural */, false /* upper case */);
1619 call.GetDocumentation()
1620 .SetTag(GetResourceTypeText(t, true /* plural */, true /* upper case */))
1621 .SetSummary("Get MD5 of attachment")
1622 .SetDescription("Get the MD5 hash of one attachment associated with the given " + r)
1623 .SetUriArgument("id", "Orthanc identifier of the " + r + " of interest")
1624 .SetUriArgument("name", "The name of the attachment")
1625 .AddAnswerType(MimeType_PlainText, "The MD5 of the attachment");
1626 return;
1627 }
1628
1615 FileInfo info; 1629 FileInfo info;
1616 if (GetAttachmentInfo(info, call) && 1630 if (GetAttachmentInfo(info, call) &&
1617 info.GetUncompressedMD5() != "") 1631 info.GetUncompressedMD5() != "")
1618 { 1632 {
1619 call.GetOutput().AnswerBuffer(boost::lexical_cast<std::string>(info.GetUncompressedMD5()), MimeType_PlainText); 1633 call.GetOutput().AnswerBuffer(boost::lexical_cast<std::string>(info.GetUncompressedMD5()), MimeType_PlainText);
1621 } 1635 }
1622 1636
1623 1637
1624 static void GetAttachmentCompressedMD5(RestApiGetCall& call) 1638 static void GetAttachmentCompressedMD5(RestApiGetCall& call)
1625 { 1639 {
1640 if (call.IsDocumentation())
1641 {
1642 ResourceType t = StringToResourceType(call.GetFullUri()[0].c_str());
1643 std::string r = GetResourceTypeText(t, false /* plural */, false /* upper case */);
1644 call.GetDocumentation()
1645 .SetTag(GetResourceTypeText(t, true /* plural */, true /* upper case */))
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. "
1648 "This is different from `.../md5` if `EnableStorage` is `true`.")
1649 .SetUriArgument("id", "Orthanc identifier of the " + r + " of interest")
1650 .SetUriArgument("name", "The name of the attachment")
1651 .AddAnswerType(MimeType_PlainText, "The MD5 of the attachment, as stored on the disk");
1652 return;
1653 }
1654
1626 FileInfo info; 1655 FileInfo info;
1627 if (GetAttachmentInfo(info, call) && 1656 if (GetAttachmentInfo(info, call) &&
1628 info.GetCompressedMD5() != "") 1657 info.GetCompressedMD5() != "")
1629 { 1658 {
1630 call.GetOutput().AnswerBuffer(boost::lexical_cast<std::string>(info.GetCompressedMD5()), MimeType_PlainText); 1659 call.GetOutput().AnswerBuffer(boost::lexical_cast<std::string>(info.GetCompressedMD5()), MimeType_PlainText);
1632 } 1661 }
1633 1662
1634 1663
1635 static void VerifyAttachment(RestApiPostCall& call) 1664 static void VerifyAttachment(RestApiPostCall& call)
1636 { 1665 {
1666 if (call.IsDocumentation())
1667 {
1668 ResourceType t = StringToResourceType(call.GetFullUri()[0].c_str());
1669 std::string r = GetResourceTypeText(t, false /* plural */, false /* upper case */);
1670 call.GetDocumentation()
1671 .SetTag(GetResourceTypeText(t, true /* plural */, true /* upper case */))
1672 .SetSummary("Verify attachment")
1673 .SetDescription("Verify that the attachment is not corrupted, by validating its MD5 hash")
1674 .SetUriArgument("id", "Orthanc identifier of the " + r + " of interest")
1675 .SetUriArgument("name", "The name of the attachment")
1676 .AddAnswerType(MimeType_Json, "On success, a valid JSON object is returned");
1677 return;
1678 }
1679
1637 ServerContext& context = OrthancRestApi::GetContext(call); 1680 ServerContext& context = OrthancRestApi::GetContext(call);
1638 CheckValidResourceType(call); 1681 CheckValidResourceType(call);
1639 1682
1640 std::string publicId = call.GetUriComponent("id", ""); 1683 std::string publicId = call.GetUriComponent("id", "");
1641 std::string name = call.GetUriComponent("name", ""); 1684 std::string name = call.GetUriComponent("name", "");