Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update missing XML fields in AndOperator, Expiration and RuleFilter #1613

Merged
merged 5 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions api/src/main/java/io/minio/messages/AndOperator.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ public class AndOperator {
@Convert(PrefixConverter.class)
private String prefix;

@Element(name = "ObjectSizeLessThan", required = false)
private Integer objectSizeLessThan;

@Element(name = "ObjectSizeGreaterThan", required = false)
private Integer objectSizeGreaterThan;

@ElementMap(
attribute = false,
entry = "Tag",
Expand Down Expand Up @@ -67,10 +73,50 @@ public AndOperator(
this.tags = (tags != null) ? Collections.unmodifiableMap(tags) : null;
}

public AndOperator(
dormanze marked this conversation as resolved.
Show resolved Hide resolved
@Nullable @Element(name = "Prefix", required = false) String prefix,
@Nullable @Element(name = "ObjectSizeLessThan", required = false) Integer objectSizeLessThan,
dormanze marked this conversation as resolved.
Show resolved Hide resolved
@Nullable @Element(name = "ObjectSizeGreaterThan", required = false)
Integer objectSizeGreaterThan,
@Nullable
@ElementMap(
attribute = false,
entry = "Tag",
inline = true,
key = "Key",
value = "Value",
required = false)
Map<String, String> tags) {
if (prefix == null && tags == null) {
dormanze marked this conversation as resolved.
Show resolved Hide resolved
throw new IllegalArgumentException("At least Prefix or Tags must be set");
}

if (tags != null) {
for (String key : tags.keySet()) {
if (key.isEmpty()) {
throw new IllegalArgumentException("Tags must not contain empty key");
}
}
}

this.prefix = prefix;
this.objectSizeLessThan = objectSizeLessThan;
this.objectSizeGreaterThan = objectSizeGreaterThan;
this.tags = (tags != null) ? Collections.unmodifiableMap(tags) : null;
}

public String prefix() {
return this.prefix;
}

public Integer objectSizeLessThan() {
return this.objectSizeLessThan;
}

public Integer objectSizeGreaterThan() {
return this.objectSizeGreaterThan;
}

public Map<String, String> tags() {
return this.tags;
}
Expand Down
27 changes: 25 additions & 2 deletions api/src/main/java/io/minio/messages/Expiration.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,16 @@ public class Expiration extends DateDays {
@Element(name = "ExpiredObjectDeleteMarker", required = false)
private Boolean expiredObjectDeleteMarker;

@Element(name = "ExpiredObjectAllVersions", required = false)
private Boolean expiredObjectAllVersions;

public Expiration(
@Nullable @Element(name = "Date", required = false) ResponseDate date,
@Nullable @Element(name = "Days", required = false) Integer days,
@Nullable @Element(name = "ExpiredObjectDeleteMarker", required = false)
Boolean expiredObjectDeleteMarker) {
Boolean expiredObjectDeleteMarker,
@Nullable @Element(name = "ExpiredObjectAllVersions", required = false)
dormanze marked this conversation as resolved.
Show resolved Hide resolved
Boolean expiredObjectAllVersions) {
if (expiredObjectDeleteMarker != null) {
if (date != null || days != null) {
throw new IllegalArgumentException(
Expand All @@ -45,13 +50,31 @@ public Expiration(
}

this.expiredObjectDeleteMarker = expiredObjectDeleteMarker;
this.expiredObjectAllVersions = expiredObjectAllVersions;
}

public Expiration(ZonedDateTime date, Integer days, Boolean expiredObjectDeleteMarker) {
this(date == null ? null : new ResponseDate(date), days, expiredObjectDeleteMarker);
this(date == null ? null : new ResponseDate(date), days, expiredObjectDeleteMarker, null);
}

public Expiration(
dormanze marked this conversation as resolved.
Show resolved Hide resolved
ZonedDateTime date,
Integer days,
Boolean expiredObjectDeleteMarker,
Boolean expiredObjectAllVersions) {
this(
date == null ? null : new ResponseDate(date),
days,
expiredObjectDeleteMarker,
expiredObjectAllVersions);
}

public Boolean expiredObjectDeleteMarker() {
return expiredObjectDeleteMarker;
}

/** Allow setting ILM rule for removing all versions of expired objects from command line. */
public Boolean expiredObjectAllVersions() {
dormanze marked this conversation as resolved.
Show resolved Hide resolved
return expiredObjectAllVersions;
}
}
32 changes: 32 additions & 0 deletions api/src/main/java/io/minio/messages/RuleFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ public class RuleFilter {
@Element(name = "Tag", required = false)
private Tag tag;

@Element(name = "ObjectSizeLessThan", required = false)
private Integer objectSizeLessThan;

@Element(name = "ObjectSizeGreaterThan", required = false)
private Integer objectSizeGreaterThan;

public RuleFilter(
@Nullable @Element(name = "And", required = false) AndOperator andOperator,
@Nullable @Element(name = "Prefix", required = false) String prefix,
Expand All @@ -51,6 +57,24 @@ public RuleFilter(
}
}

public RuleFilter(
@Nullable @Element(name = "And", required = false) AndOperator andOperator,
@Nullable @Element(name = "Prefix", required = false) String prefix,
@Nullable @Element(name = "ObjectSizeLessThan", required = false) Integer objectSizeLessThan,
dormanze marked this conversation as resolved.
Show resolved Hide resolved
@Nullable @Element(name = "ObjectSizeGreaterThan", required = false)
Integer objectSizeGreaterThan,
@Nullable @Element(name = "Tag", required = false) Tag tag) {
if (andOperator != null ^ prefix != null ^ tag != null) {
dormanze marked this conversation as resolved.
Show resolved Hide resolved
this.andOperator = andOperator;
this.prefix = prefix;
this.tag = tag;
this.objectSizeLessThan = objectSizeLessThan;
this.objectSizeGreaterThan = objectSizeGreaterThan;
} else {
throw new IllegalArgumentException("Only one of And, Prefix or Tag must be set");
}
}

public RuleFilter(@Nonnull AndOperator andOperator) {
this.andOperator = Objects.requireNonNull(andOperator, "And operator must not be null");
}
Expand All @@ -74,4 +98,12 @@ public String prefix() {
public Tag tag() {
return this.tag;
}

public Integer objectSizeLessThan() {
return this.objectSizeLessThan;
}

public Integer objectSizeGreaterThan() {
return this.objectSizeGreaterThan;
}
}