@@ -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,16 @@ 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 )
141+ permissions := make ([]logs.PermissionsInner , len (model .Permissions ))
142+ for i , permission := range model .Permissions {
143+ permissions [i ] = logs .PermissionsInner (permission )
144+ }
142145 return req .CreateAccessTokenPayload (logs.CreateAccessTokenPayload {
143146 Description : model .Description ,
144- DisplayName : & model .DisplayName ,
147+ DisplayName : model .DisplayName ,
145148 Lifetime : model .Lifetime ,
146- Permissions : & model . Permissions ,
149+ Permissions : permissions ,
147150 })
148151}
149152
@@ -152,7 +155,7 @@ func outputResult(p *print.Printer, outputFormat, instanceLabel string, accessTo
152155 return fmt .Errorf ("access token cannot be nil" )
153156 }
154157 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 ))
158+ p .Outputf ("Created access token for Logs instance %q.\n \n ID: %s\n Token: %s\n " , instanceLabel , accessToken .Id , utils .PtrValue (accessToken .AccessToken ))
156159 return nil
157160 })
158161}
0 commit comments