public static StreamDescription ConvertToDescription([CanBeNull] StreamDescriptionDto dto) => dto == null ? null : new StreamDescription(dto.Name) { Type = (StreamType)Enum.Parse(typeof(StreamType), dto.Type, true), Partitions = dto.Partitions, TTL = TimeSpan.FromMilliseconds(dto.TtlMilliseconds), ShardingKey = dto.ShardingKey, Sources = dto.Sources };
/// <inheritdoc /> public async Task <HerculesResult> CreateStreamAsync(CreateStreamQuery query, TimeSpan timeout) { var dto = new StreamDescriptionDto(query); var request = Request .Post("streams/create") .WithHeader("apiKey", getApiKey()) .WithHeader("Content-Type", "application/json") .WithContent(JsonConvert.SerializeObject(dto, settings)); var clusterResult = await client.SendAsync(request, timeout).ConfigureAwait(false); var herculesStatus = clusterResult.Status != ClusterResultStatus.Success ? ConvertFailureToHerculesStatus(clusterResult.Status) : ConvertResponseCodeToHerculesStatusForStream(clusterResult.Response.Code); return(new HerculesResult(herculesStatus)); }