// using System.Diagnostics.CodeAnalysis; // using CliWrap; // using CliWrap.Buffered; // using InnovEnergy.Lib.Utils; // // #pragma warning disable CS8618 // // namespace InnovEnergy.App.Backend.S3; // // [SuppressMessage("ReSharper", "UnusedAutoPropertyAccessor.Global")] // public class S3Cmd // { // private static readonly Command Python = Cli.Wrap("python3"); // // private const String S3CmdPath = "Resources/s3cmd.py"; // private const String S3Prefix = "s3://"; // // public String Key { get; init; } // public String Secret { get; init; } // public String Region { get; init; } = "sos-ch-dk-2.exo.io"; // // [Obsolete("Only to be used by Json-Deserializer")] public S3Cmd() // {} // // public async Task CreateBucket(String bucketName) // { // const String cors = "./Resources/CORS"; // // var makeBucket = await Run(bucketName, "mb"); // // if (makeBucket.ExitCode != 0) // return false; // // var setCors = await Run(bucketName, "setcors", cors); // // return setCors.ExitCode == 0; // } // // public async Task ListFilesInBucket(String bucketName) // { // var result = await Run(bucketName, "ls"); // return result.StandardOutput; // } // // public async Task?> GetFileLines(String bucketName, String filename) // { // try // { // await Run(bucketName + "/" + filename, "get", "--force"); // } // catch // { // return null; // } // // var lines = File.ReadAllLines($"./{filename}"); // File.Delete(filename); // return lines; // } // // public async Task DeleteBucket(String bucketName) // { // var result = await Run(bucketName, "rb"); // return result.ExitCode == 0; // } // // private Task Run(String s3Path, String operation, params String[] optionalArgs) // { // var credentials = new[] // { // S3CmdPath, // "--access_key", Key, // "--secret_key", Secret, // "--host" , Region // }; // // var args = credentials // .Append(operation) // .Concat(optionalArgs) // .Append(s3Path.EnsureStartsWith(S3Prefix)); // // var withArguments = Python // .WithArguments(args); // // return withArguments // .WithValidation(CommandResultValidation.None) // .ExecuteBufferedAsync(); // } // // }