diff --git a/ocaml/sdk-gen/csharp/autogen/src/JsonRpc.cs b/ocaml/sdk-gen/csharp/autogen/src/JsonRpc.cs index a790f397320..5575b9b20de 100644 --- a/ocaml/sdk-gen/csharp/autogen/src/JsonRpc.cs +++ b/ocaml/sdk-gen/csharp/autogen/src/JsonRpc.cs @@ -163,6 +163,7 @@ public override string ToString() public partial class JsonRpcClient { private int _globalId; + private string _userAgent; #if (NET8_0_OR_GREATER) private static readonly Type ClassType = typeof(JsonRpcClient); @@ -205,6 +206,10 @@ public JsonRpcClient(string baseUrl) Url = baseUrl; JsonRpcUrl = new Uri(new Uri(baseUrl), "/jsonrpc").ToString(); JsonRpcVersion = JsonRpcVersion.v1; + Timeout = Session.STANDARD_TIMEOUT; ++ UserAgent = Session.DefaultUserAgent; ++ KeepAlive = true; ++ AllowAutoRedirect = true; } /// @@ -215,7 +220,11 @@ public JsonRpcClient(string baseUrl) public event Action RequestEvent; public JsonRpcVersion JsonRpcVersion { get; set; } - public string UserAgent { get; set; } + public string UserAgent ++ { ++ get => _userAgent; ++ set => _userAgent = string.IsNullOrEmpty(value) ? Session.DefaultUserAgent : value; ++ } public bool KeepAlive { get; set; } public IWebProxy WebProxy { get; set; } public int Timeout { get; set; } diff --git a/ocaml/sdk-gen/csharp/autogen/src/Session.cs b/ocaml/sdk-gen/csharp/autogen/src/Session.cs index 5d999136833..7f425ade0bd 100644 --- a/ocaml/sdk-gen/csharp/autogen/src/Session.cs +++ b/ocaml/sdk-gen/csharp/autogen/src/Session.cs @@ -46,29 +46,16 @@ public partial class Session : XenObject public const int STANDARD_TIMEOUT = 24 * 60 * 60 * 1000; /// - /// This string is used as the HTTP UserAgent for each request. + /// The default HTTP UserAgent for each request. /// - public static string UserAgent = $"XenAPI/{Helper.APIVersionString(API_Version.LATEST)}"; - - /// - /// If null, no proxy is used, otherwise this proxy is used for each request. - /// - public static IWebProxy Proxy = null; - - public API_Version APIVersion = API_Version.UNKNOWN; - - public object Tag; + public static readonly string DefaultUserAgent = $"XenAPI/{Helper.APIVersionString(API_Version.LATEST)}"; #region Constructors + /// Thrown if 'client' is null public Session(JsonRpcClient client) { - client.Timeout = STANDARD_TIMEOUT; - client.KeepAlive = true; - client.UserAgent = UserAgent; - client.WebProxy = Proxy; - client.AllowAutoRedirect = true; - JsonRpcClient = client; + JsonRpcClient = client ?? throw new ArgumentNullException(nameof(client)); } public Session(string url) : @@ -230,6 +217,19 @@ public override string SaveChanges(Session session, string serverOpaqueRef, Sess #region Properties + /// ++ /// The WebProxy to use for each HTTP request. ++ /// ++ public IWebProxy Proxy ++ { ++ get => JsonRpcClient.WebProxy; ++ set => JsonRpcClient.WebProxy = value; ++ } ++ ++ public API_Version APIVersion { get; private set; } = API_Version.UNKNOWN; ++ ++ public object Tag { get; set; } + /// /// Retrieves the current users details from the UserDetails map. These values are only updated when a new session is created. /// @@ -239,15 +239,24 @@ public override string SaveChanges(Session session, string serverOpaqueRef, Sess public string Url => JsonRpcClient.Url; + /// ++ /// The UserAgent to use for each HTTP request. If set to null or empty the DefaultUserAgent will be used. ++ /// ++ public string UserAgent ++ { ++ get => JsonRpcClient.UserAgent; ++ set => JsonRpcClient.UserAgent = value; ++ } + public string ConnectionGroupName { - get => JsonRpcClient?.ConnectionGroupName; + get => JsonRpcClient.ConnectionGroupName; set => JsonRpcClient.ConnectionGroupName = value; } public int Timeout { - get => JsonRpcClient?.Timeout ?? STANDARD_TIMEOUT; + get => JsonRpcClient.Timeout; set => JsonRpcClient.Timeout = value; }