diff options
Diffstat (limited to 'src/Cepis/Health.cs')
| -rw-r--r-- | src/Cepis/Health.cs | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/Cepis/Health.cs b/src/Cepis/Health.cs new file mode 100644 index 0000000..8101529 --- /dev/null +++ b/src/Cepis/Health.cs @@ -0,0 +1,51 @@ +using System.Text.Json.Serialization; + +namespace Cepis; + +/// <summary> +/// The response of <c>GET /health</c>. +/// </summary> +/// <remarks> +/// Good for two things: checking that the API answers, and knowing <b>which +/// version of the database</b> is live. The DNE database changes every two +/// weeks; <see cref="Dne"/> identifies it. +/// </remarks> +public sealed record Health +{ + /// <summary> + /// <c>"ok"</c> when the API reports itself healthy. Wire name + /// <c>status</c>. + /// </summary> + [JsonPropertyName("status")] + public string Status { get; init; } = ""; + + /// <summary> + /// Identifier of the fortnightly DNE database behind the answers. Wire name + /// <c>dne</c>. + /// </summary> + [JsonPropertyName("dne")] + public string Dne { get; init; } = ""; + + /// <summary>How many CEPs that database holds. Wire name <c>ceps</c>.</summary> + [JsonPropertyName("ceps")] + public long Ceps { get; init; } + + /// <summary> + /// How many of those CEPs carry a coordinate. Wire name <c>geo</c>. + /// </summary> + [JsonPropertyName("geo")] + public long Geo { get; init; } + + /// <summary> + /// When the database was generated, as an ISO 8601 instant. Wire name + /// <c>base_gerada_em</c>. + /// </summary> + [JsonPropertyName("base_gerada_em")] + public string BaseGeradaEm { get; init; } = ""; + + /// <summary> + /// <see langword="true"/> when the API reports itself healthy. + /// </summary> + [JsonIgnore] + public bool Ok => Status == "ok"; +} |