Skip to content

Commit 5094310

Browse files
authored
MinioAdminClient: add missing fields to listServiceAccount API (#1624)
1 parent d1cb65b commit 5094310

File tree

2 files changed

+60
-3
lines changed

2 files changed

+60
-3
lines changed

adminapi/src/main/java/io/minio/admin/ListServiceAccountResp.java

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@
1717

1818
package io.minio.admin;
1919

20+
import com.fasterxml.jackson.annotation.JsonCreator;
2021
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
2122
import com.fasterxml.jackson.annotation.JsonProperty;
23+
import com.fasterxml.jackson.annotation.JsonValue;
2224
import java.util.List;
2325

2426
/** list service account response. */
@@ -38,12 +40,60 @@ public static class ListServiceAccountInfo {
3840
@JsonProperty("expiration")
3941
private String expiration;
4042

43+
@JsonProperty("parentUser")
44+
private String parentUser;
45+
46+
@JsonProperty("accountStatus")
47+
private AccountStatus accountStatus;
48+
49+
@JsonProperty("impliedPolicy")
50+
private boolean impliedPolicy;
51+
4152
public String expiration() {
4253
return expiration;
4354
}
4455

4556
public String accessKey() {
4657
return accessKey;
4758
}
59+
60+
public String parentUser() {
61+
return parentUser;
62+
}
63+
64+
public AccountStatus accountStatus() {
65+
return accountStatus;
66+
}
67+
68+
public boolean impliedPolicy() {
69+
return impliedPolicy;
70+
}
71+
72+
public enum AccountStatus {
73+
ON("on"),
74+
OFF("off");
75+
76+
private final String value;
77+
78+
AccountStatus(String value) {
79+
this.value = value;
80+
}
81+
82+
@JsonValue
83+
public String value() {
84+
return value;
85+
}
86+
87+
@JsonCreator
88+
public static AccountStatus fromValue(String value) {
89+
for (AccountStatus v : AccountStatus.values()) {
90+
if (v.value.equals(value)) {
91+
return v;
92+
}
93+
}
94+
95+
throw new IllegalArgumentException("unknown account status '" + value + "'");
96+
}
97+
}
4898
}
4999
}

adminapi/src/main/java/io/minio/admin/MinioAdminClient.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@
1717

1818
package io.minio.admin;
1919

20+
import com.fasterxml.jackson.databind.DeserializationFeature;
2021
import com.fasterxml.jackson.databind.JsonNode;
2122
import com.fasterxml.jackson.databind.ObjectMapper;
23+
import com.fasterxml.jackson.databind.json.JsonMapper;
2224
import com.fasterxml.jackson.databind.type.CollectionType;
2325
import com.fasterxml.jackson.databind.type.MapType;
2426
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
@@ -101,7 +103,10 @@ public String toString() {
101103

102104
private static final long DEFAULT_CONNECTION_TIMEOUT = TimeUnit.MINUTES.toMillis(1);
103105
private static final MediaType DEFAULT_MEDIA_TYPE = MediaType.parse("application/octet-stream");
104-
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
106+
private static final ObjectMapper OBJECT_MAPPER =
107+
JsonMapper.builder()
108+
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
109+
.build();
105110

106111
private static final Pattern SERVICE_ACCOUNT_NAME_REGEX =
107112
Pattern.compile("^(?!-)(?!_)[a-z_\\d-]{1,31}(?<!-)(?<!_)$", Pattern.CASE_INSENSITIVE);
@@ -657,7 +662,8 @@ public Credentials addServiceAccount(
657662
}
658663
if (name != null && !SERVICE_ACCOUNT_NAME_REGEX.matcher(name).find()) {
659664
throw new IllegalArgumentException(
660-
"name must contain non-empty alphanumeric, underscore and hyphen characters not longer than 32 characters");
665+
"name must contain non-empty alphanumeric, underscore and hyphen characters not longer"
666+
+ " than 32 characters");
661667
}
662668
if (description != null && description.length() > 256) {
663669
throw new IllegalArgumentException("description must be at most 256 characters long");
@@ -724,7 +730,8 @@ public void updateServiceAccount(
724730
}
725731
if (newName != null && !SERVICE_ACCOUNT_NAME_REGEX.matcher(newName).find()) {
726732
throw new IllegalArgumentException(
727-
"new name must contain non-empty alphanumeric, underscore and hyphen characters not longer than 32 characters");
733+
"new name must contain non-empty alphanumeric, underscore and hyphen characters not"
734+
+ " longer than 32 characters");
728735
}
729736
if (newDescription != null && newDescription.length() > 256) {
730737
throw new IllegalArgumentException("new description must be at most 256 characters long");

0 commit comments

Comments
 (0)