77 "github.com/stackitcloud/stackit-cli/internal/pkg/types"
88
99 "github.com/spf13/cobra"
10- "github.com/stackitcloud/stackit-sdk-go/services/logme"
10+ logme "github.com/stackitcloud/stackit-sdk-go/services/logme/v1api "
1111
1212 "github.com/stackitcloud/stackit-cli/internal/pkg/args"
1313 "github.com/stackitcloud/stackit-cli/internal/pkg/errors"
@@ -51,14 +51,13 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
5151 if err != nil {
5252 return err
5353 }
54-
5554 // Configure API client
5655 apiClient , err := client .ConfigureClient (params .Printer , params .CliVersion )
5756 if err != nil {
5857 return err
5958 }
6059
61- instanceLabel , err := logmeUtils .GetInstanceName (ctx , apiClient , model .ProjectId , model .InstanceId )
60+ instanceLabel , err := logmeUtils .GetInstanceName (ctx , apiClient . DefaultAPI , model .ProjectId , model .InstanceId )
6261 if err != nil {
6362 params .Printer .Debug (print .ErrorLevel , "get instance name: %v" , err )
6463 instanceLabel = model .InstanceId
@@ -109,7 +108,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel,
109108}
110109
111110func buildRequest (ctx context.Context , model * inputModel , apiClient * logme.APIClient ) logme.ApiCreateCredentialsRequest {
112- req := apiClient .CreateCredentials (ctx , model .ProjectId , model .InstanceId )
111+ req := apiClient .DefaultAPI . CreateCredentials (ctx , model .ProjectId , model .InstanceId )
113112 return req
114113}
115114
@@ -118,26 +117,26 @@ func outputResult(p *print.Printer, outputFormat string, showPassword bool, inst
118117 return fmt .Errorf ("credentials response is empty" )
119118 }
120119
121- if ! showPassword && resp .HasRaw () && resp . Raw . Credentials != nil {
122- resp .Raw .Credentials .Password = utils . Ptr ( "hidden" )
120+ if ! showPassword && resp .HasRaw () {
121+ resp .Raw .Credentials .Password = "hidden"
123122 }
124123
125124 return p .OutputResult (outputFormat , resp , func () error {
126- p .Outputf ("Created credentials for instance %q. Credentials ID: %s\n \n " , instanceLabel , utils . PtrString ( resp .Id ) )
125+ p .Outputf ("Created credentials for instance %q. Credentials ID: %s\n \n " , instanceLabel , resp .Id )
127126 // The username field cannot be set by the user so we only display it if it's not returned empty
128- if resp .HasRaw () && resp . Raw . Credentials != nil {
129- if username := resp .Raw .Credentials .Username ; username != nil && * username != "" {
130- p .Outputf ("Username: %s\n " , utils . PtrString ( username ) )
127+ if resp .HasRaw () {
128+ if username := resp .Raw .Credentials .Username ; username != "" {
129+ p .Outputf ("Username: %s\n " , username )
131130 }
132131 if ! showPassword {
133132 p .Outputf ("Password: <hidden>\n " )
134133 } else {
135- p .Outputf ("Password: %s\n " , utils . PtrString ( resp .Raw .Credentials .Password ) )
134+ p .Outputf ("Password: %s\n " , resp .Raw .Credentials .Password )
136135 }
137- p .Outputf ("Host: %s\n " , utils . PtrString ( resp .Raw .Credentials .Host ) )
136+ p .Outputf ("Host: %s\n " , resp .Raw .Credentials .Host )
138137 p .Outputf ("Port: %s\n " , utils .PtrString (resp .Raw .Credentials .Port ))
139138 }
140- p .Outputf ("URI: %s\n " , utils . PtrString ( resp .Uri ) )
139+ p .Outputf ("URI: %s\n " , resp .Uri )
141140 return nil
142141 })
143142}
0 commit comments