dreamitgetit / statuscake Goto Github PK
View Code? Open in Web Editor NEWGo client for statuscake.com
License: MIT License
Go client for statuscake.com
License: MIT License
Hi there,
Can you specify under what license is released the source code of this repository?
Having a license allow to people to know what they can do with your work and if the license allow to contribute then you may get interest of community to help to enhance it.
Many thanks.
Any plan to support contact groups? https://www.statuscake.com/api/Contact%20Groups/Add%20or%20Update%20Contact%20Group.md
It would be nice to have client functionality for the Pagespeed tests
https://www.statuscake.com/api/Page%20Speed/Create%20Pagespeed%20Test.md
https://www.statuscake.com/api/Page%20Speed/Delete%20Pagespeed%20Test.md
https://www.statuscake.com/api/Page%20Speed/Update%20Pagespeed%20Test.md
https://www.statuscake.com/api/Page%20Speed/List%20Pagespeed%20Test.md
So here's a weird one.
I received the following error when attempting to create a new StatusCake SSL test using this library:
json: cannot unmarshal number into Go struct field createSsl.Input.checkrate of type string
Indeed, after I patched my local clone of this library to dump HTTP requests and responses, upstream was observed to send a checkrate
as an integer type:
---- response dump:
dump error: <nil>
HTTP/2.0 200 OK
Access-Control-Allow-Origin: *
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Cf-Cache-Status: DYNAMIC
Cf-Ray: 5562eac079f8ca53-YUL
Content-Type: application/json
Date: Thu, 16 Jan 2020 20:42:37 GMT
Expect-Ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Pragma: no-cache
Server: cloudflare
Set-Cookie: REDACTED
Set-Cookie: REDACTED
X-Powered-By: PHP/5.6.26
X-Turbo-Charged-By: LiteSpeed
{"Success":true,"Message":165652,"Input":{"domain":"https:\/\/www.google.com\/","checkrate":86400,"contact_groups":"","alert_reminder":true,"alert_expiry":true,"alert_broken":true,"alert_mixed":false,"alert_at":"1,7,14"}}
Note this bit in particular:
"checkrate":86400
This was especially curious because I could not, at first, reproduce that behaviour with a simple user agent:
curl -Ssv \
-H 'Accept: application/json' \
-H 'Username: REDACTED' \
-H 'API: REDACTED' \
-X PUT \
-d 'domain=https://www.google.com/' \
-d 'checkrate=86400' \
-d 'contact_groups=' \
-d 'alert_at=1,2,3' \
-d 'alert_expiry=false' \
-d 'alert_reminder=false' \
-d 'alert_broken=false' \
-d 'alert_mixed=false' \
'https://app.statuscake.com/API/SSL/Update' \
| tee /tmp/checkrate-86400.json \
| jq .
Response:
{
"Success": true,
"Message": 165653,
"Input": {
"domain": "https://www.google.com/",
"checkrate": "86400",
"contact_groups": "",
"alert_reminder": false,
"alert_expiry": false,
"alert_broken": false,
"alert_mixed": false,
"alert_at": "1,2,3"
}
}
Here, checkrate
is a string, which is what this library expects.
It wasn't until some time later that I realised I was specifying different checkrate
values in my requests. My test with curl used a checkrate
of 86400, whereas my test with this library used a checkrate
of 300.
Sure enough:
curl -Ssv \
-H 'Accept: application/json' \
-H 'Username: REDACTED' \
-H 'API: REDACTED' \
-X PUT \
-d 'domain=https://www.google.com/' \
-d 'checkrate=300' \
-d 'contact_groups=' \
-d 'alert_at=1,2,3' \
-d 'alert_expiry=false' \
-d 'alert_reminder=false' \
-d 'alert_broken=false' \
-d 'alert_mixed=false' \
'https://app.statuscake.com/API/SSL/Update' \
| tee /tmp/checkrate-300.json \
| jq .
Response:
{
"Success": true,
"Message": 165654,
"Input": {
"domain": "https://www.google.com/",
"checkrate": 86400,
"contact_groups": "",
"alert_reminder": false,
"alert_expiry": false,
"alert_broken": false,
"alert_mixed": false,
"alert_at": "1,2,3"
}
}
Here, checkrate
is an integer.
I have no words.
I know this library is not to blame, but would it make sense to flick createSsl.Checkrate
over to the interface{}
type and perform a conditional conversion to an intermediate int
or string
value at runtime? (And presumably updateSsl.Checkrate
, too.)
Lest someone else in my position stumble upon this bug in the future, here's a summary of just some of the things that are entirely inaccurate in upstream's API documentation:
checkrate
parameter value. In practice, that particular value will be silently discarded and substituted with another. (Unless, presumably, you are on the highest-tier StatusCake plan.)checkrate
value, but, as noted above, it is usually a string-type value in practice.Input
key. In practice, that key is nowhere to be found. Oh, and the Message
value does not behave as documented, either. There is no resource ID in the response whatsoever.checkrate
value. In practice, the response will include an integer-type checkrate
value.Wayback links to upstream documentation - captured today:
Current StatusCake configuration only supports one contact_id. Statuscake has updated their API to accept a list of contact IDs provided as a string, separating each contact ID with a comma. The library should update accordingly.
Documentation at: https://www.statuscake.com/api/Tests/Updating%20Inserting%20and%20Deleting%20Tests.md
The client could allow to manage contact groups.
Does this API client support the methods in the API for creating SSL checks? Upstream terraform provider for statuscake does not - so curious whether the blocker is here or there.
statuscacke is building a new API to overcome the problems of the original API, certain features will only work in the new api (like the new maintenance window)
https://www.statuscake.com/api/ -> https://www.statuscake.com/api/v1/
So it may be good idea to switch to the new api
At the moment test tests are not working. Running test in CI would be great.
Hey,
while playing around with this library I discovered that wrong credentials are silently accepted and the functions (like Tests().All()
) just return an empty array.
It would be great if directly when creating a new client object, the credentials are checked against the Statuscake API to immediately raise some kind of InvalidCredentials
exception. Assuming that there is some endpoint in the Statuscake API which can be used for this check...
Best regards,
Felix
Hello, I noticed that it currently is not possible to add contact groups to status cake tests using the statuscake go client because the querystring, ContactGroup, is missing from the ContactID item in Test struct tests.go. This causes the api calls made by the client to fail when attempting to add a contact group. Once added, the calls work as expected.
Here is the snippet I am referring to in tests.go:
type Test struct {
// ThiTestID is an int, use this to get more details about this test. If not provided will insert a new check, else will update
TestID int json:"TestID" querystring:"TestID" querystringoptions:"omitempty"
// Sent tfalse To Unpause and true To Pause.
Paused bool `json:"Paused" querystring:"Paused"`
// Website name. Tags are stripped out
WebsiteName string `json:"WebsiteName" querystring:"WebsiteName"`
// Test location, either an IP (for TCP and Ping) or a fully qualified URL for other TestTypes
WebsiteURL string `json:"WebsiteURL" querystring:"WebsiteURL"`
// A Port to use on TCP Tests
Port int `json:"Port" querystring:"Port"`
// Contact group ID - will return int of contact group used else 0
ContactID int `json:"ContactID" querystring:"ContactGroup"`
//block continues in the code after this segment. End snippet
I wanted to let you know of this issue so that you could investigate. Thanks so much for your time!
Is it possible to add a method to initalize a client to interact with SSL API (/API/SSL endpoint of StatusCake API) on client.go file ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.