dnsimple-go

module
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 17, 2016 License: MIT

README

DNSimple Go Client

A Go client for the DNSimple API v2.

Build Status GoDoc

⚠ Beta Warning

This project targets the development of the API client for the DNSimple API v2. If you are looking for the initial version of the client for DNSimple API v1 then use the weppos/dnsimple-go project.

This library is currently in beta version, the methods and the implementation should be considered a work-in-progress. Changes in the method naming, method signatures, public or internal APIs may happen during the beta period.

Installation

$ go get github.com/aetrion/dnsimple-go/dnsimple

Usage

This library is a Go client you can use to interact with the DNSimple API v2. Here are some examples.

package main

import (
  "fmt"
  "os"
	"strconv"

  "github.com/aetrion/dnsimple-go/dnsimple"
)

func main() {
    oauthToken := "xxxxxxx"

    // new client
    client := dnsimple.NewClient(dnsimple.NewOauthTokenCredentials(oauthToken))

    // get the current authenticated account (if you don't know who you are)
    whoamiResponse, err := client.Identity.Whoami()
    if err != nil {
        fmt.Printf("Whoami() returned error: %v\n", err)
        os.Exit(1)
    }

    fmt.Println(whoamiResponse.Data.Account)
    fmt.Println(whoamiResponse.Data.User)

  	// either assign the account ID or fetch it from the response
  	// if you are authenticated with an account token
  	accountID := strconv.Itoa(whoamiResponse.Data.Account.ID)

    // get the list of domains
    domainsResponse, err := client.Domains.ListDomains(accountID, nil)
    if err != nil {
        fmt.Printf("Domains.ListDomains() returned error: %v\n", err)
        os.Exit(1)
    }

    // iterate over all the domains in the
    // paginated response.
    for _, domain := range domainsResponse.Data {
        fmt.Println(domain)
    }

    // List methods support a variety of options to paginate, sort and filter records.
    // Here's a few example:

    // get the list of domains filtered by name and sorted by expiration
    client.Domains.ListDomains(accountID, &dnsimple.DomainListOptions{NameLike: "com", Sort: "expiration:DESC"})
}

For more complete documentation, see godoc.

Contributing

For instructions about contributing and testing, visit the CONTRIBUTING file.

License

Copyright (c) 2014-2016 Aetrion LLC. This is Free Software distributed under the MIT license.

Directories

Path Synopsis
Package dnsimple provides a client for the DNSimple API.
Package dnsimple provides a client for the DNSimple API.
webhook
Package webhook provides the support for reading and parsing the events sent from DNSimple via webhook.
Package webhook provides the support for reading and parsing the events sent from DNSimple via webhook.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL