From ca17f8a62b0639979ea24a66bb52e64caa300889 Mon Sep 17 00:00:00 2001 From: Chris Marget Date: Tue, 13 Aug 2024 11:19:04 -0400 Subject: [PATCH] device_profile_id should not be computed --- apstra/freeform/freeform_system.go | 7 ++++--- apstra/resource_freeform_system.go | 7 ------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/apstra/freeform/freeform_system.go b/apstra/freeform/freeform_system.go index bfa5e9bd..54bcf341 100644 --- a/apstra/freeform/freeform_system.go +++ b/apstra/freeform/freeform_system.go @@ -132,12 +132,13 @@ func (o FreeformSystem) ResourceAttributes() map[string]resourceSchema.Attribute )}, }, "device_profile_id": resourceSchema.StringAttribute{ - MarkdownDescription: "Device profile ID of the System", - Optional: true, - Computed: true, + MarkdownDescription: fmt.Sprintf("Device profile ID of the System. Required when `type` is %q.", + utils.StringersToFriendlyString(apstra.SystemTypeInternal)), + Optional: true, Validators: []validator.String{ stringvalidator.LengthAtLeast(1), apstravalidator.ForbiddenWhenValueIs(path.MatchRoot("type"), types.StringValue(utils.StringersToFriendlyString(apstra.SystemTypeExternal))), + apstravalidator.RequiredWhenValueIs(path.MatchRoot("type"), types.StringValue(utils.StringersToFriendlyString(apstra.SystemTypeInternal))), }, }, "system_id": resourceSchema.StringAttribute{ diff --git a/apstra/resource_freeform_system.go b/apstra/resource_freeform_system.go index e65b00c4..c6fe449b 100644 --- a/apstra/resource_freeform_system.go +++ b/apstra/resource_freeform_system.go @@ -79,9 +79,6 @@ func (o *resourceFreeformSystem) Create(ctx context.Context, req resource.Create } plan.Id = types.StringValue(id.String()) - if plan.DeviceProfileId.IsUnknown() { - plan.DeviceProfileId = types.StringNull() - } // set state resp.Diagnostics.Append(resp.State.Set(ctx, &plan)...) @@ -164,10 +161,6 @@ func (o *resourceFreeformSystem) Update(ctx context.Context, req resource.Update return } - if plan.DeviceProfileId.IsUnknown() { - plan.DeviceProfileId = types.StringNull() - } - // set state resp.Diagnostics.Append(resp.State.Set(ctx, &plan)...) }