public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dietmar Maurer <dietmar@proxmox.com>
To: Proxmox Backup Server development discussion
	<pbs-devel@lists.proxmox.com>,  Dylan Whyte <d.whyte@proxmox.com>
Subject: Re: [pbs-devel] [PATCH proxmox-backup 2/2] fix #2847: proxmox-backup-client: add change-owner cmd
Date: Wed, 14 Oct 2020 08:56:48 +0200 (CEST)	[thread overview]
Message-ID: <896602122.89.1602658608953@webmail.proxmox.com> (raw)
In-Reply-To: <20201013085841.22773-2-d.whyte@proxmox.com>

applied, adopted to previous api changes

> On 10/13/2020 10:58 AM Dylan Whyte <d.whyte@proxmox.com> wrote:
> 
>  
> This adds a change-owner command to proxmox-backup-client,
> that allows a caller with datastore modify privileges
> to change the owner of a backup-group.
> 
> Signed-off-by: Dylan Whyte <d.whyte@proxmox.com>
> ---
>  src/bin/proxmox-backup-client.rs | 43 +++++++++++++++++++++++++++++++-
>  1 file changed, 42 insertions(+), 1 deletion(-)
> 
> diff --git a/src/bin/proxmox-backup-client.rs b/src/bin/proxmox-backup-client.rs
> index 97398f49..90cb8378 100644
> --- a/src/bin/proxmox-backup-client.rs
> +++ b/src/bin/proxmox-backup-client.rs
> @@ -412,6 +412,41 @@ async fn list_backup_groups(param: Value) -> Result<Value, Error> {
>      Ok(Value::Null)
>  }
>  
> +#[api(
> +   input: {
> +        properties: {
> +            repository: {
> +                schema: REPO_URL_SCHEMA,
> +                optional: true,
> +            },
> +            group: {
> +                type: String,
> +                description: "Backup group.",
> +            },
> +            "new-owner": {
> +                type: String,

 type: Userid

> +                description: "Userid to transfer ownership to",
> +            },
> +        }
> +   }
> +)]
> +/// Change owner of a backup group
> +async fn change_backup_owner(mut param: Value) -> Result<(), Error> {
> +
> +    let repo = extract_repository_from_value(&param)?;
> +
> +    let mut client = connect(repo.host(), repo.port(), repo.user())?;
> +
> +    param.as_object_mut().unwrap().remove("repository");
> +
> +    let path = format!("api2/json/admin/datastore/{}/change-owner", repo.store());
> +    client.post(&path, Some(param)).await?;
> +
> +    record_repository(&repo);
> +
> +    Ok(())
> +}
> +
>  #[api(
>     input: {
>          properties: {
> @@ -1967,6 +2002,11 @@ fn main() {
>      let version_cmd_def = CliCommand::new(&API_METHOD_API_VERSION)
>          .completion_cb("repository", complete_repository);
>  
> +    let change_owner_cmd_def = CliCommand::new(&API_METHOD_CHANGE_BACKUP_OWNER)
> +        .arg_param(&["group", "new-owner"])
> +        .completion_cb("group", complete_backup_group)
 
added:  .completion_cb("new-owner",  complete_user_name)
 
> +        .completion_cb("repository", complete_repository);
> +
>      let cmd_def = CliCommandMap::new()
>          .insert("backup", backup_cmd_def)
>          .insert("upload-log", upload_log_cmd_def)
> @@ -1987,7 +2027,8 @@ fn main() {
>          .insert("catalog", catalog_mgmt_cli())
>          .insert("task", task_mgmt_cli())
>          .insert("version", version_cmd_def)
> -        .insert("benchmark", benchmark_cmd_def);
> +        .insert("benchmark", benchmark_cmd_def)
> +        .insert("change-owner", change_owner_cmd_def);
>  
>      let rpcenv = CliEnvironment::new();
>      run_cli_command(cmd_def, rpcenv, Some(|future| {
> -- 
> 2.20.1
> 
> 
> 
> _______________________________________________
> pbs-devel mailing list
> pbs-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel




  reply	other threads:[~2020-10-14  6:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-13  8:58 [pbs-devel] [PATCH proxmox-backup 1/2] fix #2847: api: datastore: change backup owner Dylan Whyte
2020-10-13  8:58 ` [pbs-devel] [PATCH proxmox-backup 2/2] fix #2847: proxmox-backup-client: add change-owner cmd Dylan Whyte
2020-10-14  6:56   ` Dietmar Maurer [this message]
2020-10-14  6:33 ` [pbs-devel] [PATCH proxmox-backup 1/2] fix #2847: api: datastore: change backup owner Dietmar Maurer

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=896602122.89.1602658608953@webmail.proxmox.com \
    --to=dietmar@proxmox.com \
    --cc=d.whyte@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 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