public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox-backup] api2/node/journal: fix parameter extraction of /nodes/node/journal
@ 2021-05-25 11:19 Dominik Csapak
  2021-05-25 11:27 ` [pbs-devel] applied: " Thomas Lamprecht
  0 siblings, 1 reply; 2+ messages in thread
From: Dominik Csapak @ 2021-05-25 11:19 UTC (permalink / raw)
  To: pbs-devel

by extracting them via the api macro into the function signature

this fixes an issue, where giving 'since' and 'until' where not
used since we tried to extract them as 'str' while they were numbers.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 src/api2/node/journal.rs | 25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/src/api2/node/journal.rs b/src/api2/node/journal.rs
index 3d28a472..c5a41bda 100644
--- a/src/api2/node/journal.rs
+++ b/src/api2/node/journal.rs
@@ -60,36 +60,41 @@ use crate::config::acl::PRIV_SYS_AUDIT;
 )]
 /// Read syslog entries.
 fn get_journal(
-    param: Value,
+    since: Option<i64>,
+    until: Option<i64>,
+    lastentries: Option<u64>,
+    startcursor: Option<String>,
+    endcursor: Option<String>,
+    _param: Value,
     _info: &ApiMethod,
     _rpcenv: &mut dyn RpcEnvironment,
 ) -> Result<Value, Error> {
 
     let mut args = vec![];
 
-    if let Some(lastentries) = param["lastentries"].as_u64() {
+    if let Some(lastentries) = lastentries {
         args.push(String::from("-n"));
         args.push(format!("{}", lastentries));
     }
 
-    if let Some(since) = param["since"].as_str() {
+    if let Some(since) = since {
         args.push(String::from("-b"));
-        args.push(since.to_owned());
+        args.push(since.to_string());
     }
 
-    if let Some(until) = param["until"].as_str() {
+    if let Some(until) = until {
         args.push(String::from("-e"));
-        args.push(until.to_owned());
+        args.push(until.to_string());
     }
 
-    if let Some(startcursor) = param["startcursor"].as_str() {
+    if let Some(startcursor) = startcursor {
         args.push(String::from("-f"));
-        args.push(startcursor.to_owned());
+        args.push(startcursor);
     }
 
-    if let Some(endcursor) = param["endcursor"].as_str() {
+    if let Some(endcursor) = endcursor {
         args.push(String::from("-t"));
-        args.push(endcursor.to_owned());
+        args.push(endcursor);
     }
 
     let mut lines: Vec<String> = vec![];
-- 
2.20.1





^ permalink raw reply	[flat|nested] 2+ messages in thread

* [pbs-devel] applied: [PATCH proxmox-backup] api2/node/journal: fix parameter extraction of /nodes/node/journal
  2021-05-25 11:19 [pbs-devel] [PATCH proxmox-backup] api2/node/journal: fix parameter extraction of /nodes/node/journal Dominik Csapak
@ 2021-05-25 11:27 ` Thomas Lamprecht
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Lamprecht @ 2021-05-25 11:27 UTC (permalink / raw)
  To: Proxmox Backup Server development discussion, Dominik Csapak

On 25.05.21 13:19, Dominik Csapak wrote:
> by extracting them via the api macro into the function signature
> 
> this fixes an issue, where giving 'since' and 'until' where not
> used since we tried to extract them as 'str' while they were numbers.
> 
> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
> ---
>  src/api2/node/journal.rs | 25 +++++++++++++++----------
>  1 file changed, 15 insertions(+), 10 deletions(-)
> 
>

applied, thanks!




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-05-25 11:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-25 11:19 [pbs-devel] [PATCH proxmox-backup] api2/node/journal: fix parameter extraction of /nodes/node/journal Dominik Csapak
2021-05-25 11:27 ` [pbs-devel] applied: " Thomas Lamprecht

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal