Fix interfaces path for virtualization and DCIM
This commit is contained in:
parent
551409f431
commit
b3138a42e5
2 changed files with 70 additions and 70 deletions
|
@ -219,7 +219,7 @@ type DCIMInterfaceFilter struct {
|
||||||
Limit int64 `schema:"limit,omitempty"`
|
Limit int64 `schema:"limit,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
const interfacesPath = dcimPath + "/interfaces"
|
const dcimInterfacesPath = dcimPath + "/interfaces"
|
||||||
|
|
||||||
// List devices. DeviceFilter is used to list based on filter queries.
|
// List devices. DeviceFilter is used to list based on filter queries.
|
||||||
func (s *DCIMInterfacesService) List(ctx context.Context, f *DCIMInterfaceFilter) (*DCIMInterfaces, error) {
|
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()
|
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 {
|
if err != nil {
|
||||||
return &interfaces, err
|
return &interfaces, err
|
||||||
}
|
}
|
||||||
|
@ -256,7 +256,7 @@ func (s *DCIMInterfacesService) Create(ctx context.Context, c *NewDCIMInterface)
|
||||||
var req *http.Request
|
var req *http.Request
|
||||||
var nic DCIMInterface
|
var nic DCIMInterface
|
||||||
|
|
||||||
req, err = s.client.newRequest(ctx, "POST", interfacesPath, "", c)
|
req, err = s.client.newRequest(ctx, "POST", dcimInterfacesPath, "", c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &nic, fmt.Errorf("unable to create request: %w", err)
|
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 err error
|
||||||
var req *http.Request
|
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 {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to create request: %w", err)
|
return fmt.Errorf("unable to create request: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,23 +14,23 @@ type VirtualizationInterfacesService service
|
||||||
|
|
||||||
// NewVirtualizationInterface is used for creating a new virtualization interface
|
// NewVirtualizationInterface is used for creating a new virtualization interface
|
||||||
type NewVirtualizationInterface struct {
|
type NewVirtualizationInterface struct {
|
||||||
VirtualMachine int `json:"virtual_machine"`
|
CustomFields interface{} `json:"custom_fields"`
|
||||||
Name string `json:"name"`
|
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"`
|
Mode string `json:"mode"`
|
||||||
UntaggedVLAN int `json:"untagged_vlan"`
|
Description string `json:"description"`
|
||||||
TaggedVLANs []int `json:"tagged_vlans"`
|
MACAddress string `json:"mac_address"`
|
||||||
Tags []struct {
|
Tags []struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Slug string `json:"slug"`
|
Slug string `json:"slug"`
|
||||||
Color string `json:"color"`
|
Color string `json:"color"`
|
||||||
} `json:"tags"`
|
} `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
|
// VirtualizationInterfaces is a list of interfaces
|
||||||
|
@ -43,75 +43,75 @@ type VirtualizationInterfaces struct {
|
||||||
|
|
||||||
// VirtualizationInterface is one virtualization interface
|
// VirtualizationInterface is one virtualization interface
|
||||||
type VirtualizationInterface struct {
|
type VirtualizationInterface struct {
|
||||||
ID int `json:"id"`
|
LastUpdated time.Time `json:"last_updated"`
|
||||||
URL string `json:"url"`
|
CustomFields interface{} `json:"custom_fields"`
|
||||||
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"`
|
|
||||||
Mode struct {
|
Mode struct {
|
||||||
Label string `json:"label"`
|
Label string `json:"label"`
|
||||||
Value string `json:"value"`
|
Value string `json:"value"`
|
||||||
} `json:"mode"`
|
} `json:"mode"`
|
||||||
UntaggedVLAN struct {
|
Display string `json:"display"`
|
||||||
ID int `json:"id"`
|
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"`
|
URL string `json:"url"`
|
||||||
Display string `json:"display"`
|
Display string `json:"display"`
|
||||||
Vid int `json:"vid"`
|
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
} `json:"untagged_vlan"`
|
ID int `json:"id"`
|
||||||
|
} `json:"virtual_machine"`
|
||||||
TaggedVLANs []struct {
|
TaggedVLANs []struct {
|
||||||
ID int `json:"id"`
|
|
||||||
URL string `json:"url"`
|
URL string `json:"url"`
|
||||||
Display string `json:"display"`
|
Display string `json:"display"`
|
||||||
Vid int `json:"vid"`
|
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
|
ID int `json:"id"`
|
||||||
|
Vid int `json:"vid"`
|
||||||
} `json:"tagged_vlans"`
|
} `json:"tagged_vlans"`
|
||||||
Tags []struct {
|
Tags []struct {
|
||||||
ID int `json:"id"`
|
|
||||||
URL string `json:"url"`
|
URL string `json:"url"`
|
||||||
Display string `json:"display"`
|
Display string `json:"display"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Slug string `json:"slug"`
|
Slug string `json:"slug"`
|
||||||
Color string `json:"color"`
|
Color string `json:"color"`
|
||||||
|
ID int `json:"id"`
|
||||||
} `json:"tags"`
|
} `json:"tags"`
|
||||||
CustomFields interface{} `json:"custom_fields"`
|
Bridge struct {
|
||||||
Created string `json:"created"`
|
URL string `json:"url"`
|
||||||
LastUpdated time.Time `json:"last_updated"`
|
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"`
|
CountIPAddresses int `json:"count_ipaddresses"`
|
||||||
CountFHRPGroups int `json:"count_fhrp_groups"`
|
CountFHRPGroups int `json:"count_fhrp_groups"`
|
||||||
|
Enabled bool `json:"enabled"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// VirtualizationInterfaceFilter is used to filter out virtualization interfaces
|
// VirtualizationInterfaceFilter is used to filter out virtualization interfaces
|
||||||
|
@ -161,7 +161,7 @@ func (s *VirtualizationInterfacesService) List(ctx context.Context, f *Virtualiz
|
||||||
}
|
}
|
||||||
query = form.Encode()
|
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 {
|
if err != nil {
|
||||||
return &interfaces, err
|
return &interfaces, err
|
||||||
}
|
}
|
||||||
|
@ -180,7 +180,7 @@ func (s *VirtualizationInterfacesService) Create(ctx context.Context, c *NewVirt
|
||||||
var req *http.Request
|
var req *http.Request
|
||||||
var nic VirtualizationInterface
|
var nic VirtualizationInterface
|
||||||
|
|
||||||
req, err = s.client.newRequest(ctx, "POST", interfacesPath, "", c)
|
req, err = s.client.newRequest(ctx, "POST", virtualizationInterfacesPath, "", c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &nic, fmt.Errorf("unable to create request: %w", err)
|
return &nic, fmt.Errorf("unable to create request: %w", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue