コード例 #1
0
        public IHttpActionResult PostRegisterEndpoint([FromBody] EndpointRegistration endpoint)
        {
            endpoint.ValidateModel();

            try
            {
                var existed = _endpointRegistry.GetByNaturalKey(endpoint.MonitorType, endpoint.Address);
                RequestContext.AuthorizeRegistration(endpoint, existed, SecurityRole.Admin);

                var id = _endpointRegistry.RegisterOrUpdate(endpoint.MonitorType, endpoint.Address, endpoint.Group, endpoint.Name, endpoint.Tags, endpoint.Password);
                return(Created(new Uri(Request.RequestUri, $"/api/endpoints/{id}"), id));
            }
            catch (UnsupportedMonitorException e)
            {
                return(BadRequest(e.Message));
            }
        }