From 10b17ab3374e56fa10c97e5e754489a0868334b4 Mon Sep 17 00:00:00 2001 From: eberlep Date: Mon, 12 Dec 2022 14:36:54 +0100 Subject: [PATCH] Add missing postgres backup-config describe cmd (#218) --- cmd/postgres.go | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/cmd/postgres.go b/cmd/postgres.go index 64c6011d..829582da 100644 --- a/cmd/postgres.go +++ b/cmd/postgres.go @@ -222,7 +222,15 @@ postgres=# Aliases: []string{"ls"}, Short: "list backup configuration", RunE: func(cmd *cobra.Command, args []string) error { - return c.postgresBackupGet() + return c.postgresBackupList() + }, + PreRun: bindPFlags, + } + postgresBackupDescribeCmd := &cobra.Command{ + Use: "describe", + Short: "describe backup configuration", + RunE: func(cmd *cobra.Command, args []string) error { + return c.postgresBackupDescribe(args) }, PreRun: bindPFlags, } @@ -258,6 +266,7 @@ postgres=# postgresBackupCmd.AddCommand(postgresBackupAutoCreateCmd) postgresBackupCmd.AddCommand(postgresBackupUpdateCmd) postgresBackupCmd.AddCommand(postgresBackupListCmd) + postgresBackupCmd.AddCommand(postgresBackupDescribeCmd) postgresBackupCmd.AddCommand(postgresBackupDeleteCmd) // Create @@ -932,7 +941,8 @@ func (c *config) postgresBackupUpdate() error { return output.New().Print(response.Payload) } -func (c *config) postgresBackupGet() error { +func (c *config) postgresBackupList() error { + request := database.NewListPostgresBackupConfigsParams() resp, err := c.cloud.Database.ListPostgresBackupConfigs(request, nil) if err != nil { @@ -940,6 +950,23 @@ func (c *config) postgresBackupGet() error { } return output.New().Print(resp.Payload) } +func (c *config) postgresBackupDescribe(args []string) error { + + if len(args) < 1 { + return fmt.Errorf("missing backup id") + } + if len(args) > 1 { + return fmt.Errorf("only a single backup id is supported") + } + id := args[0] + + gbcp := database.NewGetBackupConfigParams().WithID(id) + resp, err := c.cloud.Database.GetBackupConfig(gbcp, nil) + if err != nil { + return err + } + return output.New().Print(resp.Payload) +} func (c *config) postgresBackupDelete(args []string) error { if len(args) < 1 { return fmt.Errorf("missing backup id")