Skip to content

Commit 47babd2

Browse files
committed
add new API and fix int variables
1 parent 2080f51 commit 47babd2

1 file changed

Lines changed: 70 additions & 22 deletions

File tree

src/main/java/org/databunker/DatabunkerproApi.java

Lines changed: 70 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public Map<String, Object> createUser(Map<String, Object> profile, UserOptions o
165165
if (groupname instanceof Number) {
166166
data.put("groupid", groupname);
167167
} else if (groupname instanceof String && ((String) groupname).matches("\\d+")) {
168-
data.put("groupid", groupname);
168+
data.put("groupid", Integer.parseInt((String) groupname));
169169
} else {
170170
data.put("groupname", groupname);
171171
}
@@ -177,7 +177,7 @@ public Map<String, Object> createUser(Map<String, Object> profile, UserOptions o
177177
if (rolename instanceof Number) {
178178
data.put("roleid", rolename);
179179
} else if (rolename instanceof String && ((String) rolename).matches("\\d+")) {
180-
data.put("roleid", rolename);
180+
data.put("roleid", Integer.parseInt((String) rolename));
181181
} else {
182182
data.put("rolename", rolename);
183183
}
@@ -406,7 +406,7 @@ public Map<String, Object> createRoleXToken(String roleref, BasicOptions options
406406
data.putAll(OptionsConverter.toMap(options));
407407
}
408408
if (roleref.matches("\\d+")) {
409-
data.put("roleid", roleref);
409+
data.put("roleid", Integer.parseInt(roleref));
410410
} else {
411411
data.put("rolename", roleref);
412412
}
@@ -839,7 +839,7 @@ public Map<String, Object> createConnector(ConnectorOptions options, Map<String,
839839
*/
840840
public Map<String, Object> updateConnector(String connectorid, ConnectorOptions options, Map<String, Object> requestMetadata) throws IOException {
841841
Map<String, Object> data = new HashMap<>();
842-
data.put("connectorid", connectorid);
842+
data.put("connectorid", Integer.parseInt(connectorid));
843843
if (options != null) {
844844
data.putAll(OptionsConverter.toMap(options));
845845
}
@@ -861,7 +861,7 @@ public Map<String, Object> validateConnectorConnectivity(String connectorref, Co
861861
data.putAll(OptionsConverter.toMap(options));
862862
}
863863
if (connectorref.matches("\\d+")) {
864-
data.put("connectorid", connectorref);
864+
data.put("connectorid", Integer.parseInt(connectorref));
865865
} else {
866866
data.put("connectorname", connectorref);
867867
}
@@ -871,7 +871,7 @@ public Map<String, Object> validateConnectorConnectivity(String connectorref, Co
871871
public Map<String, Object> deleteConnector(String connectorref, Map<String, Object> requestMetadata) throws IOException {
872872
Map<String, Object> data = new HashMap<>();
873873
if (connectorref.matches("\\d+")) {
874-
data.put("connectorid", connectorref);
874+
data.put("connectorid", Integer.parseInt(connectorref));
875875
} else {
876876
data.put("connectorname", connectorref);
877877
}
@@ -893,7 +893,7 @@ public Map<String, Object> getTableMetadata(String connectorref, ConnectorOption
893893
data.putAll(OptionsConverter.toMap(options));
894894
}
895895
if (connectorref.matches("\\d+")) {
896-
data.put("connectorid", connectorref);
896+
data.put("connectorid", Integer.parseInt(connectorref));
897897
} else {
898898
data.put("connectorname", connectorref);
899899
}
@@ -905,7 +905,7 @@ public Map<String, Object> connectorGetUserData(String mode, String identity, St
905905
data.put("mode", mode);
906906
data.put("identity", identity);
907907
if (connectorref.matches("\\d+")) {
908-
data.put("connectorid", connectorref);
908+
data.put("connectorid", Integer.parseInt(connectorref));
909909
} else {
910910
data.put("connectorname", connectorref);
911911
}
@@ -917,7 +917,7 @@ public Map<String, Object> connectorGetUserExtraData(String mode, String identit
917917
data.put("mode", mode);
918918
data.put("identity", identity);
919919
if (connectorref.matches("\\d+")) {
920-
data.put("connectorid", connectorref);
920+
data.put("connectorid", Integer.parseInt(connectorref));
921921
} else {
922922
data.put("connectorname", connectorref);
923923
}
@@ -929,7 +929,7 @@ public Map<String, Object> connectorDeleteUser(String mode, String identity, Str
929929
data.put("mode", mode);
930930
data.put("identity", identity);
931931
if (connectorref.matches("\\d+")) {
932-
data.put("connectorid", connectorref);
932+
data.put("connectorid", Integer.parseInt(connectorref));
933933
} else {
934934
data.put("connectorname", connectorref);
935935
}
@@ -956,7 +956,7 @@ public Map<String, Object> createGroup(GroupOptions options, Map<String, Object>
956956
public Map<String, Object> getGroup(String groupref, Map<String, Object> requestMetadata) throws IOException {
957957
Map<String, Object> data = new HashMap<>();
958958
if (groupref.matches("\\d+")) {
959-
data.put("groupid", groupref);
959+
data.put("groupid", Integer.parseInt(groupref));
960960
} else {
961961
data.put("groupname", groupref);
962962
}
@@ -985,7 +985,7 @@ public Map<String, Object> listUserGroups(String mode, String identity, Map<Stri
985985
*/
986986
public Map<String, Object> updateGroup(String groupid, GroupOptions options, Map<String, Object> requestMetadata) throws IOException {
987987
Map<String, Object> data = new HashMap<>();
988-
data.put("groupid", groupid);
988+
data.put("groupid", Integer.parseInt(groupid));
989989
if (options != null) {
990990
data.putAll(OptionsConverter.toMap(options));
991991
}
@@ -995,7 +995,7 @@ public Map<String, Object> updateGroup(String groupid, GroupOptions options, Map
995995
public Map<String, Object> deleteGroup(String groupref, Map<String, Object> requestMetadata) throws IOException {
996996
Map<String, Object> data = new HashMap<>();
997997
if (groupref.matches("\\d+")) {
998-
data.put("groupid", groupref);
998+
data.put("groupid", Integer.parseInt(groupref));
999999
} else {
10001000
data.put("groupname", groupref);
10011001
}
@@ -1007,7 +1007,7 @@ public Map<String, Object> removeUserFromGroup(String mode, String identity, Str
10071007
data.put("mode", mode);
10081008
data.put("identity", identity);
10091009
if (groupref.matches("\\d+")) {
1010-
data.put("groupid", groupref);
1010+
data.put("groupid", Integer.parseInt(groupref));
10111011
} else {
10121012
data.put("groupname", groupref);
10131013
}
@@ -1019,13 +1019,13 @@ public Map<String, Object> addUserToGroup(String mode, String identity, String g
10191019
data.put("mode", mode);
10201020
data.put("identity", identity);
10211021
if (groupref.matches("\\d+")) {
1022-
data.put("groupid", groupref);
1022+
data.put("groupid", Integer.parseInt(groupref));
10231023
} else {
10241024
data.put("groupname", groupref);
10251025
}
10261026
if (roleref != null) {
10271027
if (roleref.matches("\\d+")) {
1028-
data.put("roleid", roleref);
1028+
data.put("roleid", Integer.parseInt(roleref));
10291029
} else {
10301030
data.put("rolename", roleref);
10311031
}
@@ -1248,7 +1248,7 @@ public Map<String, Object> createRole(RoleOptions options, Map<String, Object> r
12481248
*/
12491249
public Map<String, Object> updateRole(String roleid, RoleOptions options, Map<String, Object> requestMetadata) throws IOException {
12501250
Map<String, Object> data = new HashMap<>();
1251-
data.put("roleid", roleid);
1251+
data.put("roleid", Integer.parseInt(roleid));
12521252
if (options != null) {
12531253
data.putAll(OptionsConverter.toMap(options));
12541254
}
@@ -1258,12 +1258,12 @@ public Map<String, Object> updateRole(String roleid, RoleOptions options, Map<St
12581258
public Map<String, Object> linkPolicy(String roleref, String policyref, Map<String, Object> requestMetadata) throws IOException {
12591259
Map<String, Object> data = new HashMap<>();
12601260
if (roleref.matches("\\d+")) {
1261-
data.put("roleid", roleref);
1261+
data.put("roleid", Integer.parseInt(roleref));
12621262
} else {
12631263
data.put("rolename", roleref);
12641264
}
12651265
if (policyref.matches("\\d+")) {
1266-
data.put("policyid", policyref);
1266+
data.put("policyid", Integer.parseInt(policyref));
12671267
} else {
12681268
data.put("policyname", policyref);
12691269
}
@@ -1298,7 +1298,7 @@ public Map<String, Object> createPolicy(PolicyOptions options, Map<String, Objec
12981298
*/
12991299
public Map<String, Object> updatePolicy(String policyid, PolicyOptions options, Map<String, Object> requestMetadata) throws IOException {
13001300
Map<String, Object> data = new HashMap<>();
1301-
data.put("policyid", policyid);
1301+
data.put("policyid", Integer.parseInt(policyid));
13021302
if (options != null) {
13031303
data.putAll(OptionsConverter.toMap(options));
13041304
}
@@ -1311,7 +1311,7 @@ public Map<String, Object> getPolicy(String policyref, Map<String, Object> reque
13111311
Map<String, Object> data = new HashMap<>();
13121312
if (policyref != null) {
13131313
if (policyref.matches("\\d+")) {
1314-
data.put("policyid", policyref);
1314+
data.put("policyid", Integer.parseInt(policyref));
13151315
} else {
13161316
data.put("policyname", policyref);
13171317
}
@@ -1395,7 +1395,7 @@ public Map<String, Object> bulkListGroupUsers(String unlockuuid, String groupref
13951395
Map<String, Object> data = new HashMap<>();
13961396
data.put("unlockuuid", unlockuuid);
13971397
if (groupref.matches("\\d+")) {
1398-
data.put("groupid", groupref);
1398+
data.put("groupid", Integer.parseInt(groupref));
13991399
} else {
14001400
data.put("groupname", groupref);
14011401
}
@@ -1593,6 +1593,54 @@ public Map<String, Object> searchUserProfiles(String identity, String unlockuuid
15931593
return makeRequest("SystemSearchUserProfiles", data, requestMetadata);
15941594
}
15951595

1596+
/**
1597+
* Deletes user profiles across all tenants. Only accessible by the main tenant admin.
1598+
*
1599+
* @param mode User identification mode (login, email, phone, custom, or token; token requires tenantref)
1600+
* @param identity User identifier
1601+
* @param unlockuuid UUID from bulk list unlock for authorization
1602+
* @param tenantref Optional tenant ID (numeric string) or tenant name to restrict deletion to a single tenant (null to delete across all tenants)
1603+
* @param requestMetadata Optional request metadata
1604+
* @return Deleted user profiles with tenantid, tenantname, and token per row
1605+
* @throws IOException If an I/O error occurs
1606+
*/
1607+
public Map<String, Object> deleteUserProfiles(String mode, String identity, String unlockuuid, String tenantref, Map<String, Object> requestMetadata) throws IOException {
1608+
Map<String, Object> data = new HashMap<>();
1609+
data.put("mode", mode);
1610+
data.put("identity", identity);
1611+
data.put("unlockuuid", unlockuuid);
1612+
if (tenantref != null) {
1613+
if (tenantref.matches("\\d+")) {
1614+
data.put("tenantid", Integer.parseInt(tenantref));
1615+
} else {
1616+
data.put("tenantname", tenantref);
1617+
}
1618+
}
1619+
return makeRequest("SystemDeleteUserProfiles", data, requestMetadata);
1620+
}
1621+
1622+
/**
1623+
* Restores a deleted user profile for a specific tenant. Only accessible by the main tenant admin.
1624+
*
1625+
* @param token User's unique token (UUID)
1626+
* @param unlockuuid UUID from bulk list unlock for authorization
1627+
* @param tenantref Tenant ID (numeric string) or tenant name
1628+
* @param requestMetadata Optional request metadata
1629+
* @return Restored user profile with status, result, token, and profile fields
1630+
* @throws IOException If an I/O error occurs
1631+
*/
1632+
public Map<String, Object> restoreUserProfile(String token, String unlockuuid, String tenantref, Map<String, Object> requestMetadata) throws IOException {
1633+
Map<String, Object> data = new HashMap<>();
1634+
data.put("token", token);
1635+
data.put("unlockuuid", unlockuuid);
1636+
if (tenantref.matches("\\d+")) {
1637+
data.put("tenantid", Integer.parseInt(tenantref));
1638+
} else {
1639+
data.put("tenantname", tenantref);
1640+
}
1641+
return makeRequest("SystemRestoreUserProfile", data, requestMetadata);
1642+
}
1643+
15961644
/**
15971645
* Gets user report
15981646
*

0 commit comments

Comments
 (0)