@@ -469,7 +469,16 @@ func mapFields(ctx context.Context, networkInterfaceResp *iaas.NIC, model *Model
469469 respAllowedAddresses := []string {}
470470 var diags diag.Diagnostics
471471 if networkInterfaceResp .AllowedAddresses == nil {
472- model .AllowedAddresses = types .ListNull (types .StringType )
472+ // If we send an empty list, the API will send null in the response
473+ // We should handle this case and set the value to an empty list
474+ if ! model .AllowedAddresses .IsNull () {
475+ model .AllowedAddresses , diags = types .ListValueFrom (ctx , types .StringType , []string {})
476+ if diags .HasError () {
477+ return fmt .Errorf ("map network interface allowed addresses: %w" , core .DiagsToError (diags ))
478+ }
479+ } else {
480+ model .AllowedAddresses = types .ListNull (types .StringType )
481+ }
473482 } else {
474483 for _ , n := range * networkInterfaceResp .AllowedAddresses {
475484 respAllowedAddresses = append (respAllowedAddresses , * n .String )
@@ -553,19 +562,20 @@ func toCreatePayload(ctx context.Context, model *Model) (*iaas.CreateNICPayload,
553562 }
554563 }
555564
556- allowedAddressesPayload := []iaas.AllowedAddressesInner {}
557-
565+ allowedAddressesPayload := & []iaas.AllowedAddressesInner {}
558566 if ! (model .AllowedAddresses .IsNull () || model .AllowedAddresses .IsUnknown ()) {
559567 for _ , allowedAddressModel := range model .AllowedAddresses .Elements () {
560568 allowedAddressString , ok := allowedAddressModel .(types.String )
561569 if ! ok {
562570 return nil , fmt .Errorf ("type assertion failed" )
563571 }
564572
565- allowedAddressesPayload = append (allowedAddressesPayload , iaas.AllowedAddressesInner {
573+ * allowedAddressesPayload = append (* allowedAddressesPayload , iaas.AllowedAddressesInner {
566574 String : conversion .StringValueToPointer (allowedAddressString ),
567575 })
568576 }
577+ } else {
578+ allowedAddressesPayload = nil
569579 }
570580
571581 if ! model .Labels .IsNull () && ! model .Labels .IsUnknown () {
@@ -577,14 +587,15 @@ func toCreatePayload(ctx context.Context, model *Model) (*iaas.CreateNICPayload,
577587 }
578588
579589 return & iaas.CreateNICPayload {
580- AllowedAddresses : & allowedAddressesPayload ,
590+ AllowedAddresses : allowedAddressesPayload ,
581591 SecurityGroups : & modelSecurityGroups ,
582592 Labels : labelPayload ,
583593 Name : conversion .StringValueToPointer (model .Name ),
584594 Device : conversion .StringValueToPointer (model .Device ),
585595 Ipv4 : conversion .StringValueToPointer (model .IPv4 ),
586596 Mac : conversion .StringValueToPointer (model .Mac ),
587597 Type : conversion .StringValueToPointer (model .Type ),
598+ NicSecurity : conversion .BoolValueToPointer (model .Security ),
588599 }, nil
589600}
590601
@@ -604,8 +615,7 @@ func toUpdatePayload(ctx context.Context, model *Model, currentLabels types.Map)
604615 modelSecurityGroups = append (modelSecurityGroups , securityGroupString .ValueString ())
605616 }
606617
607- allowedAddressesPayload := []iaas.AllowedAddressesInner {}
608-
618+ allowedAddressesPayload := []iaas.AllowedAddressesInner {} // Even if null in the model, we need to send an empty list to the API since it's a PATCH endpoint
609619 if ! (model .AllowedAddresses .IsNull () || model .AllowedAddresses .IsUnknown ()) {
610620 for _ , allowedAddressModel := range model .AllowedAddresses .Elements () {
611621 allowedAddressString , ok := allowedAddressModel .(types.String )
@@ -632,5 +642,6 @@ func toUpdatePayload(ctx context.Context, model *Model, currentLabels types.Map)
632642 SecurityGroups : & modelSecurityGroups ,
633643 Labels : labelPayload ,
634644 Name : conversion .StringValueToPointer (model .Name ),
645+ NicSecurity : conversion .BoolValueToPointer (model .Security ),
635646 }, nil
636647}
0 commit comments