in teamcity/pool_resource.go [333:371]
func (r *poolResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) {
// get state
var state models.PoolDataModel
diags := req.State.Get(ctx, &state)
resp.Diagnostics.Append(diags...)
if resp.Diagnostics.HasError() {
return
}
// verify state id
if state.Id.IsNull() {
resp.Diagnostics.AddAttributeError(
path.Root("id"),
"Agent pool state's id cannot be null",
"The Resource cannot delete an Agent Pool since there is an inconsistent state.",
)
return
}
id := state.Id.String()
err := r.client.DeletePool(id)
if err != nil && errors.Is(err, context.DeadlineExceeded) {
resp.Diagnostics.AddError(
"Couldn't delete agent pool: Timeout",
err.Error(),
)
return
}
if err != nil {
resp.Diagnostics.AddError(
fmt.Sprintf("Could not delete pool resource with name %s", state.Name),
err.Error(),
)
return
}
}