From: Dominik Csapak <d.csapak@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup 2/7] api2/status: add type- and statusfilter to tasks api call
Date: Mon, 5 Oct 2020 15:43:12 +0200 [thread overview]
Message-ID: <20201005134317.12425-2-d.csapak@proxmox.com> (raw)
In-Reply-To: <20201005134317.12425-1-d.csapak@proxmox.com>
we will use this for the pbs dashboard
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
src/api2/status.rs | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/src/api2/status.rs b/src/api2/status.rs
index fd40f14d..372b4822 100644
--- a/src/api2/status.rs
+++ b/src/api2/status.rs
@@ -17,6 +17,7 @@ use crate::api2::types::{
RRDMode,
RRDTimeFrameResolution,
TaskListItem,
+ TaskStateType,
Userid,
};
@@ -186,6 +187,19 @@ fn datastore_status(
description: "Only list tasks since this UNIX epoch.",
optional: true,
},
+ typefilter: {
+ optional: true,
+ type: String,
+ description: "Only list tasks, whose type contains this string.",
+ },
+ statusfilter: {
+ optional: true,
+ type: Array,
+ description: "Only list tasks which have any one of the listed status.",
+ items: {
+ type: TaskStateType,
+ },
+ },
},
},
returns: {
@@ -201,6 +215,8 @@ fn datastore_status(
/// List tasks.
pub fn list_tasks(
since: Option<i64>,
+ typefilter: Option<String>,
+ statusfilter: Option<Vec<TaskStateType>>,
_param: Value,
rpcenv: &mut dyn RpcEnvironment,
) -> Result<Vec<TaskListItem>, Error> {
@@ -223,6 +239,27 @@ pub fn list_tasks(
match info {
Ok(info) => {
if list_all || info.upid.userid == userid {
+ if let Some(filter) = &typefilter {
+ if !info.upid.worker_type.contains(filter) {
+ return None;
+ }
+ }
+
+ if let Some(filters) = &statusfilter {
+ if let Some(state) = &info.state {
+ let statetype = match state {
+ server::TaskState::OK { .. } => TaskStateType::OK,
+ server::TaskState::Unknown { .. } => TaskStateType::Unknown,
+ server::TaskState::Error { .. } => TaskStateType::Error,
+ server::TaskState::Warning { .. } => TaskStateType::Warning,
+ };
+
+ if !filters.contains(&statetype) {
+ return None;
+ }
+ }
+ }
+
Some(Ok(TaskListItem::from(info)))
} else {
None
--
2.20.1
next prev parent reply other threads:[~2020-10-05 13:43 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-05 13:43 [pbs-devel] [PATCH proxmox-backup 1/7] api2/types: add TaskStateType struct Dominik Csapak
2020-10-05 13:43 ` Dominik Csapak [this message]
2020-10-05 13:43 ` [pbs-devel] [PATCH proxmox-backup 3/7] ui: implment task history limit and make it configurable Dominik Csapak
2020-10-05 14:44 ` Thomas Lamprecht
2020-10-05 13:43 ` [pbs-devel] [PATCH proxmox-backup 4/7] ui: refactor render_icon code Dominik Csapak
2020-10-05 14:52 ` [pbs-devel] applied: " Thomas Lamprecht
2020-10-05 13:43 ` [pbs-devel] [PATCH proxmox-backup 5/7] ui: Dashboard/TaskSummary: refactor types and title Dominik Csapak
2020-10-05 14:52 ` Thomas Lamprecht
2020-10-06 6:56 ` Dominik Csapak
2020-10-05 13:43 ` [pbs-devel] [PATCH proxmox-backup 6/7] ui: Dashboard/TaskSummary: add Verifies to the Summary Dominik Csapak
2020-10-05 13:43 ` [pbs-devel] [PATCH proxmox-backup 7/7] ui: Dashboard/TaskSummary: show task overlay when clicking on a count Dominik Csapak
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=20201005134317.12425-2-d.csapak@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=pbs-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