Skip to content

simplifi/ultradns-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ultradns-go

Provides an UltraDNS API package called ultradns for go

Usage

Import:

import "github.com/simplifi/ultradns-go"

To do a basic API connection and call, construct an ultradns.APIConnection struct. ultradns.NewAPIConnection() is provided to apply default configuration while still allowing control over the underlying connection.

When creating the struct either via the NewAPIConnection() call, or directly, either the Username/Password or RefreshToken must be set. If you pass both, the RefreshToken takes precedence.

This project only supports the JSON API request/response for UltraDNS, not the optional XML format.

apiConn := ultradns.NewAPIConnection(&ultradns.APIOptions{
  // API Username.
  Username: "",

  // API Password. 
  Password: "",

  // This refresh token can be used in lieu of username/password. To initially get a RefreshToken requires a
  // Username/Password, however.
  RefreshToken: "",

  // Defaults to "https://api.ultradns.com". Typically only overridden to allow testing or to use a sandbox endpoint.
  BaseURL: "https://api.ultradns.com",

  // Timeout is a time.Duration given to the underlying http.Client
  Timeout: 5 * time.Second,
})

// apiConn has a similar API to go's net/http library

// Send a GET request to the given path. Returns a http.Response pointer and error.
resp, err := apiConn.Get("/some/api/path")

// Send a POST request to the given path. Returns a http.Response pointer and error.
resp, err := apiConn.Post("/some/api/path", json_to_send)

Examples

There are various examples in examples/ that give real examples. Most require passing in a -user and -pass flag to authenticate with UltraDNS. To build an example, run make <name of example>

For example, to compile and run the status example from examples/status/main.go:

make status
./status -user <username> -pass <password>

Testing

Ensure that golint is installed

go get -u golang.org/x/lint/golint

Run all tests, linters, etc with make.

About

UltraDNS API client for Go

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published