@@ -4,10 +4,11 @@ import (
44 "context"
55 "fmt"
66
7+ rabbitmq "github.com/stackitcloud/stackit-sdk-go/services/rabbitmq/v2api"
8+
79 "github.com/stackitcloud/stackit-cli/internal/pkg/types"
810
911 "github.com/spf13/cobra"
10- "github.com/stackitcloud/stackit-sdk-go/services/rabbitmq"
1112
1213 "github.com/stackitcloud/stackit-cli/internal/pkg/args"
1314 "github.com/stackitcloud/stackit-cli/internal/pkg/errors"
@@ -58,7 +59,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
5859 return err
5960 }
6061
61- instanceLabel , err := rabbitmqUtils .GetInstanceName (ctx , apiClient , model .ProjectId , model .InstanceId )
62+ instanceLabel , err := rabbitmqUtils .GetInstanceName (ctx , apiClient . DefaultAPI , model .ProjectId , model . Region , model .InstanceId )
6263 if err != nil {
6364 params .Printer .Debug (print .ErrorLevel , "get instance name: %v" , err )
6465 instanceLabel = model .InstanceId
@@ -109,7 +110,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel,
109110}
110111
111112func buildRequest (ctx context.Context , model * inputModel , apiClient * rabbitmq.APIClient ) rabbitmq.ApiCreateCredentialsRequest {
112- req := apiClient .CreateCredentials (ctx , model .ProjectId , model .InstanceId )
113+ req := apiClient .DefaultAPI . CreateCredentials (ctx , model .ProjectId , model . Region , model .InstanceId )
113114 return req
114115}
115116
@@ -123,29 +124,27 @@ func outputResult(p *print.Printer, model inputModel, instanceLabel string, resp
123124
124125 if ! model .ShowPassword {
125126 if resp .Raw == nil {
126- resp .Raw = & rabbitmq.RawCredentials {Credentials : & rabbitmq.Credentials {}}
127- } else if resp .Raw .Credentials == nil {
128- resp .Raw .Credentials = & rabbitmq.Credentials {}
127+ resp .Raw = & rabbitmq.RawCredentials {Credentials : rabbitmq.Credentials {}}
129128 }
130- resp .Raw .Credentials .Password = utils . Ptr ( "hidden" )
129+ resp .Raw .Credentials .Password = "hidden"
131130 }
132131
133132 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 ) )
133+ p .Outputf ("Created credentials for instance %q. Credentials ID: %s\n \n " , instanceLabel , resp .Id )
135134 // 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 " , * username )
135+ if resp .HasRaw () {
136+ if username := resp .Raw .Credentials .Username ; username != "" {
137+ p .Outputf ("Username: %s\n " , username )
139138 }
140139 if ! model .ShowPassword {
141140 p .Outputf ("Password: <hidden>\n " )
142141 } else {
143- p .Outputf ("Password: %s\n " , utils . PtrString ( resp .Raw .Credentials .Password ) )
142+ p .Outputf ("Password: %s\n " , resp .Raw .Credentials .Password )
144143 }
145- p .Outputf ("Host: %s\n " , utils . PtrString ( resp .Raw .Credentials .Host ) )
144+ p .Outputf ("Host: %s\n " , resp .Raw .Credentials .Host )
146145 p .Outputf ("Port: %s\n " , utils .PtrString (resp .Raw .Credentials .Port ))
147146 }
148- p .Outputf ("URI: %s\n " , utils . PtrString ( resp .Uri ) )
147+ p .Outputf ("URI: %s\n " , resp .Uri )
149148 return nil
150149 })
151150}
0 commit comments