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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@ on:
- 'integrated/**'
- 'stl-preview-head/**'
- 'stl-preview-base/**'
pull_request:
branches-ignore:
- 'stl-preview-head/**'
- 'stl-preview-base/**'

jobs:
lint:
timeout-minutes: 10
name: lint
runs-on: ${{ github.repository == 'stainless-sdks/orb-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork

steps:
- uses: actions/checkout@v4
Expand All @@ -35,6 +40,7 @@ jobs:
timeout-minutes: 10
name: test
runs-on: ${{ github.repository == 'stainless-sdks/orb-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
steps:
- uses: actions/checkout@v4

Expand Down
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "1.0.0"
".": "1.1.0"
}
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 116
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-c2a4808c828c8288c5c8dfe2fdfa51d4d7c1bcc33cacc6b859d0cf4b35ce95cc.yml
openapi_spec_hash: a2b5a1bfabbd03dd1b411791576eb502
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-ff68c7ee2669d61716781d01b93f34186fb7a19ff4ad6fc2c0b8f9f4d9c4a588.yml
openapi_spec_hash: 17bdc6b1ca2531dc884c6d156f404f0c
config_hash: 3c3524be9607afb24d2139ce26ce5389
32 changes: 32 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,37 @@
# Changelog

## 1.1.0 (2025-07-02)

Full Changelog: [v1.0.0...v1.1.0](https://github.com/orbcorp/orb-java/compare/v1.0.0...v1.1.0)

### Features

* **api:** api update ([91c85d4](https://github.com/orbcorp/orb-java/commit/91c85d496a9d4e2f7597a52f193df49012bfe53b))
* **api:** api update ([e58761c](https://github.com/orbcorp/orb-java/commit/e58761cd2e36bfa66ec1f17d05428acf2299653a))
* **api:** api update ([83c2707](https://github.com/orbcorp/orb-java/commit/83c2707bc9dd85f14df2c31e2837fd6c43e3349e))
* **api:** api update ([614dfad](https://github.com/orbcorp/orb-java/commit/614dfad8313393787778319ff46860ad2c548aa5))
* **client:** add a `withOptions` method ([744d7a6](https://github.com/orbcorp/orb-java/commit/744d7a67931d92a891bea1ff58140de71fca9eb8))
* **client:** implement per-endpoint base URL support ([6172f77](https://github.com/orbcorp/orb-java/commit/6172f770b4a6ccbb41f5748aee9164f8071036d7))


### Bug Fixes

* **ci:** release-doctor — report correct token name ([d631afb](https://github.com/orbcorp/orb-java/commit/d631afbee08819fa5febba75d799ebbbc688f0b9))
* **client:** bump max requests per host to max requests (5 -> 64) ([5576ea4](https://github.com/orbcorp/orb-java/commit/5576ea4d94771c0003e8f13d503cbef46a7c8221))
* **client:** don't close client on `withOptions` usage when original is gc'd ([002c10d](https://github.com/orbcorp/orb-java/commit/002c10dd581d1e95da9431baf6c157c878db04d8))


### Chores

* **ci:** enable for pull requests ([ecdbbd4](https://github.com/orbcorp/orb-java/commit/ecdbbd4212a2bcb27d7ec96013d3a6487751372c))
* **ci:** only run for pushes and fork pull requests ([cbc078a](https://github.com/orbcorp/orb-java/commit/cbc078ac5bf69fbfa3c6f165441f58cb4d493c93))
* fix formatting ([fe0ad84](https://github.com/orbcorp/orb-java/commit/fe0ad84fdeb583979218fddfc2e17d7aeab19421))


### Refactors

* **internal:** minor `ClientOptionsTest` change ([d7614c8](https://github.com/orbcorp/orb-java/commit/d7614c8bb5048cfb430094f7ae3cc877a0627aad))

## 1.0.0 (2025-06-09)

Full Changelog: [v0.57.0...v1.0.0](https://github.com/orbcorp/orb-java/compare/v0.57.0...v1.0.0)
Expand Down
21 changes: 18 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<!-- x-release-please-start-version -->

[![Maven Central](https://img.shields.io/maven-central/v/com.withorb.api/orb-java)](https://central.sonatype.com/artifact/com.withorb.api/orb-java/1.0.0)
[![Maven Central](https://img.shields.io/maven-central/v/com.withorb.api/orb-java)](https://central.sonatype.com/artifact/com.withorb.api/orb-java/1.1.0)

<!-- x-release-please-end -->

Expand All @@ -19,7 +19,7 @@ The REST API documentation can be found on [docs.withorb.com](https://docs.witho
### Gradle

```kotlin
implementation("com.withorb.api:orb-java:1.0.0")
implementation("com.withorb.api:orb-java:1.1.0")
```

### Maven
Expand All @@ -28,7 +28,7 @@ implementation("com.withorb.api:orb-java:1.0.0")
<dependency>
<groupId>com.withorb.api</groupId>
<artifactId>orb-java</artifactId>
<version>1.0.0</version>
<version>1.1.0</version>
</dependency>
```

Expand Down Expand Up @@ -104,6 +104,21 @@ See this table for the available options:
> Don't create more than one client in the same application. Each client has a connection pool and
> thread pools, which are more efficient to share between requests.

### Modifying configuration

To temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service:

```java
import com.withorb.api.client.OrbClient;

OrbClient clientWithOptions = client.withOptions(optionsBuilder -> {
optionsBuilder.baseUrl("https://example.com");
optionsBuilder.maxRetries(42);
});
```

The `withOptions()` method does not affect the original client or service.

## Requests and responses

To send a request to the Orb API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class.
Expand Down
8 changes: 4 additions & 4 deletions bin/check-release-environment
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
errors=()

if [ -z "${SONATYPE_USERNAME}" ]; then
errors+=("The ORB_SONATYPE_USERNAME secret has not been set. Please set it in either this repository's secrets or your organization secrets")
errors+=("The SONATYPE_USERNAME secret has not been set. Please set it in either this repository's secrets or your organization secrets")
fi

if [ -z "${SONATYPE_PASSWORD}" ]; then
errors+=("The ORB_SONATYPE_PASSWORD secret has not been set. Please set it in either this repository's secrets or your organization secrets")
errors+=("The SONATYPE_PASSWORD secret has not been set. Please set it in either this repository's secrets or your organization secrets")
fi

if [ -z "${GPG_SIGNING_KEY}" ]; then
errors+=("The ORB_SONATYPE_GPG_SIGNING_KEY secret has not been set. Please set it in either this repository's secrets or your organization secrets")
errors+=("The GPG_SIGNING_KEY secret has not been set. Please set it in either this repository's secrets or your organization secrets")
fi

if [ -z "${GPG_SIGNING_PASSWORD}" ]; then
errors+=("The ORB_SONATYPE_GPG_SIGNING_PASSWORD secret has not been set. Please set it in either this repository's secrets or your organization secrets")
errors+=("The GPG_SIGNING_PASSWORD secret has not been set. Please set it in either this repository's secrets or your organization secrets")
fi

lenErrors=${#errors[@]}
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
allprojects {
group = "com.withorb.api"
version = "1.0.0" // x-release-please-version
version = "1.1.0" // x-release-please-version
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.withorb.api.client.okhttp

import com.withorb.api.core.RequestOptions
import com.withorb.api.core.Timeout
import com.withorb.api.core.checkRequired
import com.withorb.api.core.http.Headers
import com.withorb.api.core.http.HttpClient
import com.withorb.api.core.http.HttpMethod
Expand All @@ -17,7 +16,6 @@ import java.time.Duration
import java.util.concurrent.CompletableFuture
import okhttp3.Call
import okhttp3.Callback
import okhttp3.HttpUrl
import okhttp3.HttpUrl.Companion.toHttpUrl
import okhttp3.MediaType
import okhttp3.MediaType.Companion.toMediaType
Expand All @@ -28,8 +26,7 @@ import okhttp3.Response
import okhttp3.logging.HttpLoggingInterceptor
import okio.BufferedSink

class OkHttpClient
private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val baseUrl: HttpUrl) :
class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpClient) :
HttpClient {

override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse {
Expand Down Expand Up @@ -140,11 +137,7 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val
}

private fun HttpRequest.toUrl(): String {
url?.let {
return it
}

val builder = baseUrl.newBuilder()
val builder = baseUrl.toHttpUrl().newBuilder()
pathSegments.forEach(builder::addPathSegment)
queryParams.keys().forEach { key ->
queryParams.values(key).forEach { builder.addQueryParameter(key, it) }
Expand Down Expand Up @@ -194,12 +187,9 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val

class Builder internal constructor() {

private var baseUrl: HttpUrl? = null
private var timeout: Timeout = Timeout.default()
private var proxy: Proxy? = null

fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl.toHttpUrl() }

fun timeout(timeout: Timeout) = apply { this.timeout = timeout }

fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build())
Expand All @@ -214,8 +204,12 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val
.writeTimeout(timeout.write())
.callTimeout(timeout.request())
.proxy(proxy)
.build(),
checkRequired("baseUrl", baseUrl),
.build()
.apply {
// We usually make all our requests to the same host so it makes sense to
// raise the per-host limit to the overall limit.
dispatcher.maxRequestsPerHost = dispatcher.maxRequests
}
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,7 @@ class OrbOkHttpClient private constructor() {
fun build(): OrbClient =
OrbClientImpl(
clientOptions
.httpClient(
OkHttpClient.builder()
.baseUrl(clientOptions.baseUrl())
.timeout(timeout)
.proxy(proxy)
.build()
)
.httpClient(OkHttpClient.builder().timeout(timeout).proxy(proxy).build())
.build()
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,7 @@ class OrbOkHttpClientAsync private constructor() {
fun build(): OrbClientAsync =
OrbClientAsyncImpl(
clientOptions
.httpClient(
OkHttpClient.builder()
.baseUrl(clientOptions.baseUrl())
.timeout(timeout)
.proxy(proxy)
.build()
)
.httpClient(OkHttpClient.builder().timeout(timeout).proxy(proxy).build())
.build()
)
}
Expand Down
16 changes: 16 additions & 0 deletions orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

package com.withorb.api.client

import com.withorb.api.core.ClientOptions
import com.withorb.api.services.blocking.AlertService
import com.withorb.api.services.blocking.BetaService
import com.withorb.api.services.blocking.CouponService
Expand All @@ -19,6 +20,7 @@ import com.withorb.api.services.blocking.SubscriptionChangeService
import com.withorb.api.services.blocking.SubscriptionService
import com.withorb.api.services.blocking.TopLevelService
import com.withorb.api.services.blocking.WebhookService
import java.util.function.Consumer

/**
* A client for interacting with the Orb REST API synchronously. You can also switch to asynchronous
Expand Down Expand Up @@ -49,6 +51,13 @@ interface OrbClient {
*/
fun withRawResponse(): WithRawResponse

/**
* Returns a view of this service with the given option modifications applied.
*
* The original service is not modified.
*/
fun withOptions(modifier: Consumer<ClientOptions.Builder>): OrbClient

fun topLevel(): TopLevelService

fun beta(): BetaService
Expand Down Expand Up @@ -99,6 +108,13 @@ interface OrbClient {
/** A view of [OrbClient] that provides access to raw HTTP responses for each method. */
interface WithRawResponse {

/**
* Returns a view of this service with the given option modifications applied.
*
* The original service is not modified.
*/
fun withOptions(modifier: Consumer<ClientOptions.Builder>): OrbClient.WithRawResponse

fun topLevel(): TopLevelService.WithRawResponse

fun beta(): BetaService.WithRawResponse
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

package com.withorb.api.client

import com.withorb.api.core.ClientOptions
import com.withorb.api.services.async.AlertServiceAsync
import com.withorb.api.services.async.BetaServiceAsync
import com.withorb.api.services.async.CouponServiceAsync
Expand All @@ -18,6 +19,7 @@ import com.withorb.api.services.async.PriceServiceAsync
import com.withorb.api.services.async.SubscriptionChangeServiceAsync
import com.withorb.api.services.async.SubscriptionServiceAsync
import com.withorb.api.services.async.TopLevelServiceAsync
import java.util.function.Consumer

/**
* A client for interacting with the Orb REST API asynchronously. You can also switch to synchronous
Expand Down Expand Up @@ -48,6 +50,13 @@ interface OrbClientAsync {
*/
fun withRawResponse(): WithRawResponse

/**
* Returns a view of this service with the given option modifications applied.
*
* The original service is not modified.
*/
fun withOptions(modifier: Consumer<ClientOptions.Builder>): OrbClientAsync

fun topLevel(): TopLevelServiceAsync

fun beta(): BetaServiceAsync
Expand Down Expand Up @@ -96,6 +105,13 @@ interface OrbClientAsync {
/** A view of [OrbClientAsync] that provides access to raw HTTP responses for each method. */
interface WithRawResponse {

/**
* Returns a view of this service with the given option modifications applied.
*
* The original service is not modified.
*/
fun withOptions(modifier: Consumer<ClientOptions.Builder>): OrbClientAsync.WithRawResponse

fun topLevel(): TopLevelServiceAsync.WithRawResponse

fun beta(): BetaServiceAsync.WithRawResponse
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import com.withorb.api.services.async.SubscriptionServiceAsync
import com.withorb.api.services.async.SubscriptionServiceAsyncImpl
import com.withorb.api.services.async.TopLevelServiceAsync
import com.withorb.api.services.async.TopLevelServiceAsyncImpl
import java.util.function.Consumer

class OrbClientAsyncImpl(private val clientOptions: ClientOptions) : OrbClientAsync {

Expand Down Expand Up @@ -116,6 +117,9 @@ class OrbClientAsyncImpl(private val clientOptions: ClientOptions) : OrbClientAs

override fun withRawResponse(): OrbClientAsync.WithRawResponse = withRawResponse

override fun withOptions(modifier: Consumer<ClientOptions.Builder>): OrbClientAsync =
OrbClientAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build())

override fun topLevel(): TopLevelServiceAsync = topLevel

override fun beta(): BetaServiceAsync = beta
Expand Down Expand Up @@ -219,6 +223,13 @@ class OrbClientAsyncImpl(private val clientOptions: ClientOptions) : OrbClientAs
SubscriptionChangeServiceAsyncImpl.WithRawResponseImpl(clientOptions)
}

override fun withOptions(
modifier: Consumer<ClientOptions.Builder>
): OrbClientAsync.WithRawResponse =
OrbClientAsyncImpl.WithRawResponseImpl(
clientOptions.toBuilder().apply(modifier::accept).build()
)

override fun topLevel(): TopLevelServiceAsync.WithRawResponse = topLevel

override fun beta(): BetaServiceAsync.WithRawResponse = beta
Expand Down
Loading