- Notifications
You must be signed in to change notification settings - Fork59
ns1/ns1-go
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
This project is inactive development.
The golang client for the NS1 API:https://ns1.com/api/
The documentation can be found here:https://pkg.go.dev/gopkg.in/ns1/ns1-go.v2
$ go get gopkg.in/ns1/ns1-go.v2
package mainimport ("fmt""log""net/http""os""time"api"gopkg.in/ns1/ns1-go.v2/rest")funcmain() {k:=os.Getenv("NS1_APIKEY")ifk=="" {fmt.Println("NS1_APIKEY environment variable is not set, giving up")os.Exit(1)}httpClient:=&http.Client{Timeout:time.Second*10}client:=api.NewClient(httpClient,api.SetAPIKey(k))zones,_,err:=client.Zones.List()iferr!=nil {log.Fatal(err)}for_,z:=rangezones {fmt.Println(z.Zone)}}
DNS views allow NS1 to serve one set of data to one group of clients(e.g. internal employees), and different results to other groups ofclients (e.g. public internet). Multiple zones can now have the samefully-qualified domain name (FQDN), with propagation controlled via ACLsand the Views feature. For more information, please refer to thisNS1 documentation page.
Users who do not need views can ignore this feature. Users who douse views must now use the user-suppliedname
field in the APIto uniquely identify a zone. More than one zone can have the sameFQDN, but theirname
fields must be unique.
For compatibility, thezone
field is unchanged in existing functions.Whenname
and FQDN differ, and you are calling a func that takeszone
,you must add thename
identifier as well. The zone's FQDN is onlyrequired during zone or record creation.
When using views, the NewNamedZone and NewNamedRecord funcs are providedto create zones and records. If not using views, you can continue usingthe older functions.
Pull Requests and issues are welcome. See theNS1 Contribution Guidelines for more information.
Run tests:
make test
Local dev: use thego.mod
replace
directive orgo work use
in client code to point to the local checkout of this repository.
Consider running./script/install-git-hooks
to install local git hooks for thisproject.
Apache2 - see the included LICENSE file for more information