1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00

go get -u github.com/tiramiseb/go-gandi (#711)

This commit is contained in:
Tom Limoncelli
2020-03-27 12:09:56 -04:00
committed by GitHub
parent 45f36ffd12
commit d14f00ce06
10 changed files with 32 additions and 48 deletions

2
go.mod
View File

@ -45,7 +45,7 @@ require (
github.com/tdewolff/minify v2.3.6+incompatible
github.com/tdewolff/parse v2.3.4+incompatible // indirect
github.com/tdewolff/test v1.0.6 // indirect
github.com/tiramiseb/go-gandi v0.0.0-20200309181223-e1cf2e430b3a
github.com/tiramiseb/go-gandi v0.0.0-20200313161345-6b74caa58663
github.com/urfave/cli/v2 v2.2.0
github.com/vultr/govultr v0.2.0
golang.org/x/crypto v0.0.0-20200320181102-891825fb96df // indirect

9
go.sum
View File

@ -39,9 +39,7 @@ github.com/DisposaBoy/JsonConfigReader v0.0.0-20171218180944-5ea4d0ddac55 h1:jbG
github.com/DisposaBoy/JsonConfigReader v0.0.0-20171218180944-5ea4d0ddac55/go.mod h1:GCzqZQHydohgVLSIqRKZeTt8IGb1Y4NaFfim3H40uUI=
github.com/TomOnTime/utfutil v0.0.0-20180511104225-09c41003ee1d h1:WtAMR0fPCOfK7TPGZ8ZpLLY18HRvL7XJ3xcs0wnREgo=
github.com/TomOnTime/utfutil v0.0.0-20180511104225-09c41003ee1d/go.mod h1:WML6KOYjeU8N6YyusMjj2qRvaPNUEvrQvaxuFcMRFJY=
github.com/alecthomas/kingpin v2.2.6+incompatible/go.mod h1:59OFYbFVLKQKq+mqrL6Rw5bR0c3ACQaawgXx0QYndlE=
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
github.com/alecthomas/kong v0.2.2/go.mod h1:kQOmtJgV+Lb4aj+I2LEn40cbtawdWJ9Y8QLq+lElKxE=
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ=
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8=
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
@ -199,6 +197,7 @@ github.com/philhug/opensrs-go v0.0.0-20171126225031-9dfa7433020d h1:nf4+lHs8TQeI
github.com/philhug/opensrs-go v0.0.0-20171126225031-9dfa7433020d/go.mod h1:VDIGNBy0tHXMDAu4gxHFQJDq3NuwqUxw2Kok7wi+6ck=
github.com/pierrec/lz4 v2.0.5+incompatible h1:2xWsjqPFWcplujydGg4WmhC/6fZqK42wMM8aXeqhl0I=
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
@ -238,8 +237,8 @@ github.com/tdewolff/parse v2.3.4+incompatible h1:x05/cnGwIMf4ceLuDMBOdQ1qGniMoxp
github.com/tdewolff/parse v2.3.4+incompatible/go.mod h1:8oBwCsVmUkgHO8M5iCzSIDtpzXOT0WXX9cWhz+bIzJQ=
github.com/tdewolff/test v1.0.6 h1:76mzYJQ83Op284kMT+63iCNCI7NEERsIN8dLM+RiKr4=
github.com/tdewolff/test v1.0.6/go.mod h1:6DAvZliBAAnD7rhVgwaM7DE5/d9NMOAJ09SqYqeK4QE=
github.com/tiramiseb/go-gandi v0.0.0-20200309181223-e1cf2e430b3a h1:OktNmi+7LyUfkvkezbCZnKeU/DMZ59FI0F7YrsPTWqc=
github.com/tiramiseb/go-gandi v0.0.0-20200309181223-e1cf2e430b3a/go.mod h1:wevS0bE43PMSmEldbtya+tp+Ow180ftEPix8Onwh+E4=
github.com/tiramiseb/go-gandi v0.0.0-20200313161345-6b74caa58663 h1:rTwjlbRvLWPYjzF8lK8tb7p+3CbEHRN20KhLqn+GYwM=
github.com/tiramiseb/go-gandi v0.0.0-20200313161345-6b74caa58663/go.mod h1:5ir8fVjXFOi0veARbG7mi3NzUZSUdiyAX7l+8QFQvd4=
github.com/urfave/cli/v2 v2.2.0 h1:JTTnM6wKzdA0Jqodd966MVj4vWbbquZykeX1sKbe2C4=
github.com/urfave/cli/v2 v2.2.0/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ=
github.com/vultr/govultr v0.2.0 h1:CZSNNCk+PHz9hzmfH2PFGkDgc3qNetwZqtcaqL8shlg=

View File

@ -122,7 +122,7 @@ func (client *api) GetZoneRecords(domain string) (models.Records, error) {
g := gandi.NewLiveDNSClient(client.apikey, gandi.Config{SharingID: client.sharingid, Debug: client.debug})
// Get all the existing records:
records, err := g.ListDomainRecords(domain)
records, err := g.GetDomainRecords(domain)
if err != nil {
return nil, err
}
@ -224,7 +224,7 @@ func (client *api) GenerateDomainCorrections(dc *models.DomainConfig, existing m
&models.Correction{
Msg: msgs,
F: func() error {
err := g.DeleteDomainRecords(domain, shortname)
err := g.DeleteDomainRecordsByName(domain, shortname)
if err != nil {
return err
}

View File

@ -1,2 +1,3 @@
/cmd/gandi
gandi
.idea

View File

@ -3,11 +3,10 @@ Gandi Go library
WIP: migrating from https://github.com/tiramiseb/go-gandi-livedns
cmd not working, fix needed
[![GoDoc](https://godoc.org/github.com/tiramiseb/go-gandi?status.svg)](https://godoc.org/github.com/tiramiseb/go-gandi)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/tiramiseb/go-gandi/master/LICENSE)
![Go](https://github.com/tiramiseb/go-gandi/workflows/Go/badge.svg)
This library interacts with [Gandi's API](https://api.gandi.net/docs/), to manage Gandi services. This API returns some data as HTTP headers, please note those are ignored by this library.
A simple CLI is also shipped with this library. It returns responses to the requests in JSON.
A simple CLI is also shipped with this library. It returns responses to the requests in JSON. Build it with `go build -o gandi ./cmd`.

View File

@ -3,7 +3,6 @@ module github.com/tiramiseb/go-gandi
go 1.13
require (
github.com/alecthomas/kingpin v2.2.6+incompatible
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d // indirect
github.com/alecthomas/kong v0.2.2
github.com/stretchr/testify v1.4.0 // indirect
)

View File

@ -1,13 +1,17 @@
github.com/alecthomas/kingpin v2.2.6+incompatible h1:5svnBTFgJjZvGKyYBtMB0+m5wvrbUHiqye8wRJMlnYI=
github.com/alecthomas/kingpin v2.2.6+incompatible/go.mod h1:59OFYbFVLKQKq+mqrL6Rw5bR0c3ACQaawgXx0QYndlE=
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafoB+tBA3gMyHYHrpOtNuDiK/uB5uXxq5wM=
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d h1:UQZhZ2O0vMHr2cI+DC1Mbh0TJxzA3RcLoMsFw+aXw7E=
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
github.com/alecthomas/kong v0.2.2 h1:sk9ucwuUP/T4+byYEdNU13ZNYzoQRML4IsrMbbUUKLk=
github.com/alecthomas/kong v0.2.2/go.mod h1:kQOmtJgV+Lb4aj+I2LEn40cbtawdWJ9Y8QLq+lElKxE=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/tiramiseb/go-gandi-livedns v0.0.0-20200115114823-77cf002f44da h1:8yQIyyxIjektbd5aNbi9BZadosFjU3Xg3imyTS6fUcM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

View File

@ -49,24 +49,6 @@ func (g *LiveDNS) UpdateDomain(fqdn string, details UpdateDomainRequest) (respon
return
}
// GetDomainAXFRSecondaries returns the list of IPs that are permitted to do AXFR transfers of the domain
func (g *LiveDNS) GetDomainAXFRSecondaries(fqdn string) (secondaries []string, err error) {
_, err = g.client.Get("domains/"+fqdn+"/axfr/slaves", nil, &secondaries)
return
}
// CreateDomainAXFRSecondary adds an IP address to the list of IPs that are permitted to do AXFR transfers of the domain
func (g *LiveDNS) CreateDomainAXFRSecondary(fqdn string, ip string) (err error) {
_, err = g.client.Put("domains/"+fqdn+"/axfr/slaves/"+ip, nil, nil)
return
}
// DeleteDomainAXFRSecondary removes an IP address from the list of IPs that are permitted to do AXFR transfers of the domain
func (g *LiveDNS) DeleteDomainAXFRSecondary(fqdn string, ip string) (response client.StandardResponse, err error) {
_, err = g.client.Delete("domains/"+fqdn+"/axfr/slaves/"+ip, nil, &response)
return
}
// GetDomainNS returns the list of the nameservers for a domain
func (g *LiveDNS) GetDomainNS(fqdn string) (ns []string, err error) {
_, err = g.client.Get("domains/"+fqdn+"/nameservers", nil, &ns)

View File

@ -11,21 +11,21 @@ type DomainRecord struct {
RrsetValues []string `json:"rrset_values,omitempty"`
}
// ListDomainRecords lists all records in the zone associated with a domain
func (g *LiveDNS) ListDomainRecords(fqdn string) (records []DomainRecord, err error) {
// GetDomainRecords lists all records in the zone associated with a domain
func (g *LiveDNS) GetDomainRecords(fqdn string) (records []DomainRecord, err error) {
_, err = g.client.Get("domains/"+fqdn+"/records", nil, &records)
return
}
// ListDomainRecordsAsText lists all records in a zone and returns them as a text file
// GetDomainRecordsAsText lists all records in a zone and returns them as a text file
// ... and by text, I mean a slice of bytes
func (g *LiveDNS) ListDomainRecordsAsText(uuid string) ([]byte, error) {
func (g *LiveDNS) GetDomainRecordsAsText(uuid string) ([]byte, error) {
_, content, err := g.client.GetBytes("domains/"+uuid+"/records", nil)
return content, err
}
// ListDomainRecordsByName lists all records with a specific name in a zone
func (g *LiveDNS) ListDomainRecordsByName(fqdn, name string) (records []DomainRecord, err error) {
// GetDomainRecordsByName lists all records with a specific name in a zone
func (g *LiveDNS) GetDomainRecordsByName(fqdn, name string) (records []DomainRecord, err error) {
_, err = g.client.Get("domains/"+fqdn+"/records/"+name, nil, &records)
return
}
@ -85,8 +85,8 @@ func (g *LiveDNS) DeleteAllDomainRecords(fqdn string) (err error) {
return
}
// DeleteDomainRecords deletes all records with the given name in the zone attached to a domain
func (g *LiveDNS) DeleteDomainRecords(fqdn, name string) (err error) {
// DeleteDomainRecordsByName deletes all records with the given name in the zone attached to a domain
func (g *LiveDNS) DeleteDomainRecordsByName(fqdn, name string) (err error) {
_, err = g.client.Delete("domains/"+fqdn+"/records/"+name, nil, nil)
return
}

2
vendor/modules.txt vendored
View File

@ -281,7 +281,7 @@ github.com/tdewolff/parse/json
github.com/tdewolff/parse/strconv
# github.com/tdewolff/test v1.0.6
## explicit
# github.com/tiramiseb/go-gandi v0.0.0-20200309181223-e1cf2e430b3a
# github.com/tiramiseb/go-gandi v0.0.0-20200313161345-6b74caa58663
## explicit
github.com/tiramiseb/go-gandi
github.com/tiramiseb/go-gandi/domain