77 "github.com/stackitcloud/stackit-cli/internal/pkg/types"
88 "github.com/stackitcloud/stackit-cli/internal/pkg/utils"
99
10- "github.com/stackitcloud/stackit-sdk-go/services/logs"
10+ logs "github.com/stackitcloud/stackit-sdk-go/services/logs/v1api "
1111
1212 "github.com/stackitcloud/stackit-cli/internal/pkg/args"
1313 cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors"
@@ -35,7 +35,7 @@ type inputModel struct {
3535 InstanceId string
3636 Description * string
3737 DisplayName string
38- Lifetime * int64
38+ Lifetime * int32
3939 Permissions []string
4040}
4141
@@ -80,7 +80,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
8080 projectLabel = model .ProjectId
8181 }
8282
83- instanceLabel , err := logsUtils .GetInstanceName (ctx , apiClient , model .ProjectId , model .Region , model .InstanceId )
83+ instanceLabel , err := logsUtils .GetInstanceName (ctx , apiClient . DefaultAPI , model .ProjectId , model .Region , model .InstanceId )
8484 if err != nil {
8585 params .Printer .Debug (print .ErrorLevel , "get instance name: %v" , err )
8686 instanceLabel = model .InstanceId
@@ -110,7 +110,7 @@ func configureFlags(cmd *cobra.Command) {
110110 cmd .Flags ().Var (flags .UUIDFlag (), instanceIdFlag , "ID of the Logs instance" )
111111 cmd .Flags ().String (displayNameFlag , "" , "Display name for the access token" )
112112 cmd .Flags ().String (descriptionFlag , "" , "Description of the access token" )
113- cmd .Flags ().Int64 (lifetimeFlag , 0 , "Lifetime of the access token in days [1 - 180]" )
113+ cmd .Flags ().Int32 (lifetimeFlag , 0 , "Lifetime of the access token in days [1 - 180]" )
114114 cmd .Flags ().StringSlice (permissionsFlag , []string {}, `Permissions of the access token ["read" "write"]` )
115115
116116 err := flags .MarkFlagsRequired (cmd , instanceIdFlag , displayNameFlag , permissionsFlag )
@@ -128,7 +128,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel,
128128 DisplayName : flags .FlagToStringValue (p , cmd , displayNameFlag ),
129129 InstanceId : flags .FlagToStringValue (p , cmd , instanceIdFlag ),
130130 Description : flags .FlagToStringPointer (p , cmd , descriptionFlag ),
131- Lifetime : flags .FlagToInt64Pointer (p , cmd , lifetimeFlag ),
131+ Lifetime : flags .FlagToInt32Pointer (p , cmd , lifetimeFlag ),
132132 Permissions : flags .FlagToStringSliceValue (p , cmd , permissionsFlag ),
133133 }
134134
@@ -137,13 +137,14 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel,
137137}
138138
139139func buildRequest (ctx context.Context , model * inputModel , apiClient * logs.APIClient ) logs.ApiCreateAccessTokenRequest {
140- req := apiClient .CreateAccessToken (ctx , model .ProjectId , model .Region , model .InstanceId )
141-
140+ req := apiClient .DefaultAPI .CreateAccessToken (ctx , model .ProjectId , model .Region , model .InstanceId )
142141 return req .CreateAccessTokenPayload (logs.CreateAccessTokenPayload {
143142 Description : model .Description ,
144- DisplayName : & model .DisplayName ,
143+ DisplayName : model .DisplayName ,
145144 Lifetime : model .Lifetime ,
146- Permissions : & model .Permissions ,
145+ Permissions : utils .Map (model .Permissions , func (t string ) logs.PermissionsInner {
146+ return logs .PermissionsInner (t )
147+ }),
147148 })
148149}
149150
@@ -152,7 +153,7 @@ func outputResult(p *print.Printer, outputFormat, instanceLabel string, accessTo
152153 return fmt .Errorf ("access token cannot be nil" )
153154 }
154155 return p .OutputResult (outputFormat , accessToken , func () error {
155- p .Outputf ("Created access token for Logs instance %q.\n \n ID: %s\n Token: %s\n " , instanceLabel , utils . PtrValue ( accessToken .Id ) , utils .PtrValue (accessToken .AccessToken ))
156+ p .Outputf ("Created access token for Logs instance %q.\n \n ID: %s\n Token: %s\n " , instanceLabel , accessToken .Id , utils .PtrValue (accessToken .AccessToken ))
156157 return nil
157158 })
158159}
0 commit comments