Skip to content

Commit 3d652c8

Browse files
committed
Update FlowSynx.Client and adapt new changes regarding that
#94
1 parent 1ddc616 commit 3d652c8

30 files changed

Lines changed: 119 additions & 238 deletions

src/FlowCtl.Core/Services/Authentication/IAuthenticationManager.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ public interface IAuthenticationManager
66
bool IsBasicAuthenticationUsed { get; }
77
AuthenticationData LoginBasic(string username, string password);
88
AuthenticationData LoginBearer(string token);
9-
Task<AuthenticationData> LoginOAuthAsync(string authority, string clientId, string? scope);
109
AuthenticationData? GetData();
1110
void Logout();
1211
}

src/FlowCtl.Infrastructure/FlowCtl.Infrastructure.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
</ItemGroup>
1818

1919
<ItemGroup>
20-
<PackageReference Include="Duende.IdentityModel.OidcClient" Version="6.0.1" />
2120
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.3" />
2221
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
2322
<PackageReference Include="Octokit" Version="14.0.0" />

src/FlowCtl.Infrastructure/Services/Authentication/AuthenticationManager.cs

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using Duende.IdentityModel.OidcClient;
2-
using FlowCtl.Core.Serialization;
1+
using FlowCtl.Core.Serialization;
32
using FlowCtl.Core.Services.Authentication;
43

54
namespace FlowCtl.Infrastructure.Services.Authentication;
@@ -47,34 +46,6 @@ public AuthenticationData LoginBearer(string token)
4746
return data;
4847
}
4948

50-
public async Task<AuthenticationData> LoginOAuthAsync(string authority, string clientId, string? scope)
51-
{
52-
var options = new OidcClientOptions
53-
{
54-
Authority = authority,
55-
ClientId = clientId,
56-
Scope = scope,
57-
RedirectUri = "http://localhost:7890/",
58-
Browser = new SystemBrowser(7890)
59-
};
60-
61-
var client = new OidcClient(options);
62-
var result = await client.LoginAsync(new LoginRequest());
63-
64-
if (result.IsError)
65-
throw new Exception(string.Format(Resources.AuthenticationManager_LoginOAuthAsync, result.Error));
66-
67-
var data = new AuthenticationData
68-
{
69-
Type = AuthenticationType.Bearer,
70-
AccessToken = result.AccessToken,
71-
Expiry = DateTime.UtcNow.AddSeconds(result.AccessTokenExpiration.Second)
72-
};
73-
74-
Save(data);
75-
return data;
76-
}
77-
7849
public AuthenticationData? GetData()
7950
{
8051
return Load();

src/FlowCtl.Infrastructure/Services/Authentication/SystemBrowser.cs

Lines changed: 0 additions & 43 deletions
This file was deleted.

src/FlowCtl/Commands/Config/Add/AddConfigCommandOptionsHandler.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using FlowCtl.Core.Services.Logger;
44
using FlowCtl.Extensions;
55
using FlowSynx.Client;
6-
using FlowSynx.Client.Requests.PluginConfig;
6+
using FlowSynx.Client.Messages.Requests.PluginConfig;
77

88
namespace FlowCtl.Commands.Config.Add;
99

@@ -41,7 +41,10 @@ private async Task Execute(AddConfigCommandOptions options, CancellationToken ca
4141
_authenticationManager.AuthenticateClient(_flowSynxClient);
4242

4343
if (!string.IsNullOrEmpty(options.Address))
44-
_flowSynxClient.ChangeConnection(options.Address);
44+
{
45+
var connection = new FlowSynxClientConnection(options.Address);
46+
_flowSynxClient.SetConnection(connection);
47+
}
4548

4649
string? jsonData;
4750
if (!string.IsNullOrEmpty(options.DataFile))
@@ -57,7 +60,7 @@ private async Task Execute(AddConfigCommandOptions options, CancellationToken ca
5760
}
5861

5962
var request = AddConfigData(jsonData);
60-
var result = await _flowSynxClient.AddPluginConfig(request, cancellationToken);
63+
var result = await _flowSynxClient.PluginConfig.AddAsync(request, cancellationToken);
6164

6265
if (result.StatusCode != 200)
6366
throw new Exception(Resources.Commands_Error_DuringProcessingRequest);

src/FlowCtl/Commands/Config/ConfigCommandOptionsHandler.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,12 @@ private async Task Execute(ConfigCommandOptions options, CancellationToken cance
3535
_authenticationManager.AuthenticateClient(_flowSynxClient);
3636

3737
if (!string.IsNullOrEmpty(options.Address))
38-
_flowSynxClient.ChangeConnection(options.Address);
38+
{
39+
var connection = new FlowSynxClientConnection(options.Address);
40+
_flowSynxClient.SetConnection(connection);
41+
}
3942

40-
var result = await _flowSynxClient.PluginConfigList(cancellationToken);
43+
var result = await _flowSynxClient.PluginConfig.ListAsync(cancellationToken);
4144

4245
if (result.StatusCode != 200)
4346
throw new Exception(Resources.Commands_Error_DuringProcessingRequest);

src/FlowCtl/Commands/Config/Delete/DeleteConfigCommandOptions.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
using FlowSynx.Client.Requests;
2-
3-
namespace FlowCtl.Commands.Config.Delete;
1+
namespace FlowCtl.Commands.Config.Delete;
42

53
internal class DeleteConfigCommandOptions : ICommandOptions
64
{

src/FlowCtl/Commands/Config/Delete/DeleteConfigCommandOptionsHandler.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using FlowCtl.Core.Services.Logger;
33
using FlowCtl.Extensions;
44
using FlowSynx.Client;
5-
using FlowSynx.Client.Requests.PluginConfig;
5+
using FlowSynx.Client.Messages.Requests.PluginConfig;
66

77
namespace FlowCtl.Commands.Config.Delete;
88

@@ -36,10 +36,13 @@ private async Task Execute(DeleteConfigCommandOptions options, CancellationToken
3636
_authenticationManager.AuthenticateClient(_flowSynxClient);
3737

3838
if (!string.IsNullOrEmpty(options.Address))
39-
_flowSynxClient.ChangeConnection(options.Address);
39+
{
40+
var connection = new FlowSynxClientConnection(options.Address);
41+
_flowSynxClient.SetConnection(connection);
42+
}
4043

4144
var request = new DeletePluginConfigRequest { Id = Guid.Parse(options.Id) };
42-
var result = await _flowSynxClient.DeletePluginConfig(request, cancellationToken);
45+
var result = await _flowSynxClient.PluginConfig.DeleteAsync(request, cancellationToken);
4346

4447
if (result.StatusCode != 200)
4548
throw new Exception(Resources.Commands_Error_DuringProcessingRequest);

src/FlowCtl/Commands/Config/Details/DetailsConfigCommandOptionsHandler.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using FlowCtl.Core.Services.Logger;
33
using FlowCtl.Extensions;
44
using FlowSynx.Client;
5-
using FlowSynx.Client.Requests.PluginConfig;
5+
using FlowSynx.Client.Messages.Requests.PluginConfig;
66

77
namespace FlowCtl.Commands.Config.Details;
88

@@ -36,10 +36,13 @@ private async Task Execute(DetailsConfigCommandOptions options, CancellationToke
3636
_authenticationManager.AuthenticateClient(_flowSynxClient);
3737

3838
if (!string.IsNullOrEmpty(options.Address))
39-
_flowSynxClient.ChangeConnection(options.Address);
39+
{
40+
var connection = new FlowSynxClientConnection(options.Address);
41+
_flowSynxClient.SetConnection(connection);
42+
}
4043

4144
var request = new PluginConfigDetailsRequest { Id = Guid.Parse(options.Id) };
42-
var result = await _flowSynxClient.PluginConfigDetails(request, cancellationToken);
45+
var result = await _flowSynxClient.PluginConfig.DetailsAsync(request, cancellationToken);
4346

4447
if (result.StatusCode != 200)
4548
throw new Exception(Resources.Commands_Error_DuringProcessingRequest);

src/FlowCtl/Commands/Health/HealthCommandOptionsHandler.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,12 @@ private async Task Execute(HealthCommandOptions options, CancellationToken cance
2626
try
2727
{
2828
if (!string.IsNullOrEmpty(options.Address))
29-
_flowSynxClient.ChangeConnection(options.Address);
29+
{
30+
var connection = new FlowSynxClientConnection(options.Address);
31+
_flowSynxClient.SetConnection(connection);
32+
}
3033

31-
var result = await _flowSynxClient.Health(cancellationToken);
34+
var result = await _flowSynxClient.HealthCheck.Check(cancellationToken);
3235

3336
if (result.StatusCode != 200)
3437
throw new Exception(Resources.Commands_Error_DuringProcessingRequest);

0 commit comments

Comments
 (0)