Skip to content
Merged
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.env
.env.local
**/.speakeasy/temp/
**/.speakeasy/logs/
# Ignore Gradle project-specific cache directory
Expand Down
419 changes: 361 additions & 58 deletions .speakeasy/gen.lock

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions .speakeasy/gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,28 @@ generation:
auth:
oAuth2ClientCredentialsEnabled: true
oAuth2PasswordEnabled: true
hoistGlobalSecurity: true
tests:
generateTests: true
generateNewTests: false
skipResponseBodyAssertions: false
java:
version: 0.8.0
version: 0.9.0
additionalDependencies: []
additionalPlugins: []
artifactID: glean-api-client
asyncMode: enabled
baseErrorName: GleanError
clientServerStatusCodesAsErrors: true
companyEmail: support@glean.com
companyName: Glean
companyURL: https://www.glean.com
defaultErrorName: APIException
enableAsync: false
enableCustomCodeRegions: false
enableStreamingUploads: false
envVarPrefix: GLEAN
flattenGlobalSecurity: true
generateSpringBootStarter: true
githubURL: github.com/gleanwork/api-client-java
groupID: com.glean.api-client
imports:
Expand Down
202 changes: 190 additions & 12 deletions .speakeasy/glean-merged-spec.yaml

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions .speakeasy/workflow.lock
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
speakeasyVersion: 1.603.0
speakeasyVersion: 1.625.0
sources:
Glean API:
sourceNamespace: glean-api-specs
sourceRevisionDigest: sha256:8f18d79a0a7d8f51de7edd5bc8ca3ccc569b81832ffc44ce95a27a12e67b9b7d
sourceBlobDigest: sha256:bb3e5a453f03cbdecf3fb3925768ef4cb0b3119083d9d36c341e1ecd721cde8b
sourceRevisionDigest: sha256:a9b49b3146d88faffb25761f988ab0445ed0366b84774a13d4754cb0eb7a3b9b
sourceBlobDigest: sha256:4408853be9bce04865c08fd37b8c11320ffd3b79ef0c70ca8fa1791df0679b1f
tags:
- latest
- speakeasy-sdk-regen-1752597383
- speakeasy-sdk-regen-1758751980
Glean-OAS:
sourceNamespace: glean-oas
sourceRevisionDigest: sha256:8841834dd58ddd4e2dcf98fc90fbd06fbf3626a29df941503cce55b9548a5317
Expand All @@ -18,10 +18,10 @@ targets:
glean:
source: Glean API
sourceNamespace: glean-api-specs
sourceRevisionDigest: sha256:8f18d79a0a7d8f51de7edd5bc8ca3ccc569b81832ffc44ce95a27a12e67b9b7d
sourceBlobDigest: sha256:bb3e5a453f03cbdecf3fb3925768ef4cb0b3119083d9d36c341e1ecd721cde8b
sourceRevisionDigest: sha256:a9b49b3146d88faffb25761f988ab0445ed0366b84774a13d4754cb0eb7a3b9b
sourceBlobDigest: sha256:4408853be9bce04865c08fd37b8c11320ffd3b79ef0c70ca8fa1791df0679b1f
codeSamplesNamespace: glean-api-specs-java-code-samples
codeSamplesRevisionDigest: sha256:e2f179bd27ebe8ef2e5db4899dbce44b41be5a1a46f7d62f7df45af109b6df27
codeSamplesRevisionDigest: sha256:c3c55caaa1b1a73bebecf700f844ac1297cd8b9cfe05af2e96def4b62243b444
workflow:
workflowVersion: 1.0.0
speakeasyVersion: latest
Expand Down
133 changes: 128 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Remember that each namespace requires its own authentication token type as descr
* [Unified SDK Architecture](#unified-sdk-architecture)
* [SDK Installation](#sdk-installation)
* [SDK Example Usage](#sdk-example-usage)
* [Asynchronous Support](#asynchronous-support)
* [Authentication](#authentication)
* [Available Resources and Operations](#available-resources-and-operations)
* [Error Handling](#error-handling)
Expand All @@ -63,15 +64,15 @@ The samples below show how a published SDK artifact is used:

Gradle:
```groovy
implementation 'com.glean.api-client:glean-api-client:0.8.0'
implementation 'com.glean.api-client:glean-api-client:0.9.0'
```

Maven:
```xml
<dependency>
<groupId>com.glean.api-client</groupId>
<artifactId>glean-api-client</artifactId>
<version>0.8.0</version>
<version>0.9.0</version>
</dependency>
```

Expand Down Expand Up @@ -116,7 +117,6 @@ public class Application {
.chatRequest(ChatRequest.builder()
.messages(List.of(
ChatMessage.builder()
.author(Author.USER)
.fragments(List.of(
ChatMessageFragment.builder()
.text("What are the company holidays this year?")
Expand Down Expand Up @@ -155,7 +155,6 @@ public class Application {
.chatRequest(ChatRequest.builder()
.messages(List.of(
ChatMessage.builder()
.author(Author.USER)
.fragments(List.of(
ChatMessageFragment.builder()
.text("What are the company holidays this year?")
Expand All @@ -170,8 +169,132 @@ public class Application {
}
}
```
#### Asynchronous Call
An asynchronous SDK client is also available that returns a [`CompletableFuture<T>`][comp-fut]. See [Asynchronous Support](#asynchronous-support) for more details on async benefits and reactive library integration.
```java
package hello.world;

import com.glean.api_client.glean_api_client.AsyncGlean;
import com.glean.api_client.glean_api_client.Glean;
import com.glean.api_client.glean_api_client.models.components.*;
import com.glean.api_client.glean_api_client.models.operations.async.ActivityResponse;
import java.time.OffsetDateTime;
import java.util.List;
import java.util.concurrent.CompletableFuture;

public class Application {

public static void main(String[] args) {

AsyncGlean sdk = Glean.builder()
.apiToken(System.getenv().getOrDefault("GLEAN_API_TOKEN", ""))
.build()
.async();

Activity req = Activity.builder()
.events(List.of(
ActivityEvent.builder()
.action(ActivityEventAction.HISTORICAL_VIEW)
.timestamp(OffsetDateTime.parse("2000-01-23T04:56:07.000Z"))
.url("https://example.com/")
.build(),
ActivityEvent.builder()
.action(ActivityEventAction.SEARCH)
.timestamp(OffsetDateTime.parse("2000-01-23T04:56:07.000Z"))
.url("https://example.com/search?q=query")
.params(ActivityEventParams.builder()
.query("query")
.build())
.build(),
ActivityEvent.builder()
.action(ActivityEventAction.VIEW)
.timestamp(OffsetDateTime.parse("2000-01-23T04:56:07.000Z"))
.url("https://example.com/")
.params(ActivityEventParams.builder()
.duration(20L)
.referrer("https://example.com/document")
.build())
.build()))
.build();

CompletableFuture<ActivityResponse> resFut = sdk.client().activity().report()
.request(req)
.call();

// handle response
}
}
```

[comp-fut]: https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CompletableFuture.html
<!-- End SDK Example Usage [usage] -->

<!-- Start Asynchronous Support [async-support] -->
## Asynchronous Support

The SDK provides comprehensive asynchronous support using Java's [`CompletableFuture<T>`][comp-fut] and [Reactive Streams `Publisher<T>`][reactive-streams] APIs. This design makes no assumptions about your choice of reactive toolkit, allowing seamless integration with any reactive library.

<details>
<summary>Why Use Async?</summary>

Asynchronous operations provide several key benefits:

- **Non-blocking I/O**: Your threads stay free for other work while operations are in flight
- **Better resource utilization**: Handle more concurrent operations with fewer threads
- **Improved scalability**: Build highly responsive applications that can handle thousands of concurrent requests
- **Reactive integration**: Works seamlessly with reactive streams and backpressure handling

</details>

<details>
<summary>Reactive Library Integration</summary>

The SDK returns [Reactive Streams `Publisher<T>`][reactive-streams] instances for operations dealing with streams involving multiple I/O interactions. We use Reactive Streams instead of JDK Flow API to provide broader compatibility with the reactive ecosystem, as most reactive libraries natively support Reactive Streams.

**Why Reactive Streams over JDK Flow?**
- **Broader ecosystem compatibility**: Most reactive libraries (Project Reactor, RxJava, Akka Streams, etc.) natively support Reactive Streams
- **Industry standard**: Reactive Streams is the de facto standard for reactive programming in Java
- **Better interoperability**: Seamless integration without additional adapters for most use cases

**Integration with Popular Libraries:**
- **Project Reactor**: Use `Flux.from(publisher)` to convert to Reactor types
- **RxJava**: Use `Flowable.fromPublisher(publisher)` for RxJava integration
- **Akka Streams**: Use `Source.fromPublisher(publisher)` for Akka Streams integration
- **Vert.x**: Use `ReadStream.fromPublisher(vertx, publisher)` for Vert.x reactive streams
- **Mutiny**: Use `Multi.createFrom().publisher(publisher)` for Quarkus Mutiny integration

**For JDK Flow API Integration:**
If you need JDK Flow API compatibility (e.g., for Quarkus/Mutiny 2), you can use adapters:
```java
// Convert Reactive Streams Publisher to Flow Publisher
Flow.Publisher<T> flowPublisher = FlowAdapters.toFlowPublisher(reactiveStreamsPublisher);

// Convert Flow Publisher to Reactive Streams Publisher
Publisher<T> reactiveStreamsPublisher = FlowAdapters.toPublisher(flowPublisher);
```

For standard single-response operations, the SDK returns `CompletableFuture<T>` for straightforward async execution.

</details>

<details>
<summary>Supported Operations</summary>

Async support is available for:

- **[Server-sent Events](#server-sent-event-streaming)**: Stream real-time events with Reactive Streams `Publisher<T>`
- **[JSONL Streaming](#jsonl-streaming)**: Process streaming JSON lines asynchronously
- **[Pagination](#pagination)**: Iterate through paginated results using `callAsPublisher()` and `callAsPublisherUnwrapped()`
- **[File Uploads](#file-uploads)**: Upload files asynchronously with progress tracking
- **[File Downloads](#file-downloads)**: Download files asynchronously with streaming support
- **[Standard Operations](#example)**: All regular API calls return `CompletableFuture<T>` for async execution

</details>

[comp-fut]: https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CompletableFuture.html
[reactive-streams]: https://www.reactive-streams.org/
<!-- End Asynchronous Support [async-support] -->

<!-- Start Authentication [security] -->
## Authentication

Expand Down Expand Up @@ -1112,7 +1235,7 @@ public class Application {
.request(req)
.call();

if (res.createCollectionResponse().isPresent()) {
if (res.oneOf().isPresent()) {
// handle response
}
}
Expand Down
12 changes: 11 additions & 1 deletion RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,14 @@ Based on:
### Generated
- [java v0.8.0] .
### Releases
- [Maven Central v0.8.0] https://central.sonatype.com/artifact/com.glean.api-client/glean-api-client/0.8.0 - .
- [Maven Central v0.8.0] https://central.sonatype.com/artifact/com.glean.api-client/glean-api-client/0.8.0 - .

## 2025-09-24 22:12:38
### Changes
Based on:
- OpenAPI Doc
- Speakeasy CLI 1.625.0 (2.715.0) https://github.com/speakeasy-api/speakeasy
### Generated
- [java v0.9.0] .
### Releases
- [Maven Central v0.9.0] https://central.sonatype.com/artifact/com.glean.api-client/glean-api-client/0.9.0 - .
2 changes: 0 additions & 2 deletions USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public class Application {
.chatRequest(ChatRequest.builder()
.messages(List.of(
ChatMessage.builder()
.author(Author.USER)
.fragments(List.of(
ChatMessageFragment.builder()
.text("What are the company holidays this year?")
Expand Down Expand Up @@ -57,7 +56,6 @@ public class Application {
.chatRequest(ChatRequest.builder()
.messages(List.of(
ChatMessage.builder()
.author(Author.USER)
.fragments(List.of(
ChatMessageFragment.builder()
.text("What are the company holidays this year?")
Expand Down
Loading