@@ -3,7 +3,6 @@ package create
33import (
44 "context"
55 "fmt"
6- "math"
76
87 logs "github.com/stackitcloud/stackit-sdk-go/services/logs/v1api"
98
@@ -37,7 +36,7 @@ type inputModel struct {
3736 * globalflags.GlobalFlagModel
3837
3938 DisplayName * string
40- RetentionDays * int64
39+ RetentionDays * int32
4140 ACL * []string
4241 Description * string
4342}
@@ -88,10 +87,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
8887 }
8988
9089 // Call API
91- req , err := buildRequest (ctx , model , apiClient )
92- if err != nil {
93- return err
94- }
90+ req := buildRequest (ctx , model , apiClient )
9591 resp , err := req .Execute ()
9692 if err != nil {
9793 return fmt .Errorf ("create Logs instance: %w" , err )
@@ -126,7 +122,7 @@ func configureFlags(cmd *cobra.Command) {
126122 cmd .Flags ().String (displayNameFlag , "" , "Display name" )
127123 cmd .Flags ().String (descriptionFlag , "" , "Description" )
128124 cmd .Flags ().StringSlice (aclFlag , []string {}, "Access control list" )
129- cmd .Flags ().Int64 (retentionDaysFlag , 0 , "The days for how long the logs should be stored before being cleaned up" )
125+ cmd .Flags ().Int32 (retentionDaysFlag , 0 , "The days for how long the logs should be stored before being cleaned up" )
130126
131127 err := flags .MarkFlagsRequired (cmd , displayNameFlag , retentionDaysFlag )
132128 cobra .CheckErr (err )
@@ -141,7 +137,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel,
141137 model := inputModel {
142138 GlobalFlagModel : globalFlags ,
143139 DisplayName : flags .FlagToStringPointer (p , cmd , displayNameFlag ),
144- RetentionDays : flags .FlagToInt64Pointer (p , cmd , retentionDaysFlag ),
140+ RetentionDays : flags .FlagToInt32Pointer (p , cmd , retentionDaysFlag ),
145141 Description : flags .FlagToStringPointer (p , cmd , descriptionFlag ),
146142 ACL : flags .FlagToStringSlicePointer (p , cmd , aclFlag ),
147143 }
@@ -150,25 +146,15 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel,
150146 return & model , nil
151147}
152148
153- func buildRequest (ctx context.Context , model * inputModel , apiClient * logs.APIClient ) ( logs.ApiCreateLogsInstanceRequest , error ) {
149+ func buildRequest (ctx context.Context , model * inputModel , apiClient * logs.APIClient ) logs.ApiCreateLogsInstanceRequest {
154150 req := apiClient .DefaultAPI .CreateLogsInstance (ctx , model .ProjectId , model .Region )
155-
156- var retentionDays int32
157- if model .RetentionDays != nil {
158- val := * model .RetentionDays
159- if val < 0 || val > math .MaxInt32 {
160- return req , fmt .Errorf ("metrics frequency value %d overflows int32" , val )
161- }
162- retentionDays = int32 (val )
163- }
164-
165151 req = req .CreateLogsInstancePayload (logs.CreateLogsInstancePayload {
166152 DisplayName : utils .PtrString (model .DisplayName ),
167153 Description : model .Description ,
168- RetentionDays : retentionDays ,
169- Acl : utils .PtrValue (model .ACL ),
154+ RetentionDays : utils . PtrValue ( model . RetentionDays ) ,
155+ Acl : utils .GetSliceFromPointer (model .ACL ),
170156 })
171- return req , nil
157+ return req
172158}
173159
174160func outputResult (p * print.Printer , model * inputModel , projectLabel string , resp * logs.LogsInstance ) error {
0 commit comments