From 85e124eb0c7b262ff9c486abe9662f515f47fc5b Mon Sep 17 00:00:00 2001 From: Andrew N Golovkov Date: Wed, 31 Jan 2018 13:45:28 +0200 Subject: update github.com/DreamItGetIT/statuscake --- .../DreamItGetIT/statuscake/cmd/statuscake/main.go | 229 --------------------- .../statuscake/fixtures/auth_error.json | 4 - .../statuscake/fixtures/tests_all_ok.json | 22 -- .../statuscake/fixtures/tests_delete_error.json | 5 - .../statuscake/fixtures/tests_delete_ok.json | 6 - .../statuscake/fixtures/tests_detail_ok.json | 34 --- .../statuscake/fixtures/tests_update_error.json | 9 - .../tests_update_error_slice_of_issues.json | 5 - .../statuscake/fixtures/tests_update_ok.json | 6 - vendor/vendor.json | 5 +- 10 files changed, 2 insertions(+), 323 deletions(-) delete mode 100644 vendor/github.com/DreamItGetIT/statuscake/cmd/statuscake/main.go delete mode 100644 vendor/github.com/DreamItGetIT/statuscake/fixtures/auth_error.json delete mode 100644 vendor/github.com/DreamItGetIT/statuscake/fixtures/tests_all_ok.json delete mode 100644 vendor/github.com/DreamItGetIT/statuscake/fixtures/tests_delete_error.json delete mode 100644 vendor/github.com/DreamItGetIT/statuscake/fixtures/tests_delete_ok.json delete mode 100644 vendor/github.com/DreamItGetIT/statuscake/fixtures/tests_detail_ok.json delete mode 100644 vendor/github.com/DreamItGetIT/statuscake/fixtures/tests_update_error.json delete mode 100644 vendor/github.com/DreamItGetIT/statuscake/fixtures/tests_update_error_slice_of_issues.json delete mode 100644 vendor/github.com/DreamItGetIT/statuscake/fixtures/tests_update_ok.json (limited to 'vendor') diff --git a/vendor/github.com/DreamItGetIT/statuscake/cmd/statuscake/main.go b/vendor/github.com/DreamItGetIT/statuscake/cmd/statuscake/main.go deleted file mode 100644 index dc86b47..0000000 --- a/vendor/github.com/DreamItGetIT/statuscake/cmd/statuscake/main.go +++ /dev/null @@ -1,229 +0,0 @@ -package main - -import ( - "fmt" - logpkg "log" - "os" - "strconv" - - "github.com/DreamItGetIT/statuscake" -) - -var log *logpkg.Logger - -type command func(*statuscake.Client, ...string) error - -var commands map[string]command - -func init() { - log = logpkg.New(os.Stderr, "", 0) - commands = map[string]command{ - "list": cmdList, - "detail": cmdDetail, - "delete": cmdDelete, - "create": cmdCreate, - "update": cmdUpdate, - } -} - -func colouredStatus(s string) string { - switch s { - case "Up": - return fmt.Sprintf("\033[0;32m%s\033[0m", s) - case "Down": - return fmt.Sprintf("\033[0;31m%s\033[0m", s) - default: - return s - } -} - -func getEnv(name string) string { - v := os.Getenv(name) - if v == "" { - log.Fatalf("`%s` env variable is required", name) - } - - return v -} - -func cmdList(c *statuscake.Client, args ...string) error { - tt := c.Tests() - tests, err := tt.All() - if err != nil { - return err - } - - for _, t := range tests { - var paused string - if t.Paused { - paused = "yes" - } else { - paused = "no" - } - - fmt.Printf("* %d: %s\n", t.TestID, colouredStatus(t.Status)) - fmt.Printf(" WebsiteName: %s\n", t.WebsiteName) - fmt.Printf(" TestType: %s\n", t.TestType) - fmt.Printf(" Paused: %s\n", paused) - fmt.Printf(" ContactID: %d\n", t.ContactID) - fmt.Printf(" Uptime: %f\n", t.Uptime) - } - - return nil -} - -func cmdDetail(c *statuscake.Client, args ...string) error { - if len(args) != 1 { - return fmt.Errorf("command `detail` requires a single argument `TestID`") - } - - id, err := strconv.Atoi(args[0]) - if err != nil { - return err - } - - tt := c.Tests() - t, err := tt.Detail(id) - if err != nil { - return err - } - - var paused string - if t.Paused { - paused = "yes" - } else { - paused = "no" - } - - fmt.Printf("* %d: %s\n", t.TestID, colouredStatus(t.Status)) - fmt.Printf(" WebsiteName: %s\n", t.WebsiteName) - fmt.Printf(" WebsiteURL: %s\n", t.WebsiteURL) - fmt.Printf(" PingURL: %s\n", t.PingURL) - fmt.Printf(" TestType: %s\n", t.TestType) - fmt.Printf(" Paused: %s\n", paused) - fmt.Printf(" ContactID: %d\n", t.ContactID) - fmt.Printf(" Uptime: %f\n", t.Uptime) - - return nil -} - -func cmdDelete(c *statuscake.Client, args ...string) error { - if len(args) != 1 { - return fmt.Errorf("command `delete` requires a single argument `TestID`") - } - - id, err := strconv.Atoi(args[0]) - if err != nil { - return err - } - - return c.Tests().Delete(id) -} - -func askString(name string) string { - var v string - - fmt.Printf("%s: ", name) - _, err := fmt.Scanln(&v) - if err != nil { - log.Fatal(err) - } - - return v -} - -func askInt(name string) int { - v := askString(name) - i, err := strconv.Atoi(v) - if err != nil { - log.Fatalf("Invalid number `%s`", v) - } - - return i -} - -func cmdCreate(c *statuscake.Client, args ...string) error { - t := &statuscake.Test{ - WebsiteName: askString("WebsiteName"), - WebsiteURL: askString("WebsiteURL"), - TestType: askString("TestType"), - CheckRate: askInt("CheckRate"), - } - - t2, err := c.Tests().Update(t) - if err != nil { - return err - } - - fmt.Printf("CREATED: \n%+v\n", t2) - - return nil -} - -func cmdUpdate(c *statuscake.Client, args ...string) error { - if len(args) != 1 { - return fmt.Errorf("command `update` requires a single argument `TestID`") - } - - id, err := strconv.Atoi(args[0]) - if err != nil { - return err - } - - tt := c.Tests() - t, err := tt.Detail(id) - if err != nil { - return err - } - - t.TestID = id - t.WebsiteName = askString(fmt.Sprintf("WebsiteName [%s]", t.WebsiteName)) - t.WebsiteURL = askString(fmt.Sprintf("WebsiteURL [%s]", t.WebsiteURL)) - t.TestType = askString(fmt.Sprintf("TestType [%s]", t.TestType)) - t.CheckRate = askInt(fmt.Sprintf("CheckRate [%d]", t.CheckRate)) - - t2, err := c.Tests().Update(t) - if err != nil { - return err - } - - fmt.Printf("UPDATED: \n%+v\n", t2) - - return nil -} - -func usage() { - fmt.Printf("Usage:\n") - fmt.Printf(" %s COMMAND\n", os.Args[0]) - fmt.Printf("Available commands:\n") - for k := range commands { - fmt.Printf(" %+v\n", k) - } -} - -func main() { - username := getEnv("STATUSCAKE_USERNAME") - apikey := getEnv("STATUSCAKE_APIKEY") - - if len(os.Args) < 2 { - usage() - os.Exit(1) - } - - var err error - - c, err := statuscake.New(statuscake.Auth{Username: username, Apikey: apikey}) - if err != nil { - log.Fatal(err) - } - - if cmd, ok := commands[os.Args[1]]; ok { - err = cmd(c, os.Args[2:]...) - } else { - err = fmt.Errorf("Unknown command `%s`", os.Args[1]) - } - - if err != nil { - log.Fatalf("Error running command `%s`: %s", os.Args[1], err.Error()) - } -} diff --git a/vendor/github.com/DreamItGetIT/statuscake/fixtures/auth_error.json b/vendor/github.com/DreamItGetIT/statuscake/fixtures/auth_error.json deleted file mode 100644 index 4f14be5..0000000 --- a/vendor/github.com/DreamItGetIT/statuscake/fixtures/auth_error.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "ErrNo": 0, - "Error": "Can not access account. Was both Username and API Key provided?" -} diff --git a/vendor/github.com/DreamItGetIT/statuscake/fixtures/tests_all_ok.json b/vendor/github.com/DreamItGetIT/statuscake/fixtures/tests_all_ok.json deleted file mode 100644 index 81a913d..0000000 --- a/vendor/github.com/DreamItGetIT/statuscake/fixtures/tests_all_ok.json +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "TestID": 100, - "Paused": false, - "TestType": "HTTP", - "WebsiteName": "www 1", - "ContactGroup": null, - "ContactID": "1", - "Status": "Up", - "Uptime": 100 - }, - { - "TestID": 101, - "Paused": true, - "TestType": "HTTP", - "WebsiteName": "www 2", - "ContactGroup": null, - "ContactID": "2", - "Status": "Down", - "Uptime": 0 - } -] diff --git a/vendor/github.com/DreamItGetIT/statuscake/fixtures/tests_delete_error.json b/vendor/github.com/DreamItGetIT/statuscake/fixtures/tests_delete_error.json deleted file mode 100644 index 6fad58e..0000000 --- a/vendor/github.com/DreamItGetIT/statuscake/fixtures/tests_delete_error.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "Success": false, - "Error": "this is an error" -} - diff --git a/vendor/github.com/DreamItGetIT/statuscake/fixtures/tests_delete_ok.json b/vendor/github.com/DreamItGetIT/statuscake/fixtures/tests_delete_ok.json deleted file mode 100644 index 0dd279b..0000000 --- a/vendor/github.com/DreamItGetIT/statuscake/fixtures/tests_delete_ok.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "TestID": 6735, - "Affected": 1, - "Success": true, - "Message": "This Check Has Been Deleted. It can not be recovered." -} diff --git a/vendor/github.com/DreamItGetIT/statuscake/fixtures/tests_detail_ok.json b/vendor/github.com/DreamItGetIT/statuscake/fixtures/tests_detail_ok.json deleted file mode 100644 index 9754aa2..0000000 --- a/vendor/github.com/DreamItGetIT/statuscake/fixtures/tests_detail_ok.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "TestID": 6735, - "TestType": "HTTP", - "Paused": false, - "WebsiteName": "NL", - "CustomHeader": "{\"some\":{\"json\": [\"value\"]}}", - "UserAgent": "product/version (comment)", - "ContactGroup": "StatusCake Alerts", - "ContactID": "536", - "Status": "Up", - "Uptime": 0, - "CheckRate": 60, - "Timeout": 40, - "LogoImage": "", - "WebsiteHost": "Various", - "NodeLocations": [ - "UK", - "JP", - "SG1", - "SLC" - ], - "FindString": "", - "DoNotFind": false, - "LastTested": "2013-01-20 14:38:18", - "NextLocation": "USNY", - "Processing": false, - "ProcessingState": "Pretest", - "ProcessingOn": "dalas.localdomain", - "DownTimes": "0", - "UseJar": 0, - "PostRaw": "", - "FinalEndpoint": "", - "FollowRedirect": false -} diff --git a/vendor/github.com/DreamItGetIT/statuscake/fixtures/tests_update_error.json b/vendor/github.com/DreamItGetIT/statuscake/fixtures/tests_update_error.json deleted file mode 100644 index a76c5eb..0000000 --- a/vendor/github.com/DreamItGetIT/statuscake/fixtures/tests_update_error.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "Issues": { - "WebsiteName": "issue a", - "WebsiteURL": "issue b", - "CheckRate": "issue c" - }, - "Success": false, - "Message": "Required Data is Missing." -} diff --git a/vendor/github.com/DreamItGetIT/statuscake/fixtures/tests_update_error_slice_of_issues.json b/vendor/github.com/DreamItGetIT/statuscake/fixtures/tests_update_error_slice_of_issues.json deleted file mode 100644 index 02e98eb..0000000 --- a/vendor/github.com/DreamItGetIT/statuscake/fixtures/tests_update_error_slice_of_issues.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "Issues": ["hello", "world"], - "Success": false, - "Message": "Required Data is Missing." -} diff --git a/vendor/github.com/DreamItGetIT/statuscake/fixtures/tests_update_ok.json b/vendor/github.com/DreamItGetIT/statuscake/fixtures/tests_update_ok.json deleted file mode 100644 index 7c2dee2..0000000 --- a/vendor/github.com/DreamItGetIT/statuscake/fixtures/tests_update_ok.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "Issues": {}, - "Success": true, - "Message": "", - "InsertID": 1234 -} diff --git a/vendor/vendor.json b/vendor/vendor.json index d2bc87c..61dd8f3 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -4,10 +4,9 @@ "package": [ { "checksumSHA1": "6Fo7YzTT+MDviHOsqg6dNw8WrV4=", - "origin": "github.com/matschaffer/statuscake", "path": "github.com/DreamItGetIT/statuscake", - "revision": "24c596002b80d84cf3bfb0f714e880c1b2e9af16", - "revisionTime": "2018-01-16T08:09:52Z" + "revision": "f69198f958d7326f3c110dd9be1c21abbd8a87a7", + "revisionTime": "2018-01-30T22:14:43Z" }, { "checksumSHA1": "FIL83loX9V9APvGQIjJpbxq53F0=", -- cgit v1.2.3