Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .codegen.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "engineHash": "91b0f90", "specHash": "ec8720b", "version": "0.1.0" }
{ "engineHash": "fa469c0", "specHash": "ec8720b", "version": "0.1.0" }
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Browse the [docs](docs/README.md) or see [API Reference](https://developer.box.c

# Upgrades

The SDK is updated regularly to include new features, enhancements, and bug fixes. If you are upgrading from manual SDK to this new generated SDK checkout the [migration guide](MIGRATION_GUIDE.md) and [changelog](CHANGELOG.md) for more information.
The SDK is updated regularly to include new features, enhancements, and bug fixes. If you are upgrading from manual SDK to this new generated SDK checkout the [migration guide](migration-guides/from-v4-to-v10.md) and [changelog](CHANGELOG.md) for more information.

# Integration Tests

Expand Down
29 changes: 29 additions & 0 deletions docs/EventStream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Event Stream

The Event Stream class utilizes long-polling to receive real-time events from Box. The SDK provides an easy way to set up and manage the event stream which returns an iterable object and yields events as they are received.

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

- [Event Stream](#event-stream)
- [Listening to the Event Stream](#listening-to-the-event-stream)
- [Deduplication](#deduplication)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

## Listening to the Event Stream

When the `EventStream` is started, it will begin long-polling asynchronously. Events received from the API are then yielded to the caller.

```java
EventStream stream = client.getEvents().getEventStream();
for (Event event : stream) {
System.out.printf(
"Received event: ID=%s, Type=%s, CreatedAt=%s%n\n",event.getEventId(),event.getEventType(),event.getCreatedAt());
}

```

## Deduplication

The `EventStream` class automatically deduplicates events based on their `eventId`. This means that if the same event is received multiple times, it will only be emitted once to the listeners.
28 changes: 28 additions & 0 deletions docs/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

- [Get events long poll endpoint](#get-events-long-poll-endpoint)
- [List user and enterprise events](#list-user-and-enterprise-events)
- [Get event stream](#get-event-stream)

## Get events long poll endpoint

Expand Down Expand Up @@ -107,3 +108,30 @@ chunk, as well as the next `stream_position` that can be
queried.


## Get event stream

Get an event stream for the Box API

This operation is performed by calling function `getEventStream`.



```
client.getEvents().getEventStream()
```

### Arguments

- queryParams `GetEventStreamQueryParams`
- Query parameters of getEvents method
- headers `GetEventStreamHeaders`
- Headers of getEvents method


### Returns

This function returns a value of type `EventStream`.




149 changes: 149 additions & 0 deletions migration-guides/from-box-java-sdk-gen-v0-to-box-java-sdk-v10.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
# Migration guide from beta release (v0.X.Y) of the `box-java-sdk-gen` to the v10 version of the `box-java-sdk`

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

- [Installation](#installation)
- [How to migrate](#how-to-migrate)
- [Maven](#maven)
- [Gradle](#gradle)
- [Union classes name changes](#union-classes-name-changes)
- [How to migrate](#how-to-migrate-1)
- [Removed unused models from schemas namespace](#removed-unused-models-from-schemas-namespace)
- [How to migrate](#how-to-migrate-2)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

## Installation

In order to start using v10 version of the Box Java SDK, you need to change the dependency in your project.
The artifact name has changed from `com.box:box-java-sdk-gen` to `com.box:box-java-sdk`.
You also need to set the version to `10.0.0` or higher. You can find the latest version on [Maven Central](https://search.maven.org/artifact/com.box/box-java-sdk).

### How to migrate

#### Maven

To start using v10 version of Box Java SDK in your Maven project replace the dependency in your `pom.xml` file.

**Old (`box-java-sdk-gen-v0`)**

```xml
<dependency>
<groupId>com.box</groupId>
<artifactId>box-java-sdk-gen</artifactId>
<version>0.8.0</version>
</dependency>
```

**New (`box-java-sdk-v10`)**

```xml
<dependency>
<groupId>com.box</groupId>
<artifactId>box-java-sdk</artifactId>
<version>10.0.0</version>
</dependency>
```

#### Gradle

To start using v10 version of Box Java SDK in your Gradle project replace the dependency in your `build.gradle` file.

**Old (`box-java-sdk-gen-v0`)**

```groovy
implementation 'com.box:box-java-sdk-gen:0.8.0'
```

**New (`box-java-sdk-v10`)**

```groovy
implementation 'com.box:box-java-sdk:10.0.0'
```

## Union classes name changes

In the beta version of the `box-java-sdk-gen` our `OneOf` class names (representing unions from the OpenAPI specification)
were fully auto-generated based on the included variants. This often resulted in overly long names that were difficult
to work with in tools like Git. For example: `MetadataFieldFilterDateRangeOrMetadataFieldFilterFloatRangeOrArrayOfStringOrNumberOrString`.
Additionally, every time the new variant was added to the `OneOf`, the class name itself changed.
Starting in v10, the names of `OneOf` classes are defined directly in the specification. This ensures that they are meaningful, short, and stable over time.

### How to migrate

If your code references any of the renamed classes, replace the old name with the new one.
If you were not explicitly using the type names, no changes are needed, since only the class names changed and their behavior remains the same.

List of changed `OneOf` classes and types associated with them:

| Old name | New name |
| ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------ |
| AiAgentAskOrAiAgentExtractOrAiAgentExtractStructuredOrAiAgentTextGen | AiAgent |
| AiAgentAskOrAiAgentReference | AiAskAgent |
| AiAgentExtractOrAiAgentReference | AiExtractAgent |
| AiAgentExtractStructuredOrAiAgentReference | AiExtractStructuredAgent |
| AiAgentReferenceOrAiAgentTextGen | AiTextGenAgent |
| AppItemEventSourceOrEventSourceOrFileOrFolderOrGenericSourceOrUser | EventSourceResource |
| FileBaseOrFolderBaseOrWebLinkBase | AppItemAssociatedItem |
| FileFullOrFolderFull | MetadataQueryResultItem |
| FileFullOrFolderFullOrWebLink | SearchResultWithSharedLinkItem/RecentItemResource/SearchResultItem |
| FileFullOrFolderMiniOrWebLink | Item |
| FileMiniOrFolderMini | Resource |
| FileOrFolderOrWebLink | LegalHoldPolicyAssignedItem/CollaborationItem |
| FileOrFolderScope | ResourceScope |
| FileOrFolderScopeScopeField | ResourceScopeScopeField |
| FileReferenceOrFolderReferenceOrWeblinkReferenceV2025R0 | HubItemReferenceV2025R0 |
| GroupMiniOrUserCollaborations | CollaborationAccessGrantee |
| IntegrationMappingPartnerItemSlackUnion | IntegrationMappingPartnerItemSlack |
| IntegrationMappingPartnerItemTeamsUnion | IntegrationMappingPartnerItemTeams |
| KeywordSkillCardOrStatusSkillCardOrTimelineSkillCardOrTranscriptSkillCard | SkillCard |
| MetadataFieldFilterDateRangeOrMetadataFieldFilterFloatRangeOrArrayOfStringOrNumberOrString | MetadataFilterValue |
| SearchResultsOrSearchResultsWithSharedLinks | SearchResultsResponse |

Some classes were split into multiple ones depending on context.

Manager functions affected by these changes:

| Function | Old return type | New return type |
| -------------------------------------- | -------------------------------------------------------------------- | --------------------- |
| AiManager.getAiAgentDefaultConfig(...) | AiAgentAskOrAiAgentExtractOrAiAgentExtractStructuredOrAiAgentTextGen | AiAgent |
| SearchManager.searchForContent(...) | SearchResultsOrSearchResultsWithSharedLinks | SearchResultsResponse |

## Removed unused models from schemas namespace

Several unused types (classes and enums) have been removed from the schemas because they were not used by any SDK functions or by the Box API.

### How to migrate

Here is the full list of removed types:

| Removed classes/enums |
| ------------------------------------------ |
| FileOrFolder |
| HubActionV2025R0 |
| MetadataQueryIndex |
| MetadataQueryIndexFieldsField |
| MetadataQueryIndexFieldsSortDirectionField |
| MetadataQueryIndexStatusField |
| RetentionPolicyAssignmentBase |
| RetentionPolicyAssignmentBaseTypeField |
| SkillInvocation |
| SkillInvocationEnterpriseField |
| SkillInvocationEnterpriseTypeField |
| SkillInvocationSkillField |
| SkillInvocationSkillTypeField |
| SkillInvocationStatusField |
| SkillInvocationStatusStateField |
| SkillInvocationTokenField |
| SkillInvocationTokenReadField |
| SkillInvocationTokenReadTokenTypeField |
| SkillInvocationTokenWriteField |
| SkillInvocationTokenWriteTokenTypeField |
| SkillInvocationTypeField |
| WebhookInvocation |
| WebhookInvocationTriggerField |
| WebhookInvocationTypeField |
| WorkflowFull |

If your code references any of these types, remove those references.
File renamed without changes.
47 changes: 47 additions & 0 deletions src/main/java/com/box/sdkgen/box/eventstream/EventStream.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.box.sdkgen.box.eventstream;

import com.box.sdkgen.managers.events.EventsManager;
import com.box.sdkgen.managers.events.GetEventStreamHeaders;
import com.box.sdkgen.managers.events.GetEventStreamQueryParams;
import com.box.sdkgen.schemas.event.Event;
import java.util.Iterator;

public class EventStream implements Iterable<Event> {

EventStreamIterator iterator;

private EventStream(Builder builder) {
this.iterator =
new EventStreamIterator(builder.eventsManager, builder.queryParams, builder.headersInput);
}

@Override
public Iterator<Event> iterator() {
return this.iterator;
}

public void stop() {
this.iterator.stop();
}

public static class Builder {
final EventsManager eventsManager;
final GetEventStreamQueryParams queryParams;
GetEventStreamHeaders headersInput;

public Builder(EventsManager eventsManager, GetEventStreamQueryParams queryParams) {
this.eventsManager = eventsManager;
this.queryParams = queryParams;
this.headersInput = new GetEventStreamHeaders();
}

public Builder headersInput(GetEventStreamHeaders headersInput) {
this.headersInput = headersInput != null ? headersInput : new GetEventStreamHeaders();
return this;
}

public EventStream build() {
return new EventStream(this);
}
}
}
Loading