public static Guid RegisterEndpoint(this RestClient client, string monitor, string address, string group, string name, string[] tags = null, Credentials credentials = null, string monitorTag=null) { var request = new RestRequest(EndpointRegistrationUrl) .AddJsonBody(new {group, monitorType = monitor, name, address, tags, monitorTag}); var response = client.Authorize(credentials).Post(request); response.VerifyValidStatus(HttpStatusCode.Created); return JsonConvert.DeserializeObject<Guid>(response.Content); }
private void DeleteEndpoint(string url, Credentials credentials) { _response = _client .Authorize(credentials) .Delete(new RestRequest(url) ); }
private void RegisterEndpoint( string url, string name, string group, string monitor, string address, string[] tags = null, string password = null, Credentials credentials = null) { object body = new { name, group, monitorType = monitor, address, tags, password }; _response = _client .Authorize(credentials) .Post(new RestRequest(url) .AddJsonBody(body) ); }
private void PostHealth(EndpointHealthUpdate[] healthUpdate, Credentials credentials) { _response = _client .Authorize(credentials) .Post(new RestRequest("api/endpoints/health") .AddJsonBody(healthUpdate) ); }
private void PostTags(string url, string[] tags, Credentials credentials) { _response = _client .Authorize(credentials) .Put(new RestRequest(url) .AddJsonBody(tags) ); }
private void When_client_request_endpoint_health_update_with_credentials(Guid endpointId, EndpointStatus status, Credentials credentials) { var updates = new [] { new EndpointHealthUpdate { EndpointId = endpointId, Status = status, CheckTimeUtc = DateTime.UtcNow, ResponseTime = TimeSpan.FromSeconds(5) } }; PostHealth(updates, credentials); }
public static IRestClient Authorize(this RestClient client, Credentials credentials) { if(credentials == null) return client; client.Authenticator = new HttpBasicAuthenticator(credentials.Id.ToString(), credentials.Password); return client; }