Repository navigation
Expand file tree
/
Copy pathDatabunkerproApi.java
More file actions
1767 lines (1611 loc) · 75.2 KB
/
Copy pathDatabunkerproApi.java
File metadata and controls
1767 lines (1611 loc) · 75.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package org.databunker;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.hc.core5.http.HttpEntity;
import org.apache.hc.core5.http.ContentType;
import org.apache.hc.core5.http.ParseException;
import org.apache.hc.core5.http.io.entity.StringEntity;
import org.apache.hc.core5.http.io.entity.EntityUtils;
import org.apache.hc.client5.http.classic.methods.HttpPost;
import org.apache.hc.client5.http.classic.methods.HttpGet;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
import org.apache.hc.client5.http.impl.classic.HttpClients;
import org.databunker.options.BasicOptions;
import org.databunker.options.UserOptions;
import org.databunker.options.SharedRecordOptions;
import org.databunker.options.LegalBasisOptions;
import org.databunker.options.AgreementAcceptOptions;
import org.databunker.options.TenantOptions;
import org.databunker.options.ProcessingActivityOptions;
import org.databunker.options.GroupOptions;
import org.databunker.options.RoleOptions;
import org.databunker.options.TokenOptions;
import org.databunker.options.PolicyOptions;
import org.databunker.options.PatchOperation;
import org.databunker.options.FileOptions;
import org.databunker.options.OptionsConverter;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Java client for DatabunkerPro API
*/
public class DatabunkerproApi implements AutoCloseable {
private final String baseURL;
private final String xBunkerToken;
private final String xBunkerTenant;
private final ObjectMapper objectMapper;
private final CloseableHttpClient httpClient;
/**
* Creates a new instance of DatabunkerproApi
*
* @param baseURL The base URL of the DatabunkerPro API
* @param xBunkerToken The X-Bunker-Token for authentication
* @param xBunkerTenant The X-Bunker-Tenant for multi-tenancy
*/
public DatabunkerproApi(String baseURL, String xBunkerToken, String xBunkerTenant) {
this.baseURL = baseURL;
this.xBunkerToken = xBunkerToken;
this.xBunkerTenant = xBunkerTenant;
this.objectMapper = new ObjectMapper();
this.httpClient = HttpClients.createDefault();
}
/**
* Makes a POST request to the DatabunkerPro API
*
* @param endpoint The API endpoint
* @param data The request data
* @param requestMetadata Additional request metadata
* @return The response from the API
* @throws IOException If an I/O error occurs
*/
private Map<String, Object> makeRequest(String endpoint, Map<String, Object> data, Map<String, Object> requestMetadata) throws IOException {
String url = baseURL + "/v2/" + endpoint;
HttpPost request = new HttpPost(url);
// Set headers
request.setHeader("Content-Type", "application/json");
if (xBunkerToken != null && !xBunkerToken.isEmpty()) {
request.setHeader("X-Bunker-Token", xBunkerToken);
}
if (xBunkerTenant != null && !xBunkerTenant.isEmpty()) {
request.setHeader("X-Bunker-Tenant", xBunkerTenant);
}
// Set request body if needed
if (data != null || requestMetadata != null) {
Map<String, Object> bodyData = data != null ? data : new HashMap<>();
if (requestMetadata != null) {
bodyData.put("request_metadata", requestMetadata);
}
StringEntity entity = new StringEntity(objectMapper.writeValueAsString(bodyData), ContentType.APPLICATION_JSON);
request.setEntity(entity);
}
try (CloseableHttpResponse response = httpClient.execute(request)) {
HttpEntity entity = response.getEntity();
String responseString = EntityUtils.toString(entity);
Map<String, Object> result = objectMapper.readValue(responseString, Map.class);
if (response.getCode() < 200 || response.getCode() >= 300) {
if (result.containsKey("status")) {
return result;
} else {
throw new IOException(result.containsKey("message") ?
(String) result.get("message") : "API request failed");
}
}
return result;
} catch (Exception error) {
System.err.println("Error making request: " + error.getMessage());
throw new IOException("API request failed", error);
}
}
/**
* Makes a raw request to the DatabunkerPro API and returns the response as a byte array
*
* @param endpoint The API endpoint
* @param data The request data
* @param requestMetadata Additional request metadata
* @return The raw response as a byte array
* @throws IOException If an I/O error occurs
*/
private byte[] rawRequest(String endpoint, Map<String, Object> data, Map<String, Object> requestMetadata) throws IOException {
String url = baseURL + "/v2/" + endpoint;
HttpPost request = new HttpPost(url);
// Set headers
request.setHeader("Content-Type", "application/json");
if (xBunkerToken != null && !xBunkerToken.isEmpty()) {
request.setHeader("X-Bunker-Token", xBunkerToken);
}
// Set request body if needed
if (data != null || requestMetadata != null) {
Map<String, Object> bodyData = data != null ? data : new HashMap<>();
if (requestMetadata != null) {
bodyData.put("request_metadata", requestMetadata);
}
StringEntity entity = new StringEntity(objectMapper.writeValueAsString(bodyData), ContentType.APPLICATION_JSON);
request.setEntity(entity);
}
try (CloseableHttpResponse response = httpClient.execute(request)) {
HttpEntity entity = response.getEntity();
return EntityUtils.toByteArray(entity);
} catch (Exception error) {
System.err.println("Error making raw request: " + error.getMessage());
throw new IOException("Raw API request failed", error);
}
}
// User Management
/**
* Creates a user
*
* @param profile User profile data
* @param options User options
* @param requestMetadata Optional request metadata
* @return The created user information
* @throws IOException If an I/O error occurs
*/
public Map<String, Object> createUser(Map<String, Object> profile, UserOptions options, Map<String, Object> requestMetadata) throws IOException {
Map<String, Object> data = new HashMap<>();
data.put("profile", profile);
if (options != null) {
if (options.getGroupname() != null) {
Object groupname = options.getGroupname();
if (groupname instanceof Number) {
data.put("groupid", groupname);
} else if (groupname instanceof String && ((String) groupname).matches("\\d+")) {
data.put("groupid", Integer.parseInt((String) groupname));
} else {
data.put("groupname", groupname);
}
} else if (options.getGroupid() != null) {
data.put("groupid", options.getGroupid());
}
if (options.getRolename() != null) {
Object rolename = options.getRolename();
if (rolename instanceof Number) {
data.put("roleid", rolename);
} else if (rolename instanceof String && ((String) rolename).matches("\\d+")) {
data.put("roleid", Integer.parseInt((String) rolename));
} else {
data.put("rolename", rolename);
}
} else if (options.getRoleid() != null) {
data.put("roleid", options.getRoleid());
}
if (options.getSlidingtime() != null) {
data.put("slidingtime", options.getSlidingtime());
}
if (options.getFinaltime() != null) {
data.put("finaltime", options.getFinaltime());
}
}
return makeRequest("UserCreate", data, requestMetadata);
}
/**
* Creates multiple users in bulk
*
* @param records Array of user records to create
* @param options Options for bulk user creation
* @param requestMetadata Optional request metadata
* @return The created users information
* @throws IOException If an I/O error occurs
*/
public Map<String, Object> createUsersBulk(Map<String, Object>[] records, BasicOptions options, Map<String, Object> requestMetadata) throws IOException {
Map<String, Object> data = new HashMap<>();
data.put("records", records);
if (options != null) {
data.putAll(OptionsConverter.toMap(options));
}
return makeRequest("UserCreateBulk", data, requestMetadata);
}
public Map<String, Object> getUser(String mode, String identity, Map<String, Object> requestMetadata) throws IOException {
Map<String, Object> data = new HashMap<>();
data.put("mode", mode);
data.put("identity", identity);
return makeRequest("UserGet", data, requestMetadata);
}
public Map<String, Object> updateUser(String mode, String identity, Map<String, Object> profile, Map<String, Object> requestMetadata) throws IOException {
Map<String, Object> data = new HashMap<>();
data.put("mode", mode);
data.put("identity", identity);
data.put("profile", profile);
return makeRequest("UserUpdate", data, requestMetadata);
}
public Map<String, Object> patchUser(String mode, String identity, Map<String, Object>[] patch, Map<String, Object> requestMetadata) throws IOException {
Map<String, Object> data = new HashMap<>();
data.put("mode", mode);
data.put("identity", identity);
data.put("patch", patch);
return makeRequest("UserPatch", data, requestMetadata);
}
/**
* Patches a user with typed patch operations
*
* @param mode User identification mode
* @param identity User's identifier
* @param patch Array of patch operations
* @param requestMetadata Optional request metadata
* @return The patched user information
* @throws IOException If an I/O error occurs
*/
public Map<String, Object> patchUser(String mode, String identity, PatchOperation[] patch, Map<String, Object> requestMetadata) throws IOException {
Map<String, Object> data = new HashMap<>();
data.put("mode", mode);
data.put("identity", identity);
data.put("patch", patch);
return makeRequest("UserPatch", data, requestMetadata);
}
public Map<String, Object> requestUserUpdate(String mode, String identity, Map<String, Object> profile, Map<String, Object> requestMetadata) throws IOException {
Map<String, Object> data = new HashMap<>();
data.put("mode", mode);
data.put("identity", identity);
data.put("profile", profile);
return makeRequest("UserUpdateRequest", data, requestMetadata);
}
public Map<String, Object> requestUserPatch(String mode, String identity, Map<String, Object>[] patch, Map<String, Object> requestMetadata) throws IOException {
Map<String, Object> data = new HashMap<>();
data.put("mode", mode);
data.put("identity", identity);
data.put("patch", patch);
return makeRequest("UserPatchRequest", data, requestMetadata);
}
/**
* Requests a user patch with typed patch operations
*
* @param mode User identification mode
* @param identity User's identifier
* @param patch Array of patch operations
* @param requestMetadata Optional request metadata
* @return The patch request result
* @throws IOException If an I/O error occurs
*/
public Map<String, Object> requestUserPatch(String mode, String identity, PatchOperation[] patch, Map<String, Object> requestMetadata) throws IOException {
Map<String, Object> data = new HashMap<>();
data.put("mode", mode);
data.put("identity", identity);
data.put("patch", patch);
return makeRequest("UserPatchRequest", data, requestMetadata);
}
public Map<String, Object> deleteUser(String mode, String identity, Map<String, Object> requestMetadata) throws IOException {
Map<String, Object> data = new HashMap<>();
data.put("mode", mode);
data.put("identity", identity);
return makeRequest("UserDelete", data, requestMetadata);
}
public Map<String, Object> requestUserDeletion(String mode, String identity, Map<String, Object> requestMetadata) throws IOException {
Map<String, Object> data = new HashMap<>();
data.put("mode", mode);
data.put("identity", identity);
return makeRequest("UserDeleteRequest", data, requestMetadata);
}
/**
* Deletes multiple users in bulk
*
* @param users Array of user identifiers to delete
* @param requestMetadata Optional request metadata
* @return The bulk deletion result
* @throws IOException If an I/O error occurs
*/
public Map<String, Object> deleteUsersBulk(Map<String, Object>[] users, Map<String, Object> requestMetadata) throws IOException {
Map<String, Object> data = new HashMap<>();
data.put("users", users);
return makeRequest("UserDeleteBulk", data, requestMetadata);
}
/**
* Searches for users using fuzzy matching. The mode is auto-detected from the identity value:
* if it contains '@' it is treated as an email, otherwise it searches login, phone, and custom fields.
*
* @param identity User identifier to search for (email, login, phone, or custom value)
* @param unlockuuid UUID from bulk list unlock for search authorization
* @param requestMetadata Optional request metadata
* @return The search results
* @throws IOException If an I/O error occurs
*/
public Map<String, Object> searchUsers(String identity, String unlockuuid, Map<String, Object> requestMetadata) throws IOException {
Map<String, Object> data = new HashMap<>();
data.put("identity", identity);
data.put("unlockuuid", unlockuuid);
return makeRequest("UserSearch", data, requestMetadata);
}
/**
* Lists all versions of a user's profile
*
* @param mode User identification mode
* @param identity User identifier
* @param requestMetadata Optional request metadata
* @return List of user versions
* @throws IOException If an I/O error occurs
*/
public Map<String, Object> listUserVersions(String mode, String identity, Map<String, Object> requestMetadata) throws IOException {
Map<String, Object> data = new HashMap<>();
data.put("mode", mode);
data.put("identity", identity);
return makeRequest("UserListVersions", data, requestMetadata);
}
// Create user API Access Token
/**
* Creates an access token for a user
*
* @param mode User identification mode (e.g., 'email', 'phone', 'token')
* @param identity User's identifier corresponding to the mode
* @param options Optional parameters for token creation
* @param requestMetadata Optional request metadata
* @return The created token information
* @throws IOException If an I/O error occurs
*/
public Map<String, Object> createUserXToken(String mode, String identity, BasicOptions options, Map<String, Object> requestMetadata) throws IOException {
Map<String, Object> data = new HashMap<>();
data.put("mode", mode);
data.put("identity", identity);
if (options != null) {
data.putAll(OptionsConverter.toMap(options));
}
return makeRequest("XTokenCreateForUser", data, requestMetadata);
}
/**
* Creates an access token for a role
*
* @param roleref Role ID or name
* @param options Optional parameters for token creation
* @param requestMetadata Optional request metadata
* @return The created token information
* @throws IOException If an I/O error occurs
*/
public Map<String, Object> createRoleXToken(String roleref, BasicOptions options, Map<String, Object> requestMetadata) throws IOException {
Map<String, Object> data = new HashMap<>();
if (options != null) {
data.putAll(OptionsConverter.toMap(options));
}
if (roleref.matches("\\d+")) {
data.put("roleid", Integer.parseInt(roleref));
} else {
data.put("rolename", roleref);
}
return makeRequest("XTokenCreateForRole", data, requestMetadata);
}
// User Request Management
public Map<String, Object> getUserRequest(String requestuuid, Map<String, Object> requestMetadata) throws IOException {
Map<String, Object> data = new HashMap<>();
data.put("requestuuid", requestuuid);
return makeRequest("UserRequestGet", data, requestMetadata);
}
public Map<String, Object> listUserRequests(String mode, String identity, int offset, int limit, Map<String, Object> requestMetadata) throws IOException {
Map<String, Object> data = new HashMap<>();
data.put("mode", mode);
data.put("identity", identity);
data.put("offset", offset);
data.put("limit", limit);
return makeRequest("UserRequestListUserRequests", data, requestMetadata);
}
/**
* Lists user requests with default offset and limit
*
* @param mode User identification mode
* @param identity User's identifier
* @param requestMetadata Optional request metadata
* @return List of user requests
* @throws IOException If an I/O error occurs
*/
public Map<String, Object> listUserRequests(String mode, String identity, Map<String, Object> requestMetadata) throws IOException {
return listUserRequests(mode, identity, 0, 10, requestMetadata);
}
/**
* Cancels a user request
*
* @param requestuuid UUID of the request to cancel
* @param options Optional parameters for cancellation
* @param requestMetadata Optional request metadata
* @return The cancellation result
* @throws IOException If an I/O error occurs
*/
public Map<String, Object> cancelUserRequest(String requestuuid, Map<String, Object> options, Map<String, Object> requestMetadata) throws IOException {
Map<String, Object> data = new HashMap<>();
data.put("requestuuid", requestuuid);
if (options != null) {
data.putAll(options);
}
return makeRequest("UserRequestCancel", data, requestMetadata);
}
/**
* Cancels a user request without additional options
*
* @param requestuuid UUID of the request to cancel
* @param requestMetadata Optional request metadata
* @return The cancellation result
* @throws IOException If an I/O error occurs
*/
public Map<String, Object> cancelUserRequest(String requestuuid, Map<String, Object> requestMetadata) throws IOException {
return cancelUserRequest(requestuuid, null, requestMetadata);
}
/**
* Approves a user request
*
* @param requestuuid UUID of the request to approve
* @param options Optional parameters for approval
* @param requestMetadata Optional request metadata
* @return The approval result
* @throws IOException If an I/O error occurs
*/
public Map<String, Object> approveUserRequest(String requestuuid, Map<String, Object> options, Map<String, Object> requestMetadata) throws IOException {
Map<String, Object> data = new HashMap<>();
data.put("requestuuid", requestuuid);
if (options != null) {
data.putAll(options);
}
return makeRequest("UserRequestApprove", data, requestMetadata);
}
/**
* Approves a user request without additional options
*
* @param requestuuid UUID of the request to approve
* @param requestMetadata Optional request metadata
* @return The approval result
* @throws IOException If an I/O error occurs
*/
public Map<String, Object> approveUserRequest(String requestuuid, Map<String, Object> requestMetadata) throws IOException {
return approveUserRequest(requestuuid, null, requestMetadata);
}
// App Data Management
public Map<String, Object> createAppData(String mode, String identity, String appname, Map<String, Object> appdata, Map<String, Object> requestMetadata) throws IOException {
Map<String, Object> requestData = new HashMap<>();
requestData.put("mode", mode);
requestData.put("identity", identity);
requestData.put("appname", appname);
requestData.put("appdata", appdata);
return makeRequest("AppdataCreate", requestData, requestMetadata);
}
public Map<String, Object> getAppData(String mode, String identity, String appname, Map<String, Object> requestMetadata) throws IOException {
Map<String, Object> data = new HashMap<>();
data.put("mode", mode);
data.put("identity", identity);
data.put("appname", appname);
return makeRequest("AppdataGet", data, requestMetadata);
}
/**
* Gets app data with version support
*
* @param mode User identification mode
* @param identity User identifier
* @param appname Application name
* @param version Specific version of the app data to retrieve
* @param requestMetadata Optional request metadata
* @return App data
* @throws IOException If an I/O error occurs
*/
public Map<String, Object> getAppData(String mode, String identity, String appname, Integer version, Map<String, Object> requestMetadata) throws IOException {
Map<String, Object> data = new HashMap<>();
data.put("mode", mode);
data.put("identity", identity);
data.put("appname", appname);
if (version != null) {
data.put("version", version);
}
return makeRequest("AppdataGet", data, requestMetadata);
}
public Map<String, Object> updateAppData(String mode, String identity, String appname, Map<String, Object> appdata, Map<String, Object> requestMetadata) throws IOException {
Map<String, Object> requestData = new HashMap<>();
requestData.put("mode", mode);
requestData.put("identity", identity);
requestData.put("appname", appname);
requestData.put("appdata", appdata);
return makeRequest("AppdataUpdate", requestData, requestMetadata);
}
public Map<String, Object> requestAppDataUpdate(String mode, String identity, String appname, Map<String, Object> appdata, Map<String, Object> requestMetadata) throws IOException {
Map<String, Object> requestData = new HashMap<>();
requestData.put("mode", mode);
requestData.put("identity", identity);
requestData.put("appname", appname);
requestData.put("appdata", appdata);
return makeRequest("AppdataUpdateRequest", requestData, requestMetadata);
}
public Map<String, Object> listAppDataNames(String mode, String identity, Map<String, Object> requestMetadata) throws IOException {
Map<String, Object> data = new HashMap<>();
data.put("mode", mode);
data.put("identity", identity);
return makeRequest("AppdataListUserAppNames", data, requestMetadata);
}
public Map<String, Object> listAppNames(Map<String, Object> requestMetadata) throws IOException {
return makeRequest("AppdataListAppNames", null, requestMetadata);
}
/**
* Deletes app data for a user
*
* @param mode User identification mode
* @param identity User identifier
* @param appname Application name
* @param requestMetadata Optional request metadata
* @return Deletion result
* @throws IOException If an I/O error occurs
*/
public Map<String, Object> deleteAppData(String mode, String identity, String appname, Map<String, Object> requestMetadata) throws IOException {
Map<String, Object> data = new HashMap<>();
data.put("mode", mode);
data.put("identity", identity);
data.put("appname", appname);
return makeRequest("AppdataDelete", data, requestMetadata);
}
/**
* Lists all versions of app data for a user
*
* @param mode User identification mode
* @param identity User identifier
* @param appname Application name
* @param requestMetadata Optional request metadata
* @return List of app data versions
* @throws IOException If an I/O error occurs
*/
public Map<String, Object> listAppDataVersions(String mode, String identity, String appname, Map<String, Object> requestMetadata) throws IOException {
Map<String, Object> data = new HashMap<>();
data.put("mode", mode);
data.put("identity", identity);
data.put("appname", appname);
return makeRequest("AppdataListVersions", data, requestMetadata);
}
// File Storage
/**
* Stores an encrypted file for a user
*
* @param mode User identification mode (login, token, email, phone, custom)
* @param identity User identifier corresponding to the mode
* @param filename Name of the file
* @param filedata File content, base64-encoded
* @param options Optional mimetype, tags and expiration
* @param requestMetadata Optional request metadata
* @return The stored file information, including its fileuuid
* @throws IOException if the request fails
*/
public Map<String, Object> createFile(String mode, String identity, String filename, String filedata, FileOptions options, Map<String, Object> requestMetadata) throws IOException {
Map<String, Object> data = new HashMap<>();
data.put("mode", mode);
data.put("identity", identity);
data.put("filename", filename);
data.put("filedata", filedata);
if (options != null) {
data.putAll(OptionsConverter.toMap(options));
}
return makeRequest("FileCreate", data, requestMetadata);
}
public Map<String, Object> createFile(String mode, String identity, String filename, String filedata, Map<String, Object> requestMetadata) throws IOException {
return createFile(mode, identity, filename, filedata, null, requestMetadata);
}
/**
* Gets a user file, selected by fileuuid or filename
*
* @param mode User identification mode
* @param identity User identifier corresponding to the mode
* @param fileuuid UUID of the file, or null
* @param filename Name of the file, or null. The newest match is returned.
* @param raw When true the decrypted bytes are returned directly, or null
* @param requestMetadata Optional request metadata
* @return The file content and metadata
* @throws IOException if the request fails
*/
public Map<String, Object> getFile(String mode, String identity, String fileuuid, String filename, Boolean raw, Map<String, Object> requestMetadata) throws IOException {
Map<String, Object> data = new HashMap<>();
data.put("mode", mode);
data.put("identity", identity);
if (fileuuid != null) {
data.put("fileuuid", fileuuid);
}
if (filename != null) {
data.put("filename", filename);
}
if (raw != null) {
data.put("raw", raw);
}
return makeRequest("FileGet", data, requestMetadata);
}
public Map<String, Object> getFile(String mode, String identity, String fileuuid, Map<String, Object> requestMetadata) throws IOException {
return getFile(mode, identity, fileuuid, null, null, requestMetadata);
}
/**
* Lists the metadata of files owned by a user
*
* @param mode User identification mode
* @param identity User identifier corresponding to the mode
* @param tag Return only files carrying this tag, or null. A single tag only.
* @param requestMetadata Optional request metadata
* @return The list of files
* @throws IOException if the request fails
*/
public Map<String, Object> listUserFiles(String mode, String identity, String tag, Map<String, Object> requestMetadata) throws IOException {
Map<String, Object> data = new HashMap<>();
data.put("mode", mode);
data.put("identity", identity);
if (tag != null) {
data.put("tag", tag);
}
return makeRequest("FileListUserFiles", data, requestMetadata);
}
public Map<String, Object> listUserFiles(String mode, String identity, Map<String, Object> requestMetadata) throws IOException {
return listUserFiles(mode, identity, null, requestMetadata);
}
/**
* Replaces the complete tag set on a file
*
* @param mode User identification mode
* @param identity User identifier corresponding to the mode
* @param fileuuid UUID of the file to retag
* @param tags The complete replacement tag set
* @param requestMetadata Optional request metadata
* @return The normalised tag set now stored
* @throws IOException if the request fails
*/
public Map<String, Object> replaceFileTags(String mode, String identity, String fileuuid, List<String> tags, Map<String, Object> requestMetadata) throws IOException {
Map<String, Object> data = new HashMap<>();
data.put("mode", mode);
data.put("identity", identity);
data.put("fileuuid", fileuuid);
data.put("tags", tags);
return makeRequest("FileReplaceTags", data, requestMetadata);
}
/**
* Deletes a user file
*
* @param mode User identification mode
* @param identity User identifier corresponding to the mode
* @param fileuuid UUID of the file to delete
* @param requestMetadata Optional request metadata
* @return The deletion result
* @throws IOException if the request fails
*/
public Map<String, Object> deleteFile(String mode, String identity, String fileuuid, Map<String, Object> requestMetadata) throws IOException {
Map<String, Object> data = new HashMap<>();
data.put("mode", mode);
data.put("identity", identity);
data.put("fileuuid", fileuuid);
return makeRequest("FileDelete", data, requestMetadata);
}
// Legal Basis Management
/**
* Creates a legal basis with typed options
*
* @param options Typed options for legal basis creation
* @param requestMetadata Optional request metadata
* @return The created legal basis information
* @throws IOException If an I/O error occurs
*/
public Map<String, Object> createLegalBasis(LegalBasisOptions options, Map<String, Object> requestMetadata) throws IOException {
Map<String, Object> data = new HashMap<>();
if (options != null) {
data.putAll(OptionsConverter.toMap(options));
}
return makeRequest("LegalBasisCreate", data, requestMetadata);
}
/**
* Updates a legal basis with typed options
*
* @param brief Brief identifier of the legal basis
* @param newbrief New brief identifier for the legal basis
* @param options Typed options for legal basis update (can be null)
* @param requestMetadata Optional request metadata
* @return The updated legal basis information
* @throws IOException If an I/O error occurs
*/
public Map<String, Object> updateLegalBasis(String brief, String newbrief, LegalBasisOptions options, Map<String, Object> requestMetadata) throws IOException {
Map<String, Object> data = new HashMap<>();
data.put("brief", brief);
data.put("newbrief", newbrief);
if (options != null) {
data.putAll(OptionsConverter.toMap(options));
}
return makeRequest("LegalBasisUpdate", data, requestMetadata);
}
public Map<String, Object> deleteLegalBasis(String brief, Map<String, Object> requestMetadata) throws IOException {
Map<String, Object> data = new HashMap<>();
data.put("brief", brief);
return makeRequest("LegalBasisDelete", data, requestMetadata);
}
public Map<String, Object> listAgreements(Map<String, Object> requestMetadata) throws IOException {
return makeRequest("LegalBasisListAgreements", null, requestMetadata);
}
// Agreement Management
/**
* Accepts an agreement
*
* @param mode User identification mode
* @param identity User's identifier
* @param brief Agreement brief identifier
* @param options Options for agreement acceptance
* @param requestMetadata Optional request metadata
* @return The agreement acceptance result
* @throws IOException If an I/O error occurs
*/
public Map<String, Object> acceptAgreement(String mode, String identity, String brief, AgreementAcceptOptions options, Map<String, Object> requestMetadata) throws IOException {
Map<String, Object> data = new HashMap<>();
data.put("mode", mode);
data.put("identity", identity);
data.put("brief", brief);
if (options != null) {
data.putAll(OptionsConverter.toMap(options));
}
return makeRequest("AgreementAccept", data, requestMetadata);
}
/**
* Accepts an agreement without additional options
*
* @param mode User identification mode
* @param identity User's identifier
* @param brief Agreement brief identifier
* @param requestMetadata Optional request metadata
* @return The agreement acceptance result
* @throws IOException If an I/O error occurs
*/
public Map<String, Object> acceptAgreement(String mode, String identity, String brief, Map<String, Object> requestMetadata) throws IOException {
Map<String, Object> data = new HashMap<>();
data.put("mode", mode);
data.put("identity", identity);
data.put("brief", brief);
return makeRequest("AgreementAccept", data, requestMetadata);
}
public Map<String, Object> cancelAgreement(String mode, String identity, String brief, Map<String, Object> requestMetadata) throws IOException {
Map<String, Object> data = new HashMap<>();
data.put("mode", mode);
data.put("identity", identity);
data.put("brief", brief);
return makeRequest("AgreementCancel", data, requestMetadata);
}
public Map<String, Object> requestAgreementCancellation(String mode, String identity, String brief, Map<String, Object> requestMetadata) throws IOException {
Map<String, Object> data = new HashMap<>();
data.put("mode", mode);
data.put("identity", identity);
data.put("brief", brief);
return makeRequest("AgreementCancelRequest", data, requestMetadata);
}
public Map<String, Object> getUserAgreement(String mode, String identity, String brief, Map<String, Object> requestMetadata) throws IOException {
Map<String, Object> data = new HashMap<>();
data.put("mode", mode);
data.put("identity", identity);
data.put("brief", brief);
return makeRequest("AgreementGet", data, requestMetadata);
}
public Map<String, Object> listUserAgreements(String mode, String identity, Map<String, Object> requestMetadata) throws IOException {
Map<String, Object> data = new HashMap<>();
data.put("mode", mode);
data.put("identity", identity);
return makeRequest("AgreementListUserAgreements", data, requestMetadata);
}
public Map<String, Object> revokeAllAgreements(String brief, Map<String, Object> requestMetadata) throws IOException {
Map<String, Object> data = new HashMap<>();
data.put("brief", brief);
return makeRequest("AgreementRevokeAll", data, requestMetadata);
}
// Processing Activity Management
public Map<String, Object> listProcessingActivities(Map<String, Object> requestMetadata) throws IOException {
return makeRequest("ProcessingActivityListActivities", null, requestMetadata);
}
/**
* Creates a processing activity with typed options
*
* @param options Typed options for processing activity creation
* @param requestMetadata Optional request metadata
* @return The created processing activity information
* @throws IOException If an I/O error occurs
*/
public Map<String, Object> createProcessingActivity(ProcessingActivityOptions options, Map<String, Object> requestMetadata) throws IOException {
Map<String, Object> data = new HashMap<>();
if (options != null) {
data.putAll(OptionsConverter.toMap(options));
}
return makeRequest("ProcessingActivityCreate", data, requestMetadata);
}
/**
* Updates a processing activity with typed options
*
* @param activity Activity identifier
* @param newactivity New activity identifier
* @param options Typed options for processing activity update
* @param requestMetadata Optional request metadata
* @return The updated processing activity information
* @throws IOException If an I/O error occurs
*/
public Map<String, Object> updateProcessingActivity(String activity, String newactivity, ProcessingActivityOptions options, Map<String, Object> requestMetadata) throws IOException {
Map<String, Object> data = new HashMap<>();
data.put("activity", activity);
data.put("newactivity", newactivity);
if (options != null) {
data.putAll(OptionsConverter.toMap(options));
}
return makeRequest("ProcessingActivityUpdate", data, requestMetadata);
}
public Map<String, Object> deleteProcessingActivity(String activity, Map<String, Object> requestMetadata) throws IOException {
Map<String, Object> data = new HashMap<>();
data.put("activity", activity);
return makeRequest("ProcessingActivityDelete", data, requestMetadata);
}
public Map<String, Object> linkProcessingActivityToLegalBasis(String activity, String brief, Map<String, Object> requestMetadata) throws IOException {
Map<String, Object> data = new HashMap<>();
data.put("activity", activity);
data.put("brief", brief);
return makeRequest("ProcessingActivityLinkLegalBasis", data, requestMetadata);
}
public Map<String, Object> unlinkProcessingActivityFromLegalBasis(String activity, String brief, Map<String, Object> requestMetadata) throws IOException {
Map<String, Object> data = new HashMap<>();
data.put("activity", activity);
data.put("brief", brief);
return makeRequest("ProcessingActivityUnlinkLegalBasis", data, requestMetadata);
}
// Group Management
/**
* Creates a group with typed options
*
* @param options Typed options for group creation
* @param requestMetadata Optional request metadata
* @return The created group information
* @throws IOException If an I/O error occurs
*/
public Map<String, Object> createGroup(GroupOptions options, Map<String, Object> requestMetadata) throws IOException {
Map<String, Object> data = new HashMap<>();
if (options != null) {
data.putAll(OptionsConverter.toMap(options));
}
return makeRequest("GroupCreate", data, requestMetadata);
}
public Map<String, Object> getGroup(String groupref, Map<String, Object> requestMetadata) throws IOException {
Map<String, Object> data = new HashMap<>();
if (groupref.matches("\\d+")) {
data.put("groupid", Integer.parseInt(groupref));
} else {
data.put("groupname", groupref);
}
return makeRequest("GroupGet", data, requestMetadata);
}
public Map<String, Object> listAllGroups(Map<String, Object> requestMetadata) throws IOException {
return makeRequest("GroupListAllGroups", null, requestMetadata);
}
public Map<String, Object> listUserGroups(String mode, String identity, Map<String, Object> requestMetadata) throws IOException {
Map<String, Object> data = new HashMap<>();
data.put("mode", mode);
data.put("identity", identity);
return makeRequest("GroupListUserGroups", data, requestMetadata);
}
/**
* Updates a group with typed options
*
* @param groupid Group ID
* @param options Typed options for group update (can be null)
* @param requestMetadata Optional request metadata
* @return The updated group information
* @throws IOException If an I/O error occurs
*/
public Map<String, Object> updateGroup(String groupid, GroupOptions options, Map<String, Object> requestMetadata) throws IOException {
Map<String, Object> data = new HashMap<>();
data.put("groupid", Integer.parseInt(groupid));
if (options != null) {
data.putAll(OptionsConverter.toMap(options));
}
return makeRequest("GroupUpdate", data, requestMetadata);
}
public Map<String, Object> deleteGroup(String groupref, Map<String, Object> requestMetadata) throws IOException {
Map<String, Object> data = new HashMap<>();
if (groupref.matches("\\d+")) {
data.put("groupid", Integer.parseInt(groupref));
} else {
data.put("groupname", groupref);
}
return makeRequest("GroupDelete", data, requestMetadata);
}
public Map<String, Object> removeUserFromGroup(String mode, String identity, String groupref, Map<String, Object> requestMetadata) throws IOException {
Map<String, Object> data = new HashMap<>();
data.put("mode", mode);
data.put("identity", identity);
if (groupref.matches("\\d+")) {
data.put("groupid", Integer.parseInt(groupref));
} else {
data.put("groupname", groupref);
}
return makeRequest("GroupDeleteUser", data, requestMetadata);
}
public Map<String, Object> addUserToGroup(String mode, String identity, String groupref, String roleref, Map<String, Object> requestMetadata) throws IOException {
Map<String, Object> data = new HashMap<>();
data.put("mode", mode);
data.put("identity", identity);
if (groupref.matches("\\d+")) {
data.put("groupid", Integer.parseInt(groupref));
} else {
data.put("groupname", groupref);
}
if (roleref != null) {
if (roleref.matches("\\d+")) {
data.put("roleid", Integer.parseInt(roleref));
} else {