// Copyright Epic Games, Inc. All Rights Reserved. using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; #pragma warning disable CA2227 // Change 'x' to be read-only by removing the property setter namespace EpicGames.Horde.Devices { /// /// The type of device pool /// public enum DevicePoolType { /// /// Available to CIS jobs /// Automation, /// /// Shared by users with remote checking and checkouts /// Shared } /// /// Create device platform request /// public class CreateDevicePlatformRequest { /// /// The name of the platform /// [Required] public string Name { get; set; } = null!; } /// /// Create device platform response object /// public class CreateDevicePlatformResponse { /// /// Id of newly created platform /// public string Id { get; set; } /// /// Constructor /// public CreateDevicePlatformResponse(string id) { Id = id; } } /// /// Update requesty object for a device platform /// public class UpdateDevicePlatformRequest { /// /// The vendor model ids for the platform /// public string[] ModelIds { get; set; } = null!; } /// /// Get object response which describes a device platform /// public class GetDevicePlatformResponse { /// /// Unique id of device platform /// public string Id { get; set; } /// /// Friendly name of device platform /// public string Name { get; set; } /// /// Platform vendor models /// public string[] ModelIds { get; set; } /// /// Response constructor /// public GetDevicePlatformResponse(string id, string name, string[] modelIds) { Id = id; Name = name; ModelIds = modelIds; } } /// /// Device pool creation request object /// public class CreateDevicePoolRequest { /// /// The name for the new pool /// [Required] public string Name { get; set; } = null!; /// /// The name for the new pool /// [Required] public DevicePoolType PoolType { get; set; } /// /// Projects associated with this device pool /// public List? ProjectIds { get; set; } } /// /// Device pool update request object /// public class UpdateDevicePoolRequest { /// /// Id of the device pool to update /// public string Id { get; set; } = null!; /// /// Projects associated with this device pool /// public List? ProjectIds { get; set; } } /// /// Device pool creation response object /// public class CreateDevicePoolResponse { /// /// Id of the newly created device pool /// public string Id { get; set; } /// /// Constructor /// public CreateDevicePoolResponse(string id) { Id = id; } } /// /// Device pool response object /// public class GetDevicePoolResponse { /// /// Id of the device pool /// public string Id { get; set; } /// /// Name of the device pool /// public string Name { get; set; } /// /// Type of the device pool /// public DevicePoolType PoolType { get; set; } /// /// Whether there is write access to the pool /// public bool WriteAccess { get; set; } /// /// Constructor /// public GetDevicePoolResponse(string id, string name, DevicePoolType poolType, bool writeAccess) { Id = id; Name = name; PoolType = poolType; WriteAccess = writeAccess; } } // Devices /// /// Device creation request object /// public class CreateDeviceRequest { /// /// The platform of the device /// [Required] public string PlatformId { get; set; } = null!; /// /// The pool to assign the device /// [Required] public string PoolId { get; set; } = null!; /// /// The friendly name of the device /// [Required] public string Name { get; set; } = null!; /// /// Whether to create the device in enabled state /// public bool? Enabled { get; set; } /// /// The network address of the device /// public string? Address { get; set; } /// /// The vendor model id of the device /// public string? ModelId { get; set; } } /// /// Device creation response object /// public class CreateDeviceResponse { /// /// The id of the newly created device /// [Required] public string Id { get; set; } = null!; /// /// Constructor /// /// public CreateDeviceResponse(string id) { Id = id; } } /// /// Get response object which describes a device (DEPRECATED) /// public class GetDeviceUtilizationResponse { /// /// The job id which utilized device /// public string? JobId { get; set; } /// /// The job's step id /// public string? StepId { get; set; } /// /// The time device was reserved /// public DateTime ReservationStartUtc { get; set; } /// /// The time device was freed /// public DateTime? ReservationFinishUtc { get; set; } } /// /// Get response object which describes a device /// public class GetDeviceResponse { /// /// The unique id of the device /// public string Id { get; set; } /// /// The platform of the device /// public string PlatformId { get; set; } /// /// The pool the device belongs to /// public string PoolId { get; set; } /// /// The friendly name of the device /// public string Name { get; set; } /// /// Whether the device is currently enabled /// public bool Enabled { get; set; } /// /// The address of the device (if it allows network connections) /// public string? Address { get; set; } /// /// The vendor model id of the device /// public string? ModelId { get; set; } /// /// Any notes provided for the device /// public string? Notes { get; set; } /// /// If the device has a marked problem /// public DateTime? ProblemTime { get; set; } /// /// If the device is in maintenance mode /// public DateTime? MaintenanceTime { get; set; } /// /// The user id that has the device checked out /// public string? CheckedOutByUserId { get; set; } /// /// The last time the device was checked out /// public DateTime? CheckOutTime { get; set; } /// /// When the checkout will expire /// public DateTime? CheckOutExpirationTime { get; set; } /// /// The last user to modifiy the device /// public string? ModifiedByUser { get; set; } /// /// When the clean pass started /// public DateTime? CleanStartTime { get; set; } /// /// When the clean pass finished /// public DateTime? CleanFinishTime { get; set; } /// /// Whether the device requires a cleaning /// public bool? CleanRequired { get; set; } /// /// Device Utilization data /// public List? Utilization { get; set; } /// /// Device response constructor /// public GetDeviceResponse(string id, string platformId, string poolId, string name, bool enabled, string? address, string? modelId, string? modifiedByUser, string? notes, DateTime? problemTime, DateTime? maintenanceTime, List? utilization, string? checkedOutByUser = null, DateTime? checkOutTime = null, DateTime? checkOutExpirationTime = null, bool? cleanRequired = null, DateTime? cleanStartTime = null, DateTime? cleanFinishTime = null) { Id = id; Name = name; PlatformId = platformId; PoolId = poolId; Enabled = enabled; Address = address; ModelId = modelId; ModifiedByUser = modifiedByUser; Notes = notes; ProblemTime = problemTime; MaintenanceTime = maintenanceTime; Utilization = utilization; CheckedOutByUserId = checkedOutByUser; CheckOutTime = checkOutTime; CheckOutExpirationTime = checkOutExpirationTime; CleanRequired = cleanRequired; CleanStartTime = cleanStartTime; CleanFinishTime = cleanFinishTime; } } /// /// Device update request object /// public class UpdateDeviceRequest { /// /// The device pool id /// public string? PoolId { get; set; } /// /// The device name /// public string? Name { get; set; } /// /// IP address or hostname of device /// public string? Address { get; set; } /// /// Device vendor model id /// public string? ModelId { get; set; } /// /// Markdown notes /// public string? Notes { get; set; } /// /// Whether device is enabled /// public bool? Enabled { get; set; } /// /// Whether the device is in maintenance mode /// public bool? Maintenance { get; set; } /// /// Whether to set or clear any device problem state /// public bool? Problem { get; set; } /// /// Additional message to attach to this request /// public string? Message { get; set; } } /// /// Device error report request object /// public class DeviceErrorRequest { /// /// Additional message to attach to this request /// public string? Message { get; set; } } /// /// Device checkout request object /// public class CheckoutDeviceRequest { /// /// Whether to checkout or in the device /// public bool Checkout { get; set; } } /// /// Device clean request object /// public class CleanDeviceRequest { /// /// Whether to set the device as being cleaned, or not /// public bool Clean { get; set; } } /// /// Device reservation request object /// public class DeviceReservationRequest { /// /// Device reservation platform id /// [Required] public string PlatformId { get; set; } = null!; /// /// The optional vendor model ids to include for this device /// public List? IncludeModels { get; set; } /// /// The optional vendor model ids to exclude for this device /// public List? ExcludeModels { get; set; } } /// /// Reservation request object /// public class CreateDeviceReservationRequest { /// /// What pool to reserve devices in /// [Required] public string PoolId { get; set; } = null!; /// /// Devices to reserve /// [Required] public List Devices { get; set; } = null!; } /// /// Device reservation response object /// public class CreateDeviceReservationResponse { /// /// The reservation id of newly created reservation /// public string Id { get; set; } = null!; /// /// The devices that were reserved /// public List Devices { get; set; } = null!; } /// /// A reservation containing one or more devices /// public class GetDeviceReservationResponse { /// /// Randomly generated unique id for this reservation /// [Required] public string Id { get; set; } = null!; /// /// Which device pool the reservation is in /// [Required] public string PoolId { get; set; } = null!; /// /// The reserved devices /// [Required] public List Devices { get; set; } = null!; /// /// JobID holding reservation /// public string? JobId { get; set; } /// /// Job step id holding reservation /// public string? StepId { get; set; } /// /// Job mame holding reservation /// public string? JobName { get; set; } /// /// Job step holding reservation /// public string? StepName { get; set; } /// /// Reservations held by a user, requires a token /// public string? UserId { get; set; } /// /// The hostname of machine holding reservation /// public string? Hostname { get; set; } /// /// The optional reservation details /// public string? ReservationDetails { get; set; } /// /// The UTC time when the reservation was created /// public DateTime CreateTimeUtc { get; set; } /// /// The legacy reservation system guid, to be removed once can update Gauntlet client in all streams /// public string LegacyGuid { get; set; } = null!; } /// /// Device telemetry respponse /// public class GetTelemetryInfoResponse { /// /// The UTC time the telemetry data was created /// [Required] public DateTime CreateTimeUtc { get; set; } /// /// The stream id which utilized device /// public string? StreamId { get; set; } /// /// The job id which utilized device /// public string? JobId { get; set; } /// /// The job name which utilized device /// public string? JobName { get; set; } /// /// The job's step id /// public string? StepId { get; set; } /// /// The job name which utilized device /// public string? StepName { get; set; } /// /// If this telemetry has a reservation, the start time of the reservation /// public DateTime? ReservationStartUtc { get; set; } /// /// If this telemetry has a reservation, the finish time of the reservation /// public DateTime? ReservationFinishUtc { get; set; } /// /// If this telemetry marks a detected device issue, the time of the issue /// public DateTime? ProblemTimeUtc { get; set; } } /// /// Device telemetry respponse /// public class GetDeviceTelemetryResponse { /// /// The device id for the telemetry data /// [Required] public string DeviceId { get; set; } = null!; /// /// Individual telemetry data points /// [Required] public List Telemetry { get; set; } = null!; /// /// Constructor /// /// /// public GetDeviceTelemetryResponse(string deviceId, List telemetry) { DeviceId = deviceId; Telemetry = telemetry; } } /// /// Stream device telemetry for pool snapshot /// public class GetDevicePoolReservationTelemetryResponse { /// /// Device id for reservation /// public string DeviceId { get; set; } /// /// Job id associated with reservation /// public string? JobId { get; set; } /// /// The step id of reservation /// public string? StepId { get; set; } /// /// The name of the job holding reservation /// public string? JobName { get; set; } /// /// The name of the step holding reservation /// public string? StepName { get; set; } /// /// constructor /// /// /// /// /// /// public GetDevicePoolReservationTelemetryResponse(string deviceId, string? jobId, string? stepId, string? jobName, string? stepName) { DeviceId = deviceId; JobId = jobId; StepId = stepId; JobName = jobName; StepName = stepName; } } /// /// Device telemetry respponse /// public class GetDevicePlatformTelemetryResponse { /// /// The corresponding platform id /// public string PlatformId { get; set; } /// /// Available devices of this platform /// public List? Available { get; set; } /// /// Devices in maintenance state /// public List? Maintenance { get; set; } /// /// Devices in problem state /// public List? Problem { get; set; } /// /// Number of devices in disabled state /// public List? Disabled { get; set; } /// /// Reserved devices /// public Dictionary>? Reserved { get; set; } /// /// Constructor /// public GetDevicePlatformTelemetryResponse(string platformId, List? available, List? maintenance, List? problem, List? disabled, Dictionary>? reserved) { PlatformId = platformId; if (available != null && available.Count > 0) { Available = available; } if (maintenance != null && maintenance.Count > 0) { Maintenance = maintenance; } if (problem != null && problem.Count > 0) { Problem = problem; } if (disabled != null && disabled.Count > 0) { Disabled = disabled; } if (reserved != null && reserved.Count > 0) { Reserved = reserved; } } } /// /// Device telemetry respponse /// public class GetDevicePoolTelemetryResponse { /// /// The UTC time the telemetry data was created /// public DateTime CreateTimeUtc { get; set; } /// /// Individual pool telemetry data points /// public Dictionary> Telemetry { get; set; } = null!; /// /// Constructor /// public GetDevicePoolTelemetryResponse(DateTime createTimeUtc, Dictionary> telemetry) { CreateTimeUtc = createTimeUtc; Telemetry = telemetry; } } // Legacy clients /// /// Reservation request for legacy clients /// public class LegacyCreateReservationRequest { /// /// The device types to reserve, these are mapped to platforms /// [Required] public string[] DeviceTypes { get; set; } = null!; /// /// The hostname of machine reserving devices /// [Required] public string Hostname { get; set; } = null!; /// /// The duration of reservation /// [Required] public string Duration { get; set; } = null!; /// /// Reservation details string /// public string? ReservationDetails { get; set; } = null; /// /// The PoolId of reservation request /// public string? PoolId { get; set; } = null; /// /// The JobId of reservation request /// public string? JobId { get; set; } = null; /// /// The StepId of reservation request /// public string? StepId { get; set; } = null; /// /// A specific device to reserve /// public string? DeviceName { get; set; } = null; } /// /// Reservation response for legacy clients /// public class GetLegacyReservationResponse { /// /// The names of the devices that were reserved /// [Required] public string[] DeviceNames { get; set; } = null!; /// /// The corresponding perf specs of the reserved devices /// [Required] public string[] DevicePerfSpecs { get; set; } = null!; /// /// The corresponding perf specs of the reserved devices /// [Required] public string[] DeviceModels { get; set; } = null!; /// /// The host name of the machine making the reservation /// [Required] public string HostName { get; set; } = null!; /// /// The start time of the reservation /// [Required] public string StartDateTime { get; set; } = null!; /// /// The duration of the reservation (before renew) /// [Required] public string Duration { get; set; } = null!; /// /// The JobId of reservation request /// public string? JobId { get; set; } = null; /// /// The StepId of reservation request /// public string? StepId { get; set; } = null; /// /// The job name of reservation request /// public string? JobName { get; set; } = null; /// /// The step name of reservation request /// public string? StepName { get; set; } = null; /// /// The legacy guid of the reservation /// [Required] public string Guid { get; set; } = null!; /// /// The step name of reservation request /// public bool? InstallRequired { get; set; } = null; } /// /// Device response for legacy clients /// public class GetLegacyDeviceResponse { /// /// The id of the reserved device /// [Required] public string Id { get; set; } = null!; /// /// The name of the reserved device /// [Required] public string Name { get; set; } = null!; /// /// The (legacy) type of the device, mapped from platform id /// [Required] public string Type { get; set; } = null!; /// /// The IP or hostname of device /// [Required] public string IPOrHostName { get; set; } = null!; /// /// The (legacy) perf spec of the device /// [Required] public string PerfSpec { get; set; } = null!; /// /// The device model information /// [Required] public string Model { get; set; } = null!; /// /// The available start time which is parsed client side /// [Required] public string AvailableStartTime { get; set; } = null!; /// /// The available end time which is parsed client side /// [Required] public string AvailableEndTime { get; set; } = null!; /// /// Whether device is enabled /// [Required] public bool Enabled { get; set; } /// /// Associated device data /// [Required] public string DeviceData { get; set; } = null!; } }