1
0
Fork 0

Merge v1.2.1-master

Signed-off-by: Emile Vauge <emile@vauge.com>
This commit is contained in:
Emile Vauge 2017-04-11 17:10:46 +02:00
parent a590155b0b
commit aeb17182b4
No known key found for this signature in database
GPG key ID: D808B4C167352E59
396 changed files with 27271 additions and 9969 deletions

View file

@ -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
}