fanatic / go-infoblox

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

Add client Get and Find methods for PTR records. #31

Closed JackBracken closed 6 years ago

JackBracken commented 6 years ago

I'm adding PTR records to the terraform infoblox provider that @prudhvitella created and need to be able to Get them from the go-infoblox client. The code is pretty much a copy-paste of the methods in record_a.go and (admittedly minimally) tested with the below example code.

package main

import (
    "fmt"

    infoblox "github.com/fanatic/go-infoblox"
)

func main() {
    recordRef := "record:ptr/blahblah:ptrrecordtest.domain.lan/default"
    recordName := "ptrrecordtest.domain.lan"

    ib := infoblox.NewClient("https://10.0.0.10", "infobloxuser", "infobloxpassword!", false, false)

    ptr, err := ib.GetRecordPtr(recordRef, nil)
    if err != nil {
        panic(err)
    }
    fmt.Println(ptr)

    findPtr, err := ib.FindRecordPtr(recordName)
    if err != nil {
        panic(err)
    }
    fmt.Println(findPtr)
}

Output is:

$ go run main.go
2018/04/03 14:20:55 WARNING: SSL cert verification  disabled
2018/04/03 14:20:55 GET /wapi/v1.4.1/record:ptr/blahblah:ptrrecordtest.domain.lan/default?  payload:
&{{record:ptr/blahblah:ptrrecordtest.domain.lan/default <nil>}     ptrrecordtest.domain.lan 0 default}
2018/04/03 14:20:55 GET /wapi/v1.4.1/record:ptr?name=ptrrecordtest.domain.lan  payload:
[{{record:ptr/blahblah:ptrrecordtest.domain.lan/default <nil>}     ptrrecordtest.domain.lan 0 default}]
fanatic commented 6 years ago

Fantastic! And thank you for doing that testing.