@@ -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,23 +276,18 @@ 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" )
281- return
282- }
283279
284- edgeCloudInstanceId := * createResp .Id
285280 // Write id attributes to state before polling via the wait handler - just in case anything goes wrong during the wait handler
286281 ctx = utils .SetAndLogStateFields (ctx , & resp .Diagnostics , & resp .State , map [string ]any {
287282 "project_id" : projectId ,
288- "instance_id" : edgeCloudInstanceId ,
283+ "instance_id" : createResp . Id ,
289284 "region" : region ,
290285 })
291286 if resp .Diagnostics .HasError () {
292287 return
293288 }
294289
295- waitResp , err := edgewait .CreateOrUpdateInstanceWaitHandler (ctx , i .client , projectId , region , edgeCloudInstanceId ).WaitWithContext (ctx )
290+ waitResp , err := edgewait .CreateOrUpdateInstanceWaitHandler (ctx , i .client . DefaultAPI , projectId , region , createResp . Id ).WaitWithContext (ctx )
296291 if err != nil {
297292 core .LogAndAddError (ctx , & resp .Diagnostics , "Error creating instance" , fmt .Sprintf ("Instance waiting: %v" , err ))
298293 return
@@ -329,7 +324,7 @@ func (i *instanceResource) Read(ctx context.Context, req resource.ReadRequest, r
329324 ctx = tflog .SetField (ctx , "instance_id" , instanceId )
330325 ctx = tflog .SetField (ctx , "region" , region )
331326
332- edgeCloudInstanceResp , err := i .client .GetInstance (ctx , projectId , region , instanceId ).Execute ()
327+ edgeCloudInstanceResp , err := i .client .DefaultAPI . GetInstance (ctx , projectId , region , instanceId ).Execute ()
333328 if err != nil {
334329 var oapiErr * oapierror.GenericOpenAPIError
335330 ok := errors .As (err , & oapiErr )
@@ -372,15 +367,15 @@ func (i *instanceResource) Update(ctx context.Context, req resource.UpdateReques
372367
373368 tflog .Info (ctx , "Updating Edge Cloud instance" , map [string ]any {"instance_id" : instanceId })
374369 payload := toUpdatePayload (& model )
375- err := i .client .UpdateInstance (ctx , projectId , region , instanceId ).UpdateInstancePayload (payload ).Execute ()
370+ err := i .client .DefaultAPI . UpdateInstance (ctx , projectId , region , instanceId ).UpdateInstancePayload (payload ).Execute ()
376371 if err != nil {
377372 core .LogAndAddError (ctx , & resp .Diagnostics , "Error updating instance" , fmt .Sprintf ("Calling API: %v" , err ))
378373 return
379374 }
380375
381376 ctx = core .LogResponse (ctx )
382377
383- waitResp , err := edgewait .CreateOrUpdateInstanceWaitHandler (ctx , i .client , projectId , region , instanceId ).WaitWithContext (ctx )
378+ waitResp , err := edgewait .CreateOrUpdateInstanceWaitHandler (ctx , i .client . DefaultAPI , projectId , region , instanceId ).WaitWithContext (ctx )
384379 if err != nil {
385380 core .LogAndAddError (ctx , & resp .Diagnostics , "Error updating instance" , fmt .Sprintf ("Instance waiting: %v" , err ))
386381 return
@@ -414,15 +409,15 @@ func (i *instanceResource) Delete(ctx context.Context, req resource.DeleteReques
414409 ctx = tflog .SetField (ctx , "instance_id" , instanceId )
415410 ctx = tflog .SetField (ctx , "region" , region )
416411
417- err := i .client .DeleteInstance (ctx , projectId , region , instanceId ).Execute ()
412+ err := i .client .DefaultAPI . DeleteInstance (ctx , projectId , region , instanceId ).Execute ()
418413 if err != nil {
419414 core .LogAndAddError (ctx , & resp .Diagnostics , "Error deleting instance" , fmt .Sprintf ("Calling API: %v" , err ))
420415 return
421416 }
422417
423418 ctx = core .LogResponse (ctx )
424419
425- _ , err = edgewait .DeleteInstanceWaitHandler (ctx , i .client , projectId , region , instanceId ).WaitWithContext (ctx )
420+ _ , err = edgewait .DeleteInstanceWaitHandler (ctx , i .client . DefaultAPI , projectId , region , instanceId ).WaitWithContext (ctx )
426421 if err != nil {
427422 core .LogAndAddError (ctx , & resp .Diagnostics , "Error deleting instance" , fmt .Sprintf ("Instance deletion waiting: %v" , err ))
428423 return
@@ -461,8 +456,8 @@ func mapFields(resp *edge.Instance, model *Model) error {
461456 var instanceId string
462457 if model .InstanceId .ValueString () != "" {
463458 instanceId = model .InstanceId .ValueString ()
464- } else if resp .Id != nil {
465- instanceId = * resp .Id
459+ } else if resp .Id != "" {
460+ instanceId = resp .Id
466461 }
467462 model .Id = utils .BuildInternalTerraformId (model .ProjectId .ValueString (), model .Region .ValueString (), instanceId )
468463 model .InstanceId = types .StringValue (instanceId )
@@ -471,10 +466,10 @@ func mapFields(resp *edge.Instance, model *Model) error {
471466 } else {
472467 model .Created = types .StringNull ()
473468 }
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 ) )
469+ model .FrontendUrl = types .StringValue (resp .FrontendUrl )
470+ model .DisplayName = types .StringValue (resp .DisplayName )
471+ model .PlanID = types .StringValue (resp .PlanId )
472+ model .Status = types .StringValue (resp .Status )
478473
479474 if resp .Description != nil {
480475 model .Description = types .StringValue (* resp .Description )
@@ -488,9 +483,9 @@ func mapFields(resp *edge.Instance, model *Model) error {
488483// toCreatePayload creates the payload for creating an Edge Cloud instance.
489484func toCreatePayload (model * Model ) edge.CreateInstancePayload {
490485 return edge.CreateInstancePayload {
491- DisplayName : model .DisplayName .ValueStringPointer (),
486+ DisplayName : model .DisplayName .ValueString (),
492487 Description : model .Description .ValueStringPointer (),
493- PlanId : model .PlanID .ValueStringPointer (),
488+ PlanId : model .PlanID .ValueString (),
494489 }
495490}
496491
0 commit comments