From b3138a42e5367187220da21c8895ae6b26ca30d8 Mon Sep 17 00:00:00 2001 From: Kalle Carlbark Date: Mon, 14 Feb 2022 14:35:21 +0100 Subject: [PATCH] Fix interfaces path for virtualization and DCIM --- dcim_interfaces.go | 8 +-- virtualization_interfaces.go | 132 +++++++++++++++++------------------ 2 files changed, 70 insertions(+), 70 deletions(-) diff --git a/dcim_interfaces.go b/dcim_interfaces.go index 0b4e459..647dc36 100644 --- a/dcim_interfaces.go +++ b/dcim_interfaces.go @@ -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) } diff --git a/virtualization_interfaces.go b/virtualization_interfaces.go index c0848ad..01b7325 100644 --- a/virtualization_interfaces.go +++ b/virtualization_interfaces.go @@ -14,23 +14,23 @@ type VirtualizationInterfacesService service // NewVirtualizationInterface is used for creating a new virtualization interface type NewVirtualizationInterface struct { - VirtualMachine int `json:"virtual_machine"` - 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"` - Tags []struct { + CustomFields interface{} `json:"custom_fields"` + Name string `json:"name"` + Mode string `json:"mode"` + 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"` - Mode struct { + 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"` - CountIPAddresses int `json:"count_ipaddresses"` - CountFHRPGroups int `json:"count_fhrp_groups"` + 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) }