Skip to content

Commit

Permalink
remove shell and admin host to keep only one of them
Browse files Browse the repository at this point in the history
  • Loading branch information
SchroterQuentin committed Aug 24, 2023
1 parent f22eb38 commit 2ea5e2e
Show file tree
Hide file tree
Showing 22 changed files with 31 additions and 49 deletions.
2 changes: 1 addition & 1 deletion Foundation.Clients/Abstractions/IFoundationClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class AdminDeviceTwinFoundationClient : IAdminDeviceTwinFoundationClient
{
private FoundationClient _root;

private HttpClient _client => _root.AdminClient;
private HttpClient _client => _root.FoundationHttpClient;


public async Task<DeviceTwinViewModel> Get(Guid deviceId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class CoreDeviceFoundationClient : ICoreDeviceFoundationClient
private FoundationClient _root;
private ILogger<CoreDeviceFoundationClient> _logger;

private HttpClient _client => _root.CoreClient;
private HttpClient _client => _root.FoundationHttpClient;

public CoreDeviceFoundationClient(ILogger<CoreDeviceFoundationClient> logger)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class CoreModelFoundationClient : ICoreModelFoundationClient
private FoundationClient _root;
private ILogger<CoreModelFoundationClient> _logger;

private HttpClient _client => _root.CoreClient;
private HttpClient _client => _root.FoundationHttpClient;

public CoreModelFoundationClient(ILogger<CoreModelFoundationClient> logger)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class CoreOrganisationFoundationClient : ICoreOrganisationFoundationClien
private FoundationClient _root;
private ILogger<CoreOrganisationFoundationClient> _logger;

private HttpClient _client => _root.CoreClient;
private HttpClient _client => _root.FoundationHttpClient;

public CoreOrganisationFoundationClient(ILogger<CoreOrganisationFoundationClient> logger)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class CorePermissionFoundationClient : ICorePermissionFoundationClient
private FoundationClient _root;
private ILogger<CorePermissionFoundationClient> _logger;

private HttpClient _client => _root.CoreClient;
private HttpClient _client => _root.FoundationHttpClient;

public CorePermissionFoundationClient(ILogger<CorePermissionFoundationClient> logger)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class CoreUserOrganisationFoundationClient : ICoreUserOrganisationFoundat
private FoundationClient _root;
private ILogger<CoreUserOrganisationFoundationClient> _logger;

private HttpClient _client => _root.CoreClient;
private HttpClient _client => _root.FoundationHttpClient;

public CoreUserOrganisationFoundationClient(ILogger<CoreUserOrganisationFoundationClient> logger)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
38 changes: 10 additions & 28 deletions Foundation.Clients/Services/FoundationClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,59 +7,41 @@ 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; }
public IGatewayFoundationClient Gateway { get; }
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class GatewayAccountFoundationClient : IGatewayAccountFoundationClient
private FoundationClient _root;
private ILogger<GatewayAccountFoundationClient> _logger;

private HttpClient _client => _root.GatewayClient;
private HttpClient _client => _root.FoundationHttpClient;

public GatewayAccountFoundationClient(ILogger<GatewayAccountFoundationClient> logger)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class GatewayTranslationFoundationClient : IGatewayTranslationFoundationC
private FoundationClient _root;
private ILogger<GatewayTranslationFoundationClient> _logger;

private HttpClient _client => _root.GatewayClient;
private HttpClient _client => _root.FoundationHttpClient;

public GatewayTranslationFoundationClient(ILogger<GatewayTranslationFoundationClient> logger)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class GatewayUserFoundationClient : IGatewayUserFoundationClient
private FoundationClient _root;
private ILogger<GatewayUserFoundationClient> _logger;

private HttpClient _client => _root.GatewayClient;
private HttpClient _client => _root.FoundationHttpClient;

public GatewayUserFoundationClient(ILogger<GatewayUserFoundationClient> logger)
{
Expand Down

0 comments on commit 2ea5e2e

Please sign in to comment.