summary refs log tree commit diff
path: root/LibSystemdCli.Models/SystemdUnitList.cs
blob: d6cba63d8ecbdc2f6ed0909e99026273a1fe9fad (plain) (blame)
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
using System.Text.Json.Serialization;

namespace LibSystemdCli.Models;

public class SystemdUnitListItem {
    [JsonPropertyName("unit")]
    public string Unit { get; set; } = null!;

    [JsonPropertyName("description")]
    public string Description { get; set; } = null!;

    [JsonPropertyName("load")]
    public string Load { get; set; } = null!;

    [JsonPropertyName("active")]
    public string Active { get; set; } = null!;

    [JsonPropertyName("sub")]
    public string Sub { get; set; } = null!;

    [JsonPropertyName("job")]
    public string Job { get; set; } = null!;

    
    [JsonPropertyName("x-fragment-paths")]
    public List<string> FragmentPaths { get; set; } = null!;
    
    [JsonIgnore]
    public string UnitType => Unit.Split('.').Last();

    [JsonIgnore]
    public bool IsSystem => IsGenerated || IsFromPackage;
    
    [JsonIgnore]
    public bool IsGenerated => FragmentPaths.Any(x => x.StartsWith("/run/systemd/generator/")) 
                               || FragmentPaths.Any(x=>x.StartsWith("/run/systemd/transient/"))
                               || FragmentPaths.Count == 0;
    
    [JsonIgnore]
    public bool IsFromPackage => FragmentPaths.Any(x => x.StartsWith("/usr/lib/systemd/"));
}