all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Fabian Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH v7 pve-manager 1/3] api: apt: add call for repository information
Date: Wed, 23 Jun 2021 15:39:02 +0200	[thread overview]
Message-ID: <20210623133904.174072-10-f.ebner@proxmox.com> (raw)
In-Reply-To: <20210623133904.174072-1-f.ebner@proxmox.com>

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---

Dependency bump for pve-rs needed.

Changes from v6:
    * adapt to backend API changes
    * merged the checkrepositories call into this one
    * the call now also gives a list of standard repositories and their
      configuration status.

 PVE/API2/APT.pm | 200 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 200 insertions(+)

diff --git a/PVE/API2/APT.pm b/PVE/API2/APT.pm
index fb4954e7..36d0e67a 100644
--- a/PVE/API2/APT.pm
+++ b/PVE/API2/APT.pm
@@ -19,6 +19,7 @@ use PVE::INotify;
 use PVE::Exception;
 use PVE::RESTHandler;
 use PVE::RPCEnvironment;
+use PVE::RS::APT::Repositories;
 use PVE::API2Tools;
 
 use JSON;
@@ -66,6 +67,7 @@ __PACKAGE__->register_method({
 
 	my $res = [ 
 	    { id => 'changelog' },
+	    { id => 'repositories' },
 	    { id => 'update' },
 	    { id => 'versions' },
 	];
@@ -478,6 +480,204 @@ __PACKAGE__->register_method({
 	return $data;
     }});
 
+__PACKAGE__->register_method({
+    name => 'repositories',
+    path => 'repositories',
+    method => 'GET',
+    proxyto => 'node',
+    description => "Get APT repository information.",
+    permissions => {
+	check => ['perm', '/nodes/{node}', [ 'Sys.Audit' ]],
+    },
+    parameters => {
+	additionalProperties => 0,
+	properties => {
+	    node => get_standard_option('pve-node'),
+	},
+    },
+    returns => {
+	type => "object",
+	description => "Result from parsing the APT repository files in /etc/apt/.",
+	properties => {
+	    files => {
+		type => "array",
+		description => "List of parsed repository files.",
+		items => {
+		    type => "object",
+		    properties => {
+			path => {
+			    type => "string",
+			    description => "Path to the problematic file.",
+			},
+			'file-type' => {
+			    type => "string",
+			    enum => [ 'list', 'sources' ],
+			    description => "Format of the file.",
+			},
+			repositories => {
+			    type => "array",
+			    description => "The parsed repositories.",
+			    items => {
+				type => "object",
+				properties => {
+				    Types => {
+					type => "array",
+					description => "List of package types.",
+					items => {
+					    type => "string",
+					    enum => [ 'deb', 'deb-src' ],
+					},
+				    },
+				    URIs => {
+					description => "List of repository URIs.",
+					type => "array",
+					items => {
+					    type => "string",
+					},
+				    },
+				    Suites => {
+					type => "array",
+					description => "List of package distribuitions",
+					items => {
+					    type => "string",
+					},
+				    },
+				    Components => {
+					type => "array",
+					description => "List of repository components",
+					optional => 1, # not present if suite is absolute
+					items => {
+					    type => "string",
+					},
+				    },
+				    Options => {
+					type => "array",
+					description => "Additional options",
+					optional => 1,
+					items => {
+					    type => "object",
+					    properties => {
+						Key => {
+						    type => "string",
+						},
+						Values => {
+						    type => "array",
+						    items => {
+							type => "string",
+						    },
+						},
+					    },
+					},
+				    },
+				    Comment => {
+					type => "string",
+					description => "Associated comment",
+					optional => 1,
+				    },
+				    FileType => {
+					type => "string",
+					enum => [ 'list', 'sources' ],
+					description => "Format of the defining file.",
+				    },
+				    Enabled => {
+					type => "boolean",
+					description => "Whether the repository is enabled or not",
+				    },
+				},
+			    },
+			},
+			digest => {
+			    type => "array",
+			    description => "Digest of the file as bytes.",
+			    items => {
+				type => "integer",
+			    },
+			},
+		    },
+		},
+	    },
+	    errors => {
+		type => "array",
+		description => "List of problematic repository files.",
+		items => {
+		    type => "object",
+		    properties => {
+			path => {
+			    type => "string",
+			    description => "Path to the problematic file.",
+			},
+			error => {
+			    type => "string",
+			    description => "The error message",
+			},
+		    },
+		},
+	    },
+	    digest => {
+		type => "string",
+		description => "Common digest of all files.",
+	    },
+	    infos => {
+		type => "array",
+		description => "Additional information/warnings for APT repositories.",
+		items => {
+		    type => "object",
+		    properties => {
+			path => {
+			    type => "string",
+			    description => "Path to the associated file.",
+			},
+			index => {
+			    type => "string",
+			    description => "Index of the associated repository within the file.",
+			},
+			property => {
+			    type => "string",
+			    description => "Property from which the info originates.",
+			    optional => 1,
+			},
+			kind => {
+			    type => "string",
+			    description => "Kind of the information (e.g. warning).",
+			},
+			message => {
+			    type => "string",
+			    description => "Information message.",
+			}
+		    },
+		},
+	    },
+	    'standard-repos' => {
+		type => "array",
+		description => "List of standard repositories and their configuration status",
+		items => {
+		    type => "object",
+		    properties => {
+			handle => {
+			    type => "string",
+			    description => "Handle to identify the repository.",
+			},
+			name => {
+			    type => "string",
+			    description => "Full name of the repository.",
+			},
+			status => {
+			    type => "boolean",
+			    optional => 1,
+			    description => "Indicating enabled/disabled status, if the " .
+				"repository is configured.",
+			},
+		    },
+		},
+	    },
+	},
+    },
+    code => sub {
+	my ($param) = @_;
+
+	return PVE::RS::APT::Repositories::repositories();
+    }});
+
 __PACKAGE__->register_method({
     name => 'versions', 
     path => 'versions', 
-- 
2.30.2





  parent reply	other threads:[~2021-06-23 13:39 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-23 13:38 [pve-devel] [PATCH-SERIES v7] APT repositories API/UI Fabian Ebner
2021-06-23 13:38 ` [pve-devel] [PATCH v7 proxmox-apt 1/5] initial commit Fabian Ebner
2021-06-23 13:38 ` [pve-devel] [PATCH v7 proxmox-apt 2/5] add files for Debian packaging Fabian Ebner
2021-06-23 13:38 ` [pve-devel] [PATCH v7 proxmox-apt 3/5] add more functions to check repositories Fabian Ebner
2021-06-23 13:38 ` [pve-devel] [PATCH v7 proxmox-apt 4/5] add handling of Proxmox standard repositories Fabian Ebner
2021-06-23 13:38 ` [pve-devel] [PATCH v7 proxmox-apt 5/5] bump version to 0.2.0-1 Fabian Ebner
2021-06-23 13:38 ` [pve-devel] [PATCH v7 proxmox-widget-toolkit 1/2] add UI for APT repositories Fabian Ebner
2021-06-23 13:39 ` [pve-devel] [PATCH v7 proxmox-widget-toolkit 2/2] add buttons for add/enable/disable Fabian Ebner
2021-06-23 13:39 ` [pve-devel] [PATCH v7 pve-rs 1/1] add bindings for proxmox-apt Fabian Ebner
2021-06-30 19:17   ` [pve-devel] applied: " Thomas Lamprecht
2021-06-23 13:39 ` Fabian Ebner [this message]
2021-06-23 13:39 ` [pve-devel] [PATCH v7 pve-manager 2/3] api: apt: add PUT and POST handler for repositories Fabian Ebner
2021-06-23 13:39 ` [pve-devel] [PATCH v7 pve-manager 3/3] ui: add panel for listing APT repositories Fabian Ebner
2021-06-23 18:02 ` [pve-devel] partially-applied: [PATCH-SERIES v7] APT repositories API/UI Thomas Lamprecht
2021-07-05  6:51 ` [pve-devel] applied-series: " Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210623133904.174072-10-f.ebner@proxmox.com \
    --to=f.ebner@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal