protected static async Task DeleteAsync(string url) { using (var client = new HttpClient()) { client.BaseAddress = SimulacronManager.BaseAddress; var response = await client.DeleteAsync(url).ConfigureAwait(false); await SimulacronBase.EnsureSuccessStatusCode(response).ConfigureAwait(false); } }
protected static async Task <T> Get <T>(string url) { using (var client = new HttpClient()) { client.BaseAddress = SimulacronManager.BaseAddress; var response = await client.GetAsync(url).ConfigureAwait(false); await SimulacronBase.EnsureSuccessStatusCode(response).ConfigureAwait(false); var dataStr = await response.Content.ReadAsStringAsync().ConfigureAwait(false); return(JsonConvert.DeserializeObject <T>(dataStr)); } }
protected static async Task <JObject> Post(string url, object body) { var bodyStr = SimulacronBase.GetJsonFromObject(body); var content = new StringContent(bodyStr, Encoding.UTF8, "application/json"); using (var client = new HttpClient()) { client.BaseAddress = SimulacronManager.BaseAddress; var response = await client.PostAsync(url, content).ConfigureAwait(false); await SimulacronBase.EnsureSuccessStatusCode(response).ConfigureAwait(false); var dataStr = await response.Content.ReadAsStringAsync().ConfigureAwait(false); return(JObject.Parse(dataStr)); } }
public Task <JObject> PrimeFluentAsync(Func <IPrimeRequestBuilder, IThenFluent> builder) { var prime = SimulacronBase.PrimeBuilder(); return(builder(prime).ApplyAsync(this)); }
public Task PrimeDeleteAsync() { return(SimulacronBase.DeleteAsync(GetPath("prime"))); }
public Task DisableConnectionListener(int attempts = 0, string type = "unbind") { return(SimulacronBase.DeleteAsync(GetPath("listener") + "?after=" + attempts + "&type=" + type)); }
public dynamic GetConnections() { return(TaskHelper.WaitToComplete(SimulacronBase.Get <dynamic>(GetPath("connections")))); }
public Task <JObject> PrimeAsync(IPrimeRequest request) { return(SimulacronBase.Post(GetPath("prime"), request.Render())); }
public Task DropConnection(string ip, int port) { return(SimulacronBase.DeleteAsync(GetPath("connection") + "/" + ip + "/" + port)); }
public Task PauseReadsAsync() { return(SimulacronBase.PutAsync(GetPath("pause-reads"), null)); }
public Task ResumeReadsAsync() { return(SimulacronBase.DeleteAsync(GetPath("pause-reads"))); }
public Task <JObject> EnableConnectionListener(int attempts = 0, string type = "unbind") { return(SimulacronBase.PutAsync(GetPath("listener") + "?after=" + attempts + "&type=" + type, null)); }
public Task <dynamic> GetConnectionsAsync() { return(SimulacronBase.GetAsync <dynamic>(GetPath("connections"))); }
public async Task RemoveAsync() { await SimulacronBase.DeleteAsync(GetPath("cluster")).ConfigureAwait(false); }
public Task Stop() { return(SimulacronBase.DeleteAsync($"/listener/{Id}?type=stop")); }
public Task <SimulacronClusterLogs> GetLogsAsync() { return(SimulacronBase.Get <SimulacronClusterLogs>(GetPath("log"))); }
public Task Start() { return(SimulacronBase.PutAsync($"/listener/{Id}", null)); }
protected Task <JObject> PostAsync(string url, object body) { return(SimulacronBase.PostAsync(_simulacronManager, url, body)); }