Skip to content

Commit

Permalink
Add OS info to SessionStatusModel; remove launchSettings
Browse files Browse the repository at this point in the history
Updated SessionStatusModel.cs to include a new OperatingSystem property, which is a dictionary with OS information, and removed [DataContract] and [DataMember] attributes. Modified SessionsController.cs to populate and return the new OperatingSystem property using RuntimeInformation and Environment classes. Removed launchSettings.json, which contained configuration settings for different profiles.
  • Loading branch information
gravity-api committed Sep 5, 2024
1 parent 895fe58 commit dff69e9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 38 deletions.
12 changes: 8 additions & 4 deletions src/Uia.DriverServer.Models/SessionStatusModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,40 @@
*
* RESOURCES
*/
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Text.Json.Serialization;

namespace Uia.DriverServer.Models
{
/// <summary>
/// Represents the status model for a WebDriver session.
/// </summary>
[DataContract]
public class SessionStatusModel
{
/// <summary>
/// Gets or sets the status message.
/// </summary>
/// <value>The status message indicating the current state of the session.</value>
[DataMember]
public string Message { get; set; }

/// <summary>
/// Gets or sets the operating system information represented as a dictionary of key-value pairs.
/// </summary>
[JsonPropertyName("os")]
public IDictionary<string, object> OperatingSystem { get; set; }

/// <summary>
/// Gets or sets a value indicating whether the session is ready.
/// </summary>
/// <value><c>true</c> if the session is ready; otherwise, <c>false</c>.</value>
[DataMember]
public bool Ready { get; set; }

/// <summary>
/// Gets or sets the collection of session identifiers.
/// </summary>
/// <value>A collection of session identifiers.</value>
[DataMember]
public IEnumerable<string> Sessions { get; set; }
}
}
19 changes: 15 additions & 4 deletions src/Uia.DriverServer/Controllers/SessionsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@

using Swashbuckle.AspNetCore.Annotations;

using System;
using System.Collections.Generic;
using System.Net.Mime;
using System.Runtime.InteropServices;

using Uia.DriverServer.Domain;
using Uia.DriverServer.Models;
Expand Down Expand Up @@ -143,11 +145,20 @@ public IActionResult GetStatus()
: "Sessions slots available, can create new session";

// Return the status as a JSON result
return new JsonResult(new SessionStatusModel
return new JsonResult(new
{
Message = message,
Ready = !isFull,
Sessions = sessions
Value = new SessionStatusModel
{
Message = message,
OperatingSystem = new Dictionary<string, object>
{
["arch"] = $"{RuntimeInformation.OSArchitecture}",
["name"] = RuntimeInformation.OSDescription,
["version"] = $"{Environment.OSVersion.Version}"
},
Ready = !isFull,
Sessions = sessions
}
});
}

Expand Down
30 changes: 0 additions & 30 deletions src/Uia.DriverServer/Properties/launchSettings.json

This file was deleted.

0 comments on commit dff69e9

Please sign in to comment.