pointdns

package module
v0.0.0-...-3167405 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2014 License: Apache-2.0 Imports: 7 Imported by: 14

README

go-pointdns

This library provides easy access to point zone & record management. For information about the services offered on Point see the website

Authentication

To access your Point account, you'll need to define your username & password. The username is your email address and the password is the API token which, can be found in My Account tab.

Example

package main

import (
    "fmt"
    pointdns "github.com/copper/go-pointdns"
)

func main() {
    email := "user@example.com"
    apiToken := "6v1a532e-384g-f3345-ca34-d71a34f376545"
    client := pointdns.NewClient(email, apiToken)

    // Create a new zone
    newZone := pointdns.Zone{Name: "example.com"}

    savedZone, _ := client.CreateZone(&newZone)
    if savedZone {
        fmt.Println("Zone successfully created")
    }

    // Get list of zones
    zones, _ := client.Zones()
    for _, zone := range zones {
        fmt.Println("Zone:\n", zone.Name)
    }

    // Create a new record
    newRecord := pointdns.Record{
        Name: "www.example.com.",
        Data: "1.2.3.4",
        RecordType: "A",
        Ttl: 1800,
        ZoneId: newZone.Id,
    }

    savedRecord, _ := client.CreateRecord(&newRecord)
    if savedRecord {
        fmt.Println("Record successfully created")
    }

    // Update a record
    newRecord.Data = "4.3.2.1"
    saved, _ := newRecord.Save()
    if saved {
        fmt.Println("Record successfully updated")
    }

    // Get list of records for zone
    records, _ := newZone.Records()
    for _, record := range records {
        fmt.Println("Record:\n", record.Name)
    }

    // Delete a record
    deletedRecord, _ := newRecord.Delete()
    if deletedRecord {
        fmt.Println("Record successfully deleted")
    }

    // Delete a zone
    deletedZone, _ := newZone.Delete()
    if deletedZone {
        fmt.Println("Zone successfully deleted")
    }
}

Copyright (c) 2014 Copper Inc. See LICENSE for details.

Documentation

Index

Constants

View Source
const (
	ApiUrl     = "https://pointhq.com"
	ApiVersion = ""
)

Variables

This section is empty.

Functions

This section is empty.

Types

type PointClient

type PointClient struct {
	Email      string
	ApiToken   string
	HttpClient *http.Client
}

func NewClient

func NewClient(email, apiToken string) *PointClient

func (*PointClient) CreateRecord

func (client *PointClient) CreateRecord(record *Record) (bool, error)

func (*PointClient) CreateZone

func (client *PointClient) CreateZone(zone *Zone) (bool, error)

func (*PointClient) Delete

func (client *PointClient) Delete(path string, val interface{}) error

func (*PointClient) DoRequest

func (client *PointClient) DoRequest(method, path string, body io.Reader) (string, int, error)

func (*PointClient) Get

func (client *PointClient) Get(path string, val interface{}) error

func (*PointClient) Record

func (client *PointClient) Record(zone interface{}, record *Record) (Record, error)

func (*PointClient) Records

func (client *PointClient) Records(zone interface{}) ([]Record, error)

func (*PointClient) Save

func (client *PointClient) Save(path string, payload Resource, val interface{}) error

func (*PointClient) Zone

func (client *PointClient) Zone(zone interface{}) (Zone, error)

func (*PointClient) Zones

func (client *PointClient) Zones() ([]Zone, error)

type Record

type Record struct {
	Id         int    `json:"id,omitempty"`
	Name       string `json:"name,omitempty"`
	Data       string `json:"data,omitempty"`
	Ttl        int    `json:"ttl,omitempty"`
	Aux        string `json:"aux,omitempty"`
	ZoneId     int    `json:"zone_id,omitempty"`
	RecordType string `json:"record_type,omitempty"`
	// contains filtered or unexported fields
}

func (*Record) Delete

func (record *Record) Delete() (bool, error)

func (*Record) Save

func (record *Record) Save() (bool, error)

type Resource

type Resource interface {
	Id() int
}

type RootRecord

type RootRecord struct {
	Record Record `json:"zone_record"`
}

func (RootRecord) Id

func (rootRecord RootRecord) Id() int

type RootZone

type RootZone struct {
	Zone Zone `json:"zone"`
}

func (RootZone) Id

func (rootZone RootZone) Id() int

type Zone

type Zone struct {
	Id     int    `json:"id,omitempty"`
	Name   string `json:"name,omitempty"`
	Ttl    int    `json:"ttl,omitempty"`
	Group  string `json:"group,omitempty"`
	UserId int    `json:"user-id,omitempty"`
	// contains filtered or unexported fields
}

func (*Zone) Delete

func (zone *Zone) Delete() (bool, error)

func (*Zone) Records

func (zone *Zone) Records() ([]Record, error)

func (*Zone) Save

func (zone *Zone) Save() (bool, error)

Jump to

Keyboard shortcuts

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