[SOLVED] using pmgsh to query the quarantine (or anything)

IEM

Well-Known Member
Sep 4, 2018
71
11
48
49
Austria
i'm having a hard time, doing anything useful with `pmgsh` (besides interacting with the config; which i find easier to either do directly on the filesystem or via the webinterface).

esp. i'd like to query the quarantine database (e.g. which receivers have quarantined emails; list basic information about quarantined emails), but fail to do so. e.g:

Code:
# pmgsh get quarantine/quarusers
200 OK
[
   {
      "mail" : "somebody@example.com"
   },
   {
      "mail" : "another@example.com"
   }
]

this looks ok (note that the email-addresses are made up, just to illustrate my point; the actual query gives me 2 results), but in the webinterface i see about 50 different email-accounts for which ther are quarantine emails.

so i try to get some data:

Code:
# pmgsh get quarantine/content
400 Parameter verification failed.
id: property is missing and it is not optional
get quarantine/content --id <string> [OPTIONS]
# pmgsh get quarantine/content --id "somebody@example.com"
400 Parameter verification failed.
id: value does not match the regex pattern
get quarantine/content --id <string> [OPTIONS]
 pmgsh help quarantine/content
help [path] [--verbose]
cd [path]
ls [path]

Undefined subroutine &main::1 called at /usr/share/perl5/PVE/RESTHandler.pm line 630.
#

wtf? i have absolutely no idea how to properly get `quarantine/content`. it seems to require some obscure ID, but what that might be i have no idea (using an email-address obviously failed).
the online help only ever gives me "Undefined subroutine" errors.

I also tried accessing `quarantine/spam` with equally little success:

Code:
# pmgsh get quarantine/spam
400 Parameter verification failed.
pmail: parameter required with role 'root'
get quarantine/spam  [OPTIONS]
# pmgsh get quarantine/spam somebody@example.com
400 too many arguments
get quarantine/spam  [OPTIONS]
# pmgsh ls quarantine/spam
resource does not define child links
# pmgsh help quarantine/spam
help [path] [--verbose]
cd [path]
ls [path]

Undefined subroutine &main::1 called at /usr/share/perl5/PVE/RESTHandler.pm line 630.
#


so: how can i effectively use `pmgsh`? which paths can i access and how? which parameters do i need to pass?
 
i guess what you want are

pmgsh get /quarantine/spamusers # get users for which there are mails in the spam quarantine in the last 24 hours; can be modified with -starttime/-endtime (both need a unix epoch)
pmgsh get /quarantine/spam -pmail 'user@domain.com' # for the quarantine of the last 24 hours (can be modified with -starttime/-endtime) of 'user@domain.com'. this contains a field 'id'
pmgsh get /quarantine/content -id 'idfromapicallbefore' # get the content of the spam mail with id 'idfromapicallbefore'

see also https://ip-of-your-pmg:8006/pmg-docs/api-viewer/index.html