Omit empty fields on NewVirtualMachine

This commit is contained in:
Kalle Carlbark 2022-02-08 14:56:51 +01:00
parent e6298e598a
commit e47de1a498
No known key found for this signature in database

View file

@ -77,25 +77,25 @@ type VirtualMachines struct {
// NewVirtualMachine is used to create new VirtualizationVirtualMachines
type NewVirtualMachine struct {
CustomFields struct{} `json:"custom_fields"`
Status string `json:"status"`
LocalContextData string `json:"local_context_data"`
Comments string `json:"comments"`
Name string `json:"name"`
Tags []struct {
Name string `json:"name"`
Slug string `json:"slug"`
Color string `json:"color"`
} `json:"tags"`
Platform int `json:"platform"`
PrimaryIP4 int `json:"primary_ip4"`
Vcpus int `json:"vcpus"`
Memory int `json:"memory"`
Disk int `json:"disk"`
Role int `json:"role"`
Cluster int `json:"cluster"`
Tenant int `json:"tenant"`
PrimaryIP6 int `json:"primary_ip6"`
CustomFields *struct{} `json:"custom_fields,omitempty"`
Status string `json:"status"`
LocalContextData string `json:"local_context_data,omitempty"`
Comments string `json:"comments,omitempty"`
Name string `json:"name"`
Tags *[]struct {
Name string `json:"name,omitempty"`
Slug string `json:"slug,omitempty"`
Color string `json:"color,omitempty"`
} `json:"tags,omitempty"`
Platform int `json:"platform,omitempty"`
PrimaryIP4 int `json:"primary_ip4,omitempty"`
VCPUs int `json:"vcpus,omitempty"`
Memory int `json:"memory,omitempty"`
Disk int `json:"disk,omitempty"`
Role int `json:"role,omitempty"`
Cluster int `json:"cluster,omitempty"`
Tenant int `json:"tenant,omitempty"`
PrimaryIP6 int `json:"primary_ip6,omitempty"`
}
// VirtualMachineFilter is used to filter dcim_device_list query to the Netbox API
@ -146,7 +146,7 @@ type VirtualMachineFilter struct {
Limit int `schema:"limit,omitempty"`
}
const virtualMachinesPath = virtualizationPath + "/virtual-machines"
const virtualMachinesPath = virtualizationPath + "/virtual-machines/"
// List secrets. SecretsFilter is used to list based on filter queries.
func (s *VirtualMachinesService) List(ctx context.Context, f *VirtualMachineFilter) (*VirtualMachines, error) {
@ -156,7 +156,6 @@ func (s *VirtualMachinesService) List(ctx context.Context, f *VirtualMachineFilt
var err error
encoder := schema.NewEncoder()
form := url.Values{}
err = encoder.Encode(f, form)
if err != nil {