In my recent projects i did bulk import via pynetbox , below is an example of cable connection between 2 interfaces , This might help you with creating new interface connections .
=======================================================================================================================================
def cables_create(self):
for nodea,porta,nodeb,portb,hairpin,row in zip(self.list_sheet4_node_a,self.list_sheet4_port_a,
self.list_sheet4_node_b,self.list_sheet4_port_b,
self.list_sheet4_hairpin,range(len(self.list_sheet4_node_a))):
a_id=0
b_id=0
#print("{}:{}:{}:{}".format(nodea,porta,nodeb,portb))
if nodea!="" and nodeb!="" and porta!="" and portb!="":
try:
a_id=(self.nb.dcim.interfaces.get(name=porta, device=self.nb.dcim.devices.get(name=nodea))).id
b_id=(self.nb.dcim.interfaces.get(name=portb, device=self.nb.dcim.devices.get(name=nodeb))).id
except AttributeError:
print("ROW : {} Device {} Interface {} or Device {} Interface {} not found".format(row,nodea,porta,nodeb,portb))
if a_id !=0 and b_id !=0:
data_input = {
"termination_a_type": "dcim.interface",
"termination_a_id": a_id,
"termination_b_type": "dcim.interface",
"termination_b_id": b_id,
"status": 'true'
}
try:
result = self.nb.dcim.cables.create(data_input)
print("ROW : {} cable Connection Made successfully {} : {} <-> {} : {}".format(row,nodea,porta,nodeb,portb))
except (self.request_error,AttributeError):
print("ROW : {} Cable Already Connected {}:{}:{}:{}".format(row,nodea,porta,nodeb,portb) )
else:
print("ROW : {} Invalid - Details not Enough for Cable Connection {}:{}:{}:{}".format(row,nodea,porta,nodeb,portb))
=======================================================================================================================================