aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/DreamItGetIT/statuscake/tests.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/DreamItGetIT/statuscake/tests.go')
-rw-r--r--vendor/github.com/DreamItGetIT/statuscake/tests.go29
1 files changed, 24 insertions, 5 deletions
diff --git a/vendor/github.com/DreamItGetIT/statuscake/tests.go b/vendor/github.com/DreamItGetIT/statuscake/tests.go
index c6e6dd2..2a2383d 100644
--- a/vendor/github.com/DreamItGetIT/statuscake/tests.go
+++ b/vendor/github.com/DreamItGetIT/statuscake/tests.go
@@ -42,7 +42,7 @@ type Test struct {
42 // Current status at last test 42 // Current status at last test
43 Status string `json:"Status"` 43 Status string `json:"Status"`
44 44
45 // 7 Day Uptime 45 // 1 Day Uptime
46 Uptime float64 `json:"Uptime"` 46 Uptime float64 `json:"Uptime"`
47 47
48 // Any test locations seperated by a comma (using the Node Location IDs) 48 // Any test locations seperated by a comma (using the Node Location IDs)
@@ -75,7 +75,7 @@ type Test struct {
75 Branding int `json:"Branding" querystring:"Branding"` 75 Branding int `json:"Branding" querystring:"Branding"`
76 76
77 // Used internally by the statuscake API 77 // Used internally by the statuscake API
78 WebsiteHost string `json:"WebsiteHost"` 78 WebsiteHost string `json:"WebsiteHost" querystring:"WebsiteHost"`
79 79
80 // Enable virus checking or not. 1 to enable 80 // Enable virus checking or not. 1 to enable
81 Virus int `json:"Virus" querystring:"Virus"` 81 Virus int `json:"Virus" querystring:"Virus"`
@@ -110,6 +110,9 @@ type Test struct {
110 // Use to specify the expected Final URL in the testing process 110 // Use to specify the expected Final URL in the testing process
111 FinalEndpoint string `json:"FinalEndpoint" querystring:"FinalEndpoint"` 111 FinalEndpoint string `json:"FinalEndpoint" querystring:"FinalEndpoint"`
112 112
113 // Use to enable SSL validation
114 EnableSSLAlert bool `json:"EnableSSLAlert" querystring:"EnableSSLAlert"`
115
113 // Use to specify whether redirects should be followed 116 // Use to specify whether redirects should be followed
114 FollowRedirect bool `json:"FollowRedirect" querystring:"FollowRedirect"` 117 FollowRedirect bool `json:"FollowRedirect" querystring:"FollowRedirect"`
115} 118}
@@ -166,9 +169,11 @@ func (t *Test) Validate() error {
166 e["FinalEndpoint"] = "must be a Valid URL" 169 e["FinalEndpoint"] = "must be a Valid URL"
167 } 170 }
168 171
169 var jsonVerifiable map[string]interface{} 172 if t.CustomHeader != "" {
170 if json.Unmarshal([]byte(t.CustomHeader), &jsonVerifiable) != nil { 173 var jsonVerifiable map[string]interface{}
171 e["CustomHeader"] = "must be provided as json string" 174 if json.Unmarshal([]byte(t.CustomHeader), &jsonVerifiable) != nil {
175 e["CustomHeader"] = "must be provided as json string"
176 }
172 } 177 }
173 178
174 if len(e) > 0 { 179 if len(e) > 0 {
@@ -244,6 +249,7 @@ func valueToQueryStringValue(v reflect.Value) string {
244// Tests is a client that implements the `Tests` API. 249// Tests is a client that implements the `Tests` API.
245type Tests interface { 250type Tests interface {
246 All() ([]*Test, error) 251 All() ([]*Test, error)
252 AllWithFilter(url.Values) ([]*Test, error)
247 Detail(int) (*Test, error) 253 Detail(int) (*Test, error)
248 Update(*Test) (*Test, error) 254 Update(*Test) (*Test, error)
249 Delete(TestID int) error 255 Delete(TestID int) error
@@ -272,6 +278,19 @@ func (tt *tests) All() ([]*Test, error) {
272 return tests, err 278 return tests, err
273} 279}
274 280
281func (tt *tests) AllWithFilter(filterOptions url.Values) ([]*Test, error) {
282 resp, err := tt.client.get("/Tests", filterOptions)
283 if err != nil {
284 return nil, err
285 }
286 defer resp.Body.Close()
287
288 var tests []*Test
289 err = json.NewDecoder(resp.Body).Decode(&tests)
290
291 return tests, err
292}
293
275func (tt *tests) Update(t *Test) (*Test, error) { 294func (tt *tests) Update(t *Test) (*Test, error) {
276 resp, err := tt.client.put("/Tests/Update", t.ToURLValues()) 295 resp, err := tt.client.put("/Tests/Update", t.ToURLValues())
277 if err != nil { 296 if err != nil {