]> git.proxmox.com Git - pmg-api.git/commitdiff
start implementation of fetchmail api
authorDietmar Maurer <dietmar@proxmox.com>
Wed, 18 Oct 2017 05:51:39 +0000 (07:51 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Wed, 18 Oct 2017 05:51:39 +0000 (07:51 +0200)
Makefile
PMG/API2/Config.pm
PMG/API2/Fetchmail.pm [new file with mode: 0644]

index 9967e88206572dda64a2dd4b9a2920a7d948b708..2195b92055c76a1f71919b6f7844e957e70b8354 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -123,6 +123,7 @@ LIBSOURCES =                                \
        PMG/API2/Tasks.pm               \
        PMG/API2/LDAP.pm                \
        PMG/API2/Domains.pm             \
+       PMG/API2/Fetchmail.pm           \
        PMG/API2/Users.pm               \
        PMG/API2/Transport.pm           \
        PMG/API2/MyNetworks.pm          \
index c8e71194dc2028d077a5f580ca2d2e5f48735baa..e0bf2c16ec16fba3c51933124d3c350ec981b717 100644 (file)
@@ -21,6 +21,7 @@ use PMG::API2::Cluster;
 use PMG::API2::MyNetworks;
 use PMG::API2::SMTPWhitelist;
 use PMG::API2::MimeTypes;
+use PMG::API2::Fetchmail;
 
 use base qw(PVE::RESTHandler);
 
@@ -44,6 +45,11 @@ __PACKAGE__->register_method ({
 __PACKAGE__->register_method ({
     subclass => "PMG::API2::Domains",
     path => 'domains',
+                             });
+
+__PACKAGE__->register_method ({
+    subclass => "PMG::API2::Fetchmail",
+    path => 'fetchmail',
 });
 
 __PACKAGE__->register_method ({
@@ -99,6 +105,7 @@ __PACKAGE__->register_method ({
        push @$res, { section => 'mimetypes' };
        push @$res, { section => 'users' };
        push @$res, { section => 'domains' };
+       push @$res, { section => 'fetchmail' };
        push @$res, { section => 'cluster' };
        push @$res, { section => 'ruledb' };
        push @$res, { section => 'transport' };
diff --git a/PMG/API2/Fetchmail.pm b/PMG/API2/Fetchmail.pm
new file mode 100644 (file)
index 0000000..291424b
--- /dev/null
@@ -0,0 +1,54 @@
+package PMG::API2::Fetchmail;
+
+use strict;
+use warnings;
+use Data::Dumper;
+
+use PVE::SafeSyslog;
+use PVE::Tools qw(extract_param);
+use PVE::JSONSchema qw(get_standard_option);
+use PVE::RESTHandler;
+use PVE::INotify;
+
+use PMG::Config;
+use PMG::Fetchmail;
+
+use base qw(PVE::RESTHandler);
+
+__PACKAGE__->register_method ({
+    name => 'index',
+    path => '',
+    method => 'GET',
+    description => "List fetchmail users.",
+    permissions => { check => [ 'admin', 'audit' ] },
+    proxyto => 'master',
+    parameters => {
+       additionalProperties => 0,
+       properties => {},
+    },
+    returns => {
+       type => 'array',
+       items => {
+           type => "object",
+           properties => {
+               id => { type => 'string'},
+               target => { type => 'string'},
+           },
+       },
+       links => [ { rel => 'child', href => "{id}" } ],
+    },
+    code => sub {
+       my ($param) = @_;
+
+       my $fmcfg = PVE::INotify::read_file('fetchmailrc');
+
+       my $res = [];
+
+       foreach my $id (sort keys %$fmcfg) {
+           push @$res, $fmcfg->{$id};
+       }
+
+       return $res;
+    }});
+
+1;