[pve-devel] [RFC manager 6/7] api: APT: add call for repository check

Fabian Ebner f.ebner at proxmox.com
Wed Jan 20 11:01:42 CET 2021


Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
---
 PVE/API2/APT.pm | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

diff --git a/PVE/API2/APT.pm b/PVE/API2/APT.pm
index e92770ca..aa3d9b94 100644
--- a/PVE/API2/APT.pm
+++ b/PVE/API2/APT.pm
@@ -69,6 +69,7 @@ __PACKAGE__->register_method({
 	    { id => 'changelog' },
 	    { id => 'update' },
 	    { id => 'repositories' },
+	    { id => 'repositoriescheck' },
 	    { id => 'versions' },
 	];
 
@@ -547,6 +548,51 @@ __PACKAGE__->register_method({
 	return PVE::APT::list_repositories();
     }});
 
+__PACKAGE__->register_method({
+    name => 'repositoriescheck',
+    path => 'repositoriescheck',
+    method => 'GET',
+    proxyto => 'node',
+    description => "Check APT repositories.",
+    permissions => {
+	check => ['perm', '/nodes/{node}', [ 'Sys.Audit' ]],
+    },
+    parameters => {
+	additionalProperties => 0,
+	properties => {
+	    node => get_standard_option('pve-node'),
+	},
+    },
+    returns => {
+	type => "array",
+	description => "List of warnings.",
+	items => {
+	    type => "object",
+	    properties => {
+		path => {
+		    type => 'string',
+		    description => "Path to the file that defines the repository.",
+		    optional => 1,
+		},
+		number => {
+		    type => 'integer',
+		    description => "Line or stanza number.",
+		    optional => 1,
+		},
+		message => {
+		    type => 'string',
+		    description => "The warning message.",
+		},
+	    },
+	},
+    },
+    code => sub {
+	my ($param) = @_;
+
+	my $repos = PVE::APT::list_repositories();
+	return PVE::APT::check_repositories($repos, 'pve');
+    }});
+
 __PACKAGE__->register_method({
     name => 'versions', 
     path => 'versions', 
-- 
2.20.1






More information about the pve-devel mailing list