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 E9C4960E3E for ; Mon, 19 Oct 2020 21:02:57 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id E116A2F1BD for ; Mon, 19 Oct 2020 21:02:27 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (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 23C9B2F11D for ; Mon, 19 Oct 2020 21:02:22 +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 DD69945E2D for ; Mon, 19 Oct 2020 21:02:21 +0200 (CEST) From: Stoiko Ivanov To: pmg-devel@lists.proxmox.com Date: Mon, 19 Oct 2020 21:02:01 +0200 Message-Id: <20201019190209.11495-5-s.ivanov@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201019190209.11495-1-s.ivanov@proxmox.com> References: <20201019190209.11495-1-s.ivanov@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.324 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_SBL 0.644 Contains an URL's NS IP listed in the Spamhaus SBL blocklist [backup.pm] URIBL_SBL_A 0.1 Contains URL's A record listed in the Spamhaus SBL blocklist [backup.pm] Subject: [pmg-devel] [RFC pmg-api 04/12] Backup: push restore options to PMG::Backup X-BeenThere: pmg-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Mail Gateway development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Oct 2020 19:02:58 -0000 that way they can be reused for the PBS restore API call Signed-off-by: Stoiko Ivanov --- src/PMG/API2/Backup.pm | 19 +------------------ src/PMG/Backup.pm | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/src/PMG/API2/Backup.pm b/src/PMG/API2/Backup.pm index 08c06b5..4ea28d1 100644 --- a/src/PMG/API2/Backup.pm +++ b/src/PMG/API2/Backup.pm @@ -202,26 +202,9 @@ __PACKAGE__->register_method ({ parameters => { additionalProperties => 0, properties => { + PMG::Backup::get_restore_options(), node => get_standard_option('pve-node'), filename => $backup_filename_property, - config => { - description => "Restore system configuration.", - type => 'boolean', - optional => 1, - default => 0, - }, - database => { - description => "Restore the rule database. This is the default.", - type => 'boolean', - optional => 1, - default => 1, - }, - statistic => { - description => "Restore statistic databases. Only considered when you restore the 'database'.", - type => 'boolean', - optional => 1, - default => 0, - }, }, }, returns => { type => "string" }, diff --git a/src/PMG/Backup.pm b/src/PMG/Backup.pm index fd7274c..aba17ad 100644 --- a/src/PMG/Backup.pm +++ b/src/PMG/Backup.pm @@ -6,6 +6,7 @@ use Data::Dumper; use File::Basename; use File::Path; +use PVE::JSONSchema qw(get_standard_option); use PVE::Tools; use PMG::pmgcfg; @@ -14,6 +15,29 @@ use PMG::Utils qw(postgres_admin_cmd); my $sa_custom_config_fn = "/etc/mail/spamassassin/custom.cf"; +sub get_restore_options { + return ( + node => get_standard_option('pve-node'), + config => { + description => "Restore system configuration.", + type => 'boolean', + optional => 1, + default => 0, + }, + database => { + description => "Restore the rule database. This is the default.", + type => 'boolean', + optional => 1, + default => 1, + }, + statistic => { + description => "Restore statistic databases. Only considered when you restore the 'database'.", + type => 'boolean', + optional => 1, + default => 0, + }); +} + sub dump_table { my ($dbh, $table, $ofh, $seq, $seqcol) = @_; -- 2.20.1