@@ -23,8 +23,8 @@ import (
2323 "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
2424 "github.com/hashicorp/terraform-plugin-framework/types"
2525 "github.com/stackitcloud/stackit-sdk-go/core/oapierror"
26- "github.com/stackitcloud/stackit-sdk-go/services/postgresflex"
27- "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/wait"
26+ postgresflex "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v2api "
27+ "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v2api/ wait"
2828)
2929
3030// Ensure the implementation satisfies the expected interfaces.
@@ -239,7 +239,7 @@ func (r *userResource) Create(ctx context.Context, req resource.CreateRequest, r
239239 return
240240 }
241241 // Create new user
242- userResp , err := r .client .CreateUser (ctx , projectId , region , instanceId ).CreateUserPayload (* payload ).Execute ()
242+ userResp , err := r .client .DefaultAPI . CreateUser (ctx , projectId , region , instanceId ).CreateUserPayload (* payload ).Execute ()
243243 if err != nil {
244244 core .LogAndAddError (ctx , & resp .Diagnostics , "Error creating user" , fmt .Sprintf ("Calling API: %v" , err ))
245245 return
@@ -289,7 +289,7 @@ func (r *userResource) Read(ctx context.Context, req resource.ReadRequest, resp
289289 ctx = tflog .SetField (ctx , "user_id" , userId )
290290 ctx = tflog .SetField (ctx , "region" , region )
291291
292- recordSetResp , err := r .client .GetUser (ctx , projectId , region , instanceId , userId ).Execute ()
292+ recordSetResp , err := r .client .DefaultAPI . GetUser (ctx , projectId , region , instanceId , userId ).Execute ()
293293 if err != nil {
294294 oapiErr , ok := err .(* oapierror.GenericOpenAPIError ) //nolint:errorlint //complaining that error.As should be used to catch wrapped errors, but this error should not be wrapped
295295 if ok && oapiErr .StatusCode == http .StatusNotFound {
@@ -364,15 +364,15 @@ func (r *userResource) Update(ctx context.Context, req resource.UpdateRequest, r
364364 }
365365
366366 // Update existing instance
367- err = r .client .UpdateUser (ctx , projectId , region , instanceId , userId ).UpdateUserPayload (* payload ).Execute ()
367+ err = r .client .DefaultAPI . UpdateUser (ctx , projectId , region , instanceId , userId ).UpdateUserPayload (* payload ).Execute ()
368368 if err != nil {
369369 core .LogAndAddError (ctx , & resp .Diagnostics , "Error updating user" , err .Error ())
370370 return
371371 }
372372
373373 ctx = core .LogResponse (ctx )
374374
375- userResp , err := r .client .GetUser (ctx , projectId , region , instanceId , userId ).Execute ()
375+ userResp , err := r .client .DefaultAPI . GetUser (ctx , projectId , region , instanceId , userId ).Execute ()
376376 if err != nil {
377377 core .LogAndAddError (ctx , & resp .Diagnostics , "Error updating user" , fmt .Sprintf ("Calling API: %v" , err ))
378378 return
@@ -416,14 +416,14 @@ func (r *userResource) Delete(ctx context.Context, req resource.DeleteRequest, r
416416 ctx = tflog .SetField (ctx , "region" , region )
417417
418418 // Delete existing record set
419- err := r .client .DeleteUser (ctx , projectId , region , instanceId , userId ).Execute ()
419+ err := r .client .DefaultAPI . DeleteUser (ctx , projectId , region , instanceId , userId ).Execute ()
420420 if err != nil {
421421 core .LogAndAddError (ctx , & resp .Diagnostics , "Error deleting user" , fmt .Sprintf ("Calling API: %v" , err ))
422422 }
423423
424424 ctx = core .LogResponse (ctx )
425425
426- _ , err = wait .DeleteUserWaitHandler (ctx , r .client , projectId , region , instanceId , userId ).WaitWithContext (ctx )
426+ _ , err = wait .DeleteUserWaitHandler (ctx , r .client . DefaultAPI , projectId , region , instanceId , userId ).WaitWithContext (ctx )
427427 if err != nil {
428428 core .LogAndAddError (ctx , & resp .Diagnostics , "Error deleting user" , fmt .Sprintf ("Instance deletion waiting: %v" , err ))
429429 return
@@ -482,7 +482,7 @@ func mapFieldsCreate(userResp *postgresflex.CreateUserResponse, model *Model, re
482482 model .Roles = types .SetNull (types .StringType )
483483 } else {
484484 roles := []attr.Value {}
485- for _ , role := range * user .Roles {
485+ for _ , role := range user .Roles {
486486 roles = append (roles , types .StringValue (role ))
487487 }
488488 rolesSet , diags := types .SetValue (types .StringType , roles )
@@ -525,7 +525,7 @@ func mapFields(userResp *postgresflex.GetUserResponse, model *Model, region stri
525525 model .Roles = types .SetNull (types .StringType )
526526 } else {
527527 roles := []attr.Value {}
528- for _ , role := range * user .Roles {
528+ for _ , role := range user .Roles {
529529 roles = append (roles , types .StringValue (role ))
530530 }
531531 rolesSet , diags := types .SetValue (types .StringType , roles )
@@ -549,7 +549,7 @@ func toCreatePayload(model *Model, roles []string) (*postgresflex.CreateUserPayl
549549 }
550550
551551 return & postgresflex.CreateUserPayload {
552- Roles : & roles ,
552+ Roles : roles ,
553553 Username : conversion .StringValueToPointer (model .Username ),
554554 }, nil
555555}
@@ -563,6 +563,6 @@ func toUpdatePayload(model *Model, roles []string) (*postgresflex.UpdateUserPayl
563563 }
564564
565565 return & postgresflex.UpdateUserPayload {
566- Roles : & roles ,
566+ Roles : roles ,
567567 }, nil
568568}
0 commit comments