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 B99B670909 for ; Mon, 6 Sep 2021 12:58:30 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id ACE33F956 for ; Mon, 6 Sep 2021 12:58:00 +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 54BCBF8DD for ; Mon, 6 Sep 2021 12:57:57 +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 183A5445C2 for ; Mon, 6 Sep 2021 12:57:57 +0200 (CEST) From: Dominik Csapak To: pbs-devel@lists.proxmox.com Date: Mon, 6 Sep 2021 12:57:52 +0200 Message-Id: <20210906105755.2651203-10-d.csapak@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210906105755.2651203-1-d.csapak@proxmox.com> References: <20210906105755.2651203-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.433 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: [pbs-devel] [PATCH proxmox-backup 09/12] proxmox-backup-client: add 'protected update command' X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Sep 2021 10:58:30 -0000 Signed-off-by: Dominik Csapak --- proxmox-backup-client/src/snapshot.rs | 51 +++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/proxmox-backup-client/src/snapshot.rs b/proxmox-backup-client/src/snapshot.rs index b63e84a6..fbf91f1b 100644 --- a/proxmox-backup-client/src/snapshot.rs +++ b/proxmox-backup-client/src/snapshot.rs @@ -358,6 +358,56 @@ async fn update_notes(param: Value) -> Result { Ok(Value::Null) } +#[api( + input: { + properties: { + repository: { + schema: REPO_URL_SCHEMA, + optional: true, + }, + snapshot: { + type: String, + description: "Snapshot path.", + }, + protected: { + type: bool, + description: "The protection status.", + }, + } + } +)] +/// Update Protection Status of a snapshot +async fn update_protection(protected: bool, param: Value) -> Result { + let repo = extract_repository_from_value(¶m)?; + let path = required_string_param(¶m, "snapshot")?; + + let snapshot: BackupDir = path.parse()?; + let mut client = connect(&repo)?; + + let path = format!("api2/json/admin/datastore/{}/protected", repo.store()); + + let args = json!({ + "backup-type": snapshot.group().backup_type(), + "backup-id": snapshot.group().backup_id(), + "backup-time": snapshot.backup_time(), + "protected": protected, + }); + + client.put(&path, Some(args)).await?; + + Ok(Value::Null) +} + +fn protected_cli() -> CliCommandMap { + CliCommandMap::new() + .insert( + "update", + CliCommand::new(&API_METHOD_UPDATE_PROTECTION) + .arg_param(&["snapshot", "protected"]) + .completion_cb("snapshot", complete_backup_snapshot), + ) +} + fn notes_cli() -> CliCommandMap { CliCommandMap::new() .insert( @@ -377,6 +427,7 @@ fn notes_cli() -> CliCommandMap { pub fn snapshot_mgtm_cli() -> CliCommandMap { CliCommandMap::new() .insert("notes", notes_cli()) + .insert("protected", protected_cli()) .insert( "list", CliCommand::new(&API_METHOD_LIST_SNAPSHOTS) -- 2.30.2