@@ -18,8 +18,8 @@ import (
1818 "github.com/hashicorp/terraform-plugin-framework/types"
1919 "github.com/hashicorp/terraform-plugin-log/tflog"
2020 "github.com/stackitcloud/stackit-sdk-go/core/oapierror"
21- "github.com/stackitcloud/stackit-sdk-go/services/edge"
22- edgewait "github.com/stackitcloud/stackit-sdk-go/services/edge/wait"
21+ edge "github.com/stackitcloud/stackit-sdk-go/services/edge/v1beta1api "
22+ edgewait "github.com/stackitcloud/stackit-sdk-go/services/edge/v1beta1api/ wait"
2323 "github.com/stackitcloud/stackit-sdk-go/services/serviceenablement"
2424 enablementWait "github.com/stackitcloud/stackit-sdk-go/services/serviceenablement/wait"
2525 "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/conversion"
@@ -264,7 +264,7 @@ func (i *instanceResource) Create(ctx context.Context, req resource.CreateReques
264264
265265 tflog .Info (ctx , "Creating new Edge Cloud instance" )
266266 payload := toCreatePayload (& model )
267- createResp , err := i .client .CreateInstance (ctx , projectId , region ).CreateInstancePayload (payload ).Execute ()
267+ createResp , err := i .client .DefaultAPI . CreateInstance (ctx , projectId , region ).CreateInstancePayload (payload ).Execute ()
268268 if err != nil {
269269 core .LogAndAddError (ctx , & resp .Diagnostics , "Error creating instance" , fmt .Sprintf ("Calling API: %v" , err ))
270270 return
@@ -276,12 +276,12 @@ func (i *instanceResource) Create(ctx context.Context, req resource.CreateReques
276276 core .LogAndAddError (ctx , & resp .Diagnostics , "Error creating instance" , "API returned nil response" )
277277 return
278278 }
279- if createResp .Id == nil {
280- core .LogAndAddError (ctx , & resp .Diagnostics , "Error creating instance" , "API returned nil Instance ID" )
279+ if createResp .Id == "" {
280+ core .LogAndAddError (ctx , & resp .Diagnostics , "Error creating instance" , "API returned empty Instance ID" )
281281 return
282282 }
283283
284- edgeCloudInstanceId := * createResp .Id
284+ edgeCloudInstanceId := createResp .Id
285285 // Write id attributes to state before polling via the wait handler - just in case anything goes wrong during the wait handler
286286 ctx = utils .SetAndLogStateFields (ctx , & resp .Diagnostics , & resp .State , map [string ]any {
287287 "project_id" : projectId ,
@@ -292,7 +292,7 @@ func (i *instanceResource) Create(ctx context.Context, req resource.CreateReques
292292 return
293293 }
294294
295- waitResp , err := edgewait .CreateOrUpdateInstanceWaitHandler (ctx , i .client , projectId , region , edgeCloudInstanceId ).WaitWithContext (ctx )
295+ waitResp , err := edgewait .CreateOrUpdateInstanceWaitHandler (ctx , i .client . DefaultAPI , projectId , region , edgeCloudInstanceId ).WaitWithContext (ctx )
296296 if err != nil {
297297 core .LogAndAddError (ctx , & resp .Diagnostics , "Error creating instance" , fmt .Sprintf ("Instance waiting: %v" , err ))
298298 return
@@ -329,7 +329,7 @@ func (i *instanceResource) Read(ctx context.Context, req resource.ReadRequest, r
329329 ctx = tflog .SetField (ctx , "instance_id" , instanceId )
330330 ctx = tflog .SetField (ctx , "region" , region )
331331
332- edgeCloudInstanceResp , err := i .client .GetInstance (ctx , projectId , region , instanceId ).Execute ()
332+ edgeCloudInstanceResp , err := i .client .DefaultAPI . GetInstance (ctx , projectId , region , instanceId ).Execute ()
333333 if err != nil {
334334 var oapiErr * oapierror.GenericOpenAPIError
335335 ok := errors .As (err , & oapiErr )
@@ -372,15 +372,15 @@ func (i *instanceResource) Update(ctx context.Context, req resource.UpdateReques
372372
373373 tflog .Info (ctx , "Updating Edge Cloud instance" , map [string ]any {"instance_id" : instanceId })
374374 payload := toUpdatePayload (& model )
375- err := i .client .UpdateInstance (ctx , projectId , region , instanceId ).UpdateInstancePayload (payload ).Execute ()
375+ err := i .client .DefaultAPI . UpdateInstance (ctx , projectId , region , instanceId ).UpdateInstancePayload (payload ).Execute ()
376376 if err != nil {
377377 core .LogAndAddError (ctx , & resp .Diagnostics , "Error updating instance" , fmt .Sprintf ("Calling API: %v" , err ))
378378 return
379379 }
380380
381381 ctx = core .LogResponse (ctx )
382382
383- waitResp , err := edgewait .CreateOrUpdateInstanceWaitHandler (ctx , i .client , projectId , region , instanceId ).WaitWithContext (ctx )
383+ waitResp , err := edgewait .CreateOrUpdateInstanceWaitHandler (ctx , i .client . DefaultAPI , projectId , region , instanceId ).WaitWithContext (ctx )
384384 if err != nil {
385385 core .LogAndAddError (ctx , & resp .Diagnostics , "Error updating instance" , fmt .Sprintf ("Instance waiting: %v" , err ))
386386 return
@@ -414,15 +414,15 @@ func (i *instanceResource) Delete(ctx context.Context, req resource.DeleteReques
414414 ctx = tflog .SetField (ctx , "instance_id" , instanceId )
415415 ctx = tflog .SetField (ctx , "region" , region )
416416
417- err := i .client .DeleteInstance (ctx , projectId , region , instanceId ).Execute ()
417+ err := i .client .DefaultAPI . DeleteInstance (ctx , projectId , region , instanceId ).Execute ()
418418 if err != nil {
419419 core .LogAndAddError (ctx , & resp .Diagnostics , "Error deleting instance" , fmt .Sprintf ("Calling API: %v" , err ))
420420 return
421421 }
422422
423423 ctx = core .LogResponse (ctx )
424424
425- _ , err = edgewait .DeleteInstanceWaitHandler (ctx , i .client , projectId , region , instanceId ).WaitWithContext (ctx )
425+ _ , err = edgewait .DeleteInstanceWaitHandler (ctx , i .client . DefaultAPI , projectId , region , instanceId ).WaitWithContext (ctx )
426426 if err != nil {
427427 core .LogAndAddError (ctx , & resp .Diagnostics , "Error deleting instance" , fmt .Sprintf ("Instance deletion waiting: %v" , err ))
428428 return
@@ -461,8 +461,8 @@ func mapFields(resp *edge.Instance, model *Model) error {
461461 var instanceId string
462462 if model .InstanceId .ValueString () != "" {
463463 instanceId = model .InstanceId .ValueString ()
464- } else if resp .Id != nil {
465- instanceId = * resp .Id
464+ } else if resp .Id != "" {
465+ instanceId = resp .Id
466466 }
467467 model .Id = utils .BuildInternalTerraformId (model .ProjectId .ValueString (), model .Region .ValueString (), instanceId )
468468 model .InstanceId = types .StringValue (instanceId )
@@ -471,10 +471,10 @@ func mapFields(resp *edge.Instance, model *Model) error {
471471 } else {
472472 model .Created = types .StringNull ()
473473 }
474- model .FrontendUrl = types .StringPointerValue (resp .FrontendUrl )
475- model .DisplayName = types .StringPointerValue (resp .DisplayName )
476- model .PlanID = types .StringPointerValue (resp .PlanId )
477- model .Status = types .StringValue (string ( * resp .Status ) )
474+ model .FrontendUrl = types .StringValue (resp .FrontendUrl )
475+ model .DisplayName = types .StringValue (resp .DisplayName )
476+ model .PlanID = types .StringValue (resp .PlanId )
477+ model .Status = types .StringValue (resp .Status )
478478
479479 if resp .Description != nil {
480480 model .Description = types .StringValue (* resp .Description )
@@ -488,9 +488,9 @@ func mapFields(resp *edge.Instance, model *Model) error {
488488// toCreatePayload creates the payload for creating an Edge Cloud instance.
489489func toCreatePayload (model * Model ) edge.CreateInstancePayload {
490490 return edge.CreateInstancePayload {
491- DisplayName : model .DisplayName .ValueStringPointer (),
491+ DisplayName : model .DisplayName .ValueString (),
492492 Description : model .Description .ValueStringPointer (),
493- PlanId : model .PlanID .ValueStringPointer (),
493+ PlanId : model .PlanID .ValueString (),
494494 }
495495}
496496
0 commit comments