// 2020 Rackspace, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"): you may // not use this file except in compliance with the License. You may obtain // a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the // License for the specific language governing permissions and limitations // under the License. package mydp import ( "github.com/kolo/xmlrpc" ) type ( // IPTDeviceResp represents the response structure from the // iptool.Devices.get resource IPTDeviceResp struct { Row Device `xmlrpc:"row"` Related []IPTDevice `xmlrpc:"related"` } // IPTDevice represents the response structure for the // IP Tool specific info about a device IPTDevice struct { IPsNote string `xmlrpc:"ips_note"` IPsSubnet string `xmlrpc:"ips_subnet"` AddressCount string `xmlrpc:"address_count"` MaxAddress string `xmlrpc:"max_address"` MinAddress string `xmlrpc:"min_address"` } // IPTIPToDevice represents the response structure for the // IP Tool specific info about IP addresses IPTIPToDevice struct { DeviceID string `xmlrpc:"DeviceID"` CustomerID string `xmlrpc:"CustomerID"` SpecificDeviceType string `xmlrpc:"SpecificDeviceType"` SpecificDeviceID string `xmlrpc:"SpecificDeviceID"` IPAddress string `xmlrpc:"ip_address"` Name string `xmlrpc:"Name"` } ) // IPToolDevices method will return an IPTDevice with the structure returned from // the IP tool XMLRPC resource. func (c *Client) IPToolDevices(deviceID int) (IPTDeviceResp, error) { var result IPTDeviceResp client, err := xmlrpc.NewClient(c.ipToolURL("xmlrpc/Devices.php"), nil) if err != nil { return result, err } err = client.Call("iptool.Devices.get", deviceID, &result) return result, err } // IPToolIPToDevice method will return an IPToDevice with the structure returned from // the IP tool XMLRPC resource. func (c *Client) IPToolIPToDevice(ipAddress string) ([]IPTIPToDevice, error) { var result []IPTIPToDevice client, err := xmlrpc.NewClient(c.ipToolURL("xmlrpc/Devices.php"), nil) if err != nil { return result, err } err = client.Call("iptool.Devices.IPToDevice", ipAddress, &result) return result, err }