summary refs log tree commit diff
path: root/LibSystemdCli.Models/SystemdUnitList.cs
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2024-01-20 08:34:32 +0100
committerRory& <root@rory.gay>2024-01-20 08:34:32 +0100
commit43e06f4b1b7ead9f8cc97fe547eb49d51f341486 (patch)
treeb700ba441320e0f3944c398080cadd296f03ef07 /LibSystemdCli.Models/SystemdUnitList.cs
downloadSystemdCtl-43e06f4b1b7ead9f8cc97fe547eb49d51f341486.tar.xz
Initial commit
Diffstat (limited to 'LibSystemdCli.Models/SystemdUnitList.cs')
-rw-r--r--LibSystemdCli.Models/SystemdUnitList.cs41
1 files changed, 41 insertions, 0 deletions
diff --git a/LibSystemdCli.Models/SystemdUnitList.cs b/LibSystemdCli.Models/SystemdUnitList.cs
new file mode 100644
index 0000000..d6cba63
--- /dev/null
+++ b/LibSystemdCli.Models/SystemdUnitList.cs
@@ -0,0 +1,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/"));
+}
\ No newline at end of file