Пример #1
0
func AddMonitor(c *middleware.Context, cmd m.AddMonitorCommand) Response {
	cmd.OrgId = c.OrgId

	if err := bus.Dispatch(&cmd); err != nil {
		return ApiError(500, "Failed to add monitor", err)
	}

	return Json(200, cmd.Result)
}
Пример #2
0
func AddMonitor(c *middleware.Context, cmd m.AddMonitorCommand) Response {
	cmd.OrgId = c.OrgId
	if cmd.EndpointId == 0 {
		return ApiError(400, "EndpointId not set.", nil)
	}
	if cmd.MonitorTypeId == 0 {
		return ApiError(400, "MonitorTypeId not set.", nil)
	}
	if cmd.Frequency == 0 {
		return ApiError(400, "Frequency not set.", nil)
	}

	if err := bus.Dispatch(&cmd); err != nil {
		return ApiError(500, "Failed to add monitor", err)
	}

	return Json(200, cmd.Result)
}