func (metric *Metric) Delete(context *ctp.ApiContext) *ctp.HttpError { metricUrl := ctp.NewLink(context.CtpBase, "@/metrics/$", metric.Id) // just to create a clean URL query := context.Session.DB("ctp").C("measurements").Find(bson.M{"metric": metricUrl}) count, err := query.Count() if err != nil { return ctp.NewInternalServerError(err) } if count > 0 { return ctp.NewHttpError(http.StatusConflict, "Metric cannot be deleted because it is still in use by some measurements.") } if !ctp.DeleteResource(context, "metrics", metric.Id) { return ctp.NewInternalServerError("Metric deletion failed") } return nil }
func serviceViewDelete(context *ctp.ApiContext, id ctp.Base64Id) bool { if !IterateChildrenDelete(context, "assets", "parent", id, assetDelete) { return false } return ctp.DeleteResource(context, "serviceViews", id) }
func assetDelete(context *ctp.ApiContext, id ctp.Base64Id) bool { if !IterateChildrenDelete(context, "attributes", "parent", id, attributeDelete) { return false } return ctp.DeleteResource(context, "assets", id) }
func measurementDelete(context *ctp.ApiContext, id ctp.Base64Id) bool { return ctp.DeleteResource(context, "measurements", id) }
func (trigger *Trigger) Delete(context *ctp.ApiContext) *ctp.HttpError { if !ctp.DeleteResource(context, "triggers", trigger.Id) { return ctp.NewHttpError(http.StatusInternalServerError, "Could not delete trigger") } return nil }
func (account *Account) Delete(context *ctp.ApiContext) *ctp.HttpError { if !ctp.DeleteResource(context, "accounts", account.Id) { return ctp.NewInternalServerError("Account deletion failed") } return nil }