fanatic / go-infoblox

Golang Infoblox WAPI Library (Deprecated)
16 stars 26 forks source link

Adding fields to Record Objects #21

Closed richardlock closed 8 years ago

richardlock commented 8 years ago

Hi,

Is it possible to add some extra fields to some of the Record Objects, such as View, Comment, etc? I'm using the Create function by supplying a body parameter (e.g. client.RecordA().Create(values, opts, body)) and creating the body using a struct:

body := &infoblox.RecordAObject{
            Name:     name,
            Ipv4Addr: value,
            Ttl:      ttl,
        }

I thought I could supply both a values and a body parameter in the API call, but it will only accept one or the other. If the structs also had the extra fields, it would allow the whole record creation to be done using JSON based on the struct. I think you can only create host records using a body parameter because you can't pass a list of ipv4addrs in the url values. So the RecordAObject struct would look like:

type RecordAObject struct {
    Object
    Comment string `json:"comment,omitempty"`
    Ipv4Addr string `json:"ipv4addr,omitempty"`
    Name string `json:"name,omitempty"`
    Ttl int `json:"ttl,omitempty"`
    View string `json:"view,omitempty"`
}

Comment and view are common to the other resources. The RecordHostObject would look like:

type RecordHostObject struct {
    Object
    Comment string `json:"comment,omitempty"`
    Configure_For_Dns bool `json:"configure_for_dns,omitempty"`
    Ipv4Addrs []HostIpv4Addr `json:"ipv4addrs,omitempty"`
    //Ipv6Addrs string `json:"ipv6addrs,omitempty"`
    Name string `json:"name,omitempty"`
    View string `json:"view,omitempty"`
}

I can submit a PR if that would help.

Thanks, Richard

fanatic commented 8 years ago

Adding fields preserves backwards compatibility and you've added them to just the objects that support them. We still use go-infoblox in production, but our use is mostly limited to ipv4 host records. Thank you for using and testing the others!