This solution provides the steps to edit the firewall rules using API on NSX for vSphere.
VMware NSX for vSphere 6.4.x
Exclude Mgmt. Services allow DISTRIBUTED_FIREWALL DISTRIBUTED_FIREWALL DISTRIBUTED_FIREWALL true 1007 MGMT Servers securitygroup-11 SecurityGroup true inout any