public class EventLog extends Object implements Iterable<BoxEvent>
An EventLog cannot be instantiated directly. Instead, use one of the static methods to retrieve a log of events.
Unlike the EventStream
class, EventLog doesn't support retrieving events in real-time.
Modifier and Type | Field and Description |
---|---|
static URLTemplate |
ENTERPRISE_EVENT_URL_TEMPLATE
Enterprise Event URL Template.
|
Modifier and Type | Method and Description |
---|---|
int |
getChunkSize()
Gets the number of events in this log, including duplicate events.
|
Date |
getEndDate()
Gets the date of the latest event in this log.
|
static EventLog |
getEnterpriseEvents(BoxAPIConnection api,
Date after,
Date before,
BoxEvent.Type... types)
Deprecated.
|
static EventLog |
getEnterpriseEvents(BoxAPIConnection api,
EnterpriseEventsRequest enterpriseEventsRequest)
|
static EventLog |
getEnterpriseEvents(BoxAPIConnection api,
String position,
Date after,
Date before,
BoxEvent.Type... types)
Deprecated.
|
static EventLog |
getEnterpriseEvents(BoxAPIConnection api,
String position,
Date after,
Date before,
int limit,
BoxEvent.Type... types)
Deprecated.
|
static EventLog |
getEnterpriseEventsStream(BoxAPIConnection api,
EnterpriseEventsStreamRequest enterpriseEventsStreamRequest)
|
int |
getLimit()
Gets the maximum number of events that this event log could contain given its start date, end date, and stream
position.
|
String |
getNextStreamPosition()
Gets the next position within the event stream for retrieving subsequent events.
|
int |
getSize()
Gets the number of events in this list, excluding duplicate events.
|
Date |
getStartDate()
Gets the date of the earliest event in this log.
|
String |
getStreamPosition()
Gets the starting position of the events in this log within the event stream.
|
Iterator<BoxEvent> |
iterator()
Returns an iterator over the events in this log.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public static final URLTemplate ENTERPRISE_EVENT_URL_TEMPLATE
@Deprecated public static EventLog getEnterpriseEvents(BoxAPIConnection api, String position, Date after, Date before, BoxEvent.Type... types)
getEnterpriseEvents(BoxAPIConnection, EnterpriseEventsRequest)
api
- the API connection to use.position
- the starting position of the event stream.after
- the lower bound on the timestamp of the events returned.before
- the upper bound on the timestamp of the events returned.types
- an optional list of event types to filter by.@Deprecated public static EventLog getEnterpriseEvents(BoxAPIConnection api, Date after, Date before, BoxEvent.Type... types)
getEnterpriseEvents(BoxAPIConnection, EnterpriseEventsRequest)
api
- the API connection to use.after
- the lower bound on the timestamp of the events returned.before
- the upper bound on the timestamp of the events returned.types
- an optional list of event types to filter by.@Deprecated public static EventLog getEnterpriseEvents(BoxAPIConnection api, String position, Date after, Date before, int limit, BoxEvent.Type... types)
getEnterpriseEvents(BoxAPIConnection, EnterpriseEventsRequest)
api
- the API connection to use.position
- the starting position of the event stream.after
- the lower bound on the timestamp of the events returned.before
- the upper bound on the timestamp of the events returned.limit
- the number of entries to be returned in the response.types
- an optional list of event types to filter by.public static EventLog getEnterpriseEvents(BoxAPIConnection api, EnterpriseEventsRequest enterpriseEventsRequest)
BoxEvent
Iterator
.
The emphasis for this stream is on completeness over latency,
which means that Box will deliver admin events in chronological order and without duplicates,
but with higher latency. You can specify start and end time/dates. This method
will only work with an API connection for an enterprise admin account
or service account with manage enterprise properties.
You can specify a date range to limit when events occured, starting from a given position within the
event stream, set limit or specify event types that should be filtered.
Example:
EnterpriseEventsRequest request = new EnterpriseEventsRequest()
.after(after) // The lower bound on the timestamp of the events returned.
.before(before) // The upper bound on the timestamp of the events returned.
.limit(20) // The number of entries to be returned in the response.
.position(position) // The starting position of the event stream.
.types(EventType.LOGIN, EventType.FAILED_LOGIN); // List of event types to filter by.
EventLog.getEnterpriseEvents(api, request);
api
- the API connection to use.enterpriseEventsRequest
- request to get events.public static EventLog getEnterpriseEventsStream(BoxAPIConnection api, EnterpriseEventsStreamRequest enterpriseEventsStreamRequest)
BoxEvent
Iterator
The emphasis for this feed is on low latency rather than chronological accuracy, which means that Box may return
events more than once and out of chronological order. Events are returned via the API around 12 seconds after they
are processed by Box (the 12 seconds buffer ensures that new events are not written after your cursor position).
Only two weeks of events are available via this feed, and you cannot set start and end time/dates. This method
will only work with an API connection for an enterprise admin account
or service account with manage enterprise properties.
You can specify a starting from a given position within the event stream,
set limit or specify event types that should be filtered.
Example:
EnterpriseEventsStreamRequest request = new EnterpriseEventsStreamRequest()
.limit(200) // The number of entries to be returned in the response.
.position(position) // The starting position of the event stream.
.types(EventType.LOGIN, EventType.FAILED_LOGIN); // List of event types to filter by.
EventLog.getEnterpriseEventsStream(api, request);
api
- the API connection to use.enterpriseEventsStreamRequest
- request to get events.public Date getStartDate()
The value returned by this method corresponds to the created_after
URL parameter that was used
when retrieving the events in this EventLog.
public Date getEndDate()
The value returned by this method corresponds to the created_before
URL parameter that was used
when retrieving the events in this EventLog.
public int getLimit()
The value returned by this method corresponds to the limit
URL parameter that was used when
retrieving the events in this EventLog.
public String getStreamPosition()
The value returned by this method corresponds to the stream_position
URL parameter that was used
when retrieving the events in this EventLog.
public String getNextStreamPosition()
The value returned by this method corresponds to the next_stream_position
field returned by the
API's events endpoint.
public int getChunkSize()
The chunk size may not be representative of the number of events returned by this EventLog's iterator because the iterator will automatically ignore duplicate events.
The value returned by this method corresponds to the chunk_size
field returned by the API's
events endpoint.
public int getSize()
The size is guaranteed to be representative of the number of events returned by this EventLog's iterator.