Added keys to S3Cmd.cs

This commit is contained in:
Kim 2023-09-08 11:52:49 +02:00
parent 3484d4bca3
commit 47c8d438d1
4 changed files with 40 additions and 3 deletions

View File

@ -14,8 +14,8 @@ public class S3Cmd
private const String? S3CmdPath = "Resources/s3cmd.py"; private const String? S3CmdPath = "Resources/s3cmd.py";
private const String S3Prefix = "s3://"; private const String S3Prefix = "s3://";
public String Key { get; init;} public String Key { get; init; } = S3Access.ReadWrite.Key;
public String Secret { get; init;} public String Secret { get; init; } = S3Access.ReadWrite.Secret;
public String Region { get; init; } = "sos-ch-dk-2.exo.io"; public String Region { get; init; } = "sos-ch-dk-2.exo.io";
// private String?[] DefaultArgs { get; } // private String?[] DefaultArgs { get; }

View File

@ -0,0 +1,30 @@
using System.Text.Json;
using System.Text.Json.Nodes;
namespace InnovEnergy.Lib.Victron.VictronVRM;
public readonly partial record struct Installation
{
public async Task<IReadOnlyList<String>> GetAlarms()
{
var reply = await VrmAccount.AlarmsRequest(IdSite).TryGetJson();
var vrmReply = new Reply(reply);
if (!vrmReply.Success)
throw new Exception(nameof(GetAlarms) + " failed");
return vrmReply.Alarms;
}
public async Task<Boolean> SetAlarms(JsonObject tags)
{
var reply = await VrmAccount.AlarmsRequest(IdSite).TryPostJson(tags);
var vrmReply = new Reply(reply);
if (!vrmReply.Success)
throw new Exception(nameof(SetAlarms) + " failed");
return vrmReply.Success;
}
}

View File

@ -9,6 +9,7 @@ public readonly record struct Reply(JsonNode Json)
public Boolean Success => Json.TryGetBoolean("success") is not null or true; public Boolean Success => Json.TryGetBoolean("success") is not null or true;
public IReadOnlyList<String> Tags => Json.GetArray<String>("tags"); public IReadOnlyList<String> Tags => Json.GetArray<String>("tags");
public IReadOnlyList<String> Alarms => Json.GetArray<String>("alarms");
public JsonArray Records => Json.GetArray("records"); public JsonArray Records => Json.GetArray("records");
public IReadOnlyList<Device> Devices => Json["records"]! public IReadOnlyList<Device> Devices => Json["records"]!

View File

@ -23,6 +23,12 @@ public static class Requests
.SetQueryParams(new { count = nDetails }); .SetQueryParams(new { count = nDetails });
} }
public static IFlurlRequest AlarmsRequest(this VrmAccount account, UInt64 installationId)
{
return InstallationRequest(account, installationId)
.AppendPathSegment("alarms");
}
public static IFlurlRequest InstallationRequest(this VrmAccount account, UInt64 installationId) public static IFlurlRequest InstallationRequest(this VrmAccount account, UInt64 installationId)
{ {
return ApiRoot return ApiRoot