コード例 #1
0
        public void EntityValidator_should_raise_validation_exception_if_endpoint_entity_token_is_short()
        {
            var endpoint = new EndpointRegistration
            {
                Address = "address", Group = "group", MonitorType = "http", Name = "name", Password = "******"
            };

            Assert.Throws <ValidationException>(() => endpoint.ValidateModel());
        }
コード例 #2
0
 public IHttpActionResult PostRegisterEndpoint([FromBody] EndpointRegistration endpoint)
 {
     endpoint.ValidateModel();
     try
     {
         var id = _endpointRegistry.RegisterOrUpdate(endpoint.MonitorType, endpoint.Address, endpoint.Group, endpoint.Name, endpoint.Tags);
         return(Created(new Uri(Request.RequestUri, $"/api/endpoints/{id}"), id));
     }
     catch (UnsupportedMonitorException e)
     {
         return(BadRequest(e.Message));
     }
 }
コード例 #3
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));
            }
        }