Fix interfaces path for virtualization and DCIM

This commit is contained in:
Kalle Carlbark 2022-02-14 14:35:21 +01:00
parent 551409f431
commit b3138a42e5
No known key found for this signature in database
2 changed files with 70 additions and 70 deletions

View file

@ -219,7 +219,7 @@ type DCIMInterfaceFilter struct {
Limit int64 `schema:"limit,omitempty"`
}
const interfacesPath = dcimPath + "/interfaces"
const dcimInterfacesPath = dcimPath + "/interfaces"
// List devices. DeviceFilter is used to list based on filter queries.
func (s *DCIMInterfacesService) List(ctx context.Context, f *DCIMInterfaceFilter) (*DCIMInterfaces, error) {
@ -237,7 +237,7 @@ func (s *DCIMInterfacesService) List(ctx context.Context, f *DCIMInterfaceFilter
}
query = form.Encode()
req, err = s.client.newRequest(ctx, "GET", interfacesPath, query, nil)
req, err = s.client.newRequest(ctx, "GET", dcimInterfacesPath, query, nil)
if err != nil {
return &interfaces, err
}
@ -256,7 +256,7 @@ func (s *DCIMInterfacesService) Create(ctx context.Context, c *NewDCIMInterface)
var req *http.Request
var nic DCIMInterface
req, err = s.client.newRequest(ctx, "POST", interfacesPath, "", c)
req, err = s.client.newRequest(ctx, "POST", dcimInterfacesPath, "", c)
if err != nil {
return &nic, fmt.Errorf("unable to create request: %w", err)
}
@ -274,7 +274,7 @@ func (s *DCIMInterfacesService) Delete(ctx context.Context, i string) error {
var err error
var req *http.Request
req, err = s.client.newRequest(ctx, "DELETE", interfacesPath+"/"+i+"/", "", nil)
req, err = s.client.newRequest(ctx, "DELETE", dcimInterfacesPath+"/"+i+"/", "", nil)
if err != nil {
return fmt.Errorf("unable to create request: %w", err)
}

View file

@ -14,23 +14,23 @@ type VirtualizationInterfacesService service
// NewVirtualizationInterface is used for creating a new virtualization interface
type NewVirtualizationInterface struct {
VirtualMachine int `json:"virtual_machine"`
CustomFields interface{} `json:"custom_fields"`
Name string `json:"name"`
Enabled bool `json:"enabled"`
Parent int `json:"parent"`
Bridge int `json:"bridge"`
MTU int `json:"mtu"`
MACAddress string `json:"mac_address"`
Description string `json:"description"`
Mode string `json:"mode"`
UntaggedVLAN int `json:"untagged_vlan"`
TaggedVLANs []int `json:"tagged_vlans"`
Description string `json:"description"`
MACAddress string `json:"mac_address"`
Tags []struct {
Name string `json:"name"`
Slug string `json:"slug"`
Color string `json:"color"`
} `json:"tags"`
CustomFields interface{} `json:"custom_fields"`
TaggedVLANs []int `json:"tagged_vlans"`
Bridge int `json:"bridge"`
Parent int `json:"parent"`
UntaggedVLAN int `json:"untagged_vlan"`
MTU int `json:"mtu"`
VirtualMachine int `json:"virtual_machine"`
Enabled bool `json:"enabled"`
}
// VirtualizationInterfaces is a list of interfaces
@ -43,75 +43,75 @@ type VirtualizationInterfaces struct {
// VirtualizationInterface is one virtualization interface
type VirtualizationInterface struct {
ID int `json:"id"`
URL string `json:"url"`
Display string `json:"display"`
VirtualMachine struct {
ID int `json:"id"`
URL string `json:"url"`
Display string `json:"display"`
Name string `json:"name"`
} `json:"virtual_machine"`
Name string `json:"name"`
Enabled bool `json:"enabled"`
Parent struct {
ID int `json:"id"`
URL string `json:"url"`
Display string `json:"display"`
VirtualMachine struct {
ID int `json:"id"`
URL string `json:"url"`
Display string `json:"display"`
Name string `json:"name"`
} `json:"virtual_machine"`
Name string `json:"name"`
} `json:"parent"`
Bridge struct {
ID int `json:"id"`
URL string `json:"url"`
Display string `json:"display"`
VirtualMachine struct {
ID int `json:"id"`
URL string `json:"url"`
Display string `json:"display"`
Name string `json:"name"`
} `json:"virtual_machine"`
Name string `json:"name"`
} `json:"bridge"`
MTU int `json:"mtu"`
MACAddress string `json:"mac_address"`
Description string `json:"description"`
LastUpdated time.Time `json:"last_updated"`
CustomFields interface{} `json:"custom_fields"`
Mode struct {
Label string `json:"label"`
Value string `json:"value"`
} `json:"mode"`
UntaggedVLAN struct {
ID int `json:"id"`
Display string `json:"display"`
Description string `json:"description"`
Created string `json:"created"`
URL string `json:"url"`
Name string `json:"name"`
MACAddress string `json:"mac_address"`
VirtualMachine struct {
URL string `json:"url"`
Display string `json:"display"`
Vid int `json:"vid"`
Name string `json:"name"`
} `json:"untagged_vlan"`
ID int `json:"id"`
} `json:"virtual_machine"`
TaggedVLANs []struct {
ID int `json:"id"`
URL string `json:"url"`
Display string `json:"display"`
Vid int `json:"vid"`
Name string `json:"name"`
ID int `json:"id"`
Vid int `json:"vid"`
} `json:"tagged_vlans"`
Tags []struct {
ID int `json:"id"`
URL string `json:"url"`
Display string `json:"display"`
Name string `json:"name"`
Slug string `json:"slug"`
Color string `json:"color"`
ID int `json:"id"`
} `json:"tags"`
CustomFields interface{} `json:"custom_fields"`
Created string `json:"created"`
LastUpdated time.Time `json:"last_updated"`
Bridge struct {
URL string `json:"url"`
Display string `json:"display"`
Name string `json:"name"`
VirtualMachine struct {
URL string `json:"url"`
Display string `json:"display"`
Name string `json:"name"`
ID int `json:"id"`
} `json:"virtual_machine"`
ID int `json:"id"`
} `json:"bridge"`
Parent struct {
URL string `json:"url"`
Display string `json:"display"`
Name string `json:"name"`
VirtualMachine struct {
URL string `json:"url"`
Display string `json:"display"`
Name string `json:"name"`
ID int `json:"id"`
} `json:"virtual_machine"`
ID int `json:"id"`
} `json:"parent"`
UntaggedVLAN struct {
URL string `json:"url"`
Display string `json:"display"`
Name string `json:"name"`
ID int `json:"id"`
Vid int `json:"vid"`
} `json:"untagged_vlan"`
ID int `json:"id"`
MTU int `json:"mtu"`
CountIPAddresses int `json:"count_ipaddresses"`
CountFHRPGroups int `json:"count_fhrp_groups"`
Enabled bool `json:"enabled"`
}
// VirtualizationInterfaceFilter is used to filter out virtualization interfaces
@ -161,7 +161,7 @@ func (s *VirtualizationInterfacesService) List(ctx context.Context, f *Virtualiz
}
query = form.Encode()
req, err = s.client.newRequest(ctx, "GET", interfacesPath, query, nil)
req, err = s.client.newRequest(ctx, "GET", virtualizationInterfacesPath, query, nil)
if err != nil {
return &interfaces, err
}
@ -180,7 +180,7 @@ func (s *VirtualizationInterfacesService) Create(ctx context.Context, c *NewVirt
var req *http.Request
var nic VirtualizationInterface
req, err = s.client.newRequest(ctx, "POST", interfacesPath, "", c)
req, err = s.client.newRequest(ctx, "POST", virtualizationInterfacesPath, "", c)
if err != nil {
return &nic, fmt.Errorf("unable to create request: %w", err)
}