From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 1BA5775263 for ; Wed, 23 Jun 2021 15:39:49 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 1C183B752 for ; Wed, 23 Jun 2021 15:39:17 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 0E398B665 for ; Wed, 23 Jun 2021 15:39:12 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id D23EE42F75 for ; Wed, 23 Jun 2021 15:39:11 +0200 (CEST) From: Fabian Ebner To: pve-devel@lists.proxmox.com Date: Wed, 23 Jun 2021 15:39:03 +0200 Message-Id: <20210623133904.174072-11-f.ebner@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210623133904.174072-1-f.ebner@proxmox.com> References: <20210623133904.174072-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.679 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH v7 pve-manager 2/3] api: apt: add PUT and POST handler for repositories X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Jun 2021 13:39:49 -0000 To allow adding/modifying them. Currently the only possible modification is enable/disable. Signed-off-by: Fabian Ebner --- New in v7. PVE/API2/APT.pm | 88 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/PVE/API2/APT.pm b/PVE/API2/APT.pm index 36d0e67a..c58203a7 100644 --- a/PVE/API2/APT.pm +++ b/PVE/API2/APT.pm @@ -678,6 +678,94 @@ __PACKAGE__->register_method({ return PVE::RS::APT::Repositories::repositories(); }}); +__PACKAGE__->register_method({ + name => 'add_repository', + path => 'repositories', + method => 'PUT', + description => "Add a standard repository to the configuration", + permissions => { + check => ['perm', '/nodes/{node}', [ 'Sys.Modify' ]], + }, + protected => 1, + proxyto => 'node', + parameters => { + additionalProperties => 0, + properties => { + node => get_standard_option('pve-node'), + handle => { + type => 'string', + description => "Handle that identifies a repository.", + }, + digest => { + type => "string", + description => "Digest to detect modifications.", + maxLength => 80, + optional => 1, + }, + }, + }, + returns => { + type => 'null', + }, + code => sub { + my ($param) = @_; + + PVE::RS::APT::Repositories::add_repository($param->{handle}, $param->{digest}); + }}); + +__PACKAGE__->register_method({ + name => 'change_repository', + path => 'repositories', + method => 'POST', + description => "Change the properties of a repository. Currently only allows enabling/disabling.", + permissions => { + check => ['perm', '/nodes/{node}', [ 'Sys.Modify' ]], + }, + protected => 1, + proxyto => 'node', + parameters => { + additionalProperties => 0, + properties => { + node => get_standard_option('pve-node'), + path => { + type => 'string', + description => "Path to the containing file.", + }, + index => { + type => 'integer', + description => "Index within the file (starting from 0).", + }, + enabled => { + type => 'boolean', + description => "Whether the repository should be enabled or not.", + optional => 1, + }, + digest => { + type => "string", + description => "Digest to detect modifications.", + maxLength => 80, + optional => 1, + }, + }, + }, + returns => { + type => 'null', + }, + code => sub { + my ($param) = @_; + + my $options = { + enabled => $param->{enabled}, + }; + + PVE::RS::APT::Repositories::change_repository( + $param->{path}, + $param->{index}, + $options, + $param->{digest} + ); + }}); + __PACKAGE__->register_method({ name => 'versions', path => 'versions', -- 2.30.2