77 "github.com/stackitcloud/stackit-cli/internal/pkg/types"
88
99 "github.com/spf13/cobra"
10- "github.com/stackitcloud/stackit-sdk-go/services/observability"
10+ observability "github.com/stackitcloud/stackit-sdk-go/services/observability/v1api "
1111
1212 "github.com/stackitcloud/stackit-cli/internal/pkg/args"
1313 cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors"
@@ -17,7 +17,6 @@ import (
1717 "github.com/stackitcloud/stackit-cli/internal/pkg/print"
1818 "github.com/stackitcloud/stackit-cli/internal/pkg/services/observability/client"
1919 observabilityUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/observability/utils"
20- "github.com/stackitcloud/stackit-cli/internal/pkg/utils"
2120)
2221
2322const (
@@ -56,7 +55,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
5655 return err
5756 }
5857
59- instanceLabel , err := observabilityUtils .GetInstanceName (ctx , apiClient , model .InstanceId , model .ProjectId )
58+ instanceLabel , err := observabilityUtils .GetInstanceName (ctx , apiClient . DefaultAPI , model .InstanceId , model .ProjectId )
6059 if err != nil {
6160 params .Printer .Debug (print .ErrorLevel , "get instance name: %v" , err )
6261 instanceLabel = model .InstanceId
@@ -69,7 +68,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
6968 }
7069
7170 // Call API
72- req := buildRequest (ctx , model , apiClient )
71+ req := buildRequest (ctx , model , apiClient . DefaultAPI )
7372 if err != nil {
7473 return err
7574 }
@@ -104,7 +103,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel,
104103 }, nil
105104}
106105
107- func buildRequest (ctx context.Context , model * inputModel , apiClient * observability.APIClient ) observability.ApiCreateCredentialsRequest {
106+ func buildRequest (ctx context.Context , model * inputModel , apiClient observability.DefaultAPI ) observability.ApiCreateCredentialsRequest {
108107 req := apiClient .CreateCredentials (ctx , model .InstanceId , model .ProjectId )
109108 return req
110109}
@@ -117,15 +116,13 @@ func outputResult(p *print.Printer, outputFormat, instanceLabel string, resp *ob
117116 return p .OutputResult (outputFormat , resp , func () error {
118117 p .Outputf ("Created credentials for instance %q.\n \n " , instanceLabel )
119118
120- if resp .Credentials != nil {
121- // The username field cannot be set by the user, so we only display it if it's not returned empty
122- username := * resp .Credentials .Username
123- if username != "" {
124- p .Outputf ("Username: %s\n " , username )
125- }
126-
127- p .Outputf ("Password: %s\n " , utils .PtrString (resp .Credentials .Password ))
119+ // The username field cannot be set by the user, so we only display it if it's not returned empty
120+ username := resp .Credentials .Username
121+ if username != "" {
122+ p .Outputf ("Username: %s\n " , username )
128123 }
124+
125+ p .Outputf ("Password: %s\n " , resp .Credentials .Password )
129126 return nil
130127 })
131128}
0 commit comments