public async Task PutLifecycleConfigurationWithLogicalAndTest(S3Provider provider, string _, ISimpleClient client) { await CreateTempBucketAsync(provider, client, async tempBucket => { S3AndCondition conditions = new S3AndCondition(); conditions.Prefix = "temp/"; conditions.Tags.Add(new KeyValuePair <string, string>("Type1", "Temp1")); conditions.Tags.Add(new KeyValuePair <string, string>("Type2", "Temp2")); S3Filter filter = new S3Filter(); filter.AndConditions = conditions; S3Rule rule = new S3Rule("Test logical and", true); rule.Filter = filter; rule.Expiration = new S3Expiration(DateTimeOffset.UtcNow.AddDays(1)); PutBucketLifecycleConfigurationResponse putResp = await client.PutBucketLifecycleConfigurationAsync(tempBucket, new[] { rule }).ConfigureAwait(false); Assert.True(putResp.IsSuccess); GetBucketLifecycleConfigurationResponse getResp = await client.GetBucketLifecycleConfigurationAsync(tempBucket).ConfigureAwait(false); Assert.True(getResp.IsSuccess); S3Rule?rule1 = Assert.Single(getResp.Rules); S3AndCondition?conditions1 = rule1.Filter?.AndConditions; Assert.NotNull(conditions1); Assert.Equal(conditions.Prefix, conditions1 !.Prefix); Assert.Equal(conditions.Tags, conditions1.Tags); }).ConfigureAwait(false); }
private static S3Filter ReadFilter(XmlReader xmlReader) { string?prefix = null; KeyValuePair <string, string>?tag = null; S3AndCondition?andCondition = null; foreach (string name in XmlHelper.ReadElements(xmlReader, "Filter")) { switch (name) { case "Prefix": prefix = xmlReader.ReadString(); break; case "Tag": tag = ReadTag(xmlReader); break; case "And": andCondition = ReadAndCondition(xmlReader); break; } } //It is allowed to have an empty filter. It means the whole bucket is affected. S3Filter filter = new S3Filter(); filter.Prefix = prefix; filter.Tag = tag; filter.AndConditions = andCondition; return(filter); }