@@ -13,7 +13,6 @@ import (
1313 billingModels "github.com/hashicorp/hcp-sdk-go/clients/cloud-billing/preview/2020-11-05/models"
1414 "github.com/hashicorp/hcp-sdk-go/clients/cloud-resource-manager/stable/2019-12-10/client/project_service"
1515 "github.com/hashicorp/hcp-sdk-go/clients/cloud-resource-manager/stable/2019-12-10/models"
16- sharedmodels "github.com/hashicorp/hcp-sdk-go/clients/cloud-shared/v1/models"
1716 "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
1817 "github.com/hashicorp/terraform-plugin-framework/path"
1918 "github.com/hashicorp/terraform-plugin-framework/resource"
@@ -132,15 +131,6 @@ func (r *resourceProject) Create(ctx context.Context, req resource.CreateRequest
132131 return
133132 }
134133
135- // Wait for the project to be created, if an operation ID is returned.
136- if res .Payload .OperationID != "" {
137- err = waitForProjectOperation (ctx , r .client , "create project" , res .Payload .Project .ID , res .Payload .OperationID )
138- if err != nil {
139- resp .Diagnostics .AddError ("Error waiting for project creation" , err .Error ())
140- return
141- }
142- }
143-
144134 p := res .GetPayload ().Project
145135 plan .ResourceID = types .StringValue (p .ID )
146136 plan .ResourceName = types .StringValue (fmt .Sprintf ("project/%s" , p .ID ))
@@ -230,21 +220,11 @@ func (r *resourceProject) Update(ctx context.Context, req resource.UpdateRequest
230220 Name : plan .Name .ValueString (),
231221 }
232222
233- res , err := clients .SetProjectNameWithRetry (r .client , setNameReq )
223+ _ , err := clients .SetProjectNameWithRetry (r .client , setNameReq )
234224 if err != nil {
235225 resp .Diagnostics .AddError ("Error updating project name" , err .Error ())
236226 return
237227 }
238-
239- // Wait for the project name to be updated, if an operation ID is returned.
240- if res .Payload .OperationID != "" {
241- // Wait for the project name to be updated.
242- err = waitForProjectOperation (ctx , r .client , "update project name" , plan .ResourceID .ValueString (), res .Payload .OperationID )
243- if err != nil {
244- resp .Diagnostics .AddError ("Error waiting for project name update" , err .Error ())
245- return
246- }
247- }
248228 }
249229
250230 // Check if the description was updated
@@ -255,21 +235,12 @@ func (r *resourceProject) Update(ctx context.Context, req resource.UpdateRequest
255235 Description : plan .Description .ValueString (),
256236 }
257237
258- res , err := clients .SetProjectDescriptionWithRetry (r .client , setDescReq )
238+ _ , err := clients .SetProjectDescriptionWithRetry (r .client , setDescReq )
259239 if err != nil {
260240 resp .Diagnostics .AddError ("Error updating project description" , err .Error ())
261241 return
262242 }
263243
264- // Wait for the project description to be updated, if an operation ID is returned.
265- if res .Payload .OperationID != "" {
266- err = waitForProjectOperation (ctx , r .client , "update project description" , plan .ResourceID .ValueString (), res .Payload .OperationID )
267- if err != nil {
268- resp .Diagnostics .AddError ("Error waiting for project description update" , err .Error ())
269- return
270- }
271- }
272-
273244 }
274245
275246 // Store the updated values
@@ -283,10 +254,10 @@ func (r *resourceProject) Delete(ctx context.Context, req resource.DeleteRequest
283254 return
284255 }
285256
286- getParams := project_service .NewProjectServiceDeleteParams ()
287- getParams .ID = state .ResourceID .ValueString ()
257+ deleteParams := project_service .NewProjectServiceDeleteParams ()
258+ deleteParams .ID = state .ResourceID .ValueString ()
288259
289- res , err := r .client . Project . ProjectServiceDelete ( getParams , nil )
260+ _ , err := clients . DeleteProjectWithRetry ( r .client , deleteParams )
290261 if err != nil {
291262 var deleteErr * project_service.ProjectServiceDeleteDefault
292263 if errors .As (err , & deleteErr ) && deleteErr .IsCode (http .StatusNotFound ) {
@@ -296,28 +267,8 @@ func (r *resourceProject) Delete(ctx context.Context, req resource.DeleteRequest
296267 resp .Diagnostics .AddError ("Error deleting project" , err .Error ())
297268 return
298269 }
299-
300- // Wait for the project to be deleted, if an operation ID is returned.
301- if res .Payload .Operation .ID != "" {
302- // For delete operations, the operation is scoped at the organization level
303- projectID := ""
304- err = waitForProjectOperation (ctx , r .client , "delete project" , projectID , res .Payload .Operation .ID )
305- if err != nil {
306- resp .Diagnostics .AddError ("Error waiting for project deletion" , err .Error ())
307- return
308- }
309- }
310270}
311271
312272func (r * resourceProject ) ImportState (ctx context.Context , req resource.ImportStateRequest , resp * resource.ImportStateResponse ) {
313273 resource .ImportStatePassthroughID (ctx , path .Root ("resource_id" ), req , resp )
314274}
315-
316- func waitForProjectOperation (ctx context.Context , client * clients.Client , operationName , projectID string , operationID string ) error {
317- loc := & sharedmodels.HashicorpCloudLocationLocation {
318- OrganizationID : client .Config .OrganizationID ,
319- ProjectID : projectID ,
320- }
321-
322- return clients .WaitForOperation (ctx , client , operationName , loc , operationID )
323- }
0 commit comments