diff options
Diffstat (limited to 'LibSystemdCli.Models')
-rw-r--r-- | LibSystemdCli.Models/LibSystemdCli.Models.csproj | 9 | ||||
-rw-r--r-- | LibSystemdCli.Models/SystemdUnitList.cs | 41 |
2 files changed, 50 insertions, 0 deletions
diff --git a/LibSystemdCli.Models/LibSystemdCli.Models.csproj b/LibSystemdCli.Models/LibSystemdCli.Models.csproj new file mode 100644 index 0000000..3a63532 --- /dev/null +++ b/LibSystemdCli.Models/LibSystemdCli.Models.csproj @@ -0,0 +1,9 @@ +<Project Sdk="Microsoft.NET.Sdk"> + + <PropertyGroup> + <TargetFramework>net8.0</TargetFramework> + <ImplicitUsings>enable</ImplicitUsings> + <Nullable>enable</Nullable> + </PropertyGroup> + +</Project> 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 |