Files
MrBlake d8f3820dae
Build Windows agent / build (win-arm64) (push) Has been cancelled
Build Windows agent / build (win-x64) (push) Has been cancelled
feat: sync hardware modules, interfaces, and MAC addresses
docs: add complete copy-and-paste deployment guide
2026-07-21 13:59:11 +02:00

46 lines
2.6 KiB
C#

using System.Text.Json.Serialization;
namespace NetBoxWindowsAgent;
internal sealed class AgentConfig
{
[JsonPropertyName("netbox_url")] public string NetBoxUrl { get; set; } = "";
[JsonPropertyName("api_token")] public string ApiToken { get; set; } = "";
[JsonPropertyName("region")] public string Region { get; set; } = "";
[JsonPropertyName("site")] public string? Site { get; set; }
[JsonPropertyName("location")] public string? Location { get; set; }
[JsonPropertyName("device_role")] public string DeviceRole { get; set; } = "windows-client";
[JsonPropertyName("verify_tls")] public bool VerifyTls { get; set; } = true;
[JsonPropertyName("allow_insecure_tls")] public bool AllowInsecureTls { get; set; } = false;
[JsonPropertyName("timeout_seconds")] public int TimeoutSeconds { get; set; } = 30;
[JsonPropertyName("collect_software")] public bool CollectSoftware { get; set; } = true;
[JsonPropertyName("max_software_entries")] public int MaxSoftwareEntries { get; set; } = 250;
[JsonPropertyName("create_hardware_modules")] public bool CreateHardwareModules { get; set; } = true;
[JsonPropertyName("create_interfaces")] public bool CreateInterfaces { get; set; } = true;
[JsonPropertyName("tags")] public List<string> Tags { get; set; } = [];
[JsonPropertyName("custom_fields")] public Dictionary<string, string> CustomFields { get; set; } = new();
}
internal sealed record HardwareInfo(
string Hostname, string Manufacturer, string Model, string Serial, string Uuid,
string WindowsCaption, string WindowsVersion, string Architecture, string Processor,
ulong MemoryBytes, IReadOnlyList<DiskInfo> Disks, IReadOnlyList<NetworkInfo> Networks,
IReadOnlyList<MemoryInfo> MemoryModules, IReadOnlyList<SoftwareInfo> Software);
internal sealed record DiskInfo(string DeviceId, string Model, string Serial, ulong SizeBytes);
internal sealed record NetworkInfo(string Name, string MacAddress, IReadOnlyList<string> IpAddresses);
internal sealed record MemoryInfo(string Bank, string Manufacturer, string PartNumber, string Serial, ulong CapacityBytes);
internal sealed record SoftwareInfo(string Name, string Version, string Publisher);
internal sealed class Page<T>
{
[JsonPropertyName("count")] public int Count { get; set; }
[JsonPropertyName("results")] public List<T> Results { get; set; } = [];
}
internal sealed class NetBoxObject
{
[JsonPropertyName("id")] public int Id { get; set; }
[JsonPropertyName("name")] public string? Name { get; set; }
[JsonPropertyName("slug")] public string? Slug { get; set; }
[JsonPropertyName("serial")] public string? Serial { get; set; }
}