From 9ff40447a04cf5a07441f337455dcf7300a69d8c Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Thu, 26 Jul 2018 21:50:44 +0000 Subject: [PATCH] --- Controllers/OpsController.cs | 10 ++++++++++ Startup.cs | 2 +- rockfishCore.csproj | 2 ++ util/OpsDiagnostics.cs | 31 +++++++++++++++++++++++++++++-- 4 files changed, 42 insertions(+), 3 deletions(-) diff --git a/Controllers/OpsController.cs b/Controllers/OpsController.cs index 1d0ed04..e5da9d8 100644 --- a/Controllers/OpsController.cs +++ b/Controllers/OpsController.cs @@ -129,6 +129,16 @@ namespace rockfishCore.Controllers //devops: https://test.helloayanova.com/api/v8/ //Spaces and backup: https://gztw1.nyc3.digitaloceanspaces.com/ //Need S3 library for c# + /* + IAmazonS3 amazonS3Client = + AWSClientFactory.CreateAmazonS3Client("your-spaces-key", "your-spaces-key-secrete", + new AmazonS3Config + { + ServiceURL = "https://nyc3.digitaloceanspaces.com" + } +); +var myBuckets = amazonS3Client.ListBuckets(); + */ return Ret; diff --git a/Startup.cs b/Startup.cs index 47199ec..2657188 100644 --- a/Startup.cs +++ b/Startup.cs @@ -110,7 +110,7 @@ namespace rockfishCore //bool bMM=RfMail.MailIsMirroringProperly(); try { - var test = OpsDiagnostics.CheckWebsite("https://test.helloayanova.com/api/v8/", "AyaNova server"); + var test = OpsDiagnostics.CheckSpacesBackupStorage(); } catch (Exception ex) { diff --git a/rockfishCore.csproj b/rockfishCore.csproj index 731256a..2bf1219 100644 --- a/rockfishCore.csproj +++ b/rockfishCore.csproj @@ -8,6 +8,8 @@ + + diff --git a/util/OpsDiagnostics.cs b/util/OpsDiagnostics.cs index 84e8382..4f9f85b 100644 --- a/util/OpsDiagnostics.cs +++ b/util/OpsDiagnostics.cs @@ -5,6 +5,8 @@ using System.Linq; using System.IO; using System.Net.Http; using System.Net.Http.Headers; +using Amazon.S3; +using Amazon.S3.Transfer; namespace rockfishCore.Util { @@ -20,15 +22,40 @@ namespace rockfishCore.Util if (Response.IsSuccessStatusCode) { var PageText = Response.Content.ReadAsStringAsync().Result; - if(PageText.Contains(mustContain)) + if (PageText.Contains(mustContain)) { - Result=true; + Result = true; } } return Result; } + public static bool CheckSpacesBackupStorage() + { + + var SECRET_KEY = "iNwbHr+sK+9is2wmRjIax+rdyEjLNvWKJBYr7w4txkY"; + var ACCESS_KEY = "CMPAFDNX53OWPC55HBJ4"; + var HOST_ENDPOINT = "https://nyc3.digitaloceanspaces.com"; + var BUCKET = "%(bucket)s.nyc3.digitaloceanspaces.com"; + AmazonS3Config clientConfig=new AmazonS3Config(); + clientConfig.ServiceURL=HOST_ENDPOINT; + IAmazonS3 s3Client = new AmazonS3Client(ACCESS_KEY, SECRET_KEY, clientConfig); + var bucketlist=s3Client.ListBucketsAsync().Result; + +// IAmazonS3 amazonS3Client = new +// AWSClientFactory.CreateAmazonS3Client("your-spaces-key", "your-spaces-key-secrete", +// new AmazonS3Config +// { +// ServiceURL = "https://nyc3.digitaloceanspaces.com" +// } +// ); +// var myBuckets = amazonS3Client.ListBuckets(); + + return false; + + } +