public IHttpActionResult DeleteEndpoint(Guid id) { RequestContext.Authorize(id, SecurityRole.Admin); if (_endpointRegistry.TryUnregisterById(id)) { return(Ok()); } return(NotFound()); }
public IHttpActionResult PostEndpointsHealth(DateTimeOffset?clientCurrentTime = null, [FromBody] params EndpointHealthUpdate[] healthUpdate) { RequestContext.Authorize(SecurityRole.Monitor); healthUpdate.ValidateModel(); var clockDifference = GetServerToClientTimeDifference(clientCurrentTime); foreach (var update in healthUpdate) { _endpointRegistry.UpdateHealth(update.EndpointId, update.ToEndpointHealth(clockDifference)); } return(Ok()); }
public IHttpActionResult PostRegisterMonitors([FromBody] params string[] monitorTypes) { RequestContext.Authorize(SecurityRole.Monitor); if (monitorTypes == null || monitorTypes.Any(string.IsNullOrWhiteSpace)) { return(BadRequest("Body cannot be null and have to contain properly named monitor types")); } foreach (var monitorType in monitorTypes) { _healthMonitorTypeRegistry.RegisterMonitorType(monitorType); } return(Ok()); }
public IHttpActionResult PostEndpointHealth(Guid id, [FromBody] HealthUpdate health, DateTimeOffset?clientCurrentTime = null) { if (_endpointRegistry.GetById(id) != null) { RequestContext.Authorize(id); } health.ValidateModel(); var clockDifference = GetServerToClientTimeDifference(clientCurrentTime); if (!_endpointRegistry.UpdateHealth(id, health.ToEndpointHealth(clockDifference))) { return(NotFound()); } return(Ok()); }
protected override bool AuthorizeCore(RequestContext requestContext) { var authorized = base.AuthorizeCore(requestContext); if (authorized) { var permission = new Kooboo.CMS.Account.Models.Permission() { AreaName = this.AreaName, Group = this.Group, Name = this.Name }; return(requestContext.Authorize(permission)); } else { return(authorized); } }
protected override bool AuthorizeCore(RequestContext requestContext) { var authorized = base.AuthorizeCore(requestContext); if (authorized) { var permission = new Permission() { Group = this.Group, Name = this.Name }; return(requestContext.Authorize(permission)); } else { return(authorized); } }
public IHttpActionResult PutUpdateEndpointTags(Guid id, [FromBody] string[] tags) { try { RequestContext.Authorize(id, SecurityRole.Admin); tags.CheckForUnallowedSymbols(); if (_endpointRegistry.TryUpdateEndpointTags(id, tags)) { return(Ok()); } return(NotFound()); } catch (ArgumentException e) { return(BadRequest(e.Message)); } }