summaryrefslogtreecommitdiffstats
path: root/src/Cepis/Health.cs
diff options
context:
space:
mode:
authorMurilo Ijanc <[email protected]>2026-07-26 12:42:38 -0300
committerMurilo Ijanc <[email protected]>2026-07-26 13:10:34 -0300
commita2b10fd494fb389e556e40134031eb86e56e11e7 (patch)
tree08b6df8a06f2c7c15488b90d57a6d8286cd57a22 /src/Cepis/Health.cs
downloadcsharp-a2b10fd494fb389e556e40134031eb86e56e11e7.tar.gz
Initial importv0.1.0
Diffstat (limited to 'src/Cepis/Health.cs')
-rw-r--r--src/Cepis/Health.cs51
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";
+}