Skip to content

Commit

Permalink
handle 404 in GetDeviceKey
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismarget-j committed Aug 22, 2024
1 parent b77ab3c commit 7123371
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions apstra/system_agents/managed_device.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,13 @@ func (o *ManagedDevice) Acknowledge(ctx context.Context, si *apstra.ManagedSyste
}

func (o *ManagedDevice) GetDeviceKey(ctx context.Context, client *apstra.Client, diags *diag.Diagnostics) {
o.DeviceKey = types.StringNull()

// Get SystemInfo from API
systemInfo, err := client.GetSystemInfo(ctx, apstra.SystemId(o.SystemId.ValueString()))
if err != nil {
if utils.IsApstra404(err) {
return // o.DeviceKey has been set to null -- better ideas?
} else {
diags.AddError(
"error reading managed device system info",
Expand All @@ -223,9 +226,7 @@ func (o *ManagedDevice) GetDeviceKey(ctx context.Context, client *apstra.Client,
}

// record device key and location if possible
if systemInfo == nil {
o.DeviceKey = types.StringNull()
} else {
if systemInfo != nil {
o.DeviceKey = types.StringValue(systemInfo.DeviceKey)
}
}
Expand Down

0 comments on commit 7123371

Please sign in to comment.