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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.prism.log
.gradle
.idea
.kotlin
build
codegen.log
kls_database.db
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.46.0"
".": "0.46.1"
}
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Changelog

## 0.46.1 (2025-03-07)

Full Changelog: [v0.46.0...v0.46.1](https://github.com/orbcorp/orb-java/compare/v0.46.0...v0.46.1)

### Chores

* **internal:** add `.kotlin` to `.gitignore` ([#323](https://github.com/orbcorp/orb-java/issues/323)) ([8c1f105](https://github.com/orbcorp/orb-java/commit/8c1f105f073072041491eeffed999a31957c4c5e))
* **internal:** codegen related update ([#321](https://github.com/orbcorp/orb-java/issues/321)) ([a45ffe2](https://github.com/orbcorp/orb-java/commit/a45ffe29a6f89939a7c624efac74e5ce890ca7d9))
* **internal:** don't generate docs ([#325](https://github.com/orbcorp/orb-java/issues/325)) ([dccfa35](https://github.com/orbcorp/orb-java/commit/dccfa351f867c99eddac02c5603ac59cf892a7ef))
* **internal:** use `getOrNull` instead of `orElse(null)` ([#324](https://github.com/orbcorp/orb-java/issues/324)) ([02fd429](https://github.com/orbcorp/orb-java/commit/02fd429784de8fe4a0ae0d4eee9fbe1544080c92))

## 0.46.0 (2025-03-07)

Full Changelog: [v0.45.0...v0.46.0](https://github.com/orbcorp/orb-java/compare/v0.45.0...v0.46.0)
Expand Down
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@

<!-- 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/0.46.0)
[![javadoc](https://javadoc.io/badge2/com.withorb.api/orb-java/0.46.0/javadoc.svg)](https://javadoc.io/doc/com.withorb.api/orb-java/0.46.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/0.46.1)

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

The Orb Java SDK provides convenient access to the Orb REST API from applications written in Java.

The Orb Java SDK is similar to the Orb Kotlin SDK but with minor differences that make it more ergonomic for use in Java, such as `Optional` instead of nullable values, `Stream` instead of `Sequence`, and `CompletableFuture` instead of suspend functions.

The REST API documentation can be found on [docs.withorb.com](https://docs.withorb.com/reference/api-reference). Javadocs are also available on [javadoc.io](https://javadoc.io/doc/com.withorb.api/orb-java/0.45.0).
The REST API documentation can be found on [docs.withorb.com](https://docs.withorb.com/reference/api-reference).

## Installation

Expand All @@ -20,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:0.46.0")
implementation("com.withorb.api:orb-java:0.46.1")
```

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

Expand Down
21 changes: 1 addition & 20 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,23 +1,4 @@
plugins {
id("org.jetbrains.dokka") version "2.0.0"
}

repositories {
mavenCentral()
}

allprojects {
group = "com.withorb.api"
version = "0.46.0" // x-release-please-version
}

subprojects {
apply(plugin = "org.jetbrains.dokka")
}

// Avoid race conditions between `dokkaJavadocCollector` and `dokkaJavadocJar` tasks
tasks.named("dokkaJavadocCollector").configure {
subprojects.flatMap { it.tasks }
.filter { it.project.name != "orb-java" && it.name == "dokkaJavadocJar" }
.forEach { mustRunAfter(it) }
version = "0.46.1" // x-release-please-version
}
8 changes: 0 additions & 8 deletions buildSrc/src/main/kotlin/orb.publish.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import com.vanniktech.maven.publish.JavadocJar
import com.vanniktech.maven.publish.KotlinJvm
import com.vanniktech.maven.publish.MavenPublishBaseExtension
import com.vanniktech.maven.publish.SonatypeHost

Expand All @@ -21,12 +19,6 @@ configure<MavenPublishBaseExtension> {
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)

coordinates(project.group.toString(), project.name, project.version.toString())
configure(
KotlinJvm(
javadocJar = JavadocJar.Dokka("dokkaJavadoc"),
sourcesJar = true,
)
)

pom {
name.set("API Reference")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import java.net.Proxy
import java.time.Clock
import java.time.Duration
import java.util.Optional
import kotlin.jvm.optionals.getOrNull

class OrbOkHttpClient private constructor() {

Expand Down Expand Up @@ -150,7 +151,7 @@ class OrbOkHttpClient private constructor() {
}

fun webhookSecret(webhookSecret: Optional<String>) =
webhookSecret(webhookSecret.orElse(null))
webhookSecret(webhookSecret.getOrNull())

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import java.net.Proxy
import java.time.Clock
import java.time.Duration
import java.util.Optional
import kotlin.jvm.optionals.getOrNull

class OrbOkHttpClientAsync private constructor() {

Expand Down Expand Up @@ -150,7 +151,7 @@ class OrbOkHttpClientAsync private constructor() {
}

fun webhookSecret(webhookSecret: Optional<String>) =
webhookSecret(webhookSecret.orElse(null))
webhookSecret(webhookSecret.getOrNull())

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import com.withorb.api.core.http.QueryParams
import com.withorb.api.core.http.RetryingHttpClient
import java.time.Clock
import java.util.Optional
import kotlin.jvm.optionals.getOrNull

class ClientOptions
private constructor(
Expand Down Expand Up @@ -100,7 +101,7 @@ private constructor(
fun webhookSecret(webhookSecret: String?) = apply { this.webhookSecret = webhookSecret }

fun webhookSecret(webhookSecret: Optional<String>) =
webhookSecret(webhookSecret.orElse(null))
webhookSecret(webhookSecret.getOrNull())

fun headers(headers: Headers) = apply {
this.headers.clear()
Expand Down
9 changes: 5 additions & 4 deletions orb-java-core/src/main/kotlin/com/withorb/api/core/Timeout.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package com.withorb.api.core
import java.time.Duration
import java.util.Objects
import java.util.Optional
import kotlin.jvm.optionals.getOrNull

/** A class containing timeouts for various processing phases of a request. */
class Timeout
Expand Down Expand Up @@ -96,7 +97,7 @@ private constructor(
*
* Defaults to `Duration.ofMinutes(1)`.
*/
fun connect(connect: Optional<Duration>) = connect(connect.orElse(null))
fun connect(connect: Optional<Duration>) = connect(connect.getOrNull())

/**
* The maximum time allowed between two data packets when waiting for the server’s response.
Expand All @@ -114,7 +115,7 @@ private constructor(
*
* Defaults to `request()`.
*/
fun read(read: Optional<Duration>) = read(read.orElse(null))
fun read(read: Optional<Duration>) = read(read.getOrNull())

/**
* The maximum time allowed between two data packets when sending the request to the server.
Expand All @@ -132,7 +133,7 @@ private constructor(
*
* Defaults to `request()`.
*/
fun write(write: Optional<Duration>) = write(write.orElse(null))
fun write(write: Optional<Duration>) = write(write.getOrNull())

/**
* The maximum time allowed for a complete HTTP call, not including retries.
Expand All @@ -156,7 +157,7 @@ private constructor(
*
* Defaults to `Duration.ofMinutes(1)`.
*/
fun request(request: Optional<Duration>) = request(request.orElse(null))
fun request(request: Optional<Duration>) = request(request.getOrNull())

fun build(): Timeout = Timeout(connect, read, write, request)
}
Expand Down
21 changes: 11 additions & 10 deletions orb-java-core/src/main/kotlin/com/withorb/api/models/Alert.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import com.withorb.api.errors.OrbInvalidDataException
import java.time.OffsetDateTime
import java.util.Objects
import java.util.Optional
import kotlin.jvm.optionals.getOrNull

/**
* [Alerts within Orb](/product-catalog/configuring-alerts) monitor spending, usage, or credit
Expand Down Expand Up @@ -220,7 +221,7 @@ private constructor(
fun currency(currency: String?) = currency(JsonField.ofNullable(currency))

/** The name of the currency the credit balance or invoice cost is denominated in. */
fun currency(currency: Optional<String>) = currency(currency.orElse(null))
fun currency(currency: Optional<String>) = currency(currency.getOrNull())

/** The name of the currency the credit balance or invoice cost is denominated in. */
fun currency(currency: JsonField<String>) = apply { this.currency = currency }
Expand All @@ -229,7 +230,7 @@ private constructor(
fun customer(customer: Customer?) = customer(JsonField.ofNullable(customer))

/** The customer the alert applies to. */
fun customer(customer: Optional<Customer>) = customer(customer.orElse(null))
fun customer(customer: Optional<Customer>) = customer(customer.getOrNull())

/** The customer the alert applies to. */
fun customer(customer: JsonField<Customer>) = apply { this.customer = customer }
Expand All @@ -244,7 +245,7 @@ private constructor(
fun metric(metric: Metric?) = metric(JsonField.ofNullable(metric))

/** The metric the alert applies to. */
fun metric(metric: Optional<Metric>) = metric(metric.orElse(null))
fun metric(metric: Optional<Metric>) = metric(metric.getOrNull())

/** The metric the alert applies to. */
fun metric(metric: JsonField<Metric>) = apply { this.metric = metric }
Expand All @@ -253,7 +254,7 @@ private constructor(
fun plan(plan: Plan?) = plan(JsonField.ofNullable(plan))

/** The plan the alert applies to. */
fun plan(plan: Optional<Plan>) = plan(plan.orElse(null))
fun plan(plan: Optional<Plan>) = plan(plan.getOrNull())

/** The plan the alert applies to. */
fun plan(plan: JsonField<Plan>) = apply { this.plan = plan }
Expand All @@ -264,7 +265,7 @@ private constructor(

/** The subscription the alert applies to. */
fun subscription(subscription: Optional<Subscription>) =
subscription(subscription.orElse(null))
subscription(subscription.getOrNull())

/** The subscription the alert applies to. */
fun subscription(subscription: JsonField<Subscription>) = apply {
Expand All @@ -275,7 +276,7 @@ private constructor(
fun thresholds(thresholds: List<Threshold>?) = thresholds(JsonField.ofNullable(thresholds))

/** The thresholds that define the conditions under which the alert will be triggered. */
fun thresholds(thresholds: Optional<List<Threshold>>) = thresholds(thresholds.orElse(null))
fun thresholds(thresholds: Optional<List<Threshold>>) = thresholds(thresholds.getOrNull())

/** The thresholds that define the conditions under which the alert will be triggered. */
fun thresholds(thresholds: JsonField<List<Threshold>>) = apply {
Expand Down Expand Up @@ -409,7 +410,7 @@ private constructor(
externalCustomerId(JsonField.ofNullable(externalCustomerId))

fun externalCustomerId(externalCustomerId: Optional<String>) =
externalCustomerId(externalCustomerId.orElse(null))
externalCustomerId(externalCustomerId.getOrNull())

fun externalCustomerId(externalCustomerId: JsonField<String>) = apply {
this.externalCustomerId = externalCustomerId
Expand Down Expand Up @@ -666,7 +667,7 @@ private constructor(

fun id(id: String?) = id(JsonField.ofNullable(id))

fun id(id: Optional<String>) = id(id.orElse(null))
fun id(id: Optional<String>) = id(id.getOrNull())

fun id(id: JsonField<String>) = apply { this.id = id }

Expand All @@ -684,7 +685,7 @@ private constructor(
* your system.
*/
fun externalPlanId(externalPlanId: Optional<String>) =
externalPlanId(externalPlanId.orElse(null))
externalPlanId(externalPlanId.getOrNull())

/**
* An optional user-defined ID for this plan resource, used throughout the system as an
Expand All @@ -697,7 +698,7 @@ private constructor(

fun name(name: String?) = name(JsonField.ofNullable(name))

fun name(name: Optional<String>) = name(name.orElse(null))
fun name(name: Optional<String>) = name(name.getOrNull())

fun name(name: JsonField<String>) = apply { this.name = name }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import com.withorb.api.core.toImmutable
import com.withorb.api.errors.OrbInvalidDataException
import java.util.Objects
import java.util.Optional
import kotlin.jvm.optionals.getOrNull

/**
* This endpoint creates a new alert to monitor a customer's credit balance. There are three types
Expand Down Expand Up @@ -181,7 +182,7 @@ private constructor(

/** The thresholds that define the values at which the alert will be triggered. */
fun thresholds(thresholds: Optional<List<Threshold>>) =
thresholds(thresholds.orElse(null))
thresholds(thresholds.getOrNull())

/** The thresholds that define the values at which the alert will be triggered. */
fun thresholds(thresholds: JsonField<List<Threshold>>) = apply {
Expand Down Expand Up @@ -294,7 +295,7 @@ private constructor(
fun thresholds(thresholds: List<Threshold>?) = apply { body.thresholds(thresholds) }

/** The thresholds that define the values at which the alert will be triggered. */
fun thresholds(thresholds: Optional<List<Threshold>>) = thresholds(thresholds.orElse(null))
fun thresholds(thresholds: Optional<List<Threshold>>) = thresholds(thresholds.getOrNull())

/** The thresholds that define the values at which the alert will be triggered. */
fun thresholds(thresholds: JsonField<List<Threshold>>) = apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import com.withorb.api.core.toImmutable
import com.withorb.api.errors.OrbInvalidDataException
import java.util.Objects
import java.util.Optional
import kotlin.jvm.optionals.getOrNull

/**
* This endpoint creates a new alert to monitor a customer's credit balance. There are three types
Expand Down Expand Up @@ -181,7 +182,7 @@ private constructor(

/** The thresholds that define the values at which the alert will be triggered. */
fun thresholds(thresholds: Optional<List<Threshold>>) =
thresholds(thresholds.orElse(null))
thresholds(thresholds.getOrNull())

/** The thresholds that define the values at which the alert will be triggered. */
fun thresholds(thresholds: JsonField<List<Threshold>>) = apply {
Expand Down Expand Up @@ -300,7 +301,7 @@ private constructor(
fun thresholds(thresholds: List<Threshold>?) = apply { body.thresholds(thresholds) }

/** The thresholds that define the values at which the alert will be triggered. */
fun thresholds(thresholds: Optional<List<Threshold>>) = thresholds(thresholds.orElse(null))
fun thresholds(thresholds: Optional<List<Threshold>>) = thresholds(thresholds.getOrNull())

/** The thresholds that define the values at which the alert will be triggered. */
fun thresholds(thresholds: JsonField<List<Threshold>>) = apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import com.withorb.api.core.toImmutable
import com.withorb.api.errors.OrbInvalidDataException
import java.util.Objects
import java.util.Optional
import kotlin.jvm.optionals.getOrNull

/**
* This endpoint is used to create alerts at the subscription level.
Expand Down Expand Up @@ -192,7 +193,7 @@ private constructor(
fun metricId(metricId: String?) = metricId(JsonField.ofNullable(metricId))

/** The metric to track usage for. */
fun metricId(metricId: Optional<String>) = metricId(metricId.orElse(null))
fun metricId(metricId: Optional<String>) = metricId(metricId.getOrNull())

/** The metric to track usage for. */
fun metricId(metricId: JsonField<String>) = apply { this.metricId = metricId }
Expand Down Expand Up @@ -303,7 +304,7 @@ private constructor(
fun metricId(metricId: String?) = apply { body.metricId(metricId) }

/** The metric to track usage for. */
fun metricId(metricId: Optional<String>) = metricId(metricId.orElse(null))
fun metricId(metricId: Optional<String>) = metricId(metricId.getOrNull())

/** The metric to track usage for. */
fun metricId(metricId: JsonField<String>) = apply { body.metricId(metricId) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.withorb.api.core.http.QueryParams
import com.withorb.api.core.toImmutable
import java.util.Objects
import java.util.Optional
import kotlin.jvm.optionals.getOrNull

/**
* This endpoint allows you to disable an alert. To disable a plan-level alert for a specific
Expand Down Expand Up @@ -100,7 +101,7 @@ private constructor(

/** Used to update the status of a plan alert scoped to this subscription_id */
fun subscriptionId(subscriptionId: Optional<String>) =
subscriptionId(subscriptionId.orElse(null))
subscriptionId(subscriptionId.getOrNull())

fun additionalHeaders(additionalHeaders: Headers) = apply {
this.additionalHeaders.clear()
Expand Down
Loading
Loading