From 2ea5e2e3b0ff41deabe9e1891f7cdec88a8d2f4d Mon Sep 17 00:00:00 2001 From: qschroter Date: Thu, 24 Aug 2023 18:11:25 +0200 Subject: [PATCH] remove shell and admin host to keep only one of them --- .../Abstractions/IFoundationClient.cs | 2 +- .../Admin/AdminDeviceFoundationClient.cs | 2 +- ...AdminDeviceOrganisationFoundationClient.cs | 2 +- .../AdminDeviceSourceFoundationClient.cs | 2 +- .../Admin/AdminDeviceTwinFoundationClient.cs | 2 +- .../AdminOrganisationFoundationClient.cs | 2 +- .../AdminOrganisationTypeFoundationClient.cs | 2 +- .../Admin/AdminPermissionFoundationClient.cs | 2 +- .../AdminRoutineExecutionFoundationClient.cs | 2 +- .../Admin/AdminRoutineFoundationClient.cs | 2 +- .../Admin/AdminSourceFoundationClient.cs | 2 +- .../AdminUserApplicationFoundationClient.cs | 2 +- .../Core/CoreDeviceFoundationClient.cs | 2 +- .../Core/CoreModelFoundationClient.cs | 2 +- .../Core/CoreOrganisationFoundationClient.cs | 2 +- .../Core/CorePermissionFoundationClient.cs | 2 +- .../CoreUserOrganisationFoundationClient.cs | 2 +- .../DispatcherRoutineFoundationClient.cs | 2 +- .../Services/FoundationClient.cs | 38 +++++-------------- .../Gateway/GatewayAccountFoundationClient.cs | 2 +- .../GatewayTranslationFoundationClient.cs | 2 +- .../Gateway/GatewayUserFoundationClient.cs | 2 +- 22 files changed, 31 insertions(+), 49 deletions(-) diff --git a/Foundation.Clients/Abstractions/IFoundationClient.cs b/Foundation.Clients/Abstractions/IFoundationClient.cs index bbe3947..8702496 100644 --- a/Foundation.Clients/Abstractions/IFoundationClient.cs +++ b/Foundation.Clients/Abstractions/IFoundationClient.cs @@ -2,7 +2,7 @@ namespace Foundation.Clients.Abstractions { public interface IFoundationClient { - void Init(string adminHost, string shellHost, string languageCode, string jwt = null); + void Init(string host, string languageCode, string jwt = null); IAdminFoundationClient Admin { get; } ICoreFoundationClient Core { get; } IGatewayFoundationClient Gateway { get; } diff --git a/Foundation.Clients/Services/Admin/AdminDeviceFoundationClient.cs b/Foundation.Clients/Services/Admin/AdminDeviceFoundationClient.cs index e8731ba..b7cc13d 100644 --- a/Foundation.Clients/Services/Admin/AdminDeviceFoundationClient.cs +++ b/Foundation.Clients/Services/Admin/AdminDeviceFoundationClient.cs @@ -17,7 +17,7 @@ public class AdminDeviceFoundationClient : IAdminDeviceFoundationClient { private FoundationClient _root; - private HttpClient _client => _root.AdminClient; + private HttpClient _client => _root.FoundationHttpClient; public void Init(IFoundationClient root) { diff --git a/Foundation.Clients/Services/Admin/AdminDeviceOrganisationFoundationClient.cs b/Foundation.Clients/Services/Admin/AdminDeviceOrganisationFoundationClient.cs index 864b069..ae226fb 100644 --- a/Foundation.Clients/Services/Admin/AdminDeviceOrganisationFoundationClient.cs +++ b/Foundation.Clients/Services/Admin/AdminDeviceOrganisationFoundationClient.cs @@ -18,7 +18,7 @@ public class AdminDeviceOrganisationFoundationClient : IAdminDeviceOrganisationF { private FoundationClient _root; - private HttpClient _client => _root.AdminClient; + private HttpClient _client => _root.FoundationHttpClient; public void Init(IFoundationClient root) diff --git a/Foundation.Clients/Services/Admin/AdminDeviceSourceFoundationClient.cs b/Foundation.Clients/Services/Admin/AdminDeviceSourceFoundationClient.cs index ccd3811..a2152cb 100644 --- a/Foundation.Clients/Services/Admin/AdminDeviceSourceFoundationClient.cs +++ b/Foundation.Clients/Services/Admin/AdminDeviceSourceFoundationClient.cs @@ -17,7 +17,7 @@ public class AdminDeviceSourceFoundationClient : IAdminDeviceSourceFoundationCli { private FoundationClient _root; - private HttpClient _client => _root.AdminClient; + private HttpClient _client => _root.FoundationHttpClient; public void Init(IFoundationClient root) diff --git a/Foundation.Clients/Services/Admin/AdminDeviceTwinFoundationClient.cs b/Foundation.Clients/Services/Admin/AdminDeviceTwinFoundationClient.cs index 6b17f80..034e466 100644 --- a/Foundation.Clients/Services/Admin/AdminDeviceTwinFoundationClient.cs +++ b/Foundation.Clients/Services/Admin/AdminDeviceTwinFoundationClient.cs @@ -20,7 +20,7 @@ public class AdminDeviceTwinFoundationClient : IAdminDeviceTwinFoundationClient { private FoundationClient _root; - private HttpClient _client => _root.AdminClient; + private HttpClient _client => _root.FoundationHttpClient; public async Task Get(Guid deviceId) diff --git a/Foundation.Clients/Services/Admin/AdminOrganisationFoundationClient.cs b/Foundation.Clients/Services/Admin/AdminOrganisationFoundationClient.cs index 7a20f25..11b23da 100644 --- a/Foundation.Clients/Services/Admin/AdminOrganisationFoundationClient.cs +++ b/Foundation.Clients/Services/Admin/AdminOrganisationFoundationClient.cs @@ -17,7 +17,7 @@ public class AdminOrganisationFoundationClient : IAdminOrganisationFoundationCli { private FoundationClient _root; - private HttpClient _client => _root.AdminClient; + private HttpClient _client => _root.FoundationHttpClient; public void Init(IFoundationClient root) { diff --git a/Foundation.Clients/Services/Admin/AdminOrganisationTypeFoundationClient.cs b/Foundation.Clients/Services/Admin/AdminOrganisationTypeFoundationClient.cs index 17b9a9c..0185a6f 100644 --- a/Foundation.Clients/Services/Admin/AdminOrganisationTypeFoundationClient.cs +++ b/Foundation.Clients/Services/Admin/AdminOrganisationTypeFoundationClient.cs @@ -18,7 +18,7 @@ public class AdminOrganisationTypeFoundationClient : IAdminOrganisationTypeFound { private FoundationClient _root; - private HttpClient _client => _root.AdminClient; + private HttpClient _client => _root.FoundationHttpClient; public void Init(IFoundationClient root) { diff --git a/Foundation.Clients/Services/Admin/AdminPermissionFoundationClient.cs b/Foundation.Clients/Services/Admin/AdminPermissionFoundationClient.cs index e48e354..a3debd7 100644 --- a/Foundation.Clients/Services/Admin/AdminPermissionFoundationClient.cs +++ b/Foundation.Clients/Services/Admin/AdminPermissionFoundationClient.cs @@ -18,7 +18,7 @@ public class AdminPermissionFoundationClient : IAdminPermissionFoundationClient { private FoundationClient _root; - private HttpClient _client => _root.AdminClient; + private HttpClient _client => _root.FoundationHttpClient; public void Init(IFoundationClient root) diff --git a/Foundation.Clients/Services/Admin/AdminRoutineExecutionFoundationClient.cs b/Foundation.Clients/Services/Admin/AdminRoutineExecutionFoundationClient.cs index 5b7b275..c08b517 100644 --- a/Foundation.Clients/Services/Admin/AdminRoutineExecutionFoundationClient.cs +++ b/Foundation.Clients/Services/Admin/AdminRoutineExecutionFoundationClient.cs @@ -18,7 +18,7 @@ public class AdminRoutineExecutionFoundationClient : IAdminRoutineExecutionFound { private FoundationClient _root; - private HttpClient _client => _root.AdminClient; + private HttpClient _client => _root.FoundationHttpClient; public void Init(IFoundationClient root) diff --git a/Foundation.Clients/Services/Admin/AdminRoutineFoundationClient.cs b/Foundation.Clients/Services/Admin/AdminRoutineFoundationClient.cs index 96e1d2b..ba321c7 100644 --- a/Foundation.Clients/Services/Admin/AdminRoutineFoundationClient.cs +++ b/Foundation.Clients/Services/Admin/AdminRoutineFoundationClient.cs @@ -18,7 +18,7 @@ public class AdminRoutineFoundationClient : IAdminRoutineFoundationClient { private FoundationClient _root; - private HttpClient _client => _root.AdminClient; + private HttpClient _client => _root.FoundationHttpClient; public void Init(IFoundationClient root) diff --git a/Foundation.Clients/Services/Admin/AdminSourceFoundationClient.cs b/Foundation.Clients/Services/Admin/AdminSourceFoundationClient.cs index 9c0582d..0b32842 100644 --- a/Foundation.Clients/Services/Admin/AdminSourceFoundationClient.cs +++ b/Foundation.Clients/Services/Admin/AdminSourceFoundationClient.cs @@ -18,7 +18,7 @@ public class AdminSourceFoundationClient : IAdminSourceFoundationClient { private FoundationClient _root; - private HttpClient _client => _root.AdminClient; + private HttpClient _client => _root.FoundationHttpClient; public void Init(IFoundationClient root) diff --git a/Foundation.Clients/Services/Admin/AdminUserApplicationFoundationClient.cs b/Foundation.Clients/Services/Admin/AdminUserApplicationFoundationClient.cs index 143b459..040b7cc 100644 --- a/Foundation.Clients/Services/Admin/AdminUserApplicationFoundationClient.cs +++ b/Foundation.Clients/Services/Admin/AdminUserApplicationFoundationClient.cs @@ -18,7 +18,7 @@ public class AdminUserApplicationFoundationClient : IAdminUserApplicationFoundat { private FoundationClient _root; - private HttpClient _client => _root.AdminClient; + private HttpClient _client => _root.FoundationHttpClient; public void Init(IFoundationClient root) diff --git a/Foundation.Clients/Services/Core/CoreDeviceFoundationClient.cs b/Foundation.Clients/Services/Core/CoreDeviceFoundationClient.cs index 4905f4b..37c3961 100644 --- a/Foundation.Clients/Services/Core/CoreDeviceFoundationClient.cs +++ b/Foundation.Clients/Services/Core/CoreDeviceFoundationClient.cs @@ -23,7 +23,7 @@ public class CoreDeviceFoundationClient : ICoreDeviceFoundationClient private FoundationClient _root; private ILogger _logger; - private HttpClient _client => _root.CoreClient; + private HttpClient _client => _root.FoundationHttpClient; public CoreDeviceFoundationClient(ILogger logger) { diff --git a/Foundation.Clients/Services/Core/CoreModelFoundationClient.cs b/Foundation.Clients/Services/Core/CoreModelFoundationClient.cs index 77b8d8b..84b5e71 100644 --- a/Foundation.Clients/Services/Core/CoreModelFoundationClient.cs +++ b/Foundation.Clients/Services/Core/CoreModelFoundationClient.cs @@ -21,7 +21,7 @@ public class CoreModelFoundationClient : ICoreModelFoundationClient private FoundationClient _root; private ILogger _logger; - private HttpClient _client => _root.CoreClient; + private HttpClient _client => _root.FoundationHttpClient; public CoreModelFoundationClient(ILogger logger) { diff --git a/Foundation.Clients/Services/Core/CoreOrganisationFoundationClient.cs b/Foundation.Clients/Services/Core/CoreOrganisationFoundationClient.cs index 3148536..9d98d29 100644 --- a/Foundation.Clients/Services/Core/CoreOrganisationFoundationClient.cs +++ b/Foundation.Clients/Services/Core/CoreOrganisationFoundationClient.cs @@ -22,7 +22,7 @@ public class CoreOrganisationFoundationClient : ICoreOrganisationFoundationClien private FoundationClient _root; private ILogger _logger; - private HttpClient _client => _root.CoreClient; + private HttpClient _client => _root.FoundationHttpClient; public CoreOrganisationFoundationClient(ILogger logger) { diff --git a/Foundation.Clients/Services/Core/CorePermissionFoundationClient.cs b/Foundation.Clients/Services/Core/CorePermissionFoundationClient.cs index 41bf936..e3c962f 100644 --- a/Foundation.Clients/Services/Core/CorePermissionFoundationClient.cs +++ b/Foundation.Clients/Services/Core/CorePermissionFoundationClient.cs @@ -22,7 +22,7 @@ public class CorePermissionFoundationClient : ICorePermissionFoundationClient private FoundationClient _root; private ILogger _logger; - private HttpClient _client => _root.CoreClient; + private HttpClient _client => _root.FoundationHttpClient; public CorePermissionFoundationClient(ILogger logger) { diff --git a/Foundation.Clients/Services/Core/CoreUserOrganisationFoundationClient.cs b/Foundation.Clients/Services/Core/CoreUserOrganisationFoundationClient.cs index 0dbf7d4..6499087 100644 --- a/Foundation.Clients/Services/Core/CoreUserOrganisationFoundationClient.cs +++ b/Foundation.Clients/Services/Core/CoreUserOrganisationFoundationClient.cs @@ -22,7 +22,7 @@ public class CoreUserOrganisationFoundationClient : ICoreUserOrganisationFoundat private FoundationClient _root; private ILogger _logger; - private HttpClient _client => _root.CoreClient; + private HttpClient _client => _root.FoundationHttpClient; public CoreUserOrganisationFoundationClient(ILogger logger) { diff --git a/Foundation.Clients/Services/Dispatcher/DispatcherRoutineFoundationClient.cs b/Foundation.Clients/Services/Dispatcher/DispatcherRoutineFoundationClient.cs index 648f858..6e7493f 100644 --- a/Foundation.Clients/Services/Dispatcher/DispatcherRoutineFoundationClient.cs +++ b/Foundation.Clients/Services/Dispatcher/DispatcherRoutineFoundationClient.cs @@ -18,7 +18,7 @@ public class DispatcherRoutineFoundationClient : IDispatcherRoutineFoundationCli { private FoundationClient _root; - private HttpClient _client => _root.DispatcherClient; + private HttpClient _client => _root.FoundationHttpClient; public void Init(IFoundationClient root) diff --git a/Foundation.Clients/Services/FoundationClient.cs b/Foundation.Clients/Services/FoundationClient.cs index 2cc22cb..c08e0ec 100644 --- a/Foundation.Clients/Services/FoundationClient.cs +++ b/Foundation.Clients/Services/FoundationClient.cs @@ -7,10 +7,7 @@ namespace Foundation.Clients.Services { public class FoundationClient : IFoundationClient { - public HttpClient AdminClient { get; } - public HttpClient CoreClient { get; } - public HttpClient GatewayClient { get; } - public HttpClient DispatcherClient { get; } + public HttpClient FoundationHttpClient { get; } public IAdminFoundationClient Admin { get; } public ICoreFoundationClient Core { get; } @@ -18,48 +15,33 @@ public class FoundationClient : IFoundationClient public IDispatcherFoundationClient Dispatcher { get; } public FoundationClient( - HttpClient adminClient, - HttpClient shellClient, - HttpClient gatewayClient, - HttpClient dispatcherClient, + HttpClient httpClient, IAdminFoundationClient adminFoundationClient, - ICoreFoundationClient shellFoundationClient, + ICoreFoundationClient coreFoundationClient, IGatewayFoundationClient gatewayFoundationClient, IDispatcherFoundationClient dispatcherFoundationClient ) { - AdminClient = adminClient; - CoreClient = shellClient; - GatewayClient = gatewayClient; - DispatcherClient = dispatcherClient; + FoundationHttpClient = httpClient; Admin = adminFoundationClient; - Core = shellFoundationClient; + Core = coreFoundationClient; Gateway = gatewayFoundationClient; Dispatcher = dispatcherFoundationClient; } - public void Init(string adminHost, string shellHost, string languageCode, string jwt = null) + public void Init(string host, string languageCode, string jwt = null) { - AdminClient.BaseAddress = new Uri($"https://{adminHost}"); - CoreClient.BaseAddress = new Uri($"https://{shellHost}"); - GatewayClient.BaseAddress = new Uri($"https://{shellHost}"); - DispatcherClient.BaseAddress = new Uri($"https://{adminHost}"); - + FoundationHttpClient.BaseAddress = new Uri($"https://{host}"); + if (!String.IsNullOrWhiteSpace(jwt)) { - CoreClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {jwt}"); - GatewayClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {jwt}"); - AdminClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {jwt}"); - DispatcherClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {jwt}"); + FoundationHttpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {jwt}"); } if (!String.IsNullOrEmpty(languageCode)) { - AdminClient.DefaultRequestHeaders.Add("Accept-Language", languageCode); - CoreClient.DefaultRequestHeaders.Add("Accept-Language", languageCode); - GatewayClient.DefaultRequestHeaders.Add("Accept-Language", languageCode); - DispatcherClient.DefaultRequestHeaders.Add("Accept-Language", languageCode); + FoundationHttpClient.DefaultRequestHeaders.Add("Accept-Language", languageCode); } Admin.Init(this); diff --git a/Foundation.Clients/Services/Gateway/GatewayAccountFoundationClient.cs b/Foundation.Clients/Services/Gateway/GatewayAccountFoundationClient.cs index 0a20c6e..7515e0f 100644 --- a/Foundation.Clients/Services/Gateway/GatewayAccountFoundationClient.cs +++ b/Foundation.Clients/Services/Gateway/GatewayAccountFoundationClient.cs @@ -21,7 +21,7 @@ public class GatewayAccountFoundationClient : IGatewayAccountFoundationClient private FoundationClient _root; private ILogger _logger; - private HttpClient _client => _root.GatewayClient; + private HttpClient _client => _root.FoundationHttpClient; public GatewayAccountFoundationClient(ILogger logger) { diff --git a/Foundation.Clients/Services/Gateway/GatewayTranslationFoundationClient.cs b/Foundation.Clients/Services/Gateway/GatewayTranslationFoundationClient.cs index 2056b2f..21a56b0 100644 --- a/Foundation.Clients/Services/Gateway/GatewayTranslationFoundationClient.cs +++ b/Foundation.Clients/Services/Gateway/GatewayTranslationFoundationClient.cs @@ -21,7 +21,7 @@ public class GatewayTranslationFoundationClient : IGatewayTranslationFoundationC private FoundationClient _root; private ILogger _logger; - private HttpClient _client => _root.GatewayClient; + private HttpClient _client => _root.FoundationHttpClient; public GatewayTranslationFoundationClient(ILogger logger) { diff --git a/Foundation.Clients/Services/Gateway/GatewayUserFoundationClient.cs b/Foundation.Clients/Services/Gateway/GatewayUserFoundationClient.cs index 900aa52..8cfe43c 100644 --- a/Foundation.Clients/Services/Gateway/GatewayUserFoundationClient.cs +++ b/Foundation.Clients/Services/Gateway/GatewayUserFoundationClient.cs @@ -21,7 +21,7 @@ public class GatewayUserFoundationClient : IGatewayUserFoundationClient private FoundationClient _root; private ILogger _logger; - private HttpClient _client => _root.GatewayClient; + private HttpClient _client => _root.FoundationHttpClient; public GatewayUserFoundationClient(ILogger logger) {