all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: Re: [pbs-devel] [PATCH backup] api: add world accessible ping dummy endpoint
Date: Wed, 21 Oct 2020 20:32:59 +0200	[thread overview]
Message-ID: <3c7181e5-9e21-9071-cfd5-dd97884e024e@proxmox.com> (raw)
In-Reply-To: <20201005145703.26529-1-t.lamprecht@proxmox.com>

On 05.10.20 16:57, Thomas Lamprecht wrote:
> This is indented to be used for the PVE storage library, replacing
> the missuse of the much more expensive status API call.
> 
> Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
> ---
> 
> I initially thought about adding this to the proxmox-backup-client as command,
> but it's not much of use there (user can just use the version command) and for
> the PVE integration we can do a simple http request with LWP, which is much
> cheaper than fork+exec the client there.
> 

any objections to this? Else I'd apply it as is..

>  src/api2.rs      |  2 ++
>  src/api2/ping.rs | 29 +++++++++++++++++++++++++++++
>  2 files changed, 31 insertions(+)
>  create mode 100644 src/api2/ping.rs
> 
> diff --git a/src/api2.rs b/src/api2.rs
> index 85d29ed2..27ef2975 100644
> --- a/src/api2.rs
> +++ b/src/api2.rs
> @@ -7,6 +7,7 @@ pub mod reader;
>  pub mod status;
>  pub mod types;
>  pub mod version;
> +pub mod ping;
>  pub mod pull;
>  mod helpers;
>  
> @@ -22,6 +23,7 @@ pub const SUBDIRS: SubdirMap = &[
>      ("backup", &backup::ROUTER),
>      ("config", &config::ROUTER),
>      ("nodes", &NODES_ROUTER),
> +    ("ping", &ping::ROUTER),
>      ("pull", &pull::ROUTER),
>      ("reader", &reader::ROUTER),
>      ("status", &status::ROUTER),
> diff --git a/src/api2/ping.rs b/src/api2/ping.rs
> new file mode 100644
> index 00000000..087b1377
> --- /dev/null
> +++ b/src/api2/ping.rs
> @@ -0,0 +1,29 @@
> +use anyhow::{Error};
> +use serde_json::{json, Value};
> +
> +use proxmox::api::{api, Router, Permission};
> +
> +#[api(
> +    returns: {
> +        description: "Dummy ping",
> +        type: Object,
> +        properties: {
> +            pong: {
> +                description: "Always true",
> +                type: bool,
> +            }
> +        }
> +    },
> +    access: {
> +        description: "Anyone can access this, because it's used for a cheap check if the API daemon is online.",
> +        permission: &Permission::World,
> +    }
> +)]
> +/// Dummy method which replies with `{ "pong": True }`
> +fn ping() -> Result<Value, Error> {
> +    Ok(json!({
> +        "pong": true,
> +    }))
> +}
> +pub const ROUTER: Router = Router::new()
> +    .get(&API_METHOD_PING);
> 





  reply	other threads:[~2020-10-21 18:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-05 14:57 Thomas Lamprecht
2020-10-21 18:32 ` Thomas Lamprecht [this message]
2020-10-22  8:18   ` Fabian Grünbichler
2020-10-22 10:34     ` Thomas Lamprecht
2020-10-24 17:14 ` [pbs-devel] applied: " Thomas Lamprecht

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=3c7181e5-9e21-9071-cfd5-dd97884e024e@proxmox.com \
    --to=t.lamprecht@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