23 #include "core/credentials/Credential_odb.h" 39 return std::make_unique<CredentialSearch>(ctx);
50 return c1->id() < c2->id();
56 json rep = json::array();
58 odb::transaction t(db->begin());
59 using Query = odb::query<Cred::Credential>;
60 std::string partial_name = req.at(
"partial_name");
61 std::set<Cred::CredentialPtr, CredentialComparator> creds;
68 for (
auto i = 0u; i < partial_name.length(); ++i)
70 auto partial_name_copy = partial_name;
71 partial_name_copy[i] = std::toupper(partial_name[i]);
72 Query q(Query::alias.like(
"%" + partial_name_copy +
"%"));
73 auto results = db->query(q);
74 for (
const auto &cred : results)
82 Query q(Query::alias.like(
"%" + partial_name +
"%"));
83 auto results = db->query(q);
84 for (
const auto &cred : results)
91 for (
const auto &cred : creds)
96 {
"alias", cred->alias()},
98 rep.push_back(result_json);
104 std::vector<ActionActionParam>
107 std::vector<ActionActionParam> perm_;
The base class for API method handler implementation.
std::vector< ActionActionParam > required_permission(const json &req) const override
Return a list of "Action" / "ActionParam" that must pass before the request is processed.
static std::string type_name(const Cred::ICredential &in)
Returns the "type-name" of the credential.
An ODB enabled credential object.
This is the header file for a generated source file, GitSHA1.cpp.
CredentialSearch(RequestContext ctx)
static MethodHandlerUPtr create(RequestContext)
std::unique_ptr< MethodHandler > MethodHandlerUPtr
odb::query< Tools::LogEntry > Query
virtual json process_impl(const json &req) override
The API method implementation.
All modules that provides features to Leosac shall be in this namespace.
#define ASSERT_LOG(cond, msg)
bool operator()(const Cred::CredentialPtr &c1, const Cred::CredentialPtr &c2)
std::shared_ptr< Credential > CredentialPtr
Holds valuable pointer to provide context to a request.
std::shared_ptr< odb::database > DBPtr