API not consistent for VM -> Interface -> IP #9440

Closed
opened 2025-12-29 20:49:59 +01:00 by adam · 1 comment
Owner

Originally created by @Daniel-Dietz on GitHub (Apr 4, 2024).

NetBox version

v3.7.4

Feature type

Change to existing functionality

Proposed functionality

The behavior of the API is not consistent

The Return of the VM contains the ID needed to create the Interfaces for the VM,
the Return of the Interface does contain an ID but the IPAM IP-Address Body does not accept it.

{
  "address": "string",
  "vrf": 0,
  "tenant": 0,
  "status": "active",
  "role": "loopback",
  "assigned_object_type": "string",
  "assigned_object_id": 9223372036854776000,
  "nat_inside": 0,
  "dns_name": "df",
  "description": "string",
  "comments": "string",
  "tags": [
    {
      "name": "string",
      "slug": "dfsas",
      "color": "5a7bfe"
    }
  ],
  "custom_fields": {
    "additionalProp1": "string",
    "additionalProp2": "string",
    "additionalProp3": "string"
  }
}

Proposed change add the field vminterface to the API where the ID of an VM Interface is accepted, this would put it inline with the Web UI where the assignment is triggered via https://netbox/ipam/ip-addresses/add/?vminterface=764

Use case

Ease of use for API development and consistency across multiple API Functions

Database changes

No response

External dependencies

No response

Originally created by @Daniel-Dietz on GitHub (Apr 4, 2024). ### NetBox version v3.7.4 ### Feature type Change to existing functionality ### Proposed functionality The behavior of the API is not consistent The Return of the VM contains the ID needed to create the Interfaces for the VM, the Return of the Interface does contain an ID but the IPAM IP-Address Body does not accept it. ``` { "address": "string", "vrf": 0, "tenant": 0, "status": "active", "role": "loopback", "assigned_object_type": "string", "assigned_object_id": 9223372036854776000, "nat_inside": 0, "dns_name": "df", "description": "string", "comments": "string", "tags": [ { "name": "string", "slug": "dfsas", "color": "5a7bfe" } ], "custom_fields": { "additionalProp1": "string", "additionalProp2": "string", "additionalProp3": "string" } } ``` Proposed change add the field vminterface to the API where the ID of an VM Interface is accepted, this would put it inline with the Web UI where the assignment is triggered via https://netbox/ipam/ip-addresses/add/?vminterface=764 ### Use case Ease of use for API development and consistency across multiple API Functions ### Database changes _No response_ ### External dependencies _No response_
adam added the type: feature label 2025-12-29 20:49:59 +01:00
adam closed this issue 2025-12-29 20:49:59 +01:00
Author
Owner

@jeremystretch commented on GitHub (Apr 5, 2024):

There is no vminterface relation for IP addresses. IP addresses can be assigned to several types of objects (device interfaces, VM interfaces, or FHRP groups) using a generic foreign key relation. This is done by specifying both the related object type (assigned_object_type) and numeric ID (assigned_object_id) as documented in the schema. This is standard convention for all generic foreign key relations in NetBox.

@jeremystretch commented on GitHub (Apr 5, 2024): There is no `vminterface` relation for IP addresses. IP addresses can be assigned to several types of objects (device interfaces, VM interfaces, or FHRP groups) using a generic foreign key relation. This is done by specifying both the related object type (`assigned_object_type`) and numeric ID (`assigned_object_id`) as documented in the schema. This is standard convention for all generic foreign key relations in NetBox.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#9440