public async Task RemoveMessageContract(string topicId, string type) { var response = await _client.DeleteAsync($"/api/v1/topics/{topicId}/messageContracts/{type}"); var content = await response.Content.ReadAsStringAsync(); HttpResponseHelper.EnsureSuccessStatusCode(response); }
public async Task <ChannelsResponse> GetAllChannels() { var response = await _client.GetAsync("/api/v1/channels?channelType=slack"); HttpResponseHelper.EnsureSuccessStatusCode(response); var content = await response.Content.ReadAsStringAsync(); return(_serializer.Deserialize <ChannelsResponse>(content)); }
public async Task <IEnumerable <KafkaCluster> > GetAllClusters() { var response = await _client.GetAsync($"/api/v1/kafka/cluster"); HttpResponseHelper.EnsureSuccessStatusCode(response); var content = await response.Content.ReadAsStringAsync(); return(_serializer.Deserialize <IEnumerable <KafkaCluster> >(content)); }
public async Task <CapabilitiesResponse> GetAll() { var response = await _client.GetAsync("/api/v1/capabilities"); HttpResponseHelper.EnsureSuccessStatusCode(response); var content = await response.Content.ReadAsStringAsync(); return(_serializer.Deserialize <CapabilitiesResponse>(content)); }
public async Task <Topic> GetTopic(string id) { var response = await _client.GetAsync($"/api/v1/topics/{id}"); HttpResponseHelper.EnsureSuccessStatusCode(response); var content = await response.Content.ReadAsStringAsync(); return(_serializer.Deserialize <Topic>(content)); }
public async Task <TopicsResponse> GetByCapabilityId(string capabilityId) { var response = await _client.GetAsync($"/api/v1/capabilities/{capabilityId}/topics"); HttpResponseHelper.EnsureSuccessStatusCode(response); var content = await response.Content.ReadAsStringAsync(); return(_serializer.Deserialize <TopicsResponse>(content)); }
public async Task DeleteCapability(string capabilityId) { var response = await _client.DeleteAsync($"/api/v1/capabilities/{capabilityId}"); HttpResponseHelper.EnsureSuccessStatusCode(response); if (response.StatusCode != HttpStatusCode.OK) { throw new Exception($"Error! Capability was not deleted. Service returned ({response.StatusCode} - {response.ReasonPhrase})"); } }
public async Task <MessageContractsResponse> GetMessageContractsByTopicId(string topicId) { var response = await _client.GetAsync($"/api/v1/topics/{topicId}/messageContracts"); HttpResponseHelper.EnsureSuccessStatusCode(response); var content = await response.Content.ReadAsStringAsync(); return(_serializer.Deserialize <MessageContractsResponse>(content)); }
public async Task JoinChannel(string channelId, string channelName, string channelType, string clientId, string clientName, string clientType) { var content = new StringContent( content: _serializer.Serialize(new { ChannelId = channelId, ChannelName = channelName, ChannelType = channelType, ClientId = clientId, ClientName = clientName, ClientType = clientType }), encoding: Encoding.UTF8, mediaType: "application/json" ); var response = await _client.PostAsync("/api/v1/connections", content); HttpResponseHelper.EnsureSuccessStatusCode(response); }
public async Task LeaveCapability(string capabilityId, string memberEmail) { var response = await _client.DeleteAsync($"/api/v1/capabilities/{capabilityId}/members/{memberEmail}"); if (response.StatusCode == HttpStatusCode.NotFound) { throw new UnknownCapabilityException(); } HttpResponseHelper.EnsureSuccessStatusCode(response); }
public async Task CreateMessageContract(string type, string description, string content, string topicId) { var reqContent = new StringContent( content: _serializer.Serialize(new { Type = type, Description = description, Content = content }), encoding: Encoding.UTF8, mediaType: "application/json" ); var response = await _client.PostAsync($"/api/v1/topics/{topicId}/messageContracts", reqContent); HttpResponseHelper.EnsureSuccessStatusCode(response); }
public async Task AddUpdateMessageContract(string type, string topicId, MessageContractInput input) { var reqContent = new StringContent( content: _serializer.Serialize(new { Description = input.Description, Content = input.Content }), encoding: Encoding.UTF8, mediaType: "application/json" ); var response = await _client.PutAsync($"/api/v1/topics/{topicId}/messageContracts/{type}", reqContent); HttpResponseHelper.EnsureSuccessStatusCode(response); }
public async Task CreateTopic(string name, string description, string capabilityId, bool isPrivate) { var content = new StringContent( content: _serializer.Serialize(new { Name = name, Description = description, IsPrivate = isPrivate, MessageContract = new MessageContract[0] }), encoding: Encoding.UTF8, mediaType: "application/json" ); var response = await _client.PostAsync($"/api/v1/capabilities/{capabilityId}/topics", content); HttpResponseHelper.EnsureSuccessStatusCode(response); }
public async Task SetCapabilityTopicCommonPrefix(string commonPrefix, string capabilityId) { var content = new StringContent( content: _serializer.Serialize(new { CommonPrefix = commonPrefix }), encoding: Encoding.UTF8, mediaType: "application/json" ); var response = await _client.PostAsync($"/api/v1/capabilities/{capabilityId}/commonPrefix", content); if (response.StatusCode == HttpStatusCode.BadRequest) { var errorObj = _serializer.Deserialize <ErrorObject>(await response.Content.ReadAsStringAsync()); throw new CapabilityTopicValidationException(errorObj.Message); } HttpResponseHelper.EnsureSuccessStatusCode(response); }
public async Task UpdateCapability(string capabilityId, string name, string description) { var content = new StringContent( content: _serializer.Serialize(new { Name = name, Description = description }), encoding: Encoding.UTF8, mediaType: "application/json" ); var response = await _client.PutAsync($"/api/v1/capabilities/{capabilityId}", content); if (response.StatusCode == HttpStatusCode.BadRequest) { var errorObj = _serializer.Deserialize <ErrorObject>(await response.Content.ReadAsStringAsync()); throw new CapabilityValidationException(errorObj.Message); } HttpResponseHelper.EnsureSuccessStatusCode(response); }
public async Task UpdateTopic(string topicId, Topic input) { var reqContent = new StringContent( content: _serializer.Serialize(new { Description = input.Description, Name = input.Name, IsPrivate = true }), encoding: Encoding.UTF8, mediaType: "application/json" ); var response = await _client.PutAsync($"/api/v1/topics/{topicId}", reqContent); var content = await response.Content.ReadAsStringAsync(); HttpResponseHelper.EnsureSuccessStatusCode(response); }
public async Task LeaveChannel(string channelId, string channelType, string clientId, string clientType) { var query = HttpUtility.ParseQueryString(String.Empty); query["clientType"] = clientType; query["clientId"] = clientId; query["channelType"] = channelType; query["channelId"] = channelId; var content = new StringContent( content: _serializer.Serialize(new { ChannelId = channelId, ClientId = clientId, ChannelType = channelType, ClientType = clientType }), encoding: Encoding.UTF8, mediaType: "application/json" ); var response = await _client.DeleteAsync($"/api/v1/connections?{query}"); HttpResponseHelper.EnsureSuccessStatusCode(response); }
public async Task <ConnectionsResponse> GetAllConnections(string clientName, string clientType, string clientId, string channelName, string channelType, string channelId) { var query = HttpUtility.ParseQueryString(String.Empty); query["clientName"] = clientName; query["clientType"] = clientType; query["clientId"] = clientId; query["channelName"] = channelName; query["channelType"] = channelType; query["channelId"] = channelId; var response = await _client.GetAsync($"/api/v1/connections?{query}"); var content = await response.Content.ReadAsStringAsync(); HttpResponseHelper.EnsureSuccessStatusCode(response); return(_serializer.Deserialize <ConnectionsResponse>(content)); }
public async Task AddContext(string capabilityId, string contextName) { var content = new StringContent( content: _serializer.Serialize(new { Name = contextName }), encoding: Encoding.UTF8, mediaType: "application/json" ); var response = await _client.PostAsync($"/api/v1/capabilities/{capabilityId}/contexts", content); var responseBody = await response.Content.ReadAsStringAsync(); if (response.StatusCode == HttpStatusCode.Conflict) { throw new ContextAlreadyAddedException(); } HttpResponseHelper.EnsureSuccessStatusCode(response); }
public async Task JoinCapability(string capabilityId, string memberEmail) { var content = new StringContent( content: _serializer.Serialize(new { Email = memberEmail }), encoding: Encoding.UTF8, mediaType: "application/json" ); var response = await _client.PostAsync($"/api/v1/capabilities/{capabilityId}/members", content); var responseBody = await response.Content.ReadAsStringAsync(); if (response.StatusCode == HttpStatusCode.Conflict) { throw new AlreadyJoinedException(); } HttpResponseHelper.EnsureSuccessStatusCode(response); }