Пример #1
0
        public static AwsClient InitAwsClient(RegionEndpoint region = null, string accessKey = null, string secretKey = null)
        {
            AwsClient client = null;

            bool hasAccessKey = (!String.IsNullOrWhiteSpace(accessKey));
            bool hasSecretKey = (!String.IsNullOrWhiteSpace(secretKey));
            bool hasRegion    = (region != null);

            if (hasAccessKey && hasSecretKey)
            {
                if (hasRegion)
                {
                    client = new AwsClient(accessKey, secretKey, region);
                }
                else
                {
                    client = new AwsClient(accessKey, secretKey);
                }
            }
            else if (hasRegion)
            {
                client = new AwsClient(region);
            }
            else
            {
                client = new AwsClient();     // Pull All Details From Environemnt Variables / Credentails Files
            }
            return(client);
        }
Пример #2
0
    internal void ConfigureDefaults()
    {
        _awsClient = new zf.AwsClient(Amazon.RegionEndpoint.USEast1);

        _bucketName = "s3://need_a_valid_bucket";
        _planPath   = $"{_bucketName}/Plans/";
        _histPath   = $"{_bucketName}/History/";
        _splxPath   = $"{_bucketName}/Security/";

        EnsurePaths();

        ProcessPlansOnSingleton   = false;
        ProcessActionsOnSingleton = true;

        LoadSuplex();
    }
Пример #3
0
    internal AwsS3Dal(string basePath, string accessKey, string secretAccessKey,
                      bool processPlansOnSingleton = false, bool processActionsOnSingleton = true) : this()
    {
        if (string.IsNullOrWhiteSpace(basePath))
        {
            basePath = CurrentPath;
        }

        _region    = Amazon.RegionEndpoint.USEast1.ToString();
        _awsClient = new zf.AwsClient(accessKey, secretAccessKey, Amazon.RegionEndpoint.USEast1);

        _bucketName = basePath;
        _planPath   = $"{basePath}/Plans/";
        _histPath   = $"{basePath}/History/";
        _splxPath   = $"{basePath}/Security/";

        EnsurePaths();

        ProcessPlansOnSingleton   = processPlansOnSingleton;
        ProcessActionsOnSingleton = processActionsOnSingleton;

        LoadSuplex();
    }
Пример #4
0
    public Dictionary <string, string> Configure(ISynapseDalConfig conifg)
    {
        if (conifg != null)
        {
            string         s    = YamlHelpers.Serialize(conifg.Config);
            AwsS3DalConfig fsds = YamlHelpers.Deserialize <AwsS3DalConfig>(s);

            _region = Amazon.RegionEndpoint.USEast1.ToString();

            if (string.IsNullOrWhiteSpace(fsds.AwsAccessKey) || string.IsNullOrWhiteSpace(fsds.AwsSecretAccessKey))
            {
                _awsClient = new zf.AwsClient(Amazon.RegionEndpoint.USEast1);
                _s3Client  = new Amazon.S3.AmazonS3Client(Amazon.RegionEndpoint.USEast1);
            }
            else
            {
                _awsClient = new zf.AwsClient(fsds.AwsAccessKey, fsds.AwsSecretAccessKey, Amazon.RegionEndpoint.USEast1);
                _s3Client  = new Amazon.S3.AmazonS3Client(fsds.AwsAccessKey, fsds.AwsSecretAccessKey, Amazon.RegionEndpoint.USEast1);
            }

            _bucketName = fsds.DefaultBucketName;

            _planPath            = fsds.PlanFolderPath;
            _histPath            = fsds.HistoryFolderPath;
            _histAsJson          = fsds.WriteHistoryAs == HistorySerializationFormat.FormattedJson || fsds.WriteHistoryAs == HistorySerializationFormat.CompressedJson;
            _histAsFormattedJson = fsds.WriteHistoryAs == HistorySerializationFormat.FormattedJson;
            _histExt             = _histAsJson ? ".json" : ".yaml";
            _splxPath            = fsds.Security.FilePath;

            EnsurePaths();

            ProcessPlansOnSingleton   = fsds.ProcessPlansOnSingleton;
            ProcessActionsOnSingleton = fsds.ProcessActionsOnSingleton;

            LoadSuplex();

            if (_splxDal == null && fsds.Security.IsRequired)
            {
                throw new Exception($"Security is required.  Could not load security file: {_splxPath}.");
            }

            if (_splxDal != null)
            {
                _splxDal.LdapRoot = conifg.LdapRoot;
                _splxDal.GlobalExternalGroupsCsv = fsds.Security.GlobalExternalGroupsCsv;
            }
        }
        else
        {
            ConfigureDefaults();
        }

        string name = nameof(AwsS3Dal);
        Dictionary <string, string> props = new Dictionary <string, string>
        {
            { name, CurrentPath },
            { $"{name} AWS Region", _region },
            { $"{name} S3 Default Bucket", _bucketName },
            { $"{name} Plan path", _planPath },
            { $"{name} History path", _histPath },
            { $"{name} Security path", _splxPath }
        };

        return(props);
    }
Пример #5
0
 /// <summary>
 /// Creates an AmazonS3ZephyrDirectory representing the url passed in.
 /// </summary>
 /// <param name="client">The client class used to connect to Amazon.</param>
 /// <param name="fullName">The Fullname or URL for the Amazon S3 directory.</param>
 public AwsS3ZephyrDirectory(AwsClient client, string fullName)
 {
     _client  = client;
     FullName = fullName;
 }
Пример #6
0
 /// <summary>
 /// Creates an empty AmazonS3ZephyrDirectory
 /// </summary>
 /// <param name="client">The client class used to connect to Amazon.</param>
 public AwsS3ZephyrDirectory(AwsClient client)
 {
     _client = client;
 }
Пример #7
0
 /// <summary>
 /// Creates an AmazonS3ZephyrDirectory representing the bucketName and objectKey passed in.
 /// </summary>
 /// <param name="client">The client class used to connect to Amazon.</param>
 /// <param name="bucketName">The Amazon S3 bucket name.</param>
 /// <param name="key">The Amazon S3 object key.</param>
 public AwsS3ZephyrDirectory(AwsClient client, string bucketName, string key)
 {
     _client  = client;
     FullName = $"s3://{bucketName}/{key}";
 }
 /// <summary>
 /// Creates an AmazonS3ZephyrFile representing the url passed in.
 /// </summary>
 /// <param name="client">The client class used to connect to Amazon.</param>
 /// <param name="fullName">The Fullname or URL for the Amazon S3 file.</param>
 public AwsS3ZephyrFile(AwsClient client, string fullName)
 {
     _client  = client;
     FullName = fullName;
 }
 /// <summary>
 /// Creates an empty AmazonS3ZephyrFile
 /// </summary>
 /// <param name="client">The client class used to connect to Amazon.</param>
 public AwsS3ZephyrFile(AwsClient client)
 {
     _client = client;
 }
Пример #10
0
 /// <summary>
 /// Wrapper method around the AwsClient constructor.
 /// </summary>
 /// <param name="profileName">The name of the AWS profile to get credentials from.</param>
 /// <param name="endpoint">The region to connect.</param>
 /// <returns></returns>
 public AwsClient AwsInitialize(string profileName, RegionEndpoint endpoint = null)
 {
     aws = new AwsClient(profileName, endpoint);
     return(aws);
 }
Пример #11
0
 /// <summary>
 /// Wrapper method around the AwsClient constructor.
 /// </summary>
 /// <param name="accessKey">The AWS Access Key Id</param>
 /// <param name="secretAccessKey">The AWS Secret Access Key</param>
 /// <param name="sessionToken">The AWS Session Token.</param>
 /// <param name="endpoint">The region to connect.</param>
 /// <returns></returns>
 public AwsClient AwsInitialize(string accessKey, string secretAccessKey, string sessionToken, RegionEndpoint endpoint = null)
 {
     aws = new AwsClient(accessKey, secretAccessKey, sessionToken, endpoint);
     return(aws);
 }
Пример #12
0
 /// <summary>
 /// Wrapper method around the AwsClient constructor.
 /// </summary>
 /// <param name="creds">The AWS Credentials to use.</param>
 /// <param name="endpoint">The region to connect.</param>
 /// <returns></returns>
 public AwsClient AwsInitialize(AWSCredentials creds, RegionEndpoint endpoint = null)
 {
     aws = new AwsClient(creds, endpoint);
     return(aws);
 }
Пример #13
0
 /// <summary>
 /// Wrapper method around the AwsClient constructor.
 /// </summary>
 /// <param name="endpoint">The region to connect.</param>
 /// <returns></returns>
 public AwsClient AwsInitialize(RegionEndpoint endpoint = null)
 {
     aws = new AwsClient(endpoint);
     return(aws);
 }