88
99 iaasClient "github.com/stackitcloud/stackit-cli/internal/pkg/services/iaas/client"
1010
11+ "github.com/spf13/cobra"
12+ serverbackup "github.com/stackitcloud/stackit-sdk-go/services/serverbackup/v2api"
13+
1114 "github.com/stackitcloud/stackit-cli/internal/pkg/args"
1215 cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors"
1316 "github.com/stackitcloud/stackit-cli/internal/pkg/examples"
@@ -16,10 +19,6 @@ import (
1619 "github.com/stackitcloud/stackit-cli/internal/pkg/print"
1720 iaasUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/iaas/utils"
1821 "github.com/stackitcloud/stackit-cli/internal/pkg/services/serverbackup/client"
19- "github.com/stackitcloud/stackit-cli/internal/pkg/utils"
20-
21- "github.com/spf13/cobra"
22- "github.com/stackitcloud/stackit-sdk-go/services/serverbackup"
2322)
2423
2524const (
@@ -36,7 +35,7 @@ type inputModel struct {
3635
3736 ServerId string
3837 BackupName string
39- BackupRetentionPeriod int64
38+ BackupRetentionPeriod int32
4039 BackupVolumeIds []string
4140}
4241
@@ -105,7 +104,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
105104func configureFlags (cmd * cobra.Command ) {
106105 cmd .Flags ().VarP (flags .UUIDFlag (), serverIdFlag , "s" , "Server ID" )
107106 cmd .Flags ().StringP (backupNameFlag , "b" , "" , "Backup name" )
108- cmd .Flags ().Int64P (backupRetentionPeriodFlag , "d" , defaultRetentionPeriod , "Backup retention period (in days)" )
107+ cmd .Flags ().Int32P (backupRetentionPeriodFlag , "d" , defaultRetentionPeriod , "Backup retention period (in days)" )
109108 cmd .Flags ().VarP (flags .UUIDSliceFlag (), backupVolumeIdsFlag , "i" , "Backup volume IDs, as comma separated UUID values." )
110109
111110 err := flags .MarkFlagsRequired (cmd , serverIdFlag , backupNameFlag )
@@ -121,7 +120,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel,
121120 model := inputModel {
122121 GlobalFlagModel : globalFlags ,
123122 ServerId : flags .FlagToStringValue (p , cmd , serverIdFlag ),
124- BackupRetentionPeriod : flags .FlagWithDefaultToInt64Value (p , cmd , backupRetentionPeriodFlag ),
123+ BackupRetentionPeriod : flags .FlagWithDefaultToInt32Value (p , cmd , backupRetentionPeriodFlag ),
125124 BackupName : flags .FlagToStringValue (p , cmd , backupNameFlag ),
126125 BackupVolumeIds : flags .FlagToStringSliceValue (p , cmd , backupVolumeIdsFlag ),
127126 }
@@ -131,11 +130,11 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel,
131130}
132131
133132func buildRequest (ctx context.Context , model * inputModel , apiClient * serverbackup.APIClient ) (serverbackup.ApiCreateBackupRequest , error ) {
134- req := apiClient .CreateBackup (ctx , model .ProjectId , model .ServerId , model .Region )
133+ req := apiClient .DefaultAPI . CreateBackup (ctx , model .ProjectId , model .ServerId , model .Region )
135134 payload := serverbackup.CreateBackupPayload {
136- Name : & model .BackupName ,
137- RetentionPeriod : & model .BackupRetentionPeriod ,
138- VolumeIds : & model .BackupVolumeIds ,
135+ Name : model .BackupName ,
136+ RetentionPeriod : model .BackupRetentionPeriod ,
137+ VolumeIds : model .BackupVolumeIds ,
139138 }
140139 if model .BackupVolumeIds == nil {
141140 payload .VolumeIds = nil
@@ -146,7 +145,7 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient *serverbacku
146145
147146func outputResult (p * print.Printer , outputFormat , serverLabel string , resp serverbackup.BackupJob ) error {
148147 return p .OutputResult (outputFormat , resp , func () error {
149- p .Outputf ("Triggered creation of server backup for server %s. Backup ID: %s\n " , serverLabel , utils . PtrString ( resp .Id ) )
148+ p .Outputf ("Triggered creation of server backup for server %s. Backup ID: %s\n " , serverLabel , resp .Id )
150149 return nil
151150 })
152151}
0 commit comments