https://github.com/libdns/namedotcom
https://github.com/libdns/namedotcom
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/libdns/namedotcom
- Owner: libdns
- License: mit
- Created: 2021-04-19T14:26:07.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2024-11-04T01:47:58.000Z (over 1 year ago)
- Last Synced: 2024-11-04T02:26:51.471Z (over 1 year ago)
- Language: Go
- Size: 30.3 KB
- Stars: 3
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
name.com for [`libdns`](https://github.com/libdns/libdns)
=======================
[](https://pkg.go.dev/github.com/libdns/namedotcom)
This package implements the [libdns interfaces](https://github.com/libdns/libdns) for name.com, allowing you to manage DNS records.
## Authenticating
To initiate the provider you need to supply the following parameters:
```go
provider := namedotcom.Provider {
Token : "NAMEDOTCOM_API_TOKEN",
User : "NAMEDOTCOM_USER_NAME",
Server: "https://api.name.com", // full url scheme expected here..
}
```
## Example
Here's a basic example of how to list, update and delete records using this provider
```go
package main
import (
"context"
"github.com/libdns/libdns"
"os"
"github.com/libdns/namedotcom"
"log"
)
func main() {
ctx := context.Background()
zone := "example.com."
// configure the name.com DNS provider
provider := namedotcom.Provider{
Token : os.GetEnv("NAMEDOTCOM_API_TOKEN"),
User : os.GetEnv("NAMEDOTCOM_USER_NAME"),
Server: os.GetEnv("NAMEDOTCOM_SERVER"),
}
// list and iterate through all records
recs, err := provider.GetRecords(ctx, zone)
if err != nil {
log.Fatal(err)
}
for _, rec := range recs {
log.Println(rec)
}
// attempts an upsert, PUT or POST for the given record
newRecs, err = provider.SetRecords(ctx, zone, []libdns.Record{
Type: "A",
Name: "sub",
Value: "1.2.3.4",
})
// delete records deletes the given record by ID.
deletedRecs, err = provider.DeleteRecords(ctx, zone, []libdns.Record{
Type: "A",
Name: "sub",
Value: "1.2.3.4",
})
}
```