summaryrefslogtreecommitdiffstats
path: root/src/Cepis/Health.cs
blob: 8101529f112db5f9a10df01bb5011fc5aaa5ee5e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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";
}