func V1DeleteMonitor(c *middleware.Context) { id := c.ParamsInt64(":id") check, err := sqlstore.GetCheckById(c.OrgId, id) if err != nil { handleError(c, err) return } // get the endpoint that the check belongs too. endpoint, err := sqlstore.GetEndpointById(c.OrgId, check.EndpointId) if err != nil { handleError(c, err) return } // now update the endpoint and remove the check. newChecks := make([]m.Check, 0) for _, ch := range endpoint.Checks { if ch.Id != id { newChecks = append(newChecks, ch) } } endpoint.Checks = newChecks err = sqlstore.UpdateEndpoint(endpoint) if err != nil { handleError(c, err) return } c.JSON(200, "monitor deleted") }
func GetOrgQuotas(c *middleware.Context) *rbody.ApiResponse { var quotas []m.OrgQuotaDTO var err error org := c.ParamsInt64("orgId") if setting.Quota.Enabled { quotas, err = sqlstore.GetOrgQuotas(org) if err != nil { return rbody.ErrResp(500, err) } } else { quotas = []m.OrgQuotaDTO{ { OrgId: org, Target: "endpoint", Limit: -1, Used: -1, }, { OrgId: org, Target: "probe", Limit: -1, Used: -1, }, } } return rbody.OkResp("quotas", quotas) }
func V1DeleteCollector(c *middleware.Context) { id := c.ParamsInt64(":id") err := sqlstore.DeleteProbe(id, c.OrgId) if err != nil { handleError(c, err) return } c.JSON(200, "collector deleted") return }
func V1GetCollectorById(c *middleware.Context) { id := c.ParamsInt64(":id") probe, err := sqlstore.GetProbeById(id, c.OrgId) if err != nil { handleError(c, err) return } c.JSON(200, probe) return }
func UpdateOrgQuota(c *middleware.Context) *rbody.ApiResponse { orgId := c.ParamsInt64(":orgId") target := c.Params(":target") limit := c.ParamsInt64(":limit") if _, ok := setting.Quota.Org.ToMap()[target]; !ok { return rbody.NotFound } quota := m.OrgQuotaDTO{ OrgId: orgId, Target: target, Limit: limit, } err := sqlstore.UpdateOrgQuota("a) if err != nil { return rbody.ErrResp(500, err) } return rbody.OkResp("quota", quota) }