mirror of
https://github.com/outbackdingo/sysadm.git
synced 2026-01-27 10:20:26 +00:00
Add a new API call for sysadm/pkg: "action"="pkg_search"
This will search with the given "search_term" (required) and return the basic info on all results found.
Optional inputs:
1) "repo" - may be used to specifiy searching a particular repository (local DB if not specified).
2) "category" - may be used to restrict searches to a particular category.
REST Request:
-------------------------------
PUT /sysadm/pkg
{
"repo" : "pcbsd-major",
"category" : "www",
"action" : "pkg_search",
"search_term" : "fire"
}
WebSocket Request:
-------------------------------
{
"id" : "fooid",
"namespace" : "sysadm",
"name" : "pkg",
"args" : {
"action" : "pkg_search",
"search_term" : "fire",
"category" : "www",
"repo" : "pcbsd-major"
}
}
Response:
-------------------------------
{
"args": {
"pkg_search": {
"www/firefox": {
"arch": "FreeBSD:11:amd64",
"cksum": "cc72c379afbd66d152cf06b7d2a14ada413f338071ecb9b084899c94d39f951e",
"comment": "Web browser based on the browser portion of Mozilla",
"cpe": "cpe:2.3:a:mozilla:firefox:45.0:::::freebsd11:x64:1",
"dep_formula": "",
"desc": "Mozilla Firefox is a free and open source web browser descended from the\nMozilla Application Suite. It is small, fast and easy to use, and offers\nmany advanced features:\n\n o Popup Blocking\n o Tabbed Browsing\n o Live Bookmarks (ie. RSS)\n o Extensions\n o Themes\n o FastFind\n o Improved Security\n\nWWW: http://www.mozilla.com/firefox",
"flatsize": "96435169",
"icon": "\\\\\\\"http://www.pcbsd.org/appcafe/icons/www_firefox.png\\\\\\\"",
"id": "12147",
"licenselogic": "1",
"maintainer": "gecko@FreeBSD.org",
"manifestdigest": "2$0$hcbb9x7urbs9nw1e44chw9bwxn339983b6q9mixxdn5ghdwuh9ny",
"name": "firefox",
"no_provide_shlib": "yes",
"olddigest": "",
"origin": "www/firefox",
"osversion": "",
"path": "All/firefox-45.0_1,1.txz",
"pkg_format_version": "",
"pkgsize": "39935776",
"prefix": "/usr/local",
"screen1": "\\\\\\\"http://www.pcbsd.org/appcafe/screenshots/www/firefox/screen1.png\\\\\\\"",
"screen2": "\\\\\\\"http://www.pcbsd.org/appcafe/screenshots/www/firefox/screen2.png\\\\\\\"",
"version": "45.0_1,1",
"www": "http://www.mozilla.com/firefox"
},
"www/firefox-esr": {
"arch": "FreeBSD:11:amd64",
"cksum": "811545c4da089b52db54ddee04af2ea8c439eb12e708f478b09141cdcca7aec5",
"comment": "Web browser based on the browser portion of Mozilla",
"cpe": "cpe:2.3:a:mozilla:firefox_esr:38.7.0:::::freebsd11:x64",
"dep_formula": "",
"desc": "Mozilla Firefox is a free and open source web browser descended from the\nMozilla Application Suite. It is small, fast and easy to use, and offers\nmany advanced features:\n\n o Popup Blocking\n o Tabbed Browsing\n o Live Bookmarks (ie. RSS)\n o Extensions\n o Themes\n o FastFind\n o Improved Security\n\nWWW: http://www.mozilla.com/firefox",
"flatsize": "86940998",
"icon": "\\\\\\\"http://www.pcbsd.org/appcafe/icons/www_firefox-esr.png\\\\\\\"",
"id": "656",
"licenselogic": "1",
"maintainer": "gecko@FreeBSD.org",
"manifestdigest": "2$0$km1kyyxoae47gyhp9gx7wz7pcnsn6jnc8yxgpz63iyynaxi7ia8y",
"name": "firefox-esr",
"no_provide_shlib": "yes",
"olddigest": "",
"origin": "www/firefox-esr",
"osversion": "",
"path": "All/firefox-esr-38.7.0,1.txz",
"pkg_format_version": "",
"pkgsize": "36352676",
"prefix": "/usr/local",
"version": "38.7.0,1",
"www": "http://www.mozilla.com/firefox"
},
"www/firefox-esr-i18n": {
"arch": "FreeBSD:11:*",
"cksum": "c389f2960fa77548435e0b905b3ef6ddb48957b76c2d8346de1f9f97dd7b23ca",
"comment": "Localized interface for Firefox",
"dep_formula": "",
"desc": "Language packs for Firefox\n\nWWW: http://www.mozilla.org/projects/l10n/",
"flatsize": "102671800",
"id": "17350",
"licenselogic": "1",
"maintainer": "gecko@FreeBSD.org",
"manifestdigest": "2$0$wzmx16rcynpdej5eckeg6c8w8z6r7oha86cmjfth4pnfu9iojdmb",
"name": "firefox-esr-i18n",
"olddigest": "",
"origin": "www/firefox-esr-i18n",
"osversion": "",
"path": "All/firefox-esr-i18n-38.7.0.txz",
"pkg_format_version": "",
"pkgsize": "10449532",
"prefix": "/usr/local",
"version": "38.7.0",
"www": "http://www.mozilla.org/projects/l10n/"
},
"www/firefox-i18n": {
"arch": "FreeBSD:11:*",
"cksum": "11ca74215bb2c9032a316692b02d4b675cc2102b0e6c9c9f79e85cb6a292e689",
"comment": "Localized interface for Firefox",
"dep_formula": "",
"desc": "Language packs for Firefox\n\nWWW: http://www.mozilla.org/projects/l10n/",
"flatsize": "107852121",
"id": "11462",
"licenselogic": "1",
"maintainer": "gecko@FreeBSD.org",
"manifestdigest": "2$0$hozjo4sqt3kn4rqak7hfr4zubt3yahigcnhmbwad7xtuqt1qxntb",
"name": "firefox-i18n",
"olddigest": "",
"origin": "www/firefox-i18n",
"osversion": "",
"path": "All/firefox-i18n-45.0.txz",
"pkg_format_version": "",
"pkgsize": "10295024",
"prefix": "/usr/local",
"version": "45.0",
"www": "http://www.mozilla.org/projects/l10n/"
},
"www/firefox-pulse": {
"arch": "FreeBSD:11:amd64",
"cksum": "76bcc4096c378a647c4517ab8fac64d3ecbf2c08a1e47ab0eb9061d95d86c195",
"comment": "Web browser based on the browser portion of Mozilla",
"cpe": "cpe:2.3:a:mozilla:firefox:45.0:::::freebsd11:x64:1",
"dep_formula": "",
"desc": "Mozilla Firefox is a free and open source web browser descended from the\nMozilla Application Suite. It is small, fast and easy to use, and offers\nmany advanced features:\n\n o Popup Blocking\n o Tabbed Browsing\n o Live Bookmarks (ie. RSS)\n o Extensions\n o Themes\n o FastFind\n o Improved Security\n\nWWW: http://www.mozilla.com/firefox",
"flatsize": "96438909",
"icon": "\\\\\\\"http://www.pcbsd.org/appcafe/icons/www_firefox-pulse.png\\\\\\\"",
"id": "5534",
"licenselogic": "1",
"maintainer": "gecko@FreeBSD.org",
"manifestdigest": "2$0$8mb8qqmcqu3ja8uy4x9nqgyeennjemumrb1q6ugyege76i4rdefb",
"name": "firefox-pulse",
"no_provide_shlib": "yes",
"olddigest": "",
"origin": "www/firefox-pulse",
"osversion": "",
"path": "All/firefox-pulse-45.0_1,1.txz",
"pkg_format_version": "",
"pkgsize": "39959876",
"prefix": "/usr/local",
"screen1": "\\\\\\\"http://www.pcbsd.org/appcafe/screenshots/www/firefox/screen1.png\\\\\\\"",
"screen2": "\\\\\\\"http://www.pcbsd.org/appcafe/screenshots/www/firefox/screen2.png\\\\\\\"",
"version": "45.0_1,1",
"www": "http://www.mozilla.com/firefox"
}
}
},
"id": "fooid",
"name": "response",
"namespace": "sysadm"
}
This commit is contained in:
@@ -699,23 +699,39 @@ RestOutputStruct::ExitCode WebSocket::EvaluateSysadmPkgRequest(const QJsonValue
|
||||
//OPTIONAL: "repo" (uses local repo database by default)
|
||||
QString repo = "local";
|
||||
if(in_args.toObject().contains("repo")){ repo = in_args.toObject().value("repo").toString(); }
|
||||
//OPTIONAL: "pkg_origins" (defaults to everything for listing functions)
|
||||
QStringList pkgs;
|
||||
if(in_args.toObject().contains("pkg_origins")){
|
||||
if(in_args.toObject().value("pkg_origins").isString()){ pkgs << in_args.toObject().value("pkg_origins").toString(); }
|
||||
else if(in_args.toObject().value("pkg_origins").isArray()){ pkgs = JsonArrayToStringList(in_args.toObject().value("pkg_origins").toArray()); }
|
||||
}
|
||||
//OPTIONAL: "category" (only used if "pkg_origins" is not specified)
|
||||
QString cat;
|
||||
if(in_args.toObject().contains("category")){ cat = in_args.toObject().value("category").toString(); }
|
||||
//OPTIONAL: "result"
|
||||
bool fullresults = true;
|
||||
if(in_args.toObject().contains("result")){ fullresults = (in_args.toObject().value("result").toString()=="full"); }
|
||||
|
||||
//Parse
|
||||
if(act=="pkg_info"){
|
||||
//OPTIONAL: "pkg_origins" (defaults to everything for listing functions)
|
||||
QStringList pkgs;
|
||||
if(in_args.toObject().contains("pkg_origins")){
|
||||
if(in_args.toObject().value("pkg_origins").isString()){ pkgs << in_args.toObject().value("pkg_origins").toString(); }
|
||||
else if(in_args.toObject().value("pkg_origins").isArray()){ pkgs = JsonArrayToStringList(in_args.toObject().value("pkg_origins").toArray()); }
|
||||
}
|
||||
//OPTIONAL: "result"
|
||||
bool fullresults = true;
|
||||
if(in_args.toObject().contains("result")){ fullresults = (in_args.toObject().value("result").toString()=="full"); }
|
||||
//Now run the info fetch routine
|
||||
QJsonObject info = sysadm::PKG::pkg_info(pkgs, repo, cat, fullresults);
|
||||
if(!info.isEmpty()){ out->insert("pkg_info",info); }
|
||||
else{ return RestOutputStruct::NOCONTENT; }
|
||||
|
||||
|
||||
}else if(act=="pkg_search"){
|
||||
//REQUIRED
|
||||
QString srch;
|
||||
if(in_args.toObject().contains("search_term")){ srch = in_args.toObject().value("search_term").toString(); }
|
||||
if(srch.isEmpty()){ return RestOutputStruct::BADREQUEST; }
|
||||
QStringList pkgs = sysadm::PKG::pkg_search(repo, srch, cat);
|
||||
if(!pkgs.isEmpty()){
|
||||
QJsonObject info = sysadm::PKG::pkg_info(pkgs, repo, cat, false); //always do simple results for a search
|
||||
if(!info.isEmpty()){ out->insert("pkg_search",info); }
|
||||
}else{
|
||||
return RestOutputStruct::NOCONTENT;
|
||||
}
|
||||
}else{
|
||||
//unknown action
|
||||
return RestOutputStruct::BADREQUEST;
|
||||
|
||||
Reference in New Issue
Block a user