1
0
Fork 0

Vendor main dependencies.

This commit is contained in:
Timo Reimann 2017-02-07 22:33:23 +01:00
parent 49a09ab7dd
commit dd5e3fba01
2738 changed files with 1045689 additions and 0 deletions

101
vendor/gopkg.in/ns1/ns1-go.v2/rest/model/dns/answer.go generated vendored Normal file
View file

@ -0,0 +1,101 @@
package dns
import (
"fmt"
"strconv"
"strings"
"gopkg.in/ns1/ns1-go.v2/rest/model/data"
)
// Answer wraps the values of a Record's "filters" attribute
type Answer struct {
Meta *data.Meta `json:"meta,omitempty"`
// Answer response data. eg:
// Av4: ["1.1.1.1"]
// Av6: ["2001:db8:85a3::8a2e:370:7334"]
// MX: [10, "2.2.2.2"]
Rdata []string `json:"answer"`
// Region(grouping) that answer belongs to.
RegionName string `json:"region,omitempty"`
}
func (a Answer) String() string {
return strings.Trim(fmt.Sprint(a.Rdata), "[]")
}
// SetRegion associates a region with this answer.
func (a *Answer) SetRegion(name string) {
a.RegionName = name
}
// NewAnswer creates a generic Answer with given rdata.
func NewAnswer(rdata []string) *Answer {
return &Answer{
Meta: &data.Meta{},
Rdata: rdata,
}
}
// NewAv4Answer creates an Answer for A record.
func NewAv4Answer(host string) *Answer {
return &Answer{
Meta: &data.Meta{},
Rdata: []string{host},
}
}
// NewAv6Answer creates an Answer for AAAA record.
func NewAv6Answer(host string) *Answer {
return &Answer{
Meta: &data.Meta{},
Rdata: []string{host},
}
}
// NewALIASAnswer creates an Answer for ALIAS record.
func NewALIASAnswer(host string) *Answer {
return &Answer{
Meta: &data.Meta{},
Rdata: []string{host},
}
}
// NewCNAMEAnswer creates an Answer for CNAME record.
func NewCNAMEAnswer(name string) *Answer {
return &Answer{
Meta: &data.Meta{},
Rdata: []string{name},
}
}
// NewTXTAnswer creates an Answer for TXT record.
func NewTXTAnswer(text string) *Answer {
return &Answer{
Meta: &data.Meta{},
Rdata: []string{text},
}
}
// NewMXAnswer creates an Answer for MX record.
func NewMXAnswer(pri int, host string) *Answer {
return &Answer{
Meta: &data.Meta{},
Rdata: []string{strconv.Itoa(pri), host},
}
}
// NewSRVAnswer creates an Answer for SRV record.
func NewSRVAnswer(priority, weight, port int, target string) *Answer {
return &Answer{
Meta: &data.Meta{},
Rdata: []string{
strconv.Itoa(priority),
strconv.Itoa(weight),
strconv.Itoa(port),
target,
},
}
}

2
vendor/gopkg.in/ns1/ns1-go.v2/rest/model/dns/doc.go generated vendored Normal file
View file

@ -0,0 +1,2 @@
// Package dns contains definitions for NS1 zones/records/answers/etc.
package dns

76
vendor/gopkg.in/ns1/ns1-go.v2/rest/model/dns/record.go generated vendored Normal file
View file

@ -0,0 +1,76 @@
package dns
import (
"fmt"
"strings"
"gopkg.in/ns1/ns1-go.v2/rest/model/data"
"gopkg.in/ns1/ns1-go.v2/rest/model/filter"
)
// Record wraps an NS1 /zone/{zone}/{domain}/{type} resource
type Record struct {
Meta *data.Meta `json:"meta,omitempty"`
ID string `json:"id,omitempty"`
Zone string `json:"zone"`
Domain string `json:"domain"`
Type string `json:"type"`
Link string `json:"link,omitempty"`
TTL int `json:"ttl,omitempty"`
UseClientSubnet *bool `json:"use_client_subnet,omitempty"`
// Answers must all be of the same type as the record.
Answers []*Answer `json:"answers"`
// The records' filter chain.
Filters []*filter.Filter `json:"filters,omitempty"`
// The records' regions.
Regions data.Regions `json:"regions,omitempty"`
}
func (r Record) String() string {
return fmt.Sprintf("%s %s", r.Domain, r.Type)
}
// NewRecord takes a zone, domain and record type t and creates a *Record with
// UseClientSubnet: true & empty Answers.
func NewRecord(zone string, domain string, t string) *Record {
if !strings.HasSuffix(domain, zone) {
domain = fmt.Sprintf("%s.%s", domain, zone)
}
return &Record{
Meta: &data.Meta{},
Zone: zone,
Domain: domain,
Type: t,
Answers: []*Answer{},
Regions: data.Regions{},
}
}
// LinkTo sets a Record Link to an FQDN.
// to is the FQDN of the target record whose config should be used. Does
// not have to be in the same zone.
func (r *Record) LinkTo(to string) {
r.Meta = nil
r.Answers = []*Answer{}
r.Link = to
}
// AddAnswer adds an answer to the record.
func (r *Record) AddAnswer(ans *Answer) {
if r.Answers == nil {
r.Answers = []*Answer{}
}
r.Answers = append(r.Answers, ans)
}
// AddFilter adds a filter to the records' filter chain(ordering of filters matters).
func (r *Record) AddFilter(fil *filter.Filter) {
if r.Filters == nil {
r.Filters = []*filter.Filter{}
}
r.Filters = append(r.Filters, fil)
}

157
vendor/gopkg.in/ns1/ns1-go.v2/rest/model/dns/zone.go generated vendored Normal file
View file

@ -0,0 +1,157 @@
package dns
import "gopkg.in/ns1/ns1-go.v2/rest/model/data"
// Zone wraps an NS1 /zone resource
type Zone struct {
// Zones have metadata tables, but no filters act on 'zone-level' meta.
Meta *data.Meta `json:"meta,omitempty"`
// Read-only fields
DNSServers []string `json:"dns_servers,omitempty"`
NetworkPools []string `json:"network_pools,omitempty"`
Pool string `json:"pool,omitempty"` // Deprecated
ID string `json:"id,omitempty"`
Zone string `json:"zone,omitempty"`
TTL int `json:"ttl,omitempty"`
NxTTL int `json:"nx_ttl,omitempty"`
Retry int `json:"retry,omitempty"`
Serial int `json:"serial,omitempty"`
Refresh int `json:"refresh,omitempty"`
Expiry int `json:"expiry,omitempty"`
Hostmaster string `json:"hostmaster,omitempty"`
// If this is a linked zone, Link points to an existing standard zone,
// reusing its configuration and records. Link is a zones' domain name.
Link *string `json:"link,omitempty"`
// Networks contains the network ids the zone is available. Most zones
// will be in the NSONE Global Network(which is id 0).
NetworkIDs []int `json:"networks,omitempty"`
Records []*ZoneRecord `json:"records,omitempty"`
// Primary contains info to enable slaving of the zone by third party dns servers.
Primary *ZonePrimary `json:"primary,omitempty"`
// Secondary contains info for slaving the zone to a primary dns server.
Secondary *ZoneSecondary `json:"secondary,omitempty"`
}
func (z Zone) String() string {
return z.Zone
}
// ZoneRecord wraps Zone's "records" attribute
type ZoneRecord struct {
Domain string `json:"Domain,omitempty"`
ID string `json:"id,omitempty"`
Link string `json:"link,omitempty"`
ShortAns []string `json:"short_answers,omitempty"`
Tier int `json:"tier,omitempty"`
TTL int `json:"ttl,omitempty"`
Type string `json:"type,omitempty"`
}
// ZonePrimary wraps a Zone's "primary" attribute
type ZonePrimary struct {
// Enabled determines whether AXFR queries (and optionally NOTIFY messages)
// will be enabled for the zone.
Enabled bool `json:"enabled"`
Secondaries []ZoneSecondaryServer `json:"secondaries"`
}
// ZoneSecondaryServer wraps elements of a Zone's "primary.secondary" attribute
type ZoneSecondaryServer struct {
// Read-Only
NetworkIDs []int `json:"networks,omitempty"`
IP string `json:"ip"`
Port int `json:"port,omitempty"`
Notify bool `json:"notify"`
}
// ZoneSecondary wraps a Zone's "secondary" attribute
type ZoneSecondary struct {
// Read-Only fields
Expired bool `json:"expired,omitempty"`
LastXfr int `json:"last_xfr,omitempty"`
Status string `json:"status,omitempty"`
Error *string `json:"error"`
PrimaryIP string `json:"primary_ip,omitempty"`
PrimaryPort int `json:"primary_port,omitempty"`
Enabled bool `json:"enabled"`
TSIG *TSIG `json:"tsig"`
}
// TSIG is a zones transaction signature.
type TSIG struct {
// Key is the encrypted TSIG key(read-only)
Key string `json:"key,omitempty"`
// Whether TSIG is enabled for a secondary zone.
Enabled bool `json:"enabled,omitempty"`
// Which hashing algorithm
Hash string `json:"hash,omitempty"`
// Name of the TSIG key
Name string `json:"name,omitempty"`
}
// NewZone takes a zone domain name and creates a new zone.
func NewZone(zone string) *Zone {
z := Zone{
Zone: zone,
}
return &z
}
// MakePrimary enables Primary, disables Secondary, and sets primary's
// Secondaries to all provided ZoneSecondaryServers
func (z *Zone) MakePrimary(secondaries ...ZoneSecondaryServer) {
z.Secondary = nil
z.Primary = &ZonePrimary{
Enabled: true,
Secondaries: secondaries,
}
if z.Primary.Secondaries == nil {
z.Primary.Secondaries = make([]ZoneSecondaryServer, 0)
}
}
// MakeSecondary enables Secondary, disables Primary, and sets secondary's
// Primary_ip to provided ip.
func (z *Zone) MakeSecondary(ip string) {
z.Secondary = &ZoneSecondary{
Enabled: true,
PrimaryIP: ip,
PrimaryPort: 53,
}
z.Primary = &ZonePrimary{
Enabled: false,
Secondaries: make([]ZoneSecondaryServer, 0),
}
}
// LinkTo sets Link to a target zone domain name and unsets all other configuration properties.
// No other zone configuration properties (such as refresh, retry, etc) may be specified,
// since they are all pulled from the target zone. Linked zones, once created, cannot be
// configured at all and cannot have records added to them. They may only be deleted, which
// does not affect the target zone at all.
func (z *Zone) LinkTo(to string) {
z.Meta = nil
z.TTL = 0
z.NxTTL = 0
z.Retry = 0
z.Refresh = 0
z.Expiry = 0
z.Primary = nil
z.DNSServers = nil
z.NetworkIDs = nil
z.NetworkPools = nil
z.Hostmaster = ""
z.Pool = ""
z.Secondary = nil
z.Link = &to
}