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
2 changes: 1 addition & 1 deletion .github/workflows/publish-sonatype.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- uses: actions/checkout@v4

- name: Set up Java
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: |
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 @@
{
".": "0.1.0-alpha.6"
".": "0.1.0-alpha.7"
}
6 changes: 3 additions & 3 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 10
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/brand-dev%2Fbrand.dev-aff48154fa37f0eb293cf660842ceab35c597509aee08f6b76df066828229c58.yml
openapi_spec_hash: a8ade5d7246da14e2ff161e829d11c12
configured_endpoints: 9
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/brand-dev%2Fbrand.dev-70f44e886c51bd700af031ad9b5c8f0042ef15fde038ba83ed08f61cd9d05266.yml
openapi_spec_hash: 9b834ba9e373689a8e2fbd8312b1f2de
config_hash: 8f3ee44d690a305369555016a77ed016
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,32 @@
# Changelog

## 0.1.0-alpha.7 (2025-07-21)

Full Changelog: [v0.1.0-alpha.6...v0.1.0-alpha.7](https://github.com/brand-dot-dev/java-sdk/compare/v0.1.0-alpha.6...v0.1.0-alpha.7)

### Features

* **api:** manual updates ([9c7c076](https://github.com/brand-dot-dev/java-sdk/commit/9c7c07621ea16a0b0adeaa57a96d826d9fa6c045))
* **client:** add https config options ([508033b](https://github.com/brand-dot-dev/java-sdk/commit/508033b672147e010fc171a69fa6d7509acf519c))


### Bug Fixes

* **client:** don't close client on `withOptions` usage when original is gc'd ([e245a89](https://github.com/brand-dot-dev/java-sdk/commit/e245a8943102c4fb296c1a6f99171bd827374daa))
* **client:** ensure error handling always occurs ([be0d357](https://github.com/brand-dot-dev/java-sdk/commit/be0d35783fd23f1d9cffb4ff60857d6e2100769f))


### Chores

* **ci:** bump `actions/setup-java` to v4 ([ce1d549](https://github.com/brand-dot-dev/java-sdk/commit/ce1d54940f67278ab37e9a1c95596df5ba9dcc75))
* **internal:** allow running specific example from cli ([39f74d7](https://github.com/brand-dot-dev/java-sdk/commit/39f74d71d29a9a7cacca25ef0dd472f8c04397ba))
* **internal:** refactor delegating from client to options ([6682663](https://github.com/brand-dot-dev/java-sdk/commit/66826635fed7d2d03e7d2deaff75b91fe0a7c034))


### Refactors

* **internal:** minor `ClientOptionsTest` change ([25962fa](https://github.com/brand-dot-dev/java-sdk/commit/25962facfb9d0e4f9c672d522f12550b7b2cd206))

## 0.1.0-alpha.6 (2025-06-29)

Full Changelog: [v0.1.0-alpha.5...v0.1.0-alpha.6](https://github.com/brand-dot-dev/java-sdk/compare/v0.1.0-alpha.5...v0.1.0-alpha.6)
Expand Down
31 changes: 26 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

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

[![Maven Central](https://img.shields.io/maven-central/v/com.branddev.api/brand-dev-java)](https://central.sonatype.com/artifact/com.branddev.api/brand-dev-java/0.1.0-alpha.6)
[![javadoc](https://javadoc.io/badge2/com.branddev.api/brand-dev-java/0.1.0-alpha.6/javadoc.svg)](https://javadoc.io/doc/com.branddev.api/brand-dev-java/0.1.0-alpha.6)
[![Maven Central](https://img.shields.io/maven-central/v/com.branddev.api/brand-dev-java)](https://central.sonatype.com/artifact/com.branddev.api/brand-dev-java/0.1.0-alpha.7)
[![javadoc](https://javadoc.io/badge2/com.branddev.api/brand-dev-java/0.1.0-alpha.7/javadoc.svg)](https://javadoc.io/doc/com.branddev.api/brand-dev-java/0.1.0-alpha.7)

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

Expand All @@ -13,7 +13,7 @@ It is generated with [Stainless](https://www.stainless.com/).

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

Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.branddev.api/brand-dev-java/0.1.0-alpha.6).
Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.branddev.api/brand-dev-java/0.1.0-alpha.7).

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

Expand All @@ -24,7 +24,7 @@ Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.branddev.api/b
### Gradle

```kotlin
implementation("com.branddev.api:brand-dev-java:0.1.0-alpha.6")
implementation("com.branddev.api:brand-dev-java:0.1.0-alpha.7")
```

### Maven
Expand All @@ -33,7 +33,7 @@ implementation("com.branddev.api:brand-dev-java:0.1.0-alpha.6")
<dependency>
<groupId>com.branddev.api</groupId>
<artifactId>brand-dev-java</artifactId>
<version>0.1.0-alpha.6</version>
<version>0.1.0-alpha.7</version>
</dependency>
```

Expand Down Expand Up @@ -330,6 +330,27 @@ BrandDevClient client = BrandDevOkHttpClient.builder()
.build();
```

### HTTPS

> [!NOTE]
> Most applications should not call these methods, and instead use the system defaults. The defaults include
> special optimizations that can be lost if the implementations are modified.

To configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods:

```java
import com.branddev.api.client.BrandDevClient;
import com.branddev.api.client.okhttp.BrandDevOkHttpClient;

BrandDevClient client = BrandDevOkHttpClient.builder()
.fromEnv()
// If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa.
.sslSocketFactory(yourSSLSocketFactory)
.trustManager(yourTrustManager)
.hostnameVerifier(yourHostnameVerifier)
.build();
```

### Custom HTTP client

The SDK consists of three artifacts:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,16 @@ import com.branddev.api.core.ClientOptions
import com.branddev.api.core.Timeout
import com.branddev.api.core.http.Headers
import com.branddev.api.core.http.QueryParams
import com.branddev.api.core.jsonMapper
import com.fasterxml.jackson.databind.json.JsonMapper
import java.net.Proxy
import java.time.Clock
import java.time.Duration
import java.util.Optional
import javax.net.ssl.HostnameVerifier
import javax.net.ssl.SSLSocketFactory
import javax.net.ssl.X509TrustManager
import kotlin.jvm.optionals.getOrNull

class BrandDevOkHttpClient private constructor() {

Expand All @@ -27,10 +33,63 @@ class BrandDevOkHttpClient private constructor() {
class Builder internal constructor() {

private var clientOptions: ClientOptions.Builder = ClientOptions.builder()
private var timeout: Timeout = Timeout.default()
private var proxy: Proxy? = null
private var sslSocketFactory: SSLSocketFactory? = null
private var trustManager: X509TrustManager? = null
private var hostnameVerifier: HostnameVerifier? = null

fun baseUrl(baseUrl: String) = apply { clientOptions.baseUrl(baseUrl) }
fun proxy(proxy: Proxy?) = apply { this.proxy = proxy }

/** Alias for calling [Builder.proxy] with `proxy.orElse(null)`. */
fun proxy(proxy: Optional<Proxy>) = proxy(proxy.getOrNull())

/**
* The socket factory used to secure HTTPS connections.
*
* If this is set, then [trustManager] must also be set.
*
* If unset, then the system default is used. Most applications should not call this method,
* and instead use the system default. The default include special optimizations that can be
* lost if the implementation is modified.
*/
fun sslSocketFactory(sslSocketFactory: SSLSocketFactory?) = apply {
this.sslSocketFactory = sslSocketFactory
}

/** Alias for calling [Builder.sslSocketFactory] with `sslSocketFactory.orElse(null)`. */
fun sslSocketFactory(sslSocketFactory: Optional<SSLSocketFactory>) =
sslSocketFactory(sslSocketFactory.getOrNull())

/**
* The trust manager used to secure HTTPS connections.
*
* If this is set, then [sslSocketFactory] must also be set.
*
* If unset, then the system default is used. Most applications should not call this method,
* and instead use the system default. The default include special optimizations that can be
* lost if the implementation is modified.
*/
fun trustManager(trustManager: X509TrustManager?) = apply {
this.trustManager = trustManager
}

/** Alias for calling [Builder.trustManager] with `trustManager.orElse(null)`. */
fun trustManager(trustManager: Optional<X509TrustManager>) =
trustManager(trustManager.getOrNull())

/**
* The verifier used to confirm that response certificates apply to requested hostnames for
* HTTPS connections.
*
* If unset, then a default hostname verifier is used.
*/
fun hostnameVerifier(hostnameVerifier: HostnameVerifier?) = apply {
this.hostnameVerifier = hostnameVerifier
}

/** Alias for calling [Builder.hostnameVerifier] with `hostnameVerifier.orElse(null)`. */
fun hostnameVerifier(hostnameVerifier: Optional<HostnameVerifier>) =
hostnameVerifier(hostnameVerifier.getOrNull())

/**
* Whether to throw an exception if any of the Jackson versions detected at runtime are
Expand All @@ -47,6 +106,30 @@ class BrandDevOkHttpClient private constructor() {

fun clock(clock: Clock) = apply { clientOptions.clock(clock) }

fun baseUrl(baseUrl: String?) = apply { clientOptions.baseUrl(baseUrl) }

/** Alias for calling [Builder.baseUrl] with `baseUrl.orElse(null)`. */
fun baseUrl(baseUrl: Optional<String>) = baseUrl(baseUrl.getOrNull())

fun responseValidation(responseValidation: Boolean) = apply {
clientOptions.responseValidation(responseValidation)
}

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

/**
* Sets the maximum time allowed for a complete HTTP call, not including retries.
*
* See [Timeout.request] for more details.
*
* For fine-grained control, pass a [Timeout] object.
*/
fun timeout(timeout: Duration) = apply { clientOptions.timeout(timeout) }

fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) }

fun apiKey(apiKey: String) = apply { clientOptions.apiKey(apiKey) }

fun headers(headers: Headers) = apply { clientOptions.headers(headers) }

fun headers(headers: Map<String, Iterable<String>>) = apply {
Expand Down Expand Up @@ -127,30 +210,6 @@ class BrandDevOkHttpClient private constructor() {
clientOptions.removeAllQueryParams(keys)
}

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

/**
* Sets the maximum time allowed for a complete HTTP call, not including retries.
*
* See [Timeout.request] for more details.
*
* For fine-grained control, pass a [Timeout] object.
*/
fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build())

fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) }

fun proxy(proxy: Proxy) = apply { this.proxy = proxy }

fun responseValidation(responseValidation: Boolean) = apply {
clientOptions.responseValidation(responseValidation)
}

fun apiKey(apiKey: String) = apply { clientOptions.apiKey(apiKey) }

fun fromEnv() = apply { clientOptions.fromEnv() }

/**
Expand All @@ -161,7 +220,15 @@ class BrandDevOkHttpClient private constructor() {
fun build(): BrandDevClient =
BrandDevClientImpl(
clientOptions
.httpClient(OkHttpClient.builder().timeout(timeout).proxy(proxy).build())
.httpClient(
OkHttpClient.builder()
.timeout(clientOptions.timeout())
.proxy(proxy)
.sslSocketFactory(sslSocketFactory)
.trustManager(trustManager)
.hostnameVerifier(hostnameVerifier)
.build()
)
.build()
)
}
Expand Down
Loading
Loading