Skip to content

Commit

Permalink
Added Health API
Browse files Browse the repository at this point in the history
  • Loading branch information
michielpost committed Apr 9, 2024
1 parent 02e0ce1 commit 4ab3617
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 8 deletions.
8 changes: 4 additions & 4 deletions Hathor.Tests/Hathor.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="dotnetstandard-bip39" Version="1.0.2" />
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PackageReference Include="MSTest.TestAdapter" Version="3.3.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.3.1" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
8 changes: 4 additions & 4 deletions Hathor.Wallet.Tests/Hathor.Wallet.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="dotnetstandard-bip39" Version="1.0.2" />
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PackageReference Include="MSTest.TestAdapter" Version="3.3.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.3.1" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
3 changes: 3 additions & 0 deletions Hathor/IHathorWalletApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ public interface IHathorWalletApi
[Post("start")]
Task<DefaultResponse> Start([Body]StartRequest startRequest);

[Get("health")]
Task<HealthResponse> GetHealth([Query]string? wallet_ids = null, [Query] bool? include_fullnode = null, [Query] bool? include_tx_mining = null);

[Post("wallet/stop")]
Task<DefaultResponse> Stop();

Expand Down
47 changes: 47 additions & 0 deletions Hathor/Models/Responses/HealthResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;

namespace Hathor.Models.Responses
{
public class HealthResponse
{
[JsonPropertyName("status")]
public string? Status { get; set; }

[JsonPropertyName("description")]
public string? Description { get; set; }

[JsonPropertyName("checks")]
public Checks? Checks { get; set; }
}

public class Checks
{
[JsonPropertyName("fullnode")]
public List<FullnodeStatus> Fullnode { get; set; } = new();

[JsonPropertyName("txMining")]
public List<FullnodeStatus> TxMining { get; set; } = new();
}

public class FullnodeStatus
{
[JsonPropertyName("status")]
public string? Status { get; set; }

[JsonPropertyName("componentType")]
public string? ComponentType { get; set; }

[JsonPropertyName("componentName")]
public string? ComponentName { get; set; }

[JsonPropertyName("output")]
public string? Output { get; set; }
}


}
3 changes: 3 additions & 0 deletions Hathor/Models/Responses/StatusResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public class StatusResponse : DefaultResponse
[JsonProperty(PropertyName = "serverUrl")]
public string? ServerUrl { get; set; }

[JsonProperty(PropertyName = "statusMessage")]
public string? StatusMessage { get; set; }

Check warning on line 26 in Hathor/Models/Responses/StatusResponse.cs

View workflow job for this annotation

GitHub Actions / build, pack & publish

'StatusResponse.StatusMessage' hides inherited member 'DefaultResponse.StatusMessage'. Use the new keyword if hiding was intended.

Check warning on line 26 in Hathor/Models/Responses/StatusResponse.cs

View workflow job for this annotation

GitHub Actions / build, pack & publish

'StatusResponse.StatusMessage' hides inherited member 'DefaultResponse.StatusMessage'. Use the new keyword if hiding was intended.

Check warning on line 26 in Hathor/Models/Responses/StatusResponse.cs

View workflow job for this annotation

GitHub Actions / build, pack & publish

'StatusResponse.StatusMessage' hides inherited member 'DefaultResponse.StatusMessage'. Use the new keyword if hiding was intended.

Check warning on line 26 in Hathor/Models/Responses/StatusResponse.cs

View workflow job for this annotation

GitHub Actions / build, pack & publish

'StatusResponse.StatusMessage' hides inherited member 'DefaultResponse.StatusMessage'. Use the new keyword if hiding was intended.

Check warning on line 26 in Hathor/Models/Responses/StatusResponse.cs

View workflow job for this annotation

GitHub Actions / build

'StatusResponse.StatusMessage' hides inherited member 'DefaultResponse.StatusMessage'. Use the new keyword if hiding was intended.

Check warning on line 26 in Hathor/Models/Responses/StatusResponse.cs

View workflow job for this annotation

GitHub Actions / build

'StatusResponse.StatusMessage' hides inherited member 'DefaultResponse.StatusMessage'. Use the new keyword if hiding was intended.

Check warning on line 26 in Hathor/Models/Responses/StatusResponse.cs

View workflow job for this annotation

GitHub Actions / build

'StatusResponse.StatusMessage' hides inherited member 'DefaultResponse.StatusMessage'. Use the new keyword if hiding was intended.

Check warning on line 26 in Hathor/Models/Responses/StatusResponse.cs

View workflow job for this annotation

GitHub Actions / build

'StatusResponse.StatusMessage' hides inherited member 'DefaultResponse.StatusMessage'. Use the new keyword if hiding was intended.

[JsonProperty(PropertyName = "state")]
public int? State { get; set; }
}
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,6 @@ var balanceInfo = await nodeClient.GetBalanceForAddress("ANY HATHOR ADDRESS")
## Acknowledgements
Development has been made possible with a grant from [Hathor](https://hathor.network).
## Hathor API Reference
https://docs.hathor.network/references/headless-wallet/http-api/

0 comments on commit 4ab3617

Please sign in to comment.