Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add missing postgres backup-config describe cmd #218

Merged
merged 1 commit into from
Dec 12, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 29 additions & 2 deletions cmd/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down Expand Up @@ -258,6 +266,7 @@ postgres=#
postgresBackupCmd.AddCommand(postgresBackupAutoCreateCmd)
postgresBackupCmd.AddCommand(postgresBackupUpdateCmd)
postgresBackupCmd.AddCommand(postgresBackupListCmd)
postgresBackupCmd.AddCommand(postgresBackupDescribeCmd)
postgresBackupCmd.AddCommand(postgresBackupDeleteCmd)

// Create
Expand Down Expand Up @@ -932,14 +941,32 @@ 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 {
return err
}
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")
Expand Down