/// <summary> /// Convert custom AwsEndpoint enum to Amazon SDK RegionEndpoint /// </summary> /// <param name="value">AwsEndpoint</param> /// <returns>AWS SDK RegionEndpoint</returns> public static RegionEndpoint ToRegionEndpoint(AwsEndpoint value) { switch (value) { case AwsEndpoint.USEast1: return(RegionEndpoint.USEast1); case AwsEndpoint.USWest1: return(RegionEndpoint.USWest1); case AwsEndpoint.USWest2: return(RegionEndpoint.USWest2); case AwsEndpoint.EUWest1: return(RegionEndpoint.EUWest1); case AwsEndpoint.EUCentral1: return(RegionEndpoint.EUCentral1); case AwsEndpoint.APNortheast1: return(RegionEndpoint.APNortheast1); case AwsEndpoint.APNortheast2: return(RegionEndpoint.APNortheast2); case AwsEndpoint.APSoutheast1: return(RegionEndpoint.APSoutheast1); case AwsEndpoint.APSoutheast2: return(RegionEndpoint.APSoutheast2); case AwsEndpoint.APSouth1: return(RegionEndpoint.APSouth1); case AwsEndpoint.SAEast1: return(RegionEndpoint.SAEast1); case AwsEndpoint.USGovCloudWest1: return(RegionEndpoint.USGovCloudWest1); case AwsEndpoint.CNNorth1: return(RegionEndpoint.CNNorth1); default: throw new NotImplementedException(string.Format("Endoint {0} not supported", value)); } }
//--- Methods --- protected override Yield Start(XDoc config, ILifetimeScope container, Result result) { yield return(Coroutine.Invoke(base.Start, config, new Result())); // are we a private storage service? _private = config["sid"].Contents == "sid://mindtouch.com/2010/10/dream/s3.storage.private"; _log.DebugFormat("storage is {0}", _private ? "private" : "public"); // is the root blocked from access? _privateRoot = config["private-root"].AsBool.GetValueOrDefault(); _log.DebugFormat("storage root is {0}accessible", _privateRoot ? "not " : ""); // set up S3 client var s3Config = new AwsS3ClientConfig() { Endpoint = AwsEndpoint.GetEndpoint(config["endpoint"].AsText) ?? AwsEndpoint.Default, Bucket = config["bucket"].AsText, Delimiter = "/", RootPath = config["folder"].AsText, PrivateKey = config["privatekey"].AsText, PublicKey = config["publickey"].AsText, Timeout = TimeSpan.FromSeconds(config["timeout"].AsDouble ?? DEFAULT_S3_TIMEOUT) }; if (string.IsNullOrEmpty(s3Config.Bucket)) { throw new ArgumentException("missing configuration parameter 'bucket'"); } if (string.IsNullOrEmpty(s3Config.PrivateKey)) { throw new ArgumentException("missing configuration parameter 'privatekey'"); } if (string.IsNullOrEmpty(s3Config.PublicKey)) { throw new ArgumentException("missing configuration parameter 'publickey'"); } _s3Client = container.Resolve <IAwsS3Client>(TypedParameter.From(s3Config)); result.Return(); }
//--- Class Constructor --- static AwsTestHelpers() { AwsEndpoint.AddEndpoint(AWS); }