diff options
author | Mat Schaffer <mat@schaffer.me> | 2018-08-20 11:45:48 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-20 11:45:48 +0900 |
commit | 7f6f2d1fae833992b11500248d537e0ba3fa48ff (patch) | |
tree | 59ede0e309433fc5796c568e5e4e60a8c1a762c9 /vendor/github.com/DreamItGetIT | |
parent | a6ddc0c931c22051c2f072877a1e0b18a939ef2e (diff) | |
parent | 65c668b059fb4da3f52a461be2e5c77ac0bcf2a7 (diff) | |
download | terraform-provider-statuscake-7f6f2d1fae833992b11500248d537e0ba3fa48ff.tar.gz terraform-provider-statuscake-7f6f2d1fae833992b11500248d537e0ba3fa48ff.tar.zst terraform-provider-statuscake-7f6f2d1fae833992b11500248d537e0ba3fa48ff.zip |
Merge pull request #18 from matschaffer/contact-groups-support
Add test contact group support
Diffstat (limited to 'vendor/github.com/DreamItGetIT')
-rw-r--r-- | vendor/github.com/DreamItGetIT/statuscake/errors.go | 8 | ||||
-rw-r--r-- | vendor/github.com/DreamItGetIT/statuscake/responses.go | 80 | ||||
-rw-r--r-- | vendor/github.com/DreamItGetIT/statuscake/tests.go | 15 |
3 files changed, 63 insertions, 40 deletions
diff --git a/vendor/github.com/DreamItGetIT/statuscake/errors.go b/vendor/github.com/DreamItGetIT/statuscake/errors.go index 4c51991..c336647 100644 --- a/vendor/github.com/DreamItGetIT/statuscake/errors.go +++ b/vendor/github.com/DreamItGetIT/statuscake/errors.go | |||
@@ -34,12 +34,15 @@ func (e ValidationError) Error() string { | |||
34 | } | 34 | } |
35 | 35 | ||
36 | type updateError struct { | 36 | type updateError struct { |
37 | Issues interface{} | 37 | Issues interface{} |
38 | Message string | ||
38 | } | 39 | } |
39 | 40 | ||
40 | func (e *updateError) Error() string { | 41 | func (e *updateError) Error() string { |
41 | var messages []string | 42 | var messages []string |
42 | 43 | ||
44 | messages = append(messages, e.Message) | ||
45 | |||
43 | if issues, ok := e.Issues.(map[string]interface{}); ok { | 46 | if issues, ok := e.Issues.(map[string]interface{}); ok { |
44 | for k, v := range issues { | 47 | for k, v := range issues { |
45 | m := fmt.Sprintf("%s %s", k, v) | 48 | m := fmt.Sprintf("%s %s", k, v) |
@@ -50,6 +53,9 @@ func (e *updateError) Error() string { | |||
50 | m := fmt.Sprint(v) | 53 | m := fmt.Sprint(v) |
51 | messages = append(messages, m) | 54 | messages = append(messages, m) |
52 | } | 55 | } |
56 | } else if issue, ok := e.Issues.(interface{}); ok { | ||
57 | m := fmt.Sprint(issue) | ||
58 | messages = append(messages, m) | ||
53 | } | 59 | } |
54 | 60 | ||
55 | return strings.Join(messages, ", ") | 61 | return strings.Join(messages, ", ") |
diff --git a/vendor/github.com/DreamItGetIT/statuscake/responses.go b/vendor/github.com/DreamItGetIT/statuscake/responses.go index 3cbf36d..e8d4af4 100644 --- a/vendor/github.com/DreamItGetIT/statuscake/responses.go +++ b/vendor/github.com/DreamItGetIT/statuscake/responses.go | |||
@@ -1,6 +1,7 @@ | |||
1 | package statuscake | 1 | package statuscake |
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "strconv" | ||
4 | "strings" | 5 | "strings" |
5 | ) | 6 | ) |
6 | 7 | ||
@@ -21,43 +22,55 @@ type deleteResponse struct { | |||
21 | Error string `json:"Error"` | 22 | Error string `json:"Error"` |
22 | } | 23 | } |
23 | 24 | ||
25 | type contactGroupDetailResponse struct { | ||
26 | ID int `json:"ID"` | ||
27 | Name string `json:"Name"` | ||
28 | Email string `json:"Email"` | ||
29 | } | ||
30 | |||
24 | type detailResponse struct { | 31 | type detailResponse struct { |
25 | Method string `json:"Method"` | 32 | Method string `json:"Method"` |
26 | TestID int `json:"TestID"` | 33 | TestID int `json:"TestID"` |
27 | TestType string `json:"TestType"` | 34 | TestType string `json:"TestType"` |
28 | Paused bool `json:"Paused"` | 35 | Paused bool `json:"Paused"` |
29 | WebsiteName string `json:"WebsiteName"` | 36 | WebsiteName string `json:"WebsiteName"` |
30 | URI string `json:"URI"` | 37 | URI string `json:"URI"` |
31 | ContactID int `json:"ContactID"` | 38 | ContactID int `json:"ContactID"` |
32 | Status string `json:"Status"` | 39 | ContactGroups []contactGroupDetailResponse `json:"ContactGroups"` |
33 | Uptime float64 `json:"Uptime"` | 40 | Status string `json:"Status"` |
34 | CustomHeader string `json:"CustomHeader"` | 41 | Uptime float64 `json:"Uptime"` |
35 | UserAgent string `json:"UserAgent"` | 42 | CustomHeader string `json:"CustomHeader"` |
36 | CheckRate int `json:"CheckRate"` | 43 | UserAgent string `json:"UserAgent"` |
37 | Timeout int `json:"Timeout"` | 44 | CheckRate int `json:"CheckRate"` |
38 | LogoImage string `json:"LogoImage"` | 45 | Timeout int `json:"Timeout"` |
39 | Confirmation int `json:"Confirmation,string"` | 46 | LogoImage string `json:"LogoImage"` |
40 | WebsiteHost string `json:"WebsiteHost"` | 47 | Confirmation int `json:"Confirmation,string"` |
41 | NodeLocations []string `json:"NodeLocations"` | 48 | WebsiteHost string `json:"WebsiteHost"` |
42 | FindString string `json:"FindString"` | 49 | NodeLocations []string `json:"NodeLocations"` |
43 | DoNotFind bool `json:"DoNotFind"` | 50 | FindString string `json:"FindString"` |
44 | LastTested string `json:"LastTested"` | 51 | DoNotFind bool `json:"DoNotFind"` |
45 | NextLocation string `json:"NextLocation"` | 52 | LastTested string `json:"LastTested"` |
46 | Port int `json:"Port"` | 53 | NextLocation string `json:"NextLocation"` |
47 | Processing bool `json:"Processing"` | 54 | Port int `json:"Port"` |
48 | ProcessingState string `json:"ProcessingState"` | 55 | Processing bool `json:"Processing"` |
49 | ProcessingOn string `json:"ProcessingOn"` | 56 | ProcessingState string `json:"ProcessingState"` |
50 | DownTimes int `json:"DownTimes,string"` | 57 | ProcessingOn string `json:"ProcessingOn"` |
51 | Sensitive bool `json:"Sensitive"` | 58 | DownTimes int `json:"DownTimes,string"` |
52 | TriggerRate int `json:"TriggerRate,string"` | 59 | Sensitive bool `json:"Sensitive"` |
53 | UseJar int `json:"UseJar"` | 60 | TriggerRate int `json:"TriggerRate,string"` |
54 | PostRaw string `json:"PostRaw"` | 61 | UseJar int `json:"UseJar"` |
55 | FinalEndpoint string `json:"FinalEndpoint"` | 62 | PostRaw string `json:"PostRaw"` |
56 | FollowRedirect bool `json:"FollowRedirect"` | 63 | FinalEndpoint string `json:"FinalEndpoint"` |
57 | StatusCodes []string `json:"StatusCodes"` | 64 | FollowRedirect bool `json:"FollowRedirect"` |
65 | StatusCodes []string `json:"StatusCodes"` | ||
58 | } | 66 | } |
59 | 67 | ||
60 | func (d *detailResponse) test() *Test { | 68 | func (d *detailResponse) test() *Test { |
69 | contactGroupIds := make([]string, len(d.ContactGroups)) | ||
70 | for i, v := range d.ContactGroups { | ||
71 | contactGroupIds[i] = strconv.Itoa(v.ID) | ||
72 | } | ||
73 | |||
61 | return &Test{ | 74 | return &Test{ |
62 | TestID: d.TestID, | 75 | TestID: d.TestID, |
63 | TestType: d.TestType, | 76 | TestType: d.TestType, |
@@ -67,6 +80,7 @@ func (d *detailResponse) test() *Test { | |||
67 | CustomHeader: d.CustomHeader, | 80 | CustomHeader: d.CustomHeader, |
68 | UserAgent: d.UserAgent, | 81 | UserAgent: d.UserAgent, |
69 | ContactID: d.ContactID, | 82 | ContactID: d.ContactID, |
83 | ContactGroup: contactGroupIds, | ||
70 | Status: d.Status, | 84 | Status: d.Status, |
71 | Uptime: d.Uptime, | 85 | Uptime: d.Uptime, |
72 | CheckRate: d.CheckRate, | 86 | CheckRate: d.CheckRate, |
diff --git a/vendor/github.com/DreamItGetIT/statuscake/tests.go b/vendor/github.com/DreamItGetIT/statuscake/tests.go index a41b0bd..c6e6dd2 100644 --- a/vendor/github.com/DreamItGetIT/statuscake/tests.go +++ b/vendor/github.com/DreamItGetIT/statuscake/tests.go | |||
@@ -12,7 +12,7 @@ const queryStringTag = "querystring" | |||
12 | 12 | ||
13 | // Test represents a statuscake Test | 13 | // Test represents a statuscake Test |
14 | type Test struct { | 14 | type Test struct { |
15 | // ThiTestID is an int, use this to get more details about this test. If not provided will insert a new check, else will update | 15 | // TestID is an int, use this to get more details about this test. If not provided will insert a new check, else will update |
16 | TestID int `json:"TestID" querystring:"TestID" querystringoptions:"omitempty"` | 16 | TestID int `json:"TestID" querystring:"TestID" querystringoptions:"omitempty"` |
17 | 17 | ||
18 | // Sent tfalse To Unpause and true To Pause. | 18 | // Sent tfalse To Unpause and true To Pause. |
@@ -33,8 +33,11 @@ type Test struct { | |||
33 | // A Port to use on TCP Tests | 33 | // A Port to use on TCP Tests |
34 | Port int `json:"Port" querystring:"Port"` | 34 | Port int `json:"Port" querystring:"Port"` |
35 | 35 | ||
36 | // Contact group ID - will return int of contact group used else 0 | 36 | // Contact group ID - deprecated in favor of ContactGroup but still provided in the API detail response |
37 | ContactID int `json:"ContactID" querystring:"ContactGroup"` | 37 | ContactID int `json:"ContactID"` |
38 | |||
39 | // Contact group IDs - will return list of ints or empty if not provided | ||
40 | ContactGroup []string `json:"ContactGroup" querystring:"ContactGroup"` | ||
38 | 41 | ||
39 | // Current status at last test | 42 | // Current status at last test |
40 | Status string `json:"Status"` | 43 | Status string `json:"Status"` |
@@ -51,7 +54,7 @@ type Test struct { | |||
51 | // A URL to ping if a site goes down. | 54 | // A URL to ping if a site goes down. |
52 | PingURL string `json:"PingURL" querystring:"PingURL"` | 55 | PingURL string `json:"PingURL" querystring:"PingURL"` |
53 | 56 | ||
54 | Confirmation int `json:"Confirmationi,string" querystring:"Confirmation"` | 57 | Confirmation int `json:"Confirmation,string" querystring:"Confirmation"` |
55 | 58 | ||
56 | // The number of seconds between checks. | 59 | // The number of seconds between checks. |
57 | CheckRate int `json:"CheckRate" querystring:"CheckRate"` | 60 | CheckRate int `json:"CheckRate" querystring:"CheckRate"` |
@@ -93,7 +96,7 @@ type Test struct { | |||
93 | TriggerRate int `json:"TriggerRate" querystring:"TriggerRate"` | 96 | TriggerRate int `json:"TriggerRate" querystring:"TriggerRate"` |
94 | 97 | ||
95 | // Tags should be seperated by a comma - no spacing between tags (this,is,a set,of,tags) | 98 | // Tags should be seperated by a comma - no spacing between tags (this,is,a set,of,tags) |
96 | TestTags string `json:"TestTags" querystring:"TestTags"` | 99 | TestTags []string `json:"TestTags" querystring:"TestTags"` |
97 | 100 | ||
98 | // Comma Seperated List of StatusCodes to Trigger Error on (on Update will replace, so send full list each time) | 101 | // Comma Seperated List of StatusCodes to Trigger Error on (on Update will replace, so send full list each time) |
99 | StatusCodes string `json:"StatusCodes" querystring:"StatusCodes"` | 102 | StatusCodes string `json:"StatusCodes" querystring:"StatusCodes"` |
@@ -283,7 +286,7 @@ func (tt *tests) Update(t *Test) (*Test, error) { | |||
283 | } | 286 | } |
284 | 287 | ||
285 | if !ur.Success { | 288 | if !ur.Success { |
286 | return nil, &updateError{Issues: ur.Issues} | 289 | return nil, &updateError{Issues: ur.Issues, Message: ur.Message} |
287 | } | 290 | } |
288 | 291 | ||
289 | t2 := *t | 292 | t2 := *t |