001package com.box.sdk;
002
003import com.eclipsesource.json.Json;
004import com.eclipsesource.json.JsonObject;
005import com.eclipsesource.json.JsonValue;
006import java.text.ParseException;
007import java.util.Date;
008import java.util.HashMap;
009import java.util.Map;
010
011/**
012 * Represents an event that was fired off by the Box events API.
013 */
014@BoxResourceType("event")
015public class BoxEvent extends BoxResource {
016    private BoxResource.Info sourceInfo;
017    private BoxEvent.Type type;
018    private BoxEvent.EventType eventType;
019    private String typeName;
020    private JsonObject sourceJSON;
021    private Date createdAt;
022    private String ipAddress;
023    private JsonObject additionalDetails;
024    private BoxCollaborator.Info accessibleBy;
025    private BoxUser.Info createdBy;
026    private String sessionID;
027    private BoxUser.Info actionBy;
028
029    /**
030     * Constructs a BoxEvent from a JSON string.
031     *
032     * @param api  the API connection to be used by the file.
033     * @param json the JSON encoded event.
034     */
035    public BoxEvent(BoxAPIConnection api, String json) {
036        this(api, Json.parse(json).asObject());
037    }
038
039    BoxEvent(BoxAPIConnection api, JsonObject jsonObject) {
040        super(api, jsonObject.get("event_id").asString());
041
042        for (JsonObject.Member member : jsonObject) {
043            if (member.getValue().isNull()) {
044                continue;
045            }
046
047            this.parseJsonMember(member);
048        }
049    }
050
051    /**
052     * Gets info about the source of this event.
053     *
054     * <p>Note that there is a bug in the enterprise event stream where certain event sources don't correctly map to a
055     * BoxResource.Info. In the case where the event source JSON cannot be mapped to a BoxResource.Info, you can use the
056     * {@link #getSourceJSON} method to access the raw JSON representation of the event source.</p>
057     *
058     * @return info about the source of this event.
059     */
060    public BoxResource.Info getSourceInfo() {
061        return this.sourceInfo;
062    }
063
064    /**
065     * Gets the raw JSON object containing information about the source of this event.
066     *
067     * <p>This method can be used to work around bugs in the enterprise events API where some enterprise event sources
068     * don't correctly map to a BoxResource.Info. In this case, this method can be used to access the raw JSON
069     * directly.</p>
070     *
071     * @return the JSON representation of the source of this event.
072     */
073    public JsonObject getSourceJSON() {
074        return this.sourceJSON;
075    }
076
077    /**
078     * Gets the type of this event.
079     *
080     * @return the type of this event.
081     * @deprecated use getEventType instead.
082     */
083    @Deprecated
084    public BoxEvent.Type getType() {
085        return this.type;
086    }
087
088    /**
089     * Gets the type of this event.
090     *
091     * @return the type of this event.
092     */
093    public BoxEvent.EventType getEventType() {
094        return this.eventType;
095    }
096
097    /**
098     * Gets the type name as String. Every BoxEvent will have typeName, some will have
099     * eventType set to specific value and some will have eventType = UNKNOWN.
100     *
101     * @return the name of the type of this event.
102     */
103    public String getTypeName() {
104        return this.typeName;
105    }
106
107    /**
108     * Gets the time that this event was created.
109     *
110     * @return the time that this event was created.
111     */
112    public Date getCreatedAt() {
113        return this.createdAt;
114    }
115
116    /**
117     * Gets the IP address of the user that triggered this event.
118     *
119     * @return the IP address of the user that triggered this event.
120     */
121    public String getIPAddress() {
122        return this.ipAddress;
123    }
124
125    /**
126     * Gets a JSON object containing additional details about this event.
127     *
128     * <p>The fields and data within the returned JSON object will vary depending on the type of the event.</p>
129     *
130     * @return a JSON object containing additional details about this event.
131     */
132    public JsonObject getAdditionalDetails() {
133        return this.additionalDetails;
134    }
135
136    /**
137     * Gets info about the collaborator who was given access to a folder within the current enterprise.
138     *
139     * <p>This field is only populated when the event is related to a collaboration that occurred within an enterprise.
140     * </p>
141     *
142     * @return info about the collaborator who was given access to a folder within the current enterprise.
143     */
144    public BoxCollaborator.Info getAccessibleBy() {
145        return this.accessibleBy;
146    }
147
148    /**
149     * Gets info about the user that triggered this event.
150     *
151     * @return info about the user that triggered this event.
152     */
153    public BoxUser.Info getCreatedBy() {
154        return this.createdBy;
155    }
156
157    /**
158     * Gets the session ID of the user that triggered this event.
159     *
160     * @return the session ID of the user that triggered this event.
161     */
162    public String getSessionID() {
163        return this.sessionID;
164    }
165
166    /**
167     * Gets the user that performed the action for this event.
168     *
169     * @return info about the user that performed that action for this event.
170     */
171    public BoxUser.Info getActionBy() {
172        return this.actionBy;
173    }
174
175    void parseJsonMember(JsonObject.Member member) {
176        JsonValue value = member.getValue();
177        if (value.isNull()) {
178            return;
179        }
180
181        String memberName = member.getName();
182        if (memberName.equals("source")) {
183            // Parsing the source might fail due to a bug in the enterprise event stream where the API returns JSON that
184            // doesn't correctly map to a BoxResource.Info. If this happens, we set the sourceInfo to null and expect
185            // the caller to use the getSourceJSON() method instead.
186            try {
187                this.sourceInfo = BoxResource.parseInfo(this.getAPI(), value.asObject());
188            } catch (Exception e) {
189                this.sourceInfo = null;
190            }
191            this.sourceJSON = JsonObject.unmodifiableObject(value.asObject());
192        } else if (memberName.equals("event_type")) {
193            String stringValue = value.asString();
194            this.typeName = stringValue;
195            for (Type t : Type.values()) {
196                if (t.name().equals(stringValue)) {
197                    this.type = t;
198                    break;
199                }
200            }
201
202            this.eventType = BoxEvent.EventType.lookupByValue(stringValue);
203
204            if (this.type == null || this.eventType == null) {
205                this.type = Type.UNKNOWN;
206                this.eventType = EventType.UNKNOWN;
207            }
208        } else if (memberName.equals("created_at")) {
209            try {
210                this.createdAt = BoxDateFormat.parse(value.asString());
211            } catch (ParseException e) {
212                assert false : "A ParseException indicates a bug in the SDK.";
213            }
214        } else if (memberName.equals("ip_address")) {
215            this.ipAddress = value.asString();
216        } else if (memberName.equals("additional_details")) {
217            this.additionalDetails = value.asObject();
218        } else if (memberName.equals("accessible_by")) {
219            this.accessibleBy = (BoxCollaborator.Info) BoxResource.parseInfo(this.getAPI(), value.asObject());
220        } else if (memberName.equals("created_by")) {
221            this.createdBy = (BoxUser.Info) BoxResource.parseInfo(this.getAPI(), value.asObject());
222        } else if (memberName.equals("session_id")) {
223            this.sessionID = value.asString();
224        } else if (memberName.equals("action_by")) {
225            this.actionBy = (BoxUser.Info) BoxResource.parseInfo(this.getAPI(), value.asObject());
226        }
227    }
228
229    /**
230     * Enumerates the possible types for an event.
231     *
232     * @deprecated use EventType instead.
233     */
234    @Deprecated
235    public enum Type {
236        /**
237         * The type of the event is unknown.
238         */
239        UNKNOWN,
240
241        /**
242         * An file or folder was created.
243         */
244        ITEM_CREATE,
245
246        /**
247         * An file or folder was uploaded.
248         */
249        ITEM_UPLOAD,
250
251        /**
252         * A comment was created on a folder, file, or other comment.
253         */
254        COMMENT_CREATE,
255
256        /**
257         * A comment was deleted on a folder, file, or other comment.
258         */
259        COMMENT_DELETE,
260
261        /**
262         * An file or folder was downloaded.
263         */
264        ITEM_DOWNLOAD,
265
266        /**
267         * A file was previewed.
268         */
269        ITEM_PREVIEW,
270
271        /**
272         * A file or folder was moved.
273         */
274        ITEM_MOVE,
275
276        /**
277         * A file or folder was copied.
278         */
279        ITEM_COPY,
280
281        /**
282         * A task was assigned.
283         */
284        TASK_ASSIGNMENT_CREATE,
285
286        /**
287         * A task was assignment was completed.
288         */
289        TASK_ASSIGNMENT_COMPLETE,
290
291        /**
292         * A task was assignment was updated.
293         */
294        TASK_ASSIGNMENT_UPDATE,
295
296
297        /**
298         * A task was created.
299         */
300        TASK_CREATE,
301
302        /**
303         * A file was locked.
304         */
305        LOCK_CREATE,
306
307        /**
308         * A file was unlocked.
309         */
310        LOCK_DESTROY,
311
312        /**
313         * A file or folder was deleted.
314         */
315        ITEM_TRASH,
316
317        /**
318         * A file or folder was recovered from the trash.
319         */
320        ITEM_UNDELETE_VIA_TRASH,
321
322        /**
323         * A collaborator was added to a folder.
324         */
325        COLLAB_ADD_COLLABORATOR,
326
327        /**
328         * A collaborator's role was change in a folder.
329         */
330        COLLAB_ROLE_CHANGE,
331
332        /**
333         * A collaborator was invited to a folder.
334         */
335        COLLAB_INVITE_COLLABORATOR,
336
337        /**
338         * A collaborator was removed from a folder.
339         */
340        COLLAB_REMOVE_COLLABORATOR,
341
342        /**
343         * A folder was marked for sync.
344         */
345        ITEM_SYNC,
346
347        /**
348         * A folder was un-marked for sync.
349         */
350        ITEM_UNSYNC,
351
352        /**
353         * A file or folder was renamed.
354         */
355        ITEM_RENAME,
356
357        /**
358         * A file or folder was enabled for sharing.
359         */
360        ITEM_SHARED_CREATE,
361
362        /**
363         * A file or folder was disabled for sharing.
364         */
365        ITEM_SHARED_UNSHARE,
366
367        /**
368         * A folder was shared.
369         */
370        ITEM_SHARED,
371
372        /**
373         * A previous version of a file was promoted to the current version.
374         */
375        ITEM_MAKE_CURRENT_VERSION,
376
377        /**
378         * A tag was added to a file or folder.
379         */
380        TAG_ITEM_CREATE,
381
382        /**
383         * 2 factor authentication enabled by user.
384         */
385        ENABLE_TWO_FACTOR_AUTH,
386
387        /**
388         * Free user accepts invitation to become a managed user.
389         */
390        MASTER_INVITE_ACCEPT,
391
392        /**
393         * Free user rejects invitation to become a managed user.
394         */
395        MASTER_INVITE_REJECT,
396
397        /**
398         * Granted Box access to account.
399         */
400        ACCESS_GRANTED,
401
402        /**
403         * Revoke Box access to account.
404         */
405        ACCESS_REVOKED,
406
407        /**
408         * A user logged in from a new device.
409         */
410        ADD_LOGIN_ACTIVITY_DEVICE,
411
412        /**
413         * A user session associated with an app was invalidated.
414         */
415        REMOVE_LOGIN_ACTIVITY_DEVICE,
416
417        /**
418         * An admin role changed for a user.
419         */
420        CHANGE_ADMIN_ROLE,
421
422        /**
423         * A user was added to a group. This is an enterprise-only event.
424         */
425        GROUP_ADD_USER,
426
427        /**
428         * A user was created. This is an enterprise-only event.
429         */
430        NEW_USER,
431
432        /**
433         * A group was created. This is an enterprise-only event.
434         */
435        GROUP_CREATION,
436
437        /**
438         * A group was deleted. This is an enterprise-only event.
439         */
440        GROUP_DELETION,
441
442        /**
443         * A user was deleted. This is an enterprise-only event.
444         */
445        DELETE_USER,
446
447        /**
448         * A group was edited. This is an enterprise-only event.
449         */
450        GROUP_EDITED,
451
452        /**
453         * A user was edited. This is an enterprise-only event.
454         */
455        EDIT_USER,
456
457        /**
458         * A group was granted access to a folder. This is an enterprise-only event.
459         */
460        GROUP_ADD_FOLDER,
461
462        /**
463         * A group was granted access to a file. This is an enterprise-only event.
464         */
465        GROUP_ADD_FILE,
466
467        /**
468         * A user was removed from a group. This is an enterprise-only event.
469         */
470        GROUP_REMOVE_USER,
471
472        /**
473         * A group had its access to a folder removed. This is an enterprise-only event.
474         */
475        GROUP_REMOVE_FOLDER,
476
477        /**
478         * A group had its access to a file removed. This is an enterprise-only event.
479         */
480        GROUP_REMOVE_FILE,
481
482        /**
483         * An administrator logged in. This is an enterprise-only event.
484         */
485        ADMIN_LOGIN,
486
487        /**
488         * A device was associated with a user. This is an enterprise-only event.
489         */
490        ADD_DEVICE_ASSOCIATION,
491
492        /**
493         * There was a failed login attempt. This is an enterprise-only event.
494         */
495        FAILED_LOGIN,
496
497        /**
498         * There was a successful login. This is an enterprise-only event.
499         */
500        LOGIN,
501
502        /**
503         * A user's OAuth2 access token was refreshed. This is an enterprise-only event.
504         */
505        USER_AUTHENTICATE_OAUTH2_TOKEN_REFRESH,
506
507        /**
508         * A device was disassociated with a user. This is an enterprise-only event.
509         */
510        REMOVE_DEVICE_ASSOCIATION,
511
512        /**
513         * A user agreed to the terms of service. This is an enterprise-only event.
514         */
515        TERMS_OF_SERVICE_AGREE,
516
517        /**
518         * A user rejected the terms of service. This is an enterprise-only event.
519         */
520        TERMS_OF_SERVICE_REJECT,
521
522        /**
523         * Virus found on a file. Event is only received by enterprises that have opted in to be notified.
524         * This is an enterprise-only event.
525         */
526        FILE_MARKED_MALICIOUS,
527
528        /**
529         * An item was copied. This is an enterprise-only event.
530         */
531        COPY,
532
533        /**
534         * An item was deleted. This is an enterprise-only event.
535         */
536        DELETE,
537
538        /**
539         * An item was downloaded. This is an enterprise-only event.
540         */
541        DOWNLOAD,
542
543        /**
544         * An item was edited. This is an enterprise-only event.
545         */
546        EDIT,
547
548        /**
549         * An item was locked. This is an enterprise-only event.
550         */
551        LOCK,
552
553        /**
554         * An item was moved. This is an enterprise-only event.
555         */
556        MOVE,
557
558        /**
559         * An item was previewed. This is an enterprise-only event.
560         */
561        PREVIEW,
562
563        /**
564         * An item was renamed. This is an enterprise-only event.
565         */
566        RENAME,
567
568        /**
569         * An item was set to be auto-deleted. This is an enterprise-only event.
570         */
571        STORAGE_EXPIRATION,
572
573        /**
574         * An item was undeleted. This is an enterprise-only event.
575         */
576        UNDELETE,
577
578        /**
579         * An item was unlocked. This is an enterprise-only event.
580         */
581        UNLOCK,
582
583        /**
584         * An item was uploaded. This is an enterprise-only event.
585         */
586        UPLOAD,
587
588        /**
589         * An shared link was created for an item. This is an enterprise-only event.
590         */
591        SHARE,
592
593        /**
594         * The shared link for an item was updated. This is an enterprise-only event.
595         */
596        ITEM_SHARED_UPDATE,
597
598        /**
599         * The expiration time for a shared link was extended. This is an enterprise-only event.
600         */
601        UPDATE_SHARE_EXPIRATION,
602
603        /**
604         * The expiration time was set for a shared link. This is an enterprise-only event.
605         */
606        SHARE_EXPIRATION,
607
608        /**
609         * The shared link for an item was REMOVE_DEVICE_ASSOCIATION. This is an enterprise-only event.
610         */
611        UNSHARE,
612
613        /**
614         * A user accepted a collaboration invite. This is an enterprise-only event.
615         */
616        COLLABORATION_ACCEPT,
617
618        /**
619         * A user's collaboration role was changed. This is an enterprise-only event.
620         */
621        COLLABORATION_ROLE_CHANGE,
622
623        /**
624         * The expiration time for a collaboration was extended. This is an enterprise-only event.
625         */
626        UPDATE_COLLABORATION_EXPIRATION,
627
628        /**
629         * A collaboration was removed from a folder. This is an enterprise-only event.
630         */
631        COLLABORATION_REMOVE,
632
633        /**
634         * A user was invited to collaborate on a folder. This is an enterprise-only event.
635         */
636        COLLABORATION_INVITE,
637
638        /**
639         * An expiration time was set for a collaboration. This is an enterprise-only event.
640         */
641        COLLABORATION_EXPIRATION,
642
643        /**
644         * Creation of metadata instance. This is an enterprise-only event.
645         */
646        METADATA_INSTANCE_CREATE,
647
648        /**
649         * Update of metadata instance. This is an enterprise-only event.
650         */
651        METADATA_INSTANCE_UPDATE,
652
653        /**
654         * Deletion of metadata instance. This is an enterprise-only event.
655         */
656        METADATA_INSTANCE_DELETE,
657
658        /**
659         * Content Workflow upload policy violation. This is an enterprise-only event.
660         */
661        CONTENT_WORKFLOW_UPLOAD_POLICY_VIOLATION,
662
663        /**
664         * Edit the permissions on a folder.  This is an enterprise-only-event.
665         */
666        CHANGE_FOLDER_PERMISSION,
667
668        /**
669         * A task assignment is deleted.  This is an enterprise-only event.
670         */
671        TASK_ASSIGNMENT_DELETE,
672
673        /**
674         * Retention is removed.  This is an enterprise-only event.
675         */
676        DATA_RETENTION_REMOVE_RETENTION,
677
678        /**
679         * Retention is created.  This is an enterprise-only event.
680         */
681        DATA_RETENTION_CREATE_RETENTION,
682
683        /**
684         * A retention policy assignment is added.  This is an enterprise-only event.
685         */
686        RETENTION_POLICY_ASSIGNMENT_ADD,
687
688        /**
689         * A legal hold assignment is created.  This is an enterprise-only event.
690         */
691        LEGAL_HOLD_ASSIGNMENT_CREATE,
692
693        /**
694         * A legal hold assignment is deleted.  This is an enterprise-only event.
695         */
696        LEGAL_HOLD_ASSIGNMENT_DELETE,
697
698        /**
699         * A legal hold policy is deleted.  This is an enterprise-only event.
700         */
701        LEGAL_HOLD_POLICY_DELETE,
702
703        /**
704         * There is a sharing policy violation.  This is an enterprise-only event.
705         */
706        CONTENT_WORKFLOW_SHARING_POLICY_VIOLATION,
707
708        /**
709         * An application public key is added.  This is an enterprise-only event.
710         */
711        APPLICATION_PUBLIC_KEY_ADDED,
712
713        /**
714         * An application public key is deleted.  This is an enterprise-only event.
715         */
716        APPLICATION_PUBLIC_KEY_DELETED,
717
718        /**
719         * A content policy is added.  This is an enterprise-only event.
720         */
721        CONTENT_WORKFLOW_POLICY_ADD,
722
723        /**
724         * An automation is added.  This is an enterprise-only event.
725         */
726        CONTENT_WORKFLOW_AUTOMATION_ADD,
727
728        /**
729         * An automation is deleted.  This is an enterprise-only event.
730         */
731        CONTENT_WORKFLOW_AUTOMATION_DELETE,
732
733        /**
734         * A user email alias is confirmed.  This is an enterprise-only event.
735         */
736        EMAIL_ALIAS_CONFIRM,
737
738        /**
739         * A user email alias is removed.  This is an enterprise-only event.
740         */
741        EMAIL_ALIAS_REMOVE,
742
743        /**
744         * A watermark is added to a file.  This is an enterprise-only event.
745         */
746        WATERMARK_LABEL_CREATE,
747
748        /**
749         * A watermark is removed from a file.  This is an enterprise-only event.
750         */
751        WATERMARK_LABEL_DELETE,
752
753        /**
754         * Creation of metadata template instance.  This is an enterprise-only event.
755         */
756        METADATA_TEMPLATE_CREATE,
757
758        /**
759         * Update of metadata template instance.  This is an enterprise-only event.
760         */
761        METADATA_TEMPLATE_UPDATE,
762
763        /**
764         * Deletion of metadata template instance.  This is an enterprise-only event.
765         */
766        METADATA_TEMPLATE_DELETE,
767
768        /**
769         * Item was opened.  This is an enterprise-only event.
770         */
771        ITEM_OPEN,
772
773        /**
774         * Item was modified.  This is an enterprise-only event.
775         */
776        ITEM_MODIFY,
777
778        /**
779         * When a policy set in the Admin console is triggered.  This is an enterprise-only event,
780         */
781        CONTENT_WORKFLOW_ABNORMAL_DOWNLOAD_ACTIVITY,
782
783        /**
784         * Folders were removed from a group in the Admin console.  This is an enterprise-only event.
785         */
786        GROUP_REMOVE_ITEM,
787
788        /**
789         * Folders were added to a group in the Admin console.  This is an enterprise-only event.
790         */
791        GROUP_ADD_ITEM,
792
793        /**
794         * An OAuth2 access token was created for a user.  This is an enterprise-only event.
795         */
796        USER_AUTHENTICATE_OAUTH2_ACCESS_TOKEN_CREATE,
797
798        /**
799         * Event for file tag updates.
800         */
801        CONTENT_ACCESS,
802
803        /**
804         * A Shield justification is approved.
805         */
806        SHIELD_JUSTIFICATION_APPROVAL,
807
808        /**
809         * A task's comment is edited.
810         */
811        TASK_UPDATE,
812
813        /**
814         * A file is retored to previous version.
815         */
816        FILE_VERSION_RESTORE,
817
818        /**
819         * Advanced settings of a folder are updated.
820         */
821        ADVANCED_FOLDER_SETTINGS_UPDATE;
822    }
823
824    /**
825     * Enumerates the possible types for an event.
826     */
827    public enum EventType {
828        /**
829         * The type of the event is unknown.
830         */
831        UNKNOWN("UNKNOWN"),
832
833        /**
834         * An file or folder was created.
835         */
836        ITEM_CREATE("ITEM_CREATE"),
837
838        /**
839         * An file or folder was uploaded.
840         */
841        ITEM_UPLOAD("ITEM_UPLOAD"),
842
843        /**
844         * A comment was created on a folder, file, or other comment.
845         */
846        COMMENT_CREATE("COMMENT_CREATE"),
847
848        /**
849         * A comment was deleted on a folder, file, or other comment.
850         */
851        COMMENT_DELETE("COMMENT_DELETE"),
852
853        /**
854         * An file or folder was downloaded.
855         */
856        ITEM_DOWNLOAD("ITEM_DOWNLOAD"),
857
858        /**
859         * A file was previewed.
860         */
861        ITEM_PREVIEW("ITEM_PREVIEW"),
862
863        /**
864         * A file or folder was moved.
865         */
866        ITEM_MOVE("ITEM_MOVE"),
867
868        /**
869         * A file or folder was copied.
870         */
871        ITEM_COPY("ITEM_COPY"),
872
873        /**
874         * A task was assigned.
875         */
876        TASK_ASSIGNMENT_CREATE("TASK_ASSIGNMENT_CREATE"),
877
878        /**
879         * A task was assignment was completed.
880         */
881        TASK_ASSIGNMENT_COMPLETE("TASK_ASSIGNMENT_COMPLETE"),
882
883        /**
884         * A task was assignment was updated.
885         */
886        TASK_ASSIGNMENT_UPDATE("TASK_ASSIGNMENT_UPDATE"),
887
888        /**
889         * A task was created.
890         */
891        TASK_CREATE("TASK_CREATE"),
892
893        /**
894         * A file was locked.
895         */
896        LOCK_CREATE("LOCK_CREATE"),
897
898        /**
899         * A file was unlocked.
900         */
901        LOCK_DESTROY("LOCK_DESTROY"),
902
903        /**
904         * A file or folder was deleted.
905         */
906        ITEM_TRASH("ITEM_TRASH"),
907
908        /**
909         * A file or folder was recovered from the trash.
910         */
911        ITEM_UNDELETE_VIA_TRASH("ITEM_UNDELETE_VIA_TRASH"),
912
913        /**
914         * A collaborator was added to a folder.
915         */
916        COLLAB_ADD_COLLABORATOR("COLLAB_ADD_COLLABORATOR"),
917
918        /**
919         * A collaborator's role was change in a folder.
920         */
921        COLLAB_ROLE_CHANGE("COLLAB_ROLE_CHANGE"),
922
923        /**
924         * A collaborator was invited to a folder.
925         */
926        COLLAB_INVITE_COLLABORATOR("COLLAB_INVITE_COLLABORATOR"),
927
928        /**
929         * A collaborator was removed from a folder.
930         */
931        COLLAB_REMOVE_COLLABORATOR("COLLAB_REMOVE_COLLABORATOR"),
932
933        /**
934         * A folder was marked for sync.
935         */
936        ITEM_SYNC("ITEM_SYNC"),
937
938        /**
939         * A folder was un-marked for sync.
940         */
941        ITEM_UNSYNC("ITEM_UNSYNC"),
942
943        /**
944         * A file or folder was renamed.
945         */
946        ITEM_RENAME("ITEM_RENAME"),
947
948        /**
949         * A file or folder was enabled for sharing.
950         */
951        ITEM_SHARED_CREATE("ITEM_SHARED_CREATE"),
952
953        /**
954         * A file or folder was disabled for sharing.
955         */
956        ITEM_SHARED_UNSHARE("ITEM_SHARED_UNSHARE"),
957
958        /**
959         * A folder was shared.
960         */
961        ITEM_SHARED("ITEM_SHARED"),
962
963        /**
964         * A previous version of a file was promoted to the current version.
965         */
966        ITEM_MAKE_CURRENT_VERSION("ITEM_MAKE_CURRENT_VERSION"),
967
968        /**
969         * A tag was added to a file or folder.
970         */
971        TAG_ITEM_CREATE("TAG_ITEM_CREATE"),
972
973        /**
974         * 2 factor authentication enabled by user.
975         */
976        ENABLE_TWO_FACTOR_AUTH("ENABLE_TWO_FACTOR_AUTH"),
977
978        /**
979         * Free user accepts invitation to become a managed user.
980         */
981        ADMIN_INVITE_ACCEPT("MASTER_INVITE_ACCEPT"),
982
983        /**
984         * Free user rejects invitation to become a managed user.
985         */
986        ADMIN_INVITE_REJECT("MASTER_INVITE_REJECT"),
987
988        /**
989         * Granted Box access to account.
990         */
991        ACCESS_GRANTED("ACCESS_GRANTED"),
992
993        /**
994         * Revoke Box access to account.
995         */
996        ACCESS_REVOKED("ACCESS_REVOKED"),
997
998        /**
999         * A user logged in from a new device.
1000         */
1001        ADD_LOGIN_ACTIVITY_DEVICE("ADD_LOGIN_ACTIVITY_DEVICE"),
1002
1003        /**
1004         * A user session associated with an app was invalidated.
1005         */
1006        REMOVE_LOGIN_ACTIVITY_DEVICE("REMOVE_LOGIN_ACTIVITY_DEVICE"),
1007
1008        /**
1009         * An admin role changed for a user.
1010         */
1011        CHANGE_ADMIN_ROLE("CHANGE_ADMIN_ROLE"),
1012
1013        /**
1014         * A user was added to a group. This is an enterprise-only event.
1015         */
1016        GROUP_ADD_USER("GROUP_ADD_USER"),
1017
1018        /**
1019         * A user was created. This is an enterprise-only event.
1020         */
1021        NEW_USER("NEW_USER"),
1022
1023        /**
1024         * A group was created. This is an enterprise-only event.
1025         */
1026        GROUP_CREATION("GROUP_CREATION"),
1027
1028        /**
1029         * A group was deleted. This is an enterprise-only event.
1030         */
1031        GROUP_DELETION("GROUP_DELETION"),
1032
1033        /**
1034         * A user was deleted. This is an enterprise-only event.
1035         */
1036        DELETE_USER("DELETE_USER"),
1037
1038        /**
1039         * A group was edited. This is an enterprise-only event.
1040         */
1041        GROUP_EDITED("GROUP_EDITED"),
1042
1043        /**
1044         * A user was edited. This is an enterprise-only event.
1045         */
1046        EDIT_USER("EDIT_USER"),
1047
1048        /**
1049         * A group was granted access to a folder. This is an enterprise-only event.
1050         */
1051        GROUP_ADD_FOLDER("GROUP_ADD_FOLDER"),
1052
1053        /**
1054         * A group was granted access to a file. This is an enterprise-only event.
1055         */
1056        GROUP_ADD_FILE("GROUP_ADD_FILE"),
1057
1058        /**
1059         * A user was removed from a group. This is an enterprise-only event.
1060         */
1061        GROUP_REMOVE_USER("GROUP_REMOVE_USER"),
1062
1063        /**
1064         * A group had its access to a folder removed. This is an enterprise-only event.
1065         */
1066        GROUP_REMOVE_FOLDER("GROUP_REMOVE_FOLDER"),
1067
1068        /**
1069         * A group had its access to a file removed. This is an enterprise-only event.
1070         */
1071        GROUP_REMOVE_FILE("GROUP_REMOVE_FILE"),
1072
1073        /**
1074         * An administrator logged in. This is an enterprise-only event.
1075         */
1076        ADMIN_LOGIN("ADMIN_LOGIN"),
1077
1078        /**
1079         * A device was associated with a user. This is an enterprise-only event.
1080         */
1081        ADD_DEVICE_ASSOCIATION("ADD_DEVICE_ASSOCIATION"),
1082
1083        /**
1084         * There was a failed login attempt. This is an enterprise-only event.
1085         */
1086        FAILED_LOGIN("FAILED_LOGIN"),
1087
1088        /**
1089         * There was a successful login. This is an enterprise-only event.
1090         */
1091        LOGIN("LOGIN"),
1092
1093        /**
1094         * A user's OAuth2 access token was refreshed. This is an enterprise-only event.
1095         */
1096        USER_AUTHENTICATE_OAUTH2_TOKEN_REFRESH("USER_AUTHENTICATE_OAUTH2_TOKEN_REFRESH"),
1097
1098        /**
1099         * A device was disassociated with a user. This is an enterprise-only event.
1100         */
1101        REMOVE_DEVICE_ASSOCIATION("REMOVE_DEVICE_ASSOCIATION"),
1102
1103        /**
1104         * A user agreed to the terms of service. This is an enterprise-only event.
1105         */
1106        TERMS_OF_SERVICE_AGREE("TERMS_OF_SERVICE_AGREE"),
1107
1108        /**
1109         * A user rejected the terms of service. This is an enterprise-only event.
1110         */
1111        TERMS_OF_SERVICE_REJECT("TERMS_OF_SERVICE_REJECT"),
1112
1113        /**
1114         * Virus found on a file. Event is only received by enterprises that have opted in to be notified.
1115         * This is an enterprise-only event.
1116         */
1117        FILE_MARKED_MALICIOUS("FILE_MARKED_MALICIOUS"),
1118
1119        /**
1120         * An item was copied. This is an enterprise-only event.
1121         */
1122        COPY("COPY"),
1123
1124        /**
1125         * An item was deleted. This is an enterprise-only event.
1126         */
1127        DELETE("DELETE"),
1128
1129        /**
1130         * An item was downloaded. This is an enterprise-only event.
1131         */
1132        DOWNLOAD("DOWNLOAD"),
1133
1134        /**
1135         * An item was edited. This is an enterprise-only event.
1136         */
1137        EDIT("EDIT"),
1138
1139        /**
1140         * An item was locked. This is an enterprise-only event.
1141         */
1142        LOCK("LOCK"),
1143
1144        /**
1145         * An item was moved. This is an enterprise-only event.
1146         */
1147        MOVE("MOVE"),
1148
1149        /**
1150         * An item was previewed. This is an enterprise-only event.
1151         */
1152        PREVIEW("PREVIEW"),
1153
1154        /**
1155         * An item was renamed. This is an enterprise-only event.
1156         */
1157        RENAME("RENAME"),
1158
1159        /**
1160         * An item was set to be auto-deleted. This is an enterprise-only event.
1161         */
1162        STORAGE_EXPIRATION("STORAGE_EXPIRATION"),
1163
1164        /**
1165         * An item was undeleted. This is an enterprise-only event.
1166         */
1167        UNDELETE("UNDELETE"),
1168
1169        /**
1170         * An item was unlocked. This is an enterprise-only event.
1171         */
1172        UNLOCK("UNLOCK"),
1173
1174        /**
1175         * An item was uploaded. This is an enterprise-only event.
1176         */
1177        UPLOAD("UPLOAD"),
1178
1179        /**
1180         * An shared link was created for an item. This is an enterprise-only event.
1181         */
1182        SHARE("SHARE"),
1183
1184        /**
1185         * The shared link for an item was updated. This is an enterprise-only event.
1186         */
1187        ITEM_SHARED_UPDATE("ITEM_SHARED_UPDATE"),
1188
1189        /**
1190         * The expiration time for a shared link was extended. This is an enterprise-only event.
1191         */
1192        UPDATE_SHARE_EXPIRATION("UPDATE_SHARE_EXPIRATION"),
1193
1194        /**
1195         * The expiration time was set for a shared link. This is an enterprise-only event.
1196         */
1197        SHARE_EXPIRATION("SHARE_EXPIRATION"),
1198
1199        /**
1200         * The shared link for an item was REMOVE_DEVICE_ASSOCIATION. This is an enterprise-only event.
1201         */
1202        UNSHARE("UNSHARE"),
1203
1204        /**
1205         * A user accepted a collaboration invite. This is an enterprise-only event.
1206         */
1207        COLLABORATION_ACCEPT("COLLABORATION_ACCEPT"),
1208
1209        /**
1210         * A user's collaboration role was changed. This is an enterprise-only event.
1211         */
1212        COLLABORATION_ROLE_CHANGE("COLLABORATION_ROLE_CHANGE"),
1213
1214        /**
1215         * The expiration time for a collaboration was extended. This is an enterprise-only event.
1216         */
1217        UPDATE_COLLABORATION_EXPIRATION("UPDATE_COLLABORATION_EXPIRATION"),
1218
1219        /**
1220         * A collaboration was removed from a folder. This is an enterprise-only event.
1221         */
1222        COLLABORATION_REMOVE("COLLABORATION_REMOVE"),
1223
1224        /**
1225         * A user was invited to collaborate on a folder. This is an enterprise-only event.
1226         */
1227        COLLABORATION_INVITE("COLLABORATION_INVITE"),
1228
1229        /**
1230         * An expiration time was set for a collaboration. This is an enterprise-only event.
1231         */
1232        COLLABORATION_EXPIRATION("COLLABORATION_EXPIRATION"),
1233
1234        /**
1235         * Creation of metadata instance. This is an enterprise-only event.
1236         */
1237        METADATA_INSTANCE_CREATE("METADATA_INSTANCE_CREATE"),
1238
1239        /**
1240         * Update of metadata instance. This is an enterprise-only event.
1241         */
1242        METADATA_INSTANCE_UPDATE("METADATA_INSTANCE_UPDATE"),
1243
1244        /**
1245         * Deletion of metadata instance. This is an enterprise-only event.
1246         */
1247        METADATA_INSTANCE_DELETE("METADATA_INSTANCE_DELETE"),
1248
1249        /**
1250         * Content Workflow upload policy violation. This is an enterprise-only event.
1251         */
1252        CONTENT_WORKFLOW_UPLOAD_POLICY_VIOLATION("CONTENT_WORKFLOW_UPLOAD_POLICY_VIOLATION"),
1253
1254        /**
1255         * Edit the permissions on a folder.  This is an enterprise-only-event.
1256         */
1257        CHANGE_FOLDER_PERMISSION("CHANGE_FOLDER_PERMISSION"),
1258
1259        /**
1260         * A task assignment is deleted.  This is an enterprise-only event.
1261         */
1262        TASK_ASSIGNMENT_DELETE("TASK_ASSIGNMENT_DELETE"),
1263
1264        /**
1265         * Retention is removed.  This is an enterprise-only event.
1266         */
1267        DATA_RETENTION_REMOVE_RETENTION("DATA_RETENTION_REMOVE_RETENTION"),
1268
1269        /**
1270         * Retention is created.  This is an enterprise-only event.
1271         */
1272        DATA_RETENTION_CREATE_RETENTION("DATA_RETENTION_CREATE_RETENTION"),
1273
1274        /**
1275         * A retention policy assignment is added.  This is an enterprise-only event.
1276         */
1277        RETENTION_POLICY_ASSIGNMENT_ADD("RETENTION_POLICY_ASSIGNMENT_ADD"),
1278
1279        /**
1280         * A legal hold assignment is created.  This is an enterprise-only event.
1281         */
1282        LEGAL_HOLD_ASSIGNMENT_CREATE("LEGAL_HOLD_ASSIGNMENT_CREATE"),
1283
1284        /**
1285         * A legal hold assignment is deleted.  This is an enterprise-only event.
1286         */
1287        LEGAL_HOLD_ASSIGNMENT_DELETE("LEGAL_HOLD_ASSIGNMENT_DELETE"),
1288
1289        /**
1290         * A legal hold policy is deleted.  This is an enterprise-only event.
1291         */
1292        LEGAL_HOLD_POLICY_DELETE("LEGAL_HOLD_POLICY_DELETE"),
1293
1294        /**
1295         * There is a sharing policy violation.  This is an enterprise-only event.
1296         */
1297        CONTENT_WORKFLOW_SHARING_POLICY_VIOLATION("CONTENT_WORKFLOW_SHARING_POLICY_VIOLATION"),
1298
1299        /**
1300         * An application public key is added.  This is an enterprise-only event.
1301         */
1302        APPLICATION_PUBLIC_KEY_ADDED("APPLICATION_PUBLIC_KEY_ADDED"),
1303
1304        /**
1305         * An application public key is deleted.  This is an enterprise-only event.
1306         */
1307        APPLICATION_PUBLIC_KEY_DELETED("APPLICATION_PUBLIC_KEY_DELETED"),
1308
1309        /**
1310         * A content policy is added.  This is an enterprise-only event.
1311         */
1312        CONTENT_WORKFLOW_POLICY_ADD("CONTENT_WORKFLOW_POLICY_ADD"),
1313
1314        /**
1315         * An automation is added.  This is an enterprise-only event.
1316         */
1317        CONTENT_WORKFLOW_AUTOMATION_ADD("CONTENT_WORKFLOW_AUTOMATION_ADD"),
1318
1319        /**
1320         * An automation is deleted.  This is an enterprise-only event.
1321         */
1322        CONTENT_WORKFLOW_AUTOMATION_DELETE("CONTENT_WORKFLOW_AUTOMATION_DELETE"),
1323
1324        /**
1325         * A user email alias is confirmed.  This is an enterprise-only event.
1326         */
1327        EMAIL_ALIAS_CONFIRM("EMAIL_ALIAS_CONFIRM"),
1328
1329        /**
1330         * A user email alias is removed.  This is an enterprise-only event.
1331         */
1332        EMAIL_ALIAS_REMOVE("EMAIL_ALIAS_REMOVE"),
1333
1334        /**
1335         * A watermark is added to a file.  This is an enterprise-only event.
1336         */
1337        WATERMARK_LABEL_CREATE("WATERMARK_LABEL_CREATE"),
1338
1339        /**
1340         * A watermark is removed from a file.  This is an enterprise-only event.
1341         */
1342        WATERMARK_LABEL_DELETE("WATERMARK_LABEL_DELETE"),
1343
1344        /**
1345         * Creation of metadata template instance.  This is an enterprise-only event.
1346         */
1347        METADATA_TEMPLATE_CREATE("METADATA_TEMPLATE_CREATE"),
1348
1349        /**
1350         * Update of metadata template instance.  This is an enterprise-only event.
1351         */
1352        METADATA_TEMPLATE_UPDATE("METADATA_TEMPLATE_UPDATE"),
1353
1354        /**
1355         * Deletion of metadata template instance.  This is an enterprise-only event.
1356         */
1357        METADATA_TEMPLATE_DELETE("METADATA_TEMPLATE_DELETE"),
1358
1359        /**
1360         * Item was opened.  This is an enterprise-only event.
1361         */
1362        ITEM_OPEN("ITEM_OPEN"),
1363
1364        /**
1365         * Item was modified.  This is an enterprise-only event.
1366         */
1367        ITEM_MODIFY("ITEM_MODIFY"),
1368
1369        /**
1370         * When a policy set in the Admin console is triggered.  This is an enterprise-only event,
1371         */
1372        CONTENT_WORKFLOW_ABNORMAL_DOWNLOAD_ACTIVITY("CONTENT_WORKFLOW_ABNORMAL_DOWNLOAD_ACTIVITY"),
1373
1374        /**
1375         * Folders were removed from a group in the Admin console.  This is an enterprise-only event.
1376         */
1377        GROUP_REMOVE_ITEM("GROUP_REMOVE_ITEM"),
1378
1379        /**
1380         * Folders were added to a group in the Admin console.  This is an enterprise-only event.
1381         */
1382        GROUP_ADD_ITEM("GROUP_ADD_ITEM"),
1383
1384        /**
1385         * An OAuth2 access token was created for a user.  This is an enterprise-only event.
1386         */
1387        USER_AUTHENTICATE_OAUTH2_ACCESS_TOKEN_CREATE("USER_AUTHENTICATE_OAUTH2_ACCESS_TOKEN_CREATE"),
1388
1389        /**
1390         * Event for file tag updates.
1391         */
1392        CONTENT_ACCESS("CONTENT_ACCESS"),
1393
1394        /**
1395         * A Shield justification is approved.
1396         */
1397        SHIELD_JUSTIFICATION_APPROVAL("SHIELD_JUSTIFICATION_APPROVAL"),
1398
1399        /**
1400         * A task's comment is edited.
1401         */
1402        TASK_UPDATE("TASK_UPDATE"),
1403
1404        /**
1405         * A file is retored to previous version.
1406         */
1407        FILE_VERSION_RESTORE("FILE_VERSION_RESTORE"),
1408
1409        /**
1410         * Advanced settings of a folder are updated.
1411         */
1412        ADVANCED_FOLDER_SETTINGS_UPDATE("ADVANCED_FOLDER_SETTINGS_UPDATE"),
1413
1414        /**
1415         * A new application is created in the Box Developer Console.
1416         */
1417        APPLICATION_CREATED("APPLICATION_CREATED"),
1418
1419        /**
1420         * Device Trust check failed.
1421         */
1422        DEVICE_TRUST_CHECK_FAILED("DEVICE_TRUST_CHECK_FAILED"),
1423
1424        /**
1425         * When a JWT application has been authorized or reauthorized.
1426         */
1427        ENTERPRISE_APP_AUTHORIZATION_UPDATE("ENTERPRISE_APP_AUTHORIZATION_UPDATE"),
1428
1429        /**
1430         * A watermarked file is downloaded.
1431         */
1432        FILE_WATERMARKED_DOWNLOAD("FILE_WATERMARKED_DOWNLOAD"),
1433
1434        /**
1435         * A legal hold policy is created.
1436         */
1437        LEGAL_HOLD_POLICY_CREATE("LEGAL_HOLD_POLICY_CREATE"),
1438
1439        /**
1440         * A legal hold policy is updated.
1441         */
1442        LEGAL_HOLD_POLICY_UPDATE("LEGAL_HOLD_POLICY_UPDATE"),
1443
1444        /**
1445         * Shield detected an anomalous download, session, location, or malicious content based on
1446         * enterprise Shield rules. See shield alert events for more information.
1447         */
1448        SHIELD_ALERT("SHIELD_ALERT"),
1449
1450        /**
1451         * Access to an external collaboration is blocked.
1452         */
1453        SHIELD_EXTERNAL_COLLAB_ACCESS_BLOCKED("SHIELD_EXTERNAL_COLLAB_ACCESS_BLOCKED"),
1454
1455        /**
1456         * Access to an external collaboration is blocked due to missing a justification.
1457         */
1458        SHIELD_EXTERNAL_COLLAB_ACCESS_BLOCKED_MISSING_JUSTIFICATION(
1459                "SHIELD_EXTERNAL_COLLAB_ACCESS_BLOCKED_MISSING_JUSTIFICATION"),
1460
1461        /**
1462         * An invite to externally collaborate is blocked.
1463         */
1464        SHIELD_EXTERNAL_COLLAB_INVITE_BLOCKED("SHIELD_EXTERNAL_COLLAB_INVITE_BLOCKED"),
1465
1466        /**
1467         * An invite to externally collaborate is blocked due to missing a justification.
1468         */
1469        SHIELD_EXTERNAL_COLLAB_INVITE_BLOCKED_MISSING_JUSTIFICATION(
1470                "SHIELD_EXTERNAL_COLLAB_INVITE_BLOCKED_MISSING_JUSTIFICATION"),
1471
1472        /**
1473         * A sign request was sent to a signer.
1474         */
1475        SIGN_DOCUMENT_ASSIGNED("SIGN_DOCUMENT_ASSIGNED"),
1476
1477        /**
1478         * A sign request was cancelled via API or UI.
1479         */
1480        SIGN_DOCUMENT_CANCELLED("SIGN_DOCUMENT_CANCELLED"),
1481
1482        /**
1483         * A sign request was signed by all signers.
1484         */
1485        SIGN_DOCUMENT_COMPLETED("SIGN_DOCUMENT_COMPLETED"),
1486
1487        /**
1488         * A sign request was converted to a .pdf for signing.
1489         */
1490        SIGN_DOCUMENT_CONVERTED("SIGN_DOCUMENT_CONVERTED"),
1491
1492        /**
1493         * A sign request was created via API or UI. The document is not yet sent to signers.
1494         */
1495        SIGN_DOCUMENT_CREATED("SIGN_DOCUMENT_CREATED"),
1496
1497        /**
1498         * A sign request was declined by a signer.
1499         */
1500        SIGN_DOCUMENT_DECLINED("SIGN_DOCUMENT_DECLINED"),
1501
1502        /**
1503         * A sign request expired with incomplete signatures.
1504         */
1505        SIGN_DOCUMENT_EXPIRED("SIGN_DOCUMENT_EXPIRED"),
1506
1507        /**
1508         * A sign request was signed by a signer.
1509         */
1510        SIGN_DOCUMENT_SIGNED("SIGN_DOCUMENT_SIGNED"),
1511
1512        /**
1513         * A signer clicked on Review Document in the signer email or visited the signing URL.
1514         */
1515        SIGN_DOCUMENT_VIEWED_BY_SIGNER("SIGN_DOCUMENT_VIEWED_BY_SIGNER"),
1516
1517        /**
1518         * A signer downloaded the signing document.
1519         */
1520        SIGNER_DOWNLOADED("SIGNER_DOWNLOADED"),
1521
1522        /**
1523         * A signer forwarded the signing document.
1524         */
1525        SIGNER_FORWARDED("SIGNER_FORWARDED"),
1526
1527        /**
1528         * Accepted terms.
1529         */
1530        TERMS_OF_SERVICE_ACCEPT("TERMS_OF_SERVICE_ACCEPT");
1531
1532        /**
1533         * Static map of all EventTypes.
1534         */
1535        private static final Map<String, BoxEvent.EventType> EVENT_TYPE_MAP = new HashMap<>(EventType.values().length);
1536
1537        /**
1538         * EVENT_TYPE_MAP initialization.
1539         */
1540        static {
1541            for (BoxEvent.EventType event : BoxEvent.EventType.values()) {
1542                EVENT_TYPE_MAP.put(event.jsonValue, event);
1543            }
1544        }
1545
1546        /**
1547         * String representation of the eventType.
1548         */
1549        private final String jsonValue;
1550
1551        /**
1552         * Constructor.
1553         *
1554         * @param jsonValue string representation of the eventType.
1555         */
1556        EventType(String jsonValue) {
1557            this.jsonValue = jsonValue;
1558        }
1559
1560        /**
1561         * Custom implementation of valueOf().
1562         *
1563         * @param jsonValue of the EventType.
1564         * @return EventType.
1565         */
1566        static BoxEvent.EventType lookupByValue(String jsonValue) {
1567            return EVENT_TYPE_MAP.get(jsonValue);
1568        }
1569
1570        /**
1571         * @return string representation of the eventType.
1572         */
1573        String toJSONString() {
1574            return this.jsonValue;
1575        }
1576    }
1577}