deleting failures API fix - postman API update

pull/127/head
Hunter Long 2019-02-12 10:17:36 -08:00
parent 0cf1e077ef
commit e1a84c9ab8
5 changed files with 52 additions and 3 deletions

View File

@ -109,6 +109,7 @@ func Router() *mux.Router {
r.Handle("/api/services/{id}", http.HandlerFunc(apiServiceUpdateHandler)).Methods("POST")
r.Handle("/api/services/{id}", http.HandlerFunc(apiServiceDeleteHandler)).Methods("DELETE")
r.Handle("/api/services/{id}/failures", http.HandlerFunc(apiServiceFailuresHandler)).Methods("GET")
r.Handle("/api/services/{id}/failures", http.HandlerFunc(servicesDeleteFailuresHandler)).Methods("DELETE")
r.Handle("/api/services/{id}/hits", http.HandlerFunc(apiServiceHitsHandler)).Methods("GET")
// API USER Routes

View File

@ -327,7 +327,8 @@ func servicesDeleteFailuresHandler(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
service := core.SelectService(utils.ToInt(vars["id"]))
service.DeleteFailures()
ExecuteResponse(w, r, "services.gohtml", core.CoreApp.Services, "/services")
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(service.AllFailures())
}
func apiServiceFailuresHandler(w http.ResponseWriter, r *http.Request) {

View File

@ -986,6 +986,53 @@
"body": "{\n \"status\": \"success\",\n \"type\": \"service\",\n \"method\": \"delete\",\n \"id\": 10,\n \"output\": {\n \"id\": 10,\n \"name\": \"Updated New Service\",\n \"domain\": \"https://google.com\",\n \"expected\": \"\",\n \"expected_status\": 200,\n \"check_interval\": 60,\n \"type\": \"http\",\n \"method\": \"GET\",\n \"post_data\": \"\",\n \"port\": 0,\n \"timeout\": 10,\n \"order_id\": 0,\n \"allow_notifications\": false,\n \"created_at\": \"2018-12-10T11:31:47.535086-08:00\",\n \"updated_at\": \"2018-12-10T11:31:47.535184-08:00\",\n \"online\": true,\n \"latency\": 0.203382878,\n \"ping_time\": 0.001664491,\n \"online_24_hours\": 0,\n \"avg_response\": \"\",\n \"status_code\": 200,\n \"last_success\": \"2018-12-10T11:31:55.455091-08:00\"\n }\n}"
}
]
},
{
"name": "Delete Service Failures",
"event": [
{
"listen": "test",
"script": {
"id": "dd4d721d-d874-448b-abc9-59c1afceb58e",
"exec": [
""
],
"type": "text/javascript"
}
}
],
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{api_key}}",
"type": "string"
}
]
},
"method": "DELETE",
"header": [],
"body": {
"mode": "raw",
"raw": ""
},
"url": {
"raw": "{{endpoint}}/api/services/{{service_id}}/failures",
"host": [
"{{endpoint}}"
],
"path": [
"api",
"services",
"{{service_id}}",
"failures"
]
},
"description": "Delete a service and stop monitoring."
},
"response": []
}
],
"auth": {

View File

@ -1,6 +1,6 @@
// Code generated by go generate; DO NOT EDIT.
// This file was generated by robots at
// 2019-02-11 11:11:00.271926 -0800 PST m=+0.838529941
// 2019-02-12 10:16:56.83889 -0800 PST m=+0.659857543
//
// This contains the most recently Markdown source for the Statping Wiki.
package source

View File

@ -1 +1 @@
0.80.47
0.80.48