in internal/provider/plan_resource.go [294:353]
func (r *planResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) {
// Get current state
var state planResourceModel
diags := req.State.Get(ctx, &state)
resp.Diagnostics.Append(diags...)
if resp.Diagnostics.HasError() {
return
}
// Get refreshed values
respObject, _, err := r.client.SLAApi.GetSla(r.authCtx, state.ID.ValueString())
if err != nil {
resp.Diagnostics.AddError(
"Error Reading SLA",
"Could not read SLA with ID "+state.ID.ValueString()+": "+err.Error(),
)
return
}
// Overwrite items with refreshed state
state.ID = types.StringValue(respObject.Id)
state.Href = types.StringValue(respObject.Href)
state.Syncdate = types.Int64Value(respObject.Syncdate)
state.Modifydate = types.Int64Value(respObject.Modifydate)
state.Stale = types.BoolValue(respObject.Stale)
state.Expirationoff = types.StringValue(respObject.Expirationoff)
state.Dedupasyncoff = types.StringValue(respObject.Dedupasyncoff)
state.Logexpirationoff = types.BoolValue(respObject.Logexpirationoff)
state.Scheduleoff = types.StringValue(respObject.Scheduleoff)
state.Application.Appname = types.StringValue(respObject.Application.Appname)
state.Application.Apptype = types.StringValue(respObject.Application.Apptype)
state.Application.Description = types.StringValue(respObject.Application.Description)
state.Application.Href = types.StringValue(respObject.Application.Href)
state.Application.Name = types.StringValue(respObject.Application.Name)
state.Application.Stale = types.BoolValue(respObject.Application.Stale)
state.Application.Syncdate = types.Int64Value(respObject.Application.Syncdate)
state.Application.Href = types.StringValue(respObject.Application.Href)
state.Application.Href = types.StringValue(respObject.Application.Href)
state.Slp.Href = types.StringValue(respObject.Slp.Href)
state.Slp.Cid = types.StringValue(respObject.Slp.Cid)
state.Slp.Name = types.StringValue(respObject.Slp.Name)
state.Slp.Stale = types.BoolValue(respObject.Slp.Stale)
state.Slp.Syncdate = types.Int64Value(respObject.Slp.Syncdate)
state.Slt.Href = types.StringValue(respObject.Slt.Href)
state.Slt.Name = types.StringValue(respObject.Slt.Name)
state.Slt.Override = types.StringValue(respObject.Slt.Override)
state.Slt.Sourcename = types.StringValue(respObject.Slt.Sourcename)
state.Slt.Stale = types.BoolValue(respObject.Slt.Stale)
// Set refreshed state
diags = resp.State.Set(ctx, &state)
resp.Diagnostics.Append(diags...)
if resp.Diagnostics.HasError() {
return
}
}