Add Dashboards (#41)

This commit is contained in:
Jonas Plum
2022-03-14 00:23:29 +01:00
committed by GitHub
parent 18a4dc54e7
commit 02c7da91da
30 changed files with 2824 additions and 279 deletions

View File

@@ -19,6 +19,12 @@ type Service interface {
CurrentUser(context.Context) (*model.UserResponse, error)
CurrentUserData(context.Context) (*model.UserDataResponse, error)
UpdateCurrentUserData(context.Context, *model.UserData) (*model.UserDataResponse, error)
DashboardData(context.Context, string, *string) (map[string]interface{}, error)
ListDashboards(context.Context) ([]*model.DashboardResponse, error)
CreateDashboard(context.Context, *model.Dashboard) (*model.DashboardResponse, error)
GetDashboard(context.Context, string) (*model.DashboardResponse, error)
UpdateDashboard(context.Context, string, *model.Dashboard) (*model.DashboardResponse, error)
DeleteDashboard(context.Context, string) error
ListJobs(context.Context) ([]*model.JobResponse, error)
RunJob(context.Context, *model.JobForm) (*model.JobResponse, error)
GetJob(context.Context, string) (*model.JobResponse, error)
@@ -91,6 +97,12 @@ func NewServer(service Service, roleAuth func([]string) func(http.Handler) http.
r.With(roleAuth([]string{"currentuser:read"})).Get("/currentuser", s.currentUserHandler)
r.With(roleAuth([]string{"currentuserdata:read"})).Get("/currentuserdata", s.currentUserDataHandler)
r.With(roleAuth([]string{"currentuserdata:write"})).Put("/currentuserdata", s.updateCurrentUserDataHandler)
r.With(roleAuth([]string{"dashboard:read"})).Get("/dashboard/data", s.dashboardDataHandler)
r.With(roleAuth([]string{"dashboard:read"})).Get("/dashboards", s.listDashboardsHandler)
r.With(roleAuth([]string{"dashboard:write"})).Post("/dashboards", s.createDashboardHandler)
r.With(roleAuth([]string{"dashboard:read"})).Get("/dashboards/{id}", s.getDashboardHandler)
r.With(roleAuth([]string{"dashboard:write"})).Put("/dashboards/{id}", s.updateDashboardHandler)
r.With(roleAuth([]string{"dashboard:write"})).Delete("/dashboards/{id}", s.deleteDashboardHandler)
r.With(roleAuth([]string{"job:read"})).Get("/jobs", s.listJobsHandler)
r.With(roleAuth([]string{"job:write"})).Post("/jobs", s.runJobHandler)
r.With(roleAuth([]string{"job:read"})).Get("/jobs/{id}", s.getJobHandler)
@@ -247,6 +259,77 @@ func (s *server) updateCurrentUserDataHandler(w http.ResponseWriter, r *http.Req
response(w, result, err)
}
func (s *server) dashboardDataHandler(w http.ResponseWriter, r *http.Request) {
aggregationP := r.URL.Query().Get("aggregation")
filterP := r.URL.Query().Get("filter")
result, err := s.service.DashboardData(r.Context(), aggregationP, &filterP)
response(w, result, err)
}
func (s *server) listDashboardsHandler(w http.ResponseWriter, r *http.Request) {
result, err := s.service.ListDashboards(r.Context())
response(w, result, err)
}
func (s *server) createDashboardHandler(w http.ResponseWriter, r *http.Request) {
body, err := io.ReadAll(r.Body)
if err != nil {
JSONError(w, err)
return
}
if validateSchema(body, model.DashboardSchema, w) {
return
}
var templateP *model.Dashboard
if err := parseBody(body, &templateP); err != nil {
JSONError(w, err)
return
}
result, err := s.service.CreateDashboard(r.Context(), templateP)
response(w, result, err)
}
func (s *server) getDashboardHandler(w http.ResponseWriter, r *http.Request) {
idP := chi.URLParam(r, "id")
result, err := s.service.GetDashboard(r.Context(), idP)
response(w, result, err)
}
func (s *server) updateDashboardHandler(w http.ResponseWriter, r *http.Request) {
idP := chi.URLParam(r, "id")
body, err := io.ReadAll(r.Body)
if err != nil {
JSONError(w, err)
return
}
if validateSchema(body, model.DashboardSchema, w) {
return
}
var dashboardP *model.Dashboard
if err := parseBody(body, &dashboardP); err != nil {
JSONError(w, err)
return
}
result, err := s.service.UpdateDashboard(r.Context(), idP, dashboardP)
response(w, result, err)
}
func (s *server) deleteDashboardHandler(w http.ResponseWriter, r *http.Request) {
idP := chi.URLParam(r, "id")
response(w, nil, s.service.DeleteDashboard(r.Context(), idP))
}
func (s *server) listJobsHandler(w http.ResponseWriter, r *http.Request) {
result, err := s.service.ListJobs(r.Context())
response(w, result, err)

View File

@@ -68,7 +68,7 @@ var Tests = []struct {
Args: Args{Method: "Get", URL: "/currentuser"},
Want: Want{
Status: 200,
Body: map[string]interface{}{"apikey": false, "blocked": false, "id": "bob", "roles": []interface{}{"admin:backup:read", "admin:backup:restore", "admin:group:write", "admin:job:read", "admin:job:write", "admin:log:read", "admin:settings:write", "admin:ticket:delete", "admin:user:write", "admin:userdata:read", "admin:userdata:write", "analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read", "engineer:automation:write", "engineer:playbook:write", "engineer:rule:write", "engineer:template:write", "engineer:tickettype:write"}},
Body: map[string]interface{}{"apikey": false, "blocked": false, "id": "bob", "roles": []interface{}{"admin:backup:read", "admin:backup:restore", "admin:dashboard:write", "admin:group:write", "admin:job:read", "admin:job:write", "admin:log:read", "admin:settings:write", "admin:ticket:delete", "admin:user:write", "admin:userdata:read", "admin:userdata:write", "analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:dashboard:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read", "engineer:automation:write", "engineer:playbook:write", "engineer:rule:write", "engineer:template:write", "engineer:tickettype:write"}},
},
},
@@ -90,6 +90,60 @@ var Tests = []struct {
},
},
{
Name: "DashboardData",
Args: Args{Method: "Get", URL: "/dashboard/data?aggregation=type&filter=status+%3D%3D+%22closed%22"},
Want: Want{
Status: 200,
Body: map[string]interface{}{"alert": 2, "incident": 1},
},
},
{
Name: "ListDashboards",
Args: Args{Method: "Get", URL: "/dashboards"},
Want: Want{
Status: 200,
Body: []interface{}{map[string]interface{}{"id": "simple", "name": "Simple", "widgets": []interface{}{map[string]interface{}{"aggregation": "owner", "filter": "status == \"open\"", "name": "open_tickets_per_user", "type": "bar", "width": 4}, map[string]interface{}{"aggregation": "CONCAT(DATE_YEAR(created), \"-\", DATE_ISOWEEK(created) < 10 ? \"0\" : \"\", DATE_ISOWEEK(created))", "name": "tickets_per_week", "type": "line", "width": 8}}}},
},
},
{
Name: "CreateDashboard",
Args: Args{Method: "Post", URL: "/dashboards", Data: map[string]interface{}{"name": "My Dashboard", "widgets": []interface{}{}}},
Want: Want{
Status: 200,
Body: map[string]interface{}{"id": "my-dashboard", "name": "My Dashboard", "widgets": []interface{}{}},
},
},
{
Name: "GetDashboard",
Args: Args{Method: "Get", URL: "/dashboards/simple"},
Want: Want{
Status: 200,
Body: map[string]interface{}{"id": "simple", "name": "Simple", "widgets": []interface{}{map[string]interface{}{"aggregation": "owner", "filter": "status == \"open\"", "name": "open_tickets_per_user", "type": "bar", "width": 4}, map[string]interface{}{"aggregation": "CONCAT(DATE_YEAR(created), \"-\", DATE_ISOWEEK(created) < 10 ? \"0\" : \"\", DATE_ISOWEEK(created))", "name": "tickets_per_week", "type": "line", "width": 8}}},
},
},
{
Name: "UpdateDashboard",
Args: Args{Method: "Put", URL: "/dashboards/simple", Data: map[string]interface{}{"name": "Simple", "widgets": []interface{}{}}},
Want: Want{
Status: 200,
Body: map[string]interface{}{"id": "simple", "name": "Simple", "widgets": []interface{}{}},
},
},
{
Name: "DeleteDashboard",
Args: Args{Method: "Delete", URL: "/dashboards/simple"},
Want: Want{
Status: 204,
Body: nil,
},
},
{
Name: "ListJobs",
Args: Args{Method: "Get", URL: "/jobs"},
@@ -185,7 +239,7 @@ var Tests = []struct {
Args: Args{Method: "Get", URL: "/settings"},
Want: Want{
Status: 200,
Body: map[string]interface{}{"artifactKinds": []interface{}{map[string]interface{}{"icon": "mdi-server", "id": "asset", "name": "Asset"}, map[string]interface{}{"icon": "mdi-bullseye", "id": "ioc", "name": "IOC"}}, "artifactStates": []interface{}{map[string]interface{}{"color": "info", "icon": "mdi-help-circle-outline", "id": "unknown", "name": "Unknown"}, map[string]interface{}{"color": "error", "icon": "mdi-skull", "id": "malicious", "name": "Malicious"}, map[string]interface{}{"color": "success", "icon": "mdi-check", "id": "clean", "name": "Clean"}}, "roles": []interface{}{"admin:backup:read", "admin:backup:restore", "admin:group:write", "admin:job:read", "admin:job:write", "admin:log:read", "admin:settings:write", "admin:ticket:delete", "admin:user:write", "admin:userdata:read", "admin:userdata:write", "analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read", "engineer:automation:write", "engineer:playbook:write", "engineer:rule:write", "engineer:template:write", "engineer:tickettype:write"}, "ticketTypes": []interface{}{map[string]interface{}{"default_playbooks": []interface{}{}, "default_template": "default", "icon": "mdi-alert", "id": "alert", "name": "Alerts"}, map[string]interface{}{"default_playbooks": []interface{}{}, "default_template": "default", "icon": "mdi-radioactive", "id": "incident", "name": "Incidents"}, map[string]interface{}{"default_playbooks": []interface{}{}, "default_template": "default", "icon": "mdi-fingerprint", "id": "investigation", "name": "Forensic Investigations"}, map[string]interface{}{"default_playbooks": []interface{}{}, "default_template": "default", "icon": "mdi-target", "id": "hunt", "name": "Threat Hunting"}}, "tier": "community", "timeformat": "YYYY-MM-DDThh:mm:ss", "version": "0.0.0-test"},
Body: map[string]interface{}{"artifactKinds": []interface{}{map[string]interface{}{"icon": "mdi-server", "id": "asset", "name": "Asset"}, map[string]interface{}{"icon": "mdi-bullseye", "id": "ioc", "name": "IOC"}}, "artifactStates": []interface{}{map[string]interface{}{"color": "info", "icon": "mdi-help-circle-outline", "id": "unknown", "name": "Unknown"}, map[string]interface{}{"color": "error", "icon": "mdi-skull", "id": "malicious", "name": "Malicious"}, map[string]interface{}{"color": "success", "icon": "mdi-check", "id": "clean", "name": "Clean"}}, "roles": []interface{}{"admin:backup:read", "admin:backup:restore", "admin:dashboard:write", "admin:group:write", "admin:job:read", "admin:job:write", "admin:log:read", "admin:settings:write", "admin:ticket:delete", "admin:user:write", "admin:userdata:read", "admin:userdata:write", "analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:dashboard:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read", "engineer:automation:write", "engineer:playbook:write", "engineer:rule:write", "engineer:template:write", "engineer:tickettype:write"}, "ticketTypes": []interface{}{map[string]interface{}{"default_playbooks": []interface{}{}, "default_template": "default", "icon": "mdi-alert", "id": "alert", "name": "Alerts"}, map[string]interface{}{"default_playbooks": []interface{}{}, "default_template": "default", "icon": "mdi-radioactive", "id": "incident", "name": "Incidents"}, map[string]interface{}{"default_playbooks": []interface{}{}, "default_template": "default", "icon": "mdi-fingerprint", "id": "investigation", "name": "Forensic Investigations"}, map[string]interface{}{"default_playbooks": []interface{}{}, "default_template": "default", "icon": "mdi-target", "id": "hunt", "name": "Threat Hunting"}}, "tier": "community", "timeformat": "YYYY-MM-DDThh:mm:ss", "version": "0.0.0-test"},
},
},
@@ -194,7 +248,7 @@ var Tests = []struct {
Args: Args{Method: "Post", URL: "/settings", Data: map[string]interface{}{"artifactKinds": []interface{}{map[string]interface{}{"icon": "mdi-server", "id": "asset", "name": "Asset"}, map[string]interface{}{"icon": "mdi-bullseye", "id": "ioc", "name": "IOC"}}, "artifactStates": []interface{}{map[string]interface{}{"color": "info", "icon": "mdi-help-circle-outline", "id": "unknown", "name": "Unknown"}, map[string]interface{}{"color": "error", "icon": "mdi-skull", "id": "malicious", "name": "Malicious"}, map[string]interface{}{"color": "success", "icon": "mdi-check", "id": "clean", "name": "Clean"}}, "timeformat": "YYYY-MM-DDThh:mm:ss"}},
Want: Want{
Status: 200,
Body: map[string]interface{}{"artifactKinds": []interface{}{map[string]interface{}{"icon": "mdi-server", "id": "asset", "name": "Asset"}, map[string]interface{}{"icon": "mdi-bullseye", "id": "ioc", "name": "IOC"}}, "artifactStates": []interface{}{map[string]interface{}{"color": "info", "icon": "mdi-help-circle-outline", "id": "unknown", "name": "Unknown"}, map[string]interface{}{"color": "error", "icon": "mdi-skull", "id": "malicious", "name": "Malicious"}, map[string]interface{}{"color": "success", "icon": "mdi-check", "id": "clean", "name": "Clean"}}, "roles": []interface{}{"admin:backup:read", "admin:backup:restore", "admin:group:write", "admin:job:read", "admin:job:write", "admin:log:read", "admin:settings:write", "admin:ticket:delete", "admin:user:write", "admin:userdata:read", "admin:userdata:write", "analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read", "engineer:automation:write", "engineer:playbook:write", "engineer:rule:write", "engineer:template:write", "engineer:tickettype:write"}, "ticketTypes": []interface{}{map[string]interface{}{"default_playbooks": []interface{}{}, "default_template": "default", "icon": "mdi-alert", "id": "alert", "name": "Alerts"}, map[string]interface{}{"default_playbooks": []interface{}{}, "default_template": "default", "icon": "mdi-radioactive", "id": "incident", "name": "Incidents"}, map[string]interface{}{"default_playbooks": []interface{}{}, "default_template": "default", "icon": "mdi-fingerprint", "id": "investigation", "name": "Forensic Investigations"}, map[string]interface{}{"default_playbooks": []interface{}{}, "default_template": "default", "icon": "mdi-target", "id": "hunt", "name": "Threat Hunting"}}, "tier": "community", "timeformat": "YYYY-MM-DDThh:mm:ss", "version": "0.0.0-test"},
Body: map[string]interface{}{"artifactKinds": []interface{}{map[string]interface{}{"icon": "mdi-server", "id": "asset", "name": "Asset"}, map[string]interface{}{"icon": "mdi-bullseye", "id": "ioc", "name": "IOC"}}, "artifactStates": []interface{}{map[string]interface{}{"color": "info", "icon": "mdi-help-circle-outline", "id": "unknown", "name": "Unknown"}, map[string]interface{}{"color": "error", "icon": "mdi-skull", "id": "malicious", "name": "Malicious"}, map[string]interface{}{"color": "success", "icon": "mdi-check", "id": "clean", "name": "Clean"}}, "roles": []interface{}{"admin:backup:read", "admin:backup:restore", "admin:dashboard:write", "admin:group:write", "admin:job:read", "admin:job:write", "admin:log:read", "admin:settings:write", "admin:ticket:delete", "admin:user:write", "admin:userdata:read", "admin:userdata:write", "analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:dashboard:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read", "engineer:automation:write", "engineer:playbook:write", "engineer:rule:write", "engineer:template:write", "engineer:tickettype:write"}, "ticketTypes": []interface{}{map[string]interface{}{"default_playbooks": []interface{}{}, "default_template": "default", "icon": "mdi-alert", "id": "alert", "name": "Alerts"}, map[string]interface{}{"default_playbooks": []interface{}{}, "default_template": "default", "icon": "mdi-radioactive", "id": "incident", "name": "Incidents"}, map[string]interface{}{"default_playbooks": []interface{}{}, "default_template": "default", "icon": "mdi-fingerprint", "id": "investigation", "name": "Forensic Investigations"}, map[string]interface{}{"default_playbooks": []interface{}{}, "default_template": "default", "icon": "mdi-target", "id": "hunt", "name": "Threat Hunting"}}, "tier": "community", "timeformat": "YYYY-MM-DDThh:mm:ss", "version": "0.0.0-test"},
},
},
@@ -554,7 +608,7 @@ var Tests = []struct {
Args: Args{Method: "Get", URL: "/users"},
Want: Want{
Status: 200,
Body: []interface{}{map[string]interface{}{"apikey": false, "blocked": false, "id": "bob", "roles": []interface{}{"admin:backup:read", "admin:backup:restore", "admin:group:write", "admin:job:read", "admin:job:write", "admin:log:read", "admin:settings:write", "admin:ticket:delete", "admin:user:write", "admin:userdata:read", "admin:userdata:write", "analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read", "engineer:automation:write", "engineer:playbook:write", "engineer:rule:write", "engineer:template:write", "engineer:tickettype:write"}}, map[string]interface{}{"apikey": true, "blocked": false, "id": "script", "roles": []interface{}{"analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read", "engineer:automation:write", "engineer:playbook:write", "engineer:rule:write", "engineer:template:write", "engineer:tickettype:write"}}},
Body: []interface{}{map[string]interface{}{"apikey": false, "blocked": false, "id": "bob", "roles": []interface{}{"admin:backup:read", "admin:backup:restore", "admin:dashboard:write", "admin:group:write", "admin:job:read", "admin:job:write", "admin:log:read", "admin:settings:write", "admin:ticket:delete", "admin:user:write", "admin:userdata:read", "admin:userdata:write", "analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:dashboard:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read", "engineer:automation:write", "engineer:playbook:write", "engineer:rule:write", "engineer:template:write", "engineer:tickettype:write"}}, map[string]interface{}{"apikey": true, "blocked": false, "id": "script", "roles": []interface{}{"analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:dashboard:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read", "engineer:automation:write", "engineer:playbook:write", "engineer:rule:write", "engineer:template:write", "engineer:tickettype:write"}}},
},
},
@@ -563,7 +617,7 @@ var Tests = []struct {
Args: Args{Method: "Post", URL: "/users", Data: map[string]interface{}{"apikey": true, "blocked": false, "id": "syncscript", "roles": []interface{}{"analyst"}}},
Want: Want{
Status: 200,
Body: map[string]interface{}{"blocked": false, "id": "syncscript", "roles": []interface{}{"analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read"}, "secret": "v39bOuobnlEljfWzjAgoKzhmnh1xSMxH"},
Body: map[string]interface{}{"blocked": false, "id": "syncscript", "roles": []interface{}{"analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:dashboard:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read"}, "secret": "v39bOuobnlEljfWzjAgoKzhmnh1xSMxH"},
},
},
@@ -572,7 +626,7 @@ var Tests = []struct {
Args: Args{Method: "Get", URL: "/users/script"},
Want: Want{
Status: 200,
Body: map[string]interface{}{"apikey": true, "blocked": false, "id": "script", "roles": []interface{}{"analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read", "engineer:automation:write", "engineer:playbook:write", "engineer:rule:write", "engineer:template:write", "engineer:tickettype:write"}},
Body: map[string]interface{}{"apikey": true, "blocked": false, "id": "script", "roles": []interface{}{"analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:dashboard:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read", "engineer:automation:write", "engineer:playbook:write", "engineer:rule:write", "engineer:template:write", "engineer:tickettype:write"}},
},
},
@@ -581,7 +635,7 @@ var Tests = []struct {
Args: Args{Method: "Put", URL: "/users/bob", Data: map[string]interface{}{"apikey": false, "blocked": false, "id": "syncscript", "roles": []interface{}{"analyst", "admin"}}},
Want: Want{
Status: 200,
Body: map[string]interface{}{"apikey": false, "blocked": false, "id": "bob", "roles": []interface{}{"admin:backup:read", "admin:backup:restore", "admin:group:write", "admin:job:read", "admin:job:write", "admin:log:read", "admin:settings:write", "admin:ticket:delete", "admin:user:write", "admin:userdata:read", "admin:userdata:write", "analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read", "engineer:automation:write", "engineer:playbook:write", "engineer:rule:write", "engineer:template:write", "engineer:tickettype:write"}},
Body: map[string]interface{}{"apikey": false, "blocked": false, "id": "bob", "roles": []interface{}{"admin:backup:read", "admin:backup:restore", "admin:dashboard:write", "admin:group:write", "admin:job:read", "admin:job:write", "admin:log:read", "admin:settings:write", "admin:ticket:delete", "admin:user:write", "admin:userdata:read", "admin:userdata:write", "analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:dashboard:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read", "engineer:automation:write", "engineer:playbook:write", "engineer:rule:write", "engineer:template:write", "engineer:tickettype:write"}},
},
},

View File

@@ -225,7 +225,7 @@
"apikey" : false,
"blocked" : false,
"id" : "bob",
"roles" : [ "admin:backup:read", "admin:backup:restore", "admin:group:write", "admin:job:read", "admin:job:write", "admin:log:read", "admin:settings:write", "admin:ticket:delete", "admin:user:write", "admin:userdata:read", "admin:userdata:write", "analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read", "engineer:automation:write", "engineer:playbook:write", "engineer:rule:write", "engineer:template:write", "engineer:tickettype:write" ]
"roles" : [ "admin:backup:read", "admin:backup:restore", "admin:dashboard:write", "admin:group:write", "admin:job:read", "admin:job:write", "admin:log:read", "admin:settings:write", "admin:ticket:delete", "admin:user:write", "admin:userdata:read", "admin:userdata:write", "analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:dashboard:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read", "engineer:automation:write", "engineer:playbook:write", "engineer:rule:write", "engineer:template:write", "engineer:tickettype:write" ]
}
}
},
@@ -307,6 +307,257 @@
"x-codegen-request-body-name" : "userdata"
}
},
"/dashboard/data" : {
"get" : {
"operationId" : "dashboardData",
"parameters" : [ {
"description" : "Aggregation",
"example" : "type",
"in" : "query",
"name" : "aggregation",
"required" : true,
"schema" : {
"type" : "string"
}
}, {
"description" : "Filter",
"example" : "status == \"closed\"",
"in" : "query",
"name" : "filter",
"schema" : {
"type" : "string"
}
} ],
"responses" : {
"200" : {
"content" : {
"application/json" : {
"schema" : {
"type" : "object"
}
},
"test" : {
"example" : {
"alert" : 2,
"incident" : 1
}
}
},
"description" : "successful operation"
}
},
"security" : [ {
"roles" : [ "dashboard:read" ]
} ],
"summary" : "Get widget data",
"tags" : [ "dashboards" ]
}
},
"/dashboards" : {
"get" : {
"operationId" : "listDashboards",
"responses" : {
"200" : {
"content" : {
"application/json" : {
"schema" : {
"items" : {
"$ref" : "#/components/schemas/DashboardResponse"
},
"type" : "array"
}
},
"test" : {
"example" : [ {
"id" : "simple",
"name" : "Simple",
"widgets" : [ {
"aggregation" : "owner",
"filter" : "status == \"open\"",
"name" : "open_tickets_per_user",
"type" : "bar",
"width" : 4
}, {
"aggregation" : "CONCAT(DATE_YEAR(created), \"-\", DATE_ISOWEEK(created) < 10 ? \"0\" : \"\", DATE_ISOWEEK(created))",
"name" : "tickets_per_week",
"type" : "line",
"width" : 8
} ]
} ]
}
},
"description" : "successful operation"
}
},
"security" : [ {
"roles" : [ "dashboard:read" ]
} ],
"summary" : "List dashboards",
"tags" : [ "dashboards" ]
},
"post" : {
"operationId" : "createDashboard",
"requestBody" : {
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/Dashboard"
}
}
},
"description" : "New template",
"required" : true
},
"responses" : {
"200" : {
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/DashboardResponse"
}
},
"test" : {
"example" : {
"id" : "my-dashboard",
"name" : "My Dashboard",
"widgets" : [ ]
}
}
},
"description" : "successful operation"
}
},
"security" : [ {
"roles" : [ "dashboard:write" ]
} ],
"summary" : "Create a new dashboard",
"tags" : [ "dashboards" ],
"x-codegen-request-body-name" : "template"
}
},
"/dashboards/{id}" : {
"delete" : {
"operationId" : "deleteDashboard",
"parameters" : [ {
"description" : "Dashboard ID",
"example" : "simple",
"in" : "path",
"name" : "id",
"required" : true,
"schema" : {
"type" : "string"
}
} ],
"responses" : {
"204" : {
"content" : { },
"description" : "successful operation"
}
},
"security" : [ {
"roles" : [ "dashboard:write" ]
} ],
"summary" : "Delete a dashboard",
"tags" : [ "dashboards" ]
},
"get" : {
"operationId" : "getDashboard",
"parameters" : [ {
"description" : "Dashboard ID",
"example" : "simple",
"in" : "path",
"name" : "id",
"required" : true,
"schema" : {
"type" : "string"
}
} ],
"responses" : {
"200" : {
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/DashboardResponse"
}
},
"test" : {
"example" : {
"id" : "simple",
"name" : "Simple",
"widgets" : [ {
"aggregation" : "owner",
"filter" : "status == \"open\"",
"name" : "open_tickets_per_user",
"type" : "bar",
"width" : 4
}, {
"aggregation" : "CONCAT(DATE_YEAR(created), \"-\", DATE_ISOWEEK(created) < 10 ? \"0\" : \"\", DATE_ISOWEEK(created))",
"name" : "tickets_per_week",
"type" : "line",
"width" : 8
} ]
}
}
},
"description" : "successful operation"
}
},
"security" : [ {
"roles" : [ "dashboard:read" ]
} ],
"summary" : "Get a single dashboard",
"tags" : [ "dashboards" ]
},
"put" : {
"operationId" : "updateDashboard",
"parameters" : [ {
"description" : "Dashboard ID",
"example" : "simple",
"in" : "path",
"name" : "id",
"required" : true,
"schema" : {
"type" : "string"
}
} ],
"requestBody" : {
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/Dashboard"
}
}
},
"description" : "Dashboard object that needs to be added",
"required" : true
},
"responses" : {
"200" : {
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/DashboardResponse"
}
},
"test" : {
"example" : {
"id" : "simple",
"name" : "Simple",
"widgets" : [ ]
}
}
},
"description" : "successful operation"
}
},
"security" : [ {
"roles" : [ "dashboard:write" ]
} ],
"summary" : "Update an existing dashboard",
"tags" : [ "dashboards" ],
"x-codegen-request-body-name" : "dashboard"
}
},
"/graph/{col}/{id}" : {
"get" : {
"operationId" : "graph",
@@ -1173,7 +1424,7 @@
"id" : "clean",
"name" : "Clean"
} ],
"roles" : [ "admin:backup:read", "admin:backup:restore", "admin:group:write", "admin:job:read", "admin:job:write", "admin:log:read", "admin:settings:write", "admin:ticket:delete", "admin:user:write", "admin:userdata:read", "admin:userdata:write", "analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read", "engineer:automation:write", "engineer:playbook:write", "engineer:rule:write", "engineer:template:write", "engineer:tickettype:write" ],
"roles" : [ "admin:backup:read", "admin:backup:restore", "admin:dashboard:write", "admin:group:write", "admin:job:read", "admin:job:write", "admin:log:read", "admin:settings:write", "admin:ticket:delete", "admin:user:write", "admin:userdata:read", "admin:userdata:write", "analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:dashboard:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read", "engineer:automation:write", "engineer:playbook:write", "engineer:rule:write", "engineer:template:write", "engineer:tickettype:write" ],
"ticketTypes" : [ {
"default_playbooks" : [ ],
"default_template" : "default",
@@ -1262,7 +1513,7 @@
"id" : "clean",
"name" : "Clean"
} ],
"roles" : [ "admin:backup:read", "admin:backup:restore", "admin:group:write", "admin:job:read", "admin:job:write", "admin:log:read", "admin:settings:write", "admin:ticket:delete", "admin:user:write", "admin:userdata:read", "admin:userdata:write", "analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read", "engineer:automation:write", "engineer:playbook:write", "engineer:rule:write", "engineer:template:write", "engineer:tickettype:write" ],
"roles" : [ "admin:backup:read", "admin:backup:restore", "admin:dashboard:write", "admin:group:write", "admin:job:read", "admin:job:write", "admin:log:read", "admin:settings:write", "admin:ticket:delete", "admin:user:write", "admin:userdata:read", "admin:userdata:write", "analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:dashboard:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read", "engineer:automation:write", "engineer:playbook:write", "engineer:rule:write", "engineer:template:write", "engineer:tickettype:write" ],
"ticketTypes" : [ {
"default_playbooks" : [ ],
"default_template" : "default",
@@ -5092,12 +5343,12 @@
"apikey" : false,
"blocked" : false,
"id" : "bob",
"roles" : [ "admin:backup:read", "admin:backup:restore", "admin:group:write", "admin:job:read", "admin:job:write", "admin:log:read", "admin:settings:write", "admin:ticket:delete", "admin:user:write", "admin:userdata:read", "admin:userdata:write", "analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read", "engineer:automation:write", "engineer:playbook:write", "engineer:rule:write", "engineer:template:write", "engineer:tickettype:write" ]
"roles" : [ "admin:backup:read", "admin:backup:restore", "admin:dashboard:write", "admin:group:write", "admin:job:read", "admin:job:write", "admin:log:read", "admin:settings:write", "admin:ticket:delete", "admin:user:write", "admin:userdata:read", "admin:userdata:write", "analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:dashboard:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read", "engineer:automation:write", "engineer:playbook:write", "engineer:rule:write", "engineer:template:write", "engineer:tickettype:write" ]
}, {
"apikey" : true,
"blocked" : false,
"id" : "script",
"roles" : [ "analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read", "engineer:automation:write", "engineer:playbook:write", "engineer:rule:write", "engineer:template:write", "engineer:tickettype:write" ]
"roles" : [ "analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:dashboard:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read", "engineer:automation:write", "engineer:playbook:write", "engineer:rule:write", "engineer:template:write", "engineer:tickettype:write" ]
} ]
}
},
@@ -5135,7 +5386,7 @@
"example" : {
"blocked" : false,
"id" : "syncscript",
"roles" : [ "analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read" ],
"roles" : [ "analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:dashboard:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read" ],
"secret" : "v39bOuobnlEljfWzjAgoKzhmnh1xSMxH"
}
}
@@ -5201,7 +5452,7 @@
"apikey" : true,
"blocked" : false,
"id" : "script",
"roles" : [ "analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read", "engineer:automation:write", "engineer:playbook:write", "engineer:rule:write", "engineer:template:write", "engineer:tickettype:write" ]
"roles" : [ "analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:dashboard:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read", "engineer:automation:write", "engineer:playbook:write", "engineer:rule:write", "engineer:template:write", "engineer:tickettype:write" ]
}
}
},
@@ -5250,7 +5501,7 @@
"apikey" : false,
"blocked" : false,
"id" : "bob",
"roles" : [ "admin:backup:read", "admin:backup:restore", "admin:group:write", "admin:job:read", "admin:job:write", "admin:log:read", "admin:settings:write", "admin:ticket:delete", "admin:user:write", "admin:userdata:read", "admin:userdata:write", "analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read", "engineer:automation:write", "engineer:playbook:write", "engineer:rule:write", "engineer:template:write", "engineer:tickettype:write" ]
"roles" : [ "admin:backup:read", "admin:backup:restore", "admin:dashboard:write", "admin:group:write", "admin:job:read", "admin:job:write", "admin:log:read", "admin:settings:write", "admin:ticket:delete", "admin:user:write", "admin:userdata:read", "admin:userdata:write", "analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:dashboard:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read", "engineer:automation:write", "engineer:playbook:write", "engineer:rule:write", "engineer:template:write", "engineer:tickettype:write" ]
}
}
},
@@ -5431,6 +5682,39 @@
},
"type" : "object"
},
"Dashboard" : {
"properties" : {
"name" : {
"type" : "string"
},
"widgets" : {
"items" : {
"$ref" : "#/components/schemas/Widget"
},
"type" : "array"
}
},
"required" : [ "name", "widgets" ],
"type" : "object"
},
"DashboardResponse" : {
"properties" : {
"id" : {
"type" : "string"
},
"name" : {
"type" : "string"
},
"widgets" : {
"items" : {
"$ref" : "#/components/schemas/Widget"
},
"type" : "array"
}
},
"required" : [ "id", "name", "widgets" ],
"type" : "object"
},
"Enrichment" : {
"properties" : {
"created" : {
@@ -6895,6 +7179,30 @@
},
"required" : [ "apikey", "blocked", "id", "roles" ],
"type" : "object"
},
"Widget" : {
"properties" : {
"aggregation" : {
"type" : "string"
},
"filter" : {
"type" : "string"
},
"name" : {
"type" : "string"
},
"type" : {
"enum" : [ "bar", "line", "pie" ],
"type" : "string"
},
"width" : {
"maximum" : 12,
"minimum" : 1,
"type" : "integer"
}
},
"required" : [ "aggregation", "name", "type", "width" ],
"type" : "object"
}
}
},

View File

@@ -141,6 +141,33 @@ definitions:
ticket:
$ref: '#/definitions/TicketResponse'
type: object
Dashboard:
properties:
name:
type: string
widgets:
items:
$ref: '#/definitions/Widget'
type: array
required:
- name
- widgets
type: object
DashboardResponse:
properties:
id:
type: string
name:
type: string
widgets:
items:
$ref: '#/definitions/Widget'
type: array
required:
- id
- name
- widgets
type: object
Enrichment:
properties:
created:
@@ -1335,6 +1362,30 @@ definitions:
- roles
- apikey
type: object
Widget:
properties:
aggregation:
type: string
filter:
type: string
name:
type: string
type:
enum:
- bar
- line
- pie
type: string
width:
maximum: 12
minimum: 1
type: integer
required:
- name
- type
- aggregation
- width
type: object
host: .
info:
description: API for the catalyst incident response platform.
@@ -1576,6 +1627,7 @@ paths:
roles:
- admin:backup:read
- admin:backup:restore
- admin:dashboard:write
- admin:group:write
- admin:job:read
- admin:job:write
@@ -1589,6 +1641,7 @@ paths:
- analyst:currentsettings:write
- analyst:currentuser:read
- analyst:currentuserdata:read
- analyst:dashboard:read
- analyst:file
- analyst:group:read
- analyst:playbook:read
@@ -1659,6 +1712,183 @@ paths:
summary: Update current user data
tags:
- userdata
/dashboard/data:
get:
operationId: dashboardData
parameters:
- description: Aggregation
in: query
name: aggregation
required: true
type: string
x-example: type
- description: Filter
in: query
name: filter
type: string
x-example: status == "closed"
responses:
"200":
description: successful operation
examples:
test:
alert: 2
incident: 1
schema:
type: object
security:
- roles:
- dashboard:read
summary: Get widget data
tags:
- dashboards
/dashboards:
get:
operationId: listDashboards
responses:
"200":
description: successful operation
examples:
test:
- id: simple
name: Simple
widgets:
- aggregation: owner
filter: status == "open"
name: open_tickets_per_user
type: bar
width: 4
- aggregation: 'CONCAT(DATE_YEAR(created), "-", DATE_ISOWEEK(created)
< 10 ? "0" : "", DATE_ISOWEEK(created))'
name: tickets_per_week
type: line
width: 8
schema:
items:
$ref: '#/definitions/DashboardResponse'
type: array
security:
- roles:
- dashboard:read
summary: List dashboards
tags:
- dashboards
post:
operationId: createDashboard
parameters:
- description: New template
in: body
name: template
required: true
schema:
$ref: '#/definitions/Dashboard'
x-example:
name: My Dashboard
widgets: []
responses:
"200":
description: successful operation
examples:
test:
id: my-dashboard
name: My Dashboard
widgets: []
schema:
$ref: '#/definitions/DashboardResponse'
security:
- roles:
- dashboard:write
summary: Create a new dashboard
tags:
- dashboards
/dashboards/{id}:
delete:
operationId: deleteDashboard
parameters:
- description: Dashboard ID
in: path
name: id
required: true
type: string
x-example: simple
responses:
"204":
description: successful operation
security:
- roles:
- dashboard:write
summary: Delete a dashboard
tags:
- dashboards
get:
operationId: getDashboard
parameters:
- description: Dashboard ID
in: path
name: id
required: true
type: string
x-example: simple
responses:
"200":
description: successful operation
examples:
test:
id: simple
name: Simple
widgets:
- aggregation: owner
filter: status == "open"
name: open_tickets_per_user
type: bar
width: 4
- aggregation: 'CONCAT(DATE_YEAR(created), "-", DATE_ISOWEEK(created)
< 10 ? "0" : "", DATE_ISOWEEK(created))'
name: tickets_per_week
type: line
width: 8
schema:
$ref: '#/definitions/DashboardResponse'
security:
- roles:
- dashboard:read
summary: Get a single dashboard
tags:
- dashboards
put:
operationId: updateDashboard
parameters:
- description: Dashboard ID
in: path
name: id
required: true
type: string
x-example: simple
- description: Dashboard object that needs to be added
in: body
name: dashboard
required: true
schema:
$ref: '#/definitions/Dashboard'
x-example:
name: Simple
widgets: []
responses:
"200":
description: successful operation
examples:
test:
id: simple
name: Simple
widgets: []
schema:
$ref: '#/definitions/DashboardResponse'
security:
- roles:
- dashboard:write
summary: Update an existing dashboard
tags:
- dashboards
/graph/{col}/{id}:
get:
operationId: graph
@@ -2601,6 +2831,7 @@ paths:
roles:
- admin:backup:read
- admin:backup:restore
- admin:dashboard:write
- admin:group:write
- admin:job:read
- admin:job:write
@@ -2614,6 +2845,7 @@ paths:
- analyst:currentsettings:write
- analyst:currentuser:read
- analyst:currentuserdata:read
- analyst:dashboard:read
- analyst:file
- analyst:group:read
- analyst:playbook:read
@@ -2720,6 +2952,7 @@ paths:
roles:
- admin:backup:read
- admin:backup:restore
- admin:dashboard:write
- admin:group:write
- admin:job:read
- admin:job:write
@@ -2733,6 +2966,7 @@ paths:
- analyst:currentsettings:write
- analyst:currentuser:read
- analyst:currentuserdata:read
- analyst:dashboard:read
- analyst:file
- analyst:group:read
- analyst:playbook:read
@@ -7122,6 +7356,7 @@ paths:
roles:
- admin:backup:read
- admin:backup:restore
- admin:dashboard:write
- admin:group:write
- admin:job:read
- admin:job:write
@@ -7135,6 +7370,7 @@ paths:
- analyst:currentsettings:write
- analyst:currentuser:read
- analyst:currentuserdata:read
- analyst:dashboard:read
- analyst:file
- analyst:group:read
- analyst:playbook:read
@@ -7158,6 +7394,7 @@ paths:
- analyst:currentsettings:write
- analyst:currentuser:read
- analyst:currentuserdata:read
- analyst:dashboard:read
- analyst:file
- analyst:group:read
- analyst:playbook:read
@@ -7210,6 +7447,7 @@ paths:
- analyst:currentsettings:write
- analyst:currentuser:read
- analyst:currentuserdata:read
- analyst:dashboard:read
- analyst:file
- analyst:group:read
- analyst:playbook:read
@@ -7270,6 +7508,7 @@ paths:
- analyst:currentsettings:write
- analyst:currentuser:read
- analyst:currentuserdata:read
- analyst:dashboard:read
- analyst:file
- analyst:group:read
- analyst:playbook:read
@@ -7326,6 +7565,7 @@ paths:
roles:
- admin:backup:read
- admin:backup:restore
- admin:dashboard:write
- admin:group:write
- admin:job:read
- admin:job:write
@@ -7339,6 +7579,7 @@ paths:
- analyst:currentsettings:write
- analyst:currentuser:read
- analyst:currentuserdata:read
- analyst:dashboard:read
- analyst:file
- analyst:group:read
- analyst:playbook:read

View File

@@ -225,7 +225,7 @@
"apikey" : false,
"blocked" : false,
"id" : "bob",
"roles" : [ "admin:backup:read", "admin:backup:restore", "admin:group:write", "admin:job:read", "admin:job:write", "admin:log:read", "admin:settings:write", "admin:ticket:delete", "admin:user:write", "admin:userdata:read", "admin:userdata:write", "analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read", "engineer:automation:write", "engineer:playbook:write", "engineer:rule:write", "engineer:template:write", "engineer:tickettype:write" ]
"roles" : [ "admin:backup:read", "admin:backup:restore", "admin:dashboard:write", "admin:group:write", "admin:job:read", "admin:job:write", "admin:log:read", "admin:settings:write", "admin:ticket:delete", "admin:user:write", "admin:userdata:read", "admin:userdata:write", "analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:dashboard:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read", "engineer:automation:write", "engineer:playbook:write", "engineer:rule:write", "engineer:template:write", "engineer:tickettype:write" ]
}
}
},
@@ -307,6 +307,257 @@
"x-codegen-request-body-name" : "userdata"
}
},
"/dashboard/data" : {
"get" : {
"operationId" : "dashboardData",
"parameters" : [ {
"description" : "Aggregation",
"example" : "type",
"in" : "query",
"name" : "aggregation",
"required" : true,
"schema" : {
"type" : "string"
}
}, {
"description" : "Filter",
"example" : "status == \"closed\"",
"in" : "query",
"name" : "filter",
"schema" : {
"type" : "string"
}
} ],
"responses" : {
"200" : {
"content" : {
"application/json" : {
"schema" : {
"type" : "object"
}
},
"test" : {
"example" : {
"alert" : 2,
"incident" : 1
}
}
},
"description" : "successful operation"
}
},
"security" : [ {
"roles" : [ "dashboard:read" ]
} ],
"summary" : "Get widget data",
"tags" : [ "dashboards" ]
}
},
"/dashboards" : {
"get" : {
"operationId" : "listDashboards",
"responses" : {
"200" : {
"content" : {
"application/json" : {
"schema" : {
"items" : {
"$ref" : "#/components/schemas/DashboardResponse"
},
"type" : "array"
}
},
"test" : {
"example" : [ {
"id" : "simple",
"name" : "Simple",
"widgets" : [ {
"aggregation" : "owner",
"filter" : "status == \"open\"",
"name" : "open_tickets_per_user",
"type" : "bar",
"width" : 4
}, {
"aggregation" : "CONCAT(DATE_YEAR(created), \"-\", DATE_ISOWEEK(created) < 10 ? \"0\" : \"\", DATE_ISOWEEK(created))",
"name" : "tickets_per_week",
"type" : "line",
"width" : 8
} ]
} ]
}
},
"description" : "successful operation"
}
},
"security" : [ {
"roles" : [ "dashboard:read" ]
} ],
"summary" : "List dashboards",
"tags" : [ "dashboards" ]
},
"post" : {
"operationId" : "createDashboard",
"requestBody" : {
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/Dashboard"
}
}
},
"description" : "New template",
"required" : true
},
"responses" : {
"200" : {
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/DashboardResponse"
}
},
"test" : {
"example" : {
"id" : "my-dashboard",
"name" : "My Dashboard",
"widgets" : [ ]
}
}
},
"description" : "successful operation"
}
},
"security" : [ {
"roles" : [ "dashboard:write" ]
} ],
"summary" : "Create a new dashboard",
"tags" : [ "dashboards" ],
"x-codegen-request-body-name" : "template"
}
},
"/dashboards/{id}" : {
"delete" : {
"operationId" : "deleteDashboard",
"parameters" : [ {
"description" : "Dashboard ID",
"example" : "simple",
"in" : "path",
"name" : "id",
"required" : true,
"schema" : {
"type" : "string"
}
} ],
"responses" : {
"204" : {
"content" : { },
"description" : "successful operation"
}
},
"security" : [ {
"roles" : [ "dashboard:write" ]
} ],
"summary" : "Delete a dashboard",
"tags" : [ "dashboards" ]
},
"get" : {
"operationId" : "getDashboard",
"parameters" : [ {
"description" : "Dashboard ID",
"example" : "simple",
"in" : "path",
"name" : "id",
"required" : true,
"schema" : {
"type" : "string"
}
} ],
"responses" : {
"200" : {
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/DashboardResponse"
}
},
"test" : {
"example" : {
"id" : "simple",
"name" : "Simple",
"widgets" : [ {
"aggregation" : "owner",
"filter" : "status == \"open\"",
"name" : "open_tickets_per_user",
"type" : "bar",
"width" : 4
}, {
"aggregation" : "CONCAT(DATE_YEAR(created), \"-\", DATE_ISOWEEK(created) < 10 ? \"0\" : \"\", DATE_ISOWEEK(created))",
"name" : "tickets_per_week",
"type" : "line",
"width" : 8
} ]
}
}
},
"description" : "successful operation"
}
},
"security" : [ {
"roles" : [ "dashboard:read" ]
} ],
"summary" : "Get a single dashboard",
"tags" : [ "dashboards" ]
},
"put" : {
"operationId" : "updateDashboard",
"parameters" : [ {
"description" : "Dashboard ID",
"example" : "simple",
"in" : "path",
"name" : "id",
"required" : true,
"schema" : {
"type" : "string"
}
} ],
"requestBody" : {
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/Dashboard"
}
}
},
"description" : "Dashboard object that needs to be added",
"required" : true
},
"responses" : {
"200" : {
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/DashboardResponse"
}
},
"test" : {
"example" : {
"id" : "simple",
"name" : "Simple",
"widgets" : [ ]
}
}
},
"description" : "successful operation"
}
},
"security" : [ {
"roles" : [ "dashboard:write" ]
} ],
"summary" : "Update an existing dashboard",
"tags" : [ "dashboards" ],
"x-codegen-request-body-name" : "dashboard"
}
},
"/jobs" : {
"get" : {
"operationId" : "listJobs",
@@ -743,7 +994,7 @@
"id" : "clean",
"name" : "Clean"
} ],
"roles" : [ "admin:backup:read", "admin:backup:restore", "admin:group:write", "admin:job:read", "admin:job:write", "admin:log:read", "admin:settings:write", "admin:ticket:delete", "admin:user:write", "admin:userdata:read", "admin:userdata:write", "analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read", "engineer:automation:write", "engineer:playbook:write", "engineer:rule:write", "engineer:template:write", "engineer:tickettype:write" ],
"roles" : [ "admin:backup:read", "admin:backup:restore", "admin:dashboard:write", "admin:group:write", "admin:job:read", "admin:job:write", "admin:log:read", "admin:settings:write", "admin:ticket:delete", "admin:user:write", "admin:userdata:read", "admin:userdata:write", "analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:dashboard:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read", "engineer:automation:write", "engineer:playbook:write", "engineer:rule:write", "engineer:template:write", "engineer:tickettype:write" ],
"ticketTypes" : [ {
"default_playbooks" : [ ],
"default_template" : "default",
@@ -832,7 +1083,7 @@
"id" : "clean",
"name" : "Clean"
} ],
"roles" : [ "admin:backup:read", "admin:backup:restore", "admin:group:write", "admin:job:read", "admin:job:write", "admin:log:read", "admin:settings:write", "admin:ticket:delete", "admin:user:write", "admin:userdata:read", "admin:userdata:write", "analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read", "engineer:automation:write", "engineer:playbook:write", "engineer:rule:write", "engineer:template:write", "engineer:tickettype:write" ],
"roles" : [ "admin:backup:read", "admin:backup:restore", "admin:dashboard:write", "admin:group:write", "admin:job:read", "admin:job:write", "admin:log:read", "admin:settings:write", "admin:ticket:delete", "admin:user:write", "admin:userdata:read", "admin:userdata:write", "analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:dashboard:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read", "engineer:automation:write", "engineer:playbook:write", "engineer:rule:write", "engineer:template:write", "engineer:tickettype:write" ],
"ticketTypes" : [ {
"default_playbooks" : [ ],
"default_template" : "default",
@@ -4662,12 +4913,12 @@
"apikey" : false,
"blocked" : false,
"id" : "bob",
"roles" : [ "admin:backup:read", "admin:backup:restore", "admin:group:write", "admin:job:read", "admin:job:write", "admin:log:read", "admin:settings:write", "admin:ticket:delete", "admin:user:write", "admin:userdata:read", "admin:userdata:write", "analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read", "engineer:automation:write", "engineer:playbook:write", "engineer:rule:write", "engineer:template:write", "engineer:tickettype:write" ]
"roles" : [ "admin:backup:read", "admin:backup:restore", "admin:dashboard:write", "admin:group:write", "admin:job:read", "admin:job:write", "admin:log:read", "admin:settings:write", "admin:ticket:delete", "admin:user:write", "admin:userdata:read", "admin:userdata:write", "analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:dashboard:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read", "engineer:automation:write", "engineer:playbook:write", "engineer:rule:write", "engineer:template:write", "engineer:tickettype:write" ]
}, {
"apikey" : true,
"blocked" : false,
"id" : "script",
"roles" : [ "analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read", "engineer:automation:write", "engineer:playbook:write", "engineer:rule:write", "engineer:template:write", "engineer:tickettype:write" ]
"roles" : [ "analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:dashboard:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read", "engineer:automation:write", "engineer:playbook:write", "engineer:rule:write", "engineer:template:write", "engineer:tickettype:write" ]
} ]
}
},
@@ -4705,7 +4956,7 @@
"example" : {
"blocked" : false,
"id" : "syncscript",
"roles" : [ "analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read" ],
"roles" : [ "analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:dashboard:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read" ],
"secret" : "v39bOuobnlEljfWzjAgoKzhmnh1xSMxH"
}
}
@@ -4771,7 +5022,7 @@
"apikey" : true,
"blocked" : false,
"id" : "script",
"roles" : [ "analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read", "engineer:automation:write", "engineer:playbook:write", "engineer:rule:write", "engineer:template:write", "engineer:tickettype:write" ]
"roles" : [ "analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:dashboard:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read", "engineer:automation:write", "engineer:playbook:write", "engineer:rule:write", "engineer:template:write", "engineer:tickettype:write" ]
}
}
},
@@ -4820,7 +5071,7 @@
"apikey" : false,
"blocked" : false,
"id" : "bob",
"roles" : [ "admin:backup:read", "admin:backup:restore", "admin:group:write", "admin:job:read", "admin:job:write", "admin:log:read", "admin:settings:write", "admin:ticket:delete", "admin:user:write", "admin:userdata:read", "admin:userdata:write", "analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read", "engineer:automation:write", "engineer:playbook:write", "engineer:rule:write", "engineer:template:write", "engineer:tickettype:write" ]
"roles" : [ "admin:backup:read", "admin:backup:restore", "admin:dashboard:write", "admin:group:write", "admin:job:read", "admin:job:write", "admin:log:read", "admin:settings:write", "admin:ticket:delete", "admin:user:write", "admin:userdata:read", "admin:userdata:write", "analyst:automation:read", "analyst:currentsettings:write", "analyst:currentuser:read", "analyst:currentuserdata:read", "analyst:dashboard:read", "analyst:file", "analyst:group:read", "analyst:playbook:read", "analyst:rule:read", "analyst:settings:read", "analyst:template:read", "analyst:ticket:read", "analyst:ticket:write", "analyst:tickettype:read", "analyst:user:read", "engineer:automation:write", "engineer:playbook:write", "engineer:rule:write", "engineer:template:write", "engineer:tickettype:write" ]
}
}
},
@@ -5001,6 +5252,39 @@
},
"type" : "object"
},
"Dashboard" : {
"properties" : {
"name" : {
"type" : "string"
},
"widgets" : {
"items" : {
"$ref" : "#/components/schemas/Widget"
},
"type" : "array"
}
},
"required" : [ "name", "widgets" ],
"type" : "object"
},
"DashboardResponse" : {
"properties" : {
"id" : {
"type" : "string"
},
"name" : {
"type" : "string"
},
"widgets" : {
"items" : {
"$ref" : "#/components/schemas/Widget"
},
"type" : "array"
}
},
"required" : [ "id", "name", "widgets" ],
"type" : "object"
},
"Enrichment" : {
"properties" : {
"created" : {
@@ -6316,6 +6600,30 @@
},
"required" : [ "apikey", "blocked", "id", "roles" ],
"type" : "object"
},
"Widget" : {
"properties" : {
"aggregation" : {
"type" : "string"
},
"filter" : {
"type" : "string"
},
"name" : {
"type" : "string"
},
"type" : {
"enum" : [ "bar", "line", "pie" ],
"type" : "string"
},
"width" : {
"maximum" : 12,
"minimum" : 1,
"type" : "integer"
}
},
"required" : [ "aggregation", "name", "type", "width" ],
"type" : "object"
}
}
},

View File

@@ -141,6 +141,33 @@ definitions:
ticket:
$ref: '#/definitions/TicketResponse'
type: object
Dashboard:
properties:
name:
type: string
widgets:
items:
$ref: '#/definitions/Widget'
type: array
required:
- name
- widgets
type: object
DashboardResponse:
properties:
id:
type: string
name:
type: string
widgets:
items:
$ref: '#/definitions/Widget'
type: array
required:
- id
- name
- widgets
type: object
Enrichment:
properties:
created:
@@ -1216,6 +1243,30 @@ definitions:
- roles
- apikey
type: object
Widget:
properties:
aggregation:
type: string
filter:
type: string
name:
type: string
type:
enum:
- bar
- line
- pie
type: string
width:
maximum: 12
minimum: 1
type: integer
required:
- name
- type
- aggregation
- width
type: object
host: .
info:
description: API for the catalyst incident response platform.
@@ -1457,6 +1508,7 @@ paths:
roles:
- admin:backup:read
- admin:backup:restore
- admin:dashboard:write
- admin:group:write
- admin:job:read
- admin:job:write
@@ -1470,6 +1522,7 @@ paths:
- analyst:currentsettings:write
- analyst:currentuser:read
- analyst:currentuserdata:read
- analyst:dashboard:read
- analyst:file
- analyst:group:read
- analyst:playbook:read
@@ -1540,6 +1593,183 @@ paths:
summary: Update current user data
tags:
- userdata
/dashboard/data:
get:
operationId: dashboardData
parameters:
- description: Aggregation
in: query
name: aggregation
required: true
type: string
x-example: type
- description: Filter
in: query
name: filter
type: string
x-example: status == "closed"
responses:
"200":
description: successful operation
examples:
test:
alert: 2
incident: 1
schema:
type: object
security:
- roles:
- dashboard:read
summary: Get widget data
tags:
- dashboards
/dashboards:
get:
operationId: listDashboards
responses:
"200":
description: successful operation
examples:
test:
- id: simple
name: Simple
widgets:
- aggregation: owner
filter: status == "open"
name: open_tickets_per_user
type: bar
width: 4
- aggregation: 'CONCAT(DATE_YEAR(created), "-", DATE_ISOWEEK(created)
< 10 ? "0" : "", DATE_ISOWEEK(created))'
name: tickets_per_week
type: line
width: 8
schema:
items:
$ref: '#/definitions/DashboardResponse'
type: array
security:
- roles:
- dashboard:read
summary: List dashboards
tags:
- dashboards
post:
operationId: createDashboard
parameters:
- description: New template
in: body
name: template
required: true
schema:
$ref: '#/definitions/Dashboard'
x-example:
name: My Dashboard
widgets: []
responses:
"200":
description: successful operation
examples:
test:
id: my-dashboard
name: My Dashboard
widgets: []
schema:
$ref: '#/definitions/DashboardResponse'
security:
- roles:
- dashboard:write
summary: Create a new dashboard
tags:
- dashboards
/dashboards/{id}:
delete:
operationId: deleteDashboard
parameters:
- description: Dashboard ID
in: path
name: id
required: true
type: string
x-example: simple
responses:
"204":
description: successful operation
security:
- roles:
- dashboard:write
summary: Delete a dashboard
tags:
- dashboards
get:
operationId: getDashboard
parameters:
- description: Dashboard ID
in: path
name: id
required: true
type: string
x-example: simple
responses:
"200":
description: successful operation
examples:
test:
id: simple
name: Simple
widgets:
- aggregation: owner
filter: status == "open"
name: open_tickets_per_user
type: bar
width: 4
- aggregation: 'CONCAT(DATE_YEAR(created), "-", DATE_ISOWEEK(created)
< 10 ? "0" : "", DATE_ISOWEEK(created))'
name: tickets_per_week
type: line
width: 8
schema:
$ref: '#/definitions/DashboardResponse'
security:
- roles:
- dashboard:read
summary: Get a single dashboard
tags:
- dashboards
put:
operationId: updateDashboard
parameters:
- description: Dashboard ID
in: path
name: id
required: true
type: string
x-example: simple
- description: Dashboard object that needs to be added
in: body
name: dashboard
required: true
schema:
$ref: '#/definitions/Dashboard'
x-example:
name: Simple
widgets: []
responses:
"200":
description: successful operation
examples:
test:
id: simple
name: Simple
widgets: []
schema:
$ref: '#/definitions/DashboardResponse'
security:
- roles:
- dashboard:write
summary: Update an existing dashboard
tags:
- dashboards
/jobs:
get:
operationId: listJobs
@@ -2189,6 +2419,7 @@ paths:
roles:
- admin:backup:read
- admin:backup:restore
- admin:dashboard:write
- admin:group:write
- admin:job:read
- admin:job:write
@@ -2202,6 +2433,7 @@ paths:
- analyst:currentsettings:write
- analyst:currentuser:read
- analyst:currentuserdata:read
- analyst:dashboard:read
- analyst:file
- analyst:group:read
- analyst:playbook:read
@@ -2308,6 +2540,7 @@ paths:
roles:
- admin:backup:read
- admin:backup:restore
- admin:dashboard:write
- admin:group:write
- admin:job:read
- admin:job:write
@@ -2321,6 +2554,7 @@ paths:
- analyst:currentsettings:write
- analyst:currentuser:read
- analyst:currentuserdata:read
- analyst:dashboard:read
- analyst:file
- analyst:group:read
- analyst:playbook:read
@@ -6710,6 +6944,7 @@ paths:
roles:
- admin:backup:read
- admin:backup:restore
- admin:dashboard:write
- admin:group:write
- admin:job:read
- admin:job:write
@@ -6723,6 +6958,7 @@ paths:
- analyst:currentsettings:write
- analyst:currentuser:read
- analyst:currentuserdata:read
- analyst:dashboard:read
- analyst:file
- analyst:group:read
- analyst:playbook:read
@@ -6746,6 +6982,7 @@ paths:
- analyst:currentsettings:write
- analyst:currentuser:read
- analyst:currentuserdata:read
- analyst:dashboard:read
- analyst:file
- analyst:group:read
- analyst:playbook:read
@@ -6798,6 +7035,7 @@ paths:
- analyst:currentsettings:write
- analyst:currentuser:read
- analyst:currentuserdata:read
- analyst:dashboard:read
- analyst:file
- analyst:group:read
- analyst:playbook:read
@@ -6858,6 +7096,7 @@ paths:
- analyst:currentsettings:write
- analyst:currentuser:read
- analyst:currentuserdata:read
- analyst:dashboard:read
- analyst:file
- analyst:group:read
- analyst:playbook:read
@@ -6914,6 +7153,7 @@ paths:
roles:
- admin:backup:read
- admin:backup:restore
- admin:dashboard:write
- admin:group:write
- admin:job:read
- admin:job:write
@@ -6927,6 +7167,7 @@ paths:
- analyst:currentsettings:write
- analyst:currentuser:read
- analyst:currentuserdata:read
- analyst:dashboard:read
- analyst:file
- analyst:group:read
- analyst:playbook:read

View File

@@ -16,6 +16,8 @@ var (
CommentSchema = new(gojsonschema.Schema)
CommentFormSchema = new(gojsonschema.Schema)
ContextSchema = new(gojsonschema.Schema)
DashboardSchema = new(gojsonschema.Schema)
DashboardResponseSchema = new(gojsonschema.Schema)
EnrichmentSchema = new(gojsonschema.Schema)
EnrichmentFormSchema = new(gojsonschema.Schema)
FileSchema = new(gojsonschema.Schema)
@@ -60,6 +62,7 @@ var (
UserDataResponseSchema = new(gojsonschema.Schema)
UserFormSchema = new(gojsonschema.Schema)
UserResponseSchema = new(gojsonschema.Schema)
WidgetSchema = new(gojsonschema.Schema)
)
func init() {
@@ -72,6 +75,8 @@ func init() {
gojsonschema.NewStringLoader(`{"type":"object","properties":{"created":{"format":"date-time","type":"string"},"creator":{"type":"string"},"message":{"type":"string"}},"required":["creator","created","message"],"$id":"#/definitions/Comment"}`),
gojsonschema.NewStringLoader(`{"type":"object","properties":{"created":{"format":"date-time","type":"string"},"creator":{"type":"string"},"message":{"type":"string"}},"required":["message"],"$id":"#/definitions/CommentForm"}`),
gojsonschema.NewStringLoader(`{"type":"object","properties":{"artifact":{"$ref":"#/definitions/Artifact"},"playbook":{"$ref":"#/definitions/PlaybookResponse"},"task":{"$ref":"#/definitions/TaskResponse"},"ticket":{"$ref":"#/definitions/TicketResponse"}},"$id":"#/definitions/Context"}`),
gojsonschema.NewStringLoader(`{"type":"object","properties":{"name":{"type":"string"},"widgets":{"items":{"$ref":"#/definitions/Widget"},"type":"array"}},"required":["name","widgets"],"$id":"#/definitions/Dashboard"}`),
gojsonschema.NewStringLoader(`{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"widgets":{"items":{"$ref":"#/definitions/Widget"},"type":"array"}},"required":["id","name","widgets"],"$id":"#/definitions/DashboardResponse"}`),
gojsonschema.NewStringLoader(`{"type":"object","properties":{"created":{"format":"date-time","type":"string"},"data":{"type":"object"},"name":{"type":"string"}},"required":["name","data","created"],"$id":"#/definitions/Enrichment"}`),
gojsonschema.NewStringLoader(`{"type":"object","properties":{"data":{"type":"object"},"name":{"type":"string"}},"required":["name","data"],"$id":"#/definitions/EnrichmentForm"}`),
gojsonschema.NewStringLoader(`{"type":"object","properties":{"key":{"type":"string"},"name":{"type":"string"}},"required":["key","name"],"$id":"#/definitions/File"}`),
@@ -116,6 +121,7 @@ func init() {
gojsonschema.NewStringLoader(`{"type":"object","properties":{"email":{"type":"string"},"id":{"type":"string"},"image":{"type":"string"},"name":{"type":"string"},"timeformat":{"title":"Time Format (https://moment.github.io/luxon/docs/manual/formatting.html#table-of-tokens)","type":"string"}},"required":["id"],"$id":"#/definitions/UserDataResponse"}`),
gojsonschema.NewStringLoader(`{"type":"object","properties":{"apikey":{"type":"boolean"},"blocked":{"type":"boolean"},"id":{"type":"string"},"roles":{"items":{"type":"string"},"type":"array"}},"required":["id","blocked","roles","apikey"],"$id":"#/definitions/UserForm"}`),
gojsonschema.NewStringLoader(`{"type":"object","properties":{"apikey":{"type":"boolean"},"blocked":{"type":"boolean"},"id":{"type":"string"},"roles":{"items":{"type":"string"},"type":"array"}},"required":["id","blocked","roles","apikey"],"$id":"#/definitions/UserResponse"}`),
gojsonschema.NewStringLoader(`{"type":"object","properties":{"aggregation":{"type":"string"},"filter":{"type":"string"},"name":{"type":"string"},"type":{"type":"string","enum":["bar","line","pie"]},"width":{"maximum":12,"type":"integer"}},"required":["name","type","aggregation","width"],"$id":"#/definitions/Widget"}`),
)
if err != nil {
panic(err)
@@ -129,6 +135,8 @@ func init() {
CommentSchema = mustCompile(`#/definitions/Comment`)
CommentFormSchema = mustCompile(`#/definitions/CommentForm`)
ContextSchema = mustCompile(`#/definitions/Context`)
DashboardSchema = mustCompile(`#/definitions/Dashboard`)
DashboardResponseSchema = mustCompile(`#/definitions/DashboardResponse`)
EnrichmentSchema = mustCompile(`#/definitions/Enrichment`)
EnrichmentFormSchema = mustCompile(`#/definitions/EnrichmentForm`)
FileSchema = mustCompile(`#/definitions/File`)
@@ -173,6 +181,7 @@ func init() {
UserDataResponseSchema = mustCompile(`#/definitions/UserDataResponse`)
UserFormSchema = mustCompile(`#/definitions/UserForm`)
UserResponseSchema = mustCompile(`#/definitions/UserResponse`)
WidgetSchema = mustCompile(`#/definitions/Widget`)
}
type Artifact struct {
@@ -230,6 +239,17 @@ type Context struct {
Ticket *TicketResponse `json:"ticket,omitempty"`
}
type Dashboard struct {
Name string `json:"name"`
Widgets []*Widget `json:"widgets"`
}
type DashboardResponse struct {
ID string `json:"id"`
Name string `json:"name"`
Widgets []*Widget `json:"widgets"`
}
type Enrichment struct {
Created time.Time `json:"created"`
Data map[string]interface{} `json:"data"`
@@ -600,6 +620,14 @@ type UserResponse struct {
Roles []string `json:"roles"`
}
type Widget struct {
Aggregation string `json:"aggregation"`
Filter *string `json:"filter,omitempty"`
Name string `json:"name"`
Type string `json:"type"`
Width int `json:"width"`
}
func mustCompile(uri string) *gojsonschema.Schema {
s, err := schemaLoader.Compile(gojsonschema.NewReferenceLoader(uri))
if err != nil {
@@ -632,4 +660,10 @@ const (
TypeColorSuccess = "success"
TypeColorWarning = "warning"
WidgetTypeBar = "bar"
WidgetTypeLine = "line"
WidgetTypePie = "pie"
)