private RestMSDomain CreateFeed(string domainUri, string name) { s_logger.LogDebug("Creating the feed {0} on the RestMS server: {1}", name, _gateway.Configuration.RestMS.Uri.AbsoluteUri); var client = _gateway.Client(); try { var response = client.SendAsync(_gateway.CreateRequest( domainUri, _gateway.CreateEntityBody( new RestMSFeed { Name = name, Type = "Default", Title = name })) ).Result; response.EnsureSuccessStatusCode(); return(_gateway.ParseResponse <RestMSDomain>(response)); } catch (AggregateException ae) { foreach (var exception in ae.Flatten().InnerExceptions) { s_logger.LogError(exception, "Threw exception adding Feed {0} to RestMS Server {1}", name, exception.Message); } throw new RestMSClientException($"Error adding the Feed {name} to the RestMS server, see log for details"); } }
public RestMSPipe GetPipe() { /*TODO: Optimize this by using a repository approach with the repository checking for modification * through etag and serving existing version if not modified and grabbing new version if changed*/ s_logger.LogDebug("Getting the pipe from the RestMS server: {URL}", PipeUri); var client = _gateway.Client(); try { var response = client.GetAsync(PipeUri).Result; response.EnsureSuccessStatusCode(); return(_gateway.ParseResponse <RestMSPipe>(response)); } catch (AggregateException ae) { foreach (var exception in ae.Flatten().InnerExceptions) { s_logger.LogError(exception, "Threw exception getting Pipe {URL} from RestMS Server {Request}", PipeUri, exception.Message); } throw new RestMSClientException("Error retrieving the domain from the RestMS server, see log for details"); } }
/// <summary> /// Gets the default domain. /// </summary> /// <returns>RestMSDomain.</returns> /// <exception cref="RestMSClientException"></exception> public RestMSDomain GetDomain() { _logger.Value.DebugFormat("Getting the default domain from the RestMS server: {0}", _gateway.Configuration.RestMS.Uri.AbsoluteUri); try { var response = _gateway.Client().GetAsync(_gateway.Configuration.RestMS.Uri).Result; response.EnsureSuccessStatusCode(); return(_gateway.ParseResponse <RestMSDomain>(response)); } catch (AggregateException ae) { foreach (var exception in ae.Flatten().InnerExceptions) { _logger.Value.ErrorFormat("Threw exception getting Domain from RestMS Server {0}", exception.Message); } throw new RestMSClientException("Error retrieving the domain from the RestMS server, see log for details"); } }
public RestMSJoin CreateJoin(string pipeUri, string routingKey) { _logger.Value.DebugFormat("Creating the join with key {0} for pipe {1}", routingKey, pipeUri); var client = _gateway.Client(); try { var response = client.SendAsync( _gateway.CreateRequest( pipeUri, _gateway.CreateEntityBody( new RestMSJoin { Address = routingKey, Feed = _feed.FeedUri, Type = "Default" } ) ) ) .Result; response.EnsureSuccessStatusCode(); var pipe = _gateway.ParseResponse <RestMSPipe>(response); return(pipe.Joins.FirstOrDefault()); } catch (AggregateException ae) { foreach (var exception in ae.Flatten().InnerExceptions) { _logger.Value.ErrorFormat("Threw exception adding join with routingKey {0} to Pipe {1} on RestMS Server {2}", routingKey, pipeUri, exception.Message); } throw new RestMSClientException(string.Format("Error adding the join with routingKey {0} to Pipe {1} to the RestMS server, see log for details", routingKey, pipeUri)); } }