X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=vendor%2Fgithub.com%2FDreamItGetIT%2Fstatuscake%2Ftests.go;h=2a2383d550be493609a5c9f5d5da0b2177ccdaed;hb=24c95871c559e4d0a284f4c245d6e7afaeb5b9a7;hp=c6e6dd2d14f4e1ea309dfecda5bf696403ba177c;hpb=ccbb72b7349103fd7e39a47a2ec5312bcc00017f;p=github%2Ffretlink%2Fterraform-provider-statuscake.git 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 { // Current status at last test Status string `json:"Status"` - // 7 Day Uptime + // 1 Day Uptime Uptime float64 `json:"Uptime"` // Any test locations seperated by a comma (using the Node Location IDs) @@ -75,7 +75,7 @@ type Test struct { Branding int `json:"Branding" querystring:"Branding"` // Used internally by the statuscake API - WebsiteHost string `json:"WebsiteHost"` + WebsiteHost string `json:"WebsiteHost" querystring:"WebsiteHost"` // Enable virus checking or not. 1 to enable Virus int `json:"Virus" querystring:"Virus"` @@ -110,6 +110,9 @@ type Test struct { // Use to specify the expected Final URL in the testing process FinalEndpoint string `json:"FinalEndpoint" querystring:"FinalEndpoint"` + // Use to enable SSL validation + EnableSSLAlert bool `json:"EnableSSLAlert" querystring:"EnableSSLAlert"` + // Use to specify whether redirects should be followed FollowRedirect bool `json:"FollowRedirect" querystring:"FollowRedirect"` } @@ -166,9 +169,11 @@ func (t *Test) Validate() error { e["FinalEndpoint"] = "must be a Valid URL" } - var jsonVerifiable map[string]interface{} - if json.Unmarshal([]byte(t.CustomHeader), &jsonVerifiable) != nil { - e["CustomHeader"] = "must be provided as json string" + if t.CustomHeader != "" { + var jsonVerifiable map[string]interface{} + if json.Unmarshal([]byte(t.CustomHeader), &jsonVerifiable) != nil { + e["CustomHeader"] = "must be provided as json string" + } } if len(e) > 0 { @@ -244,6 +249,7 @@ func valueToQueryStringValue(v reflect.Value) string { // Tests is a client that implements the `Tests` API. type Tests interface { All() ([]*Test, error) + AllWithFilter(url.Values) ([]*Test, error) Detail(int) (*Test, error) Update(*Test) (*Test, error) Delete(TestID int) error @@ -272,6 +278,19 @@ func (tt *tests) All() ([]*Test, error) { return tests, err } +func (tt *tests) AllWithFilter(filterOptions url.Values) ([]*Test, error) { + resp, err := tt.client.get("/Tests", filterOptions) + if err != nil { + return nil, err + } + defer resp.Body.Close() + + var tests []*Test + err = json.NewDecoder(resp.Body).Decode(&tests) + + return tests, err +} + func (tt *tests) Update(t *Test) (*Test, error) { resp, err := tt.client.put("/Tests/Update", t.ToURLValues()) if err != nil {