An open API service indexing awesome lists of open source software.

https://github.com/libdns/nicrudns


https://github.com/libdns/nicrudns

Last synced: 4 months ago
JSON representation

Awesome Lists containing this project

README

          

Golang client for NIC.ru API for [`libdns`](https://github.com/libdns/libdns)
=======================

[![Go Reference](https://pkg.go.dev/badge/test.svg)](https://pkg.go.dev/github.com/libdns/TODO:PROVIDER_NAME)

This package implements the [libdns interfaces](https://github.com/libdns/libdns) for NIC.ru API, allowing you to manage DNS records.

Usage Example:
```
package examples

import (
"context"
"fmt"
"github.com/libdns/libdns"
"github.com/libdns/nicrudns"
"github.com/pkg/errors"
"time"
)

var (
provider = nicrudns.Provider{}
zoneName string
)

func ExampleLibdnsProvider() error {
ctx := context.TODO()
var records = []libdns.Record{
{
Type: `A`,
Name: `www`,
Value: `1.2.3.4`,
TTL: time.Hour,
},
}
if records, err := provider.AppendRecords(ctx, zoneName, records); err != nil {
return errors.Wrap(err, `append records error`)
} else {
for _, record := range records {
fmt.Println(record.Name, record.TTL, record.TTL, record.Value)
}
return nil
}
}

func ExampleNicruClient() error {
client := nicrudns.NewClient(&provider)
var names = []string{`www`}
if response, err := client.AddA(zoneName, names, `1.2.3.4`, `3600`); err != nil {
return errors.Wrap(err, `add records error`)
} else {
for _, rr := range response.Data.Zone[0].Rr {
fmt.Println(rr.Name, rr.Type, rr.Ttl, rr.A.String())
}
return nil
}
}
```