delete_nat_rule
Remove a NAT rule from a Tier-1 gateway in VMware NSX to manage network address translation configurations.
Instructions
Delete a NAT rule from a Tier-1 gateway.
Args: tier1_id: The Tier-1 gateway ID. rule_id: The NAT rule ID to delete. target: Optional NSX Manager target name from config. Uses default if omitted.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tier1_id | Yes | ||
| rule_id | Yes | ||
| target | No |
Output Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- vmware_nsx/ops/nat_route_mgmt.py:112-136 (handler)The actual implementation of the delete_nat_rule function that executes the API call to delete a NAT rule on a Tier-1 gateway.
def delete_nat_rule( client: NsxClient, tier1_id: str, rule_id: str, ) -> dict: """Delete a NAT rule from a Tier-1 gateway. Args: client: Authenticated NSX API client. tier1_id: Tier-1 gateway identifier. rule_id: NAT rule identifier to delete. Returns: Dict with deletion status. """ _validate_id(tier1_id) _validate_id(rule_id) path = ( f"/policy/api/v1/infra/tier-1s/{tier1_id}" f"/nat/USER/nat-rules/{rule_id}" ) client.delete(path) _log.info("Deleted NAT rule %s from Tier-1 %s", rule_id, tier1_id) return {"deleted": True, "tier1_id": tier1_id, "rule_id": rule_id} - mcp_server/server.py:598-615 (registration)The MCP tool registration and wrapper function for deleting a NAT rule. Note: The import in this file is listed as 'vmware_nsx.ops.nat_mgmt', however the search revealed the code is in 'vmware_nsx.ops.nat_route_mgmt'. It appears 'vmware_nsx/ops/nat_mgmt' may be an alias or misdirection, but the functional implementation is in 'nat_route_mgmt.py'.
def delete_nat_rule( tier1_id: str, rule_id: str, target: str | None = None, ) -> str: """Delete a NAT rule from a Tier-1 gateway. Args: tier1_id: The Tier-1 gateway ID. rule_id: The NAT rule ID to delete. target: Optional NSX Manager target name from config. Uses default if omitted. """ from vmware_nsx.ops.nat_mgmt import delete_nat_rule as _delete client = _get_connection(target) _delete(client, tier1_id, rule_id) return f"NAT rule '{rule_id}' deleted from '{tier1_id}'."