https://github.com/simplifi/ultradns-go
UltraDNS API client for Go
https://github.com/simplifi/ultradns-go
Last synced: 11 months ago
JSON representation
UltraDNS API client for Go
- Host: GitHub
- URL: https://github.com/simplifi/ultradns-go
- Owner: simplifi
- License: mit
- Created: 2020-02-22T15:43:42.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-05-29T21:32:30.000Z (about 6 years ago)
- Last Synced: 2025-07-05T03:14:27.929Z (12 months ago)
- Language: Go
- Size: 27.3 KB
- Stars: 0
- Watchers: 13
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ultradns-go
Provides an UltraDNS API package called `ultradns` for go
## Usage
Import:
```go
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.
```go
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 `
For example, to compile and run the status example from `examples/status/main.go`:
```
make status
./status -user -pass
```
## Testing
Ensure that golint is installed
```
go get -u golang.org/x/lint/golint
```
Run all tests, linters, etc with `make`.