Merge v1.2.1-master
Signed-off-by: Emile Vauge <emile@vauge.com>
This commit is contained in:
parent
a590155b0b
commit
aeb17182b4
396 changed files with 27271 additions and 9969 deletions
17
vendor/gopkg.in/ns1/ns1-go.v2/rest/account_apikey.go
generated
vendored
17
vendor/gopkg.in/ns1/ns1-go.v2/rest/account_apikey.go
generated
vendored
|
@ -49,9 +49,9 @@ func (s *APIKeysService) Get(keyID string) (*account.APIKey, *http.Response, err
|
|||
if err.(*Error).Message == "unknown api key" {
|
||||
return nil, resp, ErrKeyMissing
|
||||
}
|
||||
default:
|
||||
return nil, resp, err
|
||||
|
||||
}
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return &a, resp, nil
|
||||
|
@ -74,9 +74,8 @@ func (s *APIKeysService) Create(a *account.APIKey) (*http.Response, error) {
|
|||
if err.(*Error).Message == fmt.Sprintf("api key with name \"%s\" exists", a.Name) {
|
||||
return resp, ErrKeyExists
|
||||
}
|
||||
default:
|
||||
return resp, err
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
|
@ -101,9 +100,8 @@ func (s *APIKeysService) Update(a *account.APIKey) (*http.Response, error) {
|
|||
if err.(*Error).Message == "unknown api key" {
|
||||
return resp, ErrKeyMissing
|
||||
}
|
||||
default:
|
||||
return resp, err
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
|
@ -127,9 +125,8 @@ func (s *APIKeysService) Delete(keyID string) (*http.Response, error) {
|
|||
if err.(*Error).Message == "unknown api key" {
|
||||
return resp, ErrKeyMissing
|
||||
}
|
||||
default:
|
||||
return resp, err
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
|
@ -137,7 +134,7 @@ func (s *APIKeysService) Delete(keyID string) (*http.Response, error) {
|
|||
|
||||
var (
|
||||
// ErrKeyExists bundles PUT create error.
|
||||
ErrKeyExists = errors.New("Key already exists.")
|
||||
ErrKeyExists = errors.New("key already exists")
|
||||
// ErrKeyMissing bundles GET/POST/DELETE error.
|
||||
ErrKeyMissing = errors.New("Key does not exist.")
|
||||
ErrKeyMissing = errors.New("key does not exist")
|
||||
)
|
||||
|
|
16
vendor/gopkg.in/ns1/ns1-go.v2/rest/account_team.go
generated
vendored
16
vendor/gopkg.in/ns1/ns1-go.v2/rest/account_team.go
generated
vendored
|
@ -48,9 +48,8 @@ func (s *TeamsService) Get(id string) (*account.Team, *http.Response, error) {
|
|||
if err.(*Error).Message == "Unknown team id" {
|
||||
return nil, resp, ErrTeamMissing
|
||||
}
|
||||
default:
|
||||
return nil, resp, err
|
||||
}
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return &t, resp, nil
|
||||
|
@ -73,9 +72,8 @@ func (s *TeamsService) Create(t *account.Team) (*http.Response, error) {
|
|||
if err.(*Error).Message == fmt.Sprintf("team with name \"%s\" exists", t.Name) {
|
||||
return resp, ErrTeamExists
|
||||
}
|
||||
default:
|
||||
return resp, err
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
|
@ -100,9 +98,8 @@ func (s *TeamsService) Update(t *account.Team) (*http.Response, error) {
|
|||
if err.(*Error).Message == "unknown team id" {
|
||||
return resp, ErrTeamMissing
|
||||
}
|
||||
default:
|
||||
return resp, err
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
|
@ -126,9 +123,8 @@ func (s *TeamsService) Delete(id string) (*http.Response, error) {
|
|||
if err.(*Error).Message == "unknown team id" {
|
||||
return resp, ErrTeamMissing
|
||||
}
|
||||
default:
|
||||
return resp, err
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
|
@ -136,7 +132,7 @@ func (s *TeamsService) Delete(id string) (*http.Response, error) {
|
|||
|
||||
var (
|
||||
// ErrTeamExists bundles PUT create error.
|
||||
ErrTeamExists = errors.New("Team already exists.")
|
||||
ErrTeamExists = errors.New("team already exists")
|
||||
// ErrTeamMissing bundles GET/POST/DELETE error.
|
||||
ErrTeamMissing = errors.New("Team does not exist.")
|
||||
ErrTeamMissing = errors.New("team does not exist")
|
||||
)
|
||||
|
|
16
vendor/gopkg.in/ns1/ns1-go.v2/rest/account_user.go
generated
vendored
16
vendor/gopkg.in/ns1/ns1-go.v2/rest/account_user.go
generated
vendored
|
@ -48,9 +48,8 @@ func (s *UsersService) Get(username string) (*account.User, *http.Response, erro
|
|||
if err.(*Error).Message == "Unknown user" {
|
||||
return nil, resp, ErrUserMissing
|
||||
}
|
||||
default:
|
||||
return nil, resp, err
|
||||
}
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return &u, resp, nil
|
||||
|
@ -73,9 +72,8 @@ func (s *UsersService) Create(u *account.User) (*http.Response, error) {
|
|||
if err.(*Error).Message == "request failed:Login Name is already in use." {
|
||||
return resp, ErrUserExists
|
||||
}
|
||||
default:
|
||||
return resp, err
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
|
@ -100,9 +98,8 @@ func (s *UsersService) Update(u *account.User) (*http.Response, error) {
|
|||
if err.(*Error).Message == "Unknown user" {
|
||||
return resp, ErrUserMissing
|
||||
}
|
||||
default:
|
||||
return resp, err
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
|
@ -126,9 +123,8 @@ func (s *UsersService) Delete(username string) (*http.Response, error) {
|
|||
if err.(*Error).Message == "Unknown user" {
|
||||
return resp, ErrUserMissing
|
||||
}
|
||||
default:
|
||||
return resp, err
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
|
@ -136,7 +132,7 @@ func (s *UsersService) Delete(username string) (*http.Response, error) {
|
|||
|
||||
var (
|
||||
// ErrUserExists bundles PUT create error.
|
||||
ErrUserExists = errors.New("User already exists.")
|
||||
ErrUserExists = errors.New("user already exists")
|
||||
// ErrUserMissing bundles GET/POST/DELETE error.
|
||||
ErrUserMissing = errors.New("User does not exist.")
|
||||
ErrUserMissing = errors.New("user does not exist")
|
||||
)
|
||||
|
|
20
vendor/gopkg.in/ns1/ns1-go.v2/rest/client.go
generated
vendored
20
vendor/gopkg.in/ns1/ns1-go.v2/rest/client.go
generated
vendored
|
@ -271,3 +271,23 @@ func parseRate(resp *http.Response) RateLimit {
|
|||
|
||||
return rl
|
||||
}
|
||||
|
||||
// SetTimeParam sets a url timestamp query param given the parameters name.
|
||||
func SetTimeParam(key string, t time.Time) func(*url.Values) {
|
||||
return func(v *url.Values) { v.Set(key, strconv.Itoa(int(t.Unix()))) }
|
||||
}
|
||||
|
||||
// SetBoolParam sets a url boolean query param given the parameters name.
|
||||
func SetBoolParam(key string, b bool) func(*url.Values) {
|
||||
return func(v *url.Values) { v.Set(key, strconv.FormatBool(b)) }
|
||||
}
|
||||
|
||||
// SetStringParam sets a url string query param given the parameters name.
|
||||
func SetStringParam(key, val string) func(*url.Values) {
|
||||
return func(v *url.Values) { v.Set(key, val) }
|
||||
}
|
||||
|
||||
// SetIntParam sets a url integer query param given the parameters name.
|
||||
func SetIntParam(key string, val int) func(*url.Values) {
|
||||
return func(v *url.Values) { v.Set(key, strconv.Itoa(val)) }
|
||||
}
|
||||
|
|
15
vendor/gopkg.in/ns1/ns1-go.v2/rest/model/monitor/job.go
generated
vendored
15
vendor/gopkg.in/ns1/ns1-go.v2/rest/model/monitor/job.go
generated
vendored
|
@ -19,10 +19,10 @@ type Job struct {
|
|||
Config Config `json:"config"`
|
||||
|
||||
// The current status of the monitor.
|
||||
Status map[string]Status `json:"status,omitempty"`
|
||||
Status map[string]*Status `json:"status,omitempty"`
|
||||
|
||||
// Rules for determining failure conditions.
|
||||
Rules []*Rule `json:"rules"`
|
||||
Rules []*Rule `json:"rules,omitempty"`
|
||||
|
||||
// List of regions in which to run the monitor.
|
||||
// eg, ["dal", "sin", "sjc", "lga", "ams"]
|
||||
|
@ -66,7 +66,7 @@ type Job struct {
|
|||
|
||||
// If true, notifications are sent for any regional failure (and failback if desired),
|
||||
// in addition to global state notifications.
|
||||
NotifyRegional bool `json:"notidy_regional"`
|
||||
NotifyRegional bool `json:"notify_regional"`
|
||||
|
||||
// If true, a notification is sent when a job returns to an "up" state.
|
||||
NotifyFailback bool `json:"notify_failback"`
|
||||
|
@ -99,6 +99,15 @@ type Status struct {
|
|||
Status string `json:"status"`
|
||||
}
|
||||
|
||||
// StatusLog wraps an NS1 /monitoring/history resource
|
||||
type StatusLog struct {
|
||||
Job string `json:"job"`
|
||||
Region string `json:"region"`
|
||||
Status string `json:"status"`
|
||||
Since int `json:"since"`
|
||||
Until int `json:"until"`
|
||||
}
|
||||
|
||||
// Rule wraps an element of a Job's "rules" attribute
|
||||
type Rule struct {
|
||||
Key string `json:"key"`
|
||||
|
|
26
vendor/gopkg.in/ns1/ns1-go.v2/rest/monitor_job.go
generated
vendored
26
vendor/gopkg.in/ns1/ns1-go.v2/rest/monitor_job.go
generated
vendored
|
@ -3,6 +3,7 @@ package rest
|
|||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"gopkg.in/ns1/ns1-go.v2/rest/model/monitor"
|
||||
)
|
||||
|
@ -106,3 +107,28 @@ func (s *JobsService) Delete(id string) (*http.Response, error) {
|
|||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// History takes an ID and returns status log history for a specific monitoring job.
|
||||
//
|
||||
// NS1 API docs: https://ns1.com/api/#history-get
|
||||
func (s *JobsService) History(id string, opts ...func(*url.Values)) ([]*monitor.StatusLog, *http.Response, error) {
|
||||
v := url.Values{}
|
||||
for _, opt := range opts {
|
||||
opt(&v)
|
||||
}
|
||||
|
||||
path := fmt.Sprintf("%s/%s?%s", "monitoring/history", id, v.Encode())
|
||||
|
||||
req, err := s.client.NewRequest("GET", path, nil)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
var slgs []*monitor.StatusLog
|
||||
resp, err := s.client.Do(req, &slgs)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return slgs, resp, nil
|
||||
}
|
||||
|
|
10
vendor/gopkg.in/ns1/ns1-go.v2/rest/monitor_notify.go
generated
vendored
10
vendor/gopkg.in/ns1/ns1-go.v2/rest/monitor_notify.go
generated
vendored
|
@ -48,9 +48,8 @@ func (s *NotificationsService) Get(listID string) (*monitor.NotifyList, *http.Re
|
|||
if err.(*Error).Message == "unknown notification list" {
|
||||
return nil, resp, ErrListMissing
|
||||
}
|
||||
default:
|
||||
return nil, resp, err
|
||||
}
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return &nl, resp, nil
|
||||
|
@ -73,9 +72,8 @@ func (s *NotificationsService) Create(nl *monitor.NotifyList) (*http.Response, e
|
|||
if err.(*Error).Message == fmt.Sprintf("notification list with name \"%s\" exists", nl.Name) {
|
||||
return resp, ErrListExists
|
||||
}
|
||||
default:
|
||||
return resp, err
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
|
@ -122,7 +120,7 @@ func (s *NotificationsService) Delete(listID string) (*http.Response, error) {
|
|||
|
||||
var (
|
||||
// ErrListExists bundles PUT create error.
|
||||
ErrListExists = errors.New("Notify List already exists.")
|
||||
ErrListExists = errors.New("notify List already exists")
|
||||
// ErrListMissing bundles GET/POST/DELETE error.
|
||||
ErrListMissing = errors.New("Notify List does not exist.")
|
||||
ErrListMissing = errors.New("notify List does not exist")
|
||||
)
|
||||
|
|
16
vendor/gopkg.in/ns1/ns1-go.v2/rest/record.go
generated
vendored
16
vendor/gopkg.in/ns1/ns1-go.v2/rest/record.go
generated
vendored
|
@ -30,9 +30,8 @@ func (s *RecordsService) Get(zone, domain, t string) (*dns.Record, *http.Respons
|
|||
if err.(*Error).Message == "record not found" {
|
||||
return nil, resp, ErrRecordMissing
|
||||
}
|
||||
default:
|
||||
return nil, resp, err
|
||||
}
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return &r, resp, nil
|
||||
|
@ -61,9 +60,8 @@ func (s *RecordsService) Create(r *dns.Record) (*http.Response, error) {
|
|||
case "record already exists":
|
||||
return resp, ErrRecordExists
|
||||
}
|
||||
default:
|
||||
return resp, err
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
|
@ -92,9 +90,8 @@ func (s *RecordsService) Update(r *dns.Record) (*http.Response, error) {
|
|||
case "record already exists":
|
||||
return resp, ErrRecordExists
|
||||
}
|
||||
default:
|
||||
return resp, err
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
|
@ -118,9 +115,8 @@ func (s *RecordsService) Delete(zone string, domain string, t string) (*http.Res
|
|||
if err.(*Error).Message == "record not found" {
|
||||
return resp, ErrRecordMissing
|
||||
}
|
||||
default:
|
||||
return resp, err
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
|
@ -128,7 +124,7 @@ func (s *RecordsService) Delete(zone string, domain string, t string) (*http.Res
|
|||
|
||||
var (
|
||||
// ErrRecordExists bundles PUT create error.
|
||||
ErrRecordExists = errors.New("Record already exists.")
|
||||
ErrRecordExists = errors.New("record already exists")
|
||||
// ErrRecordMissing bundles GET/POST/DELETE error.
|
||||
ErrRecordMissing = errors.New("Record does not exist.")
|
||||
ErrRecordMissing = errors.New("record does not exist")
|
||||
)
|
||||
|
|
16
vendor/gopkg.in/ns1/ns1-go.v2/rest/zone.go
generated
vendored
16
vendor/gopkg.in/ns1/ns1-go.v2/rest/zone.go
generated
vendored
|
@ -48,9 +48,8 @@ func (s *ZonesService) Get(zone string) (*dns.Zone, *http.Response, error) {
|
|||
if err.(*Error).Message == "zone not found" {
|
||||
return nil, resp, ErrZoneMissing
|
||||
}
|
||||
default:
|
||||
return nil, resp, err
|
||||
}
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return &z, resp, nil
|
||||
|
@ -75,9 +74,8 @@ func (s *ZonesService) Create(z *dns.Zone) (*http.Response, error) {
|
|||
if err.(*Error).Message == "zone already exists" {
|
||||
return resp, ErrZoneExists
|
||||
}
|
||||
default:
|
||||
return resp, err
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
|
@ -102,9 +100,8 @@ func (s *ZonesService) Update(z *dns.Zone) (*http.Response, error) {
|
|||
if err.(*Error).Message == "zone not found" {
|
||||
return resp, ErrZoneMissing
|
||||
}
|
||||
default:
|
||||
return resp, err
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
|
@ -128,9 +125,8 @@ func (s *ZonesService) Delete(zone string) (*http.Response, error) {
|
|||
if err.(*Error).Message == "zone not found" {
|
||||
return resp, ErrZoneMissing
|
||||
}
|
||||
default:
|
||||
return resp, err
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
|
@ -138,7 +134,7 @@ func (s *ZonesService) Delete(zone string) (*http.Response, error) {
|
|||
|
||||
var (
|
||||
// ErrZoneExists bundles PUT create error.
|
||||
ErrZoneExists = errors.New("Zone already exists.")
|
||||
ErrZoneExists = errors.New("zone already exists")
|
||||
// ErrZoneMissing bundles GET/POST/DELETE error.
|
||||
ErrZoneMissing = errors.New("Zone does not exist.")
|
||||
ErrZoneMissing = errors.New("zone does not exist")
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue