Skip to content

Questions about go-netbox/v3 (openapi) #166

Answered by jqueuniet
smutel asked this question in Q&A
Discussion options

You must be logged in to vote

I posted a creation example earlier in the OpenAPI discussion, but here it is for convenience:

// Create an IP address
req := netbox.WritableIPAddressRequest{
	Address: address,
}
req.SetTenant(tenant.Id)
req.SetStatus("active")
if vrf != nil {
	req.SetVrf(vrf.Id)
}

ipAddress, resp, err := client.
	IpamApi.
	IpamIpAddressesCreate(ctx).
	WritableIPAddressRequest(req).
	Execute()

Here is another for a VM interface with slightly different calls:

req := netbox.NewWritableVMInterfaceRequestWithDefaults()
req.SetName(fmt.Sprintf("net%d", vif.Index))
req.SetVirtualMachine(vm.Id)

if vif.MTU != 0 {
	req.SetMtu(vif.MTU)
}

nbvif, resp, err := client.
	VirtualizationAPI.
	VirtualizationInterfacesC…

Replies: 1 comment 11 replies

Comment options

You must be logged in to vote
11 replies
@jacobsalmela
Comment options

@jqueuniet
Comment options

@smutel
Comment options

@jqueuniet
Comment options

@smutel
Comment options

Answer selected by smutel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants