@@ -17,7 +17,7 @@ import (
1717 "github.com/stackitcloud/stackit-cli/internal/pkg/utils"
1818
1919 "github.com/spf13/cobra"
20- "github.com/stackitcloud/stackit-sdk-go/services/redis"
20+ redis "github.com/stackitcloud/stackit-sdk-go/services/redis/v2api "
2121)
2222
2323const (
@@ -58,7 +58,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
5858 return err
5959 }
6060
61- instanceLabel , err := redisUtils .GetInstanceName (ctx , apiClient , model .ProjectId , model .InstanceId )
61+ instanceLabel , err := redisUtils .GetInstanceName (ctx , apiClient . DefaultAPI , model .ProjectId , model .InstanceId , model . Region )
6262 if err != nil {
6363 params .Printer .Debug (print .ErrorLevel , "get instance name: %v" , err )
6464 instanceLabel = model .InstanceId
@@ -109,7 +109,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel,
109109}
110110
111111func buildRequest (ctx context.Context , model * inputModel , apiClient * redis.APIClient ) redis.ApiCreateCredentialsRequest {
112- req := apiClient .CreateCredentials (ctx , model .ProjectId , model .InstanceId )
112+ req := apiClient .DefaultAPI . CreateCredentials (ctx , model .ProjectId , model . Region , model .InstanceId )
113113 return req
114114}
115115
@@ -122,30 +122,27 @@ func outputResult(p *print.Printer, model inputModel, instanceLabel string, resp
122122 }
123123 if ! model .ShowPassword {
124124 if resp .Raw == nil {
125- resp .Raw = & redis.RawCredentials {}
125+ resp .Raw = & redis.RawCredentials {Credentials : redis. Credentials {} }
126126 }
127- if resp .Raw .Credentials == nil {
128- resp .Raw .Credentials = & redis.Credentials {}
129- }
130- resp .Raw .Credentials .Password = utils .Ptr ("hidden" )
127+ resp .Raw .Credentials .Password = "hidden"
131128 }
132129
133130 return p .OutputResult (model .OutputFormat , resp , func () error {
134- p .Outputf ("Created credentials for instance %q. Credentials ID: %s\n \n " , instanceLabel , utils . PtrString ( resp .Id ) )
131+ p .Outputf ("Created credentials for instance %q. Credentials ID: %s\n \n " , instanceLabel , resp .Id )
135132 // The username field cannot be set by the user, so we only display it if it's not returned empty
136- if resp .HasRaw () && resp . Raw . Credentials != nil {
137- if username := resp .Raw .Credentials .Username ; username != nil && * username != "" {
138- p .Outputf ("Username: %s\n " , utils . PtrString ( username ) )
133+ if resp .HasRaw () {
134+ if username := resp .Raw .Credentials .Username ; username != "" {
135+ p .Outputf ("Username: %s\n " , username )
139136 }
140137 if ! model .ShowPassword {
141138 p .Outputf ("Password: <hidden>\n " )
142139 } else {
143- p .Outputf ("Password: %s\n " , utils . PtrString ( resp .Raw .Credentials .Password ) )
140+ p .Outputf ("Password: %s\n " , resp .Raw .Credentials .Password )
144141 }
145- p .Outputf ("Host: %s\n " , utils . PtrString ( resp .Raw .Credentials .Host ) )
142+ p .Outputf ("Host: %s\n " , resp .Raw .Credentials .Host )
146143 p .Outputf ("Port: %s\n " , utils .PtrString (resp .Raw .Credentials .Port ))
147144 }
148- p .Outputf ("URI: %s\n " , utils . PtrString ( resp .Uri ) )
145+ p .Outputf ("URI: %s\n " , resp .Uri )
149146 return nil
150147 })
151148}
0 commit comments