// Set Replication configuration for the bucket
        public async static Task Run(MinioClient minio,
                                     string bucketName = "my-bucket-name")
        {
            try
            {
                Console.WriteLine("Running example for API: SetBucketReplication");
                Dictionary <string, string> tags = new Dictionary <string, string>()
                {
                    { "key1", "value1" },
                    { "key2", "value2" },
                    { "key3", "value3" }
                };
                ReplicationRule rule =
                    new ReplicationRule(
                        new DeleteMarkerReplication(DeleteMarkerReplication.StatusEnabled),
                        new ReplicationDestination(
                            null, null, "Bucket-ARN", null, null, null, null),
                        null,
                        new RuleFilter(new AndOperator("PREFIX", Tagging.GetBucketTags(tags)), null, null),
                        new DeleteReplication(DeleteReplication.StatusDisabled),
                        1,
                        "REPLICATION-ID",
                        "PREFIX",
                        null,
                        ReplicationRule.StatusEnabled
                        );
                List <ReplicationRule> rules = new List <ReplicationRule>();
                rules.Add(rule);
                ReplicationConfiguration repl = new ReplicationConfiguration("REPLICATION-ROLE", rules);

                await minio.SetBucketReplicationAsync(
                    new SetBucketReplicationArgs()
                    .WithBucket(bucketName)
                    .WithConfiguration(repl)
                    );

                Console.WriteLine($"Bucket Replication set for bucket {bucketName}.");
                Console.WriteLine();
            }
            catch (Exception e)
            {
                Console.WriteLine($"[Bucket]  Exception: {e}");
            }
        }
        // Set Replication configuration for the bucket
        public async static Task Run(MinioClient minio,
                                     string bucketName       = "my-bucket-name",
                                     string destBucketName   = "dest-bucket-name",
                                     string replicationCfgID = "my-replication-ID")
        {
            var setArgs = new SetVersioningArgs()
                          .WithBucket(bucketName)
                          .WithVersioningEnabled();
            await minio.SetVersioningAsync(setArgs);

            setArgs = new SetVersioningArgs()
                      .WithBucket(destBucketName)
                      .WithVersioningEnabled();
            await minio.SetVersioningAsync(setArgs);

            string serverEndPoint = "";
            string schema         = "http://";
            string accessKey      = "";
            string secretKey      = "";

            if (Environment.GetEnvironmentVariable("SERVER_ENDPOINT") != null)
            {
                serverEndPoint = Environment.GetEnvironmentVariable("SERVER_ENDPOINT");
                accessKey      = Environment.GetEnvironmentVariable("ACCESS_KEY");
                secretKey      = Environment.GetEnvironmentVariable("SECRET_KEY");
                if (Environment.GetEnvironmentVariable("ENABLE_HTTPS") != null)
                {
                    if (Environment.GetEnvironmentVariable("ENABLE_HTTPS").Equals("1"))
                    {
                        schema = "https://";
                    }
                }
            }
            else
            {
                serverEndPoint = "play.min.io";
                accessKey      = "Q3AM3UQ867SPQQA43P2F";
                secretKey      = "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG";
                schema         = "http://";
            }

            var cmdFullPathMC = Bash("which mc").TrimEnd('\r', '\n', ' ');
            var cmdAlias      = cmdFullPathMC + " alias list | egrep -B1 \"" +
                                schema + serverEndPoint + "\" | grep -v URL";
            var alias = Bash(cmdAlias).TrimEnd('\r', '\n', ' ');

            var cmdRemoteAdd = cmdFullPathMC + " admin bucket remote add " +
                               alias + "/" + bucketName + "/ " + schema +
                               accessKey + ":" + secretKey + "@" +
                               serverEndPoint + "/" + destBucketName +
                               " --service replication --region us-east-1";

            var arn = Bash(cmdRemoteAdd).Replace("Remote ARN = `", "").Replace("`.", "");

            ReplicationRule rule =
                new ReplicationRule(
                    new DeleteMarkerReplication(DeleteMarkerReplication.StatusDisabled),
                    new ReplicationDestination(null, null,
                                               "arn:aws:s3:::" + destBucketName,
                                               null, null, null, null),
                    new ExistingObjectReplication(ExistingObjectReplication.StatusEnabled),
                    new RuleFilter(null, null, null),
                    new DeleteReplication(DeleteReplication.StatusDisabled),
                    1,
                    replicationCfgID,
                    "",
                    new SourceSelectionCriteria(new SseKmsEncryptedObjects(
                                                    SseKmsEncryptedObjects.StatusEnabled)),
                    ReplicationRule.StatusEnabled
                    );
            List <ReplicationRule> rules = new List <ReplicationRule>();

            rules.Add(rule);
            ReplicationConfiguration repl = new ReplicationConfiguration(arn, rules);

            await minio.SetBucketReplicationAsync(
                new SetBucketReplicationArgs()
                .WithBucket(bucketName)
                .WithConfiguration(repl)
                );
        }