diff --git a/.release-please-manifest.json b/.release-please-manifest.json
index 2b2b4fa9..fed4b17f 100644
--- a/.release-please-manifest.json
+++ b/.release-please-manifest.json
@@ -1,3 +1,3 @@
{
- ".": "0.51.0"
+ ".": "0.52.0"
}
\ No newline at end of file
diff --git a/.stats.yml b/.stats.yml
index d1b66331..2262920e 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,2 +1,4 @@
configured_endpoints: 103
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-36a6db97756e8658369c9af3c0ac532ecacb032e5b8f6211094dcb4052943ff3.yml
+openapi_spec_hash: 26886fa8e59fa3674320897e3409e540
+config_hash: ec4f1e02d3528e3a93a73e33bca17c2a
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 317710e1..8b64a4d3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,35 @@
# Changelog
+## 0.52.0 (2025-03-26)
+
+Full Changelog: [v0.51.0...v0.52.0](https://github.com/orbcorp/orb-java/compare/v0.51.0...v0.52.0)
+
+### Features
+
+* **client:** support a lower jackson version ([#368](https://github.com/orbcorp/orb-java/issues/368)) ([659e62b](https://github.com/orbcorp/orb-java/commit/659e62bfba72b4fbf261db18cbcc4ced30f7953d))
+* **client:** throw on incompatible jackson version ([659e62b](https://github.com/orbcorp/orb-java/commit/659e62bfba72b4fbf261db18cbcc4ced30f7953d))
+
+
+### Bug Fixes
+
+* **client:** map deserialization bug ([da01e21](https://github.com/orbcorp/orb-java/commit/da01e21aab23d7a6b429cbc1c96f48354ca2f0ca))
+
+
+### Chores
+
+* **internal:** delete unused methods and annotations ([#369](https://github.com/orbcorp/orb-java/issues/369)) ([da01e21](https://github.com/orbcorp/orb-java/commit/da01e21aab23d7a6b429cbc1c96f48354ca2f0ca))
+* **internal:** fix example formatting ([#364](https://github.com/orbcorp/orb-java/issues/364)) ([99e8b5b](https://github.com/orbcorp/orb-java/commit/99e8b5b46b1cba17b06d5fa92fcf8e084d64f6b3))
+* **internal:** make multipart assertions more robust ([4f4527e](https://github.com/orbcorp/orb-java/commit/4f4527eaa976d407948d20998b46bc1489c86b2c))
+* **internal:** remove unnecessary `assertNotNull` calls ([4f4527e](https://github.com/orbcorp/orb-java/commit/4f4527eaa976d407948d20998b46bc1489c86b2c))
+* **internal:** remove unnecessary import ([#365](https://github.com/orbcorp/orb-java/issues/365)) ([3a0fe1e](https://github.com/orbcorp/orb-java/commit/3a0fe1e9bf719ef3606c30ff48ba6a7dd06f7911))
+
+
+### Documentation
+
+* minor readme tweak ([#367](https://github.com/orbcorp/orb-java/issues/367)) ([bc3f6c3](https://github.com/orbcorp/orb-java/commit/bc3f6c3c810124041192a841b531039b27cfb840))
+* refine comments on multipart params ([#362](https://github.com/orbcorp/orb-java/issues/362)) ([4f4527e](https://github.com/orbcorp/orb-java/commit/4f4527eaa976d407948d20998b46bc1489c86b2c))
+* update readme exception docs ([#366](https://github.com/orbcorp/orb-java/issues/366)) ([9443b23](https://github.com/orbcorp/orb-java/commit/9443b239a271eb97bf16f5d8cd432f6c97db2aa4))
+
## 0.51.0 (2025-03-20)
Full Changelog: [v0.50.0...v0.51.0](https://github.com/orbcorp/orb-java/compare/v0.50.0...v0.51.0)
diff --git a/README.md b/README.md
index 7abd226f..69c6aa50 100644
--- a/README.md
+++ b/README.md
@@ -2,11 +2,11 @@
-[](https://central.sonatype.com/artifact/com.withorb.api/orb-java/0.51.0)
+[](https://central.sonatype.com/artifact/com.withorb.api/orb-java/0.52.0)
-The Orb Java SDK provides convenient access to the Orb REST API from applications written in Java.
+The Orb Java SDK provides convenient access to the [Orb REST API](https://docs.withorb.com/reference/api-reference) 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.
@@ -19,16 +19,16 @@ The REST API documentation can be found on [docs.withorb.com](https://docs.witho
### Gradle
```kotlin
-implementation("com.withorb.api:orb-java:0.51.0")
+implementation("com.withorb.api:orb-java:0.52.0")
```
### Maven
```xml
- com.withorb.api
- orb-java
- 0.51.0
+ com.withorb.api
+ orb-java
+ 0.52.0
```
@@ -195,16 +195,16 @@ The SDK throws custom unchecked exception types:
- [`OrbServiceException`](orb-java-core/src/main/kotlin/com/withorb/api/errors/OrbServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code:
- | Status | Exception |
- | ------ | ------------------------------- |
- | 400 | `BadRequestException` |
- | 401 | `AuthenticationException` |
- | 403 | `PermissionDeniedException` |
- | 404 | `NotFoundException` |
- | 422 | `UnprocessableEntityException` |
- | 429 | `RateLimitException` |
- | 5xx | `InternalServerException` |
- | others | `UnexpectedStatusCodeException` |
+ | Status | Exception |
+ | ------ | ------------------------------------------------------------------------------------------------------------------------ |
+ | 400 | [`BadRequestException`](orb-java-core/src/main/kotlin/com/withorb/api/errors/BadRequestException.kt) |
+ | 401 | [`UnauthorizedException`](orb-java-core/src/main/kotlin/com/withorb/api/errors/UnauthorizedException.kt) |
+ | 403 | [`PermissionDeniedException`](orb-java-core/src/main/kotlin/com/withorb/api/errors/PermissionDeniedException.kt) |
+ | 404 | [`NotFoundException`](orb-java-core/src/main/kotlin/com/withorb/api/errors/NotFoundException.kt) |
+ | 422 | [`UnprocessableEntityException`](orb-java-core/src/main/kotlin/com/withorb/api/errors/UnprocessableEntityException.kt) |
+ | 429 | [`RateLimitException`](orb-java-core/src/main/kotlin/com/withorb/api/errors/RateLimitException.kt) |
+ | 5xx | [`InternalServerException`](orb-java-core/src/main/kotlin/com/withorb/api/errors/InternalServerException.kt) |
+ | others | [`UnexpectedStatusCodeException`](orb-java-core/src/main/kotlin/com/withorb/api/errors/UnexpectedStatusCodeException.kt) |
- [`OrbIoException`](orb-java-core/src/main/kotlin/com/withorb/api/errors/OrbIoException.kt): I/O networking errors.
diff --git a/build.gradle.kts b/build.gradle.kts
index 1125eda6..3434d43f 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -1,4 +1,4 @@
allprojects {
group = "com.withorb.api"
- version = "0.51.0" // x-release-please-version
+ version = "0.52.0" // x-release-please-version
}
diff --git a/orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClient.kt b/orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClient.kt
index 3d036c50..e3b5ce1e 100644
--- a/orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClient.kt
+++ b/orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClient.kt
@@ -38,6 +38,17 @@ class OrbOkHttpClient private constructor() {
this.baseUrl = baseUrl
}
+ /**
+ * Whether to throw an exception if any of the Jackson versions detected at runtime are
+ * incompatible with the SDK's minimum supported Jackson version (2.13.4).
+ *
+ * Defaults to true. Use extreme caution when disabling this option. There is no guarantee
+ * that the SDK will work correctly when using an incompatible Jackson version.
+ */
+ fun checkJacksonVersionCompatibility(checkJacksonVersionCompatibility: Boolean) = apply {
+ clientOptions.checkJacksonVersionCompatibility(checkJacksonVersionCompatibility)
+ }
+
fun jsonMapper(jsonMapper: JsonMapper) = apply { clientOptions.jsonMapper(jsonMapper) }
fun clock(clock: Clock) = apply { clientOptions.clock(clock) }
diff --git a/orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClientAsync.kt b/orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClientAsync.kt
index e7a9f330..ef9cbe65 100644
--- a/orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClientAsync.kt
+++ b/orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClientAsync.kt
@@ -38,6 +38,17 @@ class OrbOkHttpClientAsync private constructor() {
this.baseUrl = baseUrl
}
+ /**
+ * Whether to throw an exception if any of the Jackson versions detected at runtime are
+ * incompatible with the SDK's minimum supported Jackson version (2.13.4).
+ *
+ * Defaults to true. Use extreme caution when disabling this option. There is no guarantee
+ * that the SDK will work correctly when using an incompatible Jackson version.
+ */
+ fun checkJacksonVersionCompatibility(checkJacksonVersionCompatibility: Boolean) = apply {
+ clientOptions.checkJacksonVersionCompatibility(checkJacksonVersionCompatibility)
+ }
+
fun jsonMapper(jsonMapper: JsonMapper) = apply { clientOptions.jsonMapper(jsonMapper) }
fun clock(clock: Clock) = apply { clientOptions.clock(clock) }
diff --git a/orb-java-core/build.gradle.kts b/orb-java-core/build.gradle.kts
index b53bd811..a0bbeafb 100644
--- a/orb-java-core/build.gradle.kts
+++ b/orb-java-core/build.gradle.kts
@@ -3,6 +3,19 @@ plugins {
id("orb.publish")
}
+configurations.all {
+ resolutionStrategy {
+ // Compile and test against a lower Jackson version to ensure we're compatible with it.
+ // We publish with a higher version (see below) to ensure users depend on a secure version by default.
+ force("com.fasterxml.jackson.core:jackson-core:2.13.4")
+ force("com.fasterxml.jackson.core:jackson-databind:2.13.4")
+ force("com.fasterxml.jackson.core:jackson-annotations:2.13.4")
+ force("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.13.4")
+ force("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.13.4")
+ force("com.fasterxml.jackson.module:jackson-module-kotlin:2.13.4")
+ }
+}
+
dependencies {
api("com.fasterxml.jackson.core:jackson-core:2.18.1")
api("com.fasterxml.jackson.core:jackson-databind:2.18.1")
diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/Check.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/Check.kt
index 4a68492f..82fe7ba1 100644
--- a/orb-java-core/src/main/kotlin/com/withorb/api/core/Check.kt
+++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/Check.kt
@@ -2,6 +2,9 @@
package com.withorb.api.core
+import com.fasterxml.jackson.core.Version
+import com.fasterxml.jackson.core.util.VersionUtil
+
fun checkRequired(name: String, value: T?): T =
checkNotNull(value) { "`$name` is required, but was not set" }
@@ -39,3 +42,46 @@ internal fun checkMaxLength(name: String, value: String, maxLength: Int): String
"`$name` must have at most length $maxLength, but was ${it.length}"
}
}
+
+@JvmSynthetic
+internal fun checkJacksonVersionCompatibility() {
+ val incompatibleJacksonVersions =
+ RUNTIME_JACKSON_VERSIONS.mapNotNull {
+ when {
+ it.majorVersion != MINIMUM_JACKSON_VERSION.majorVersion ->
+ it to "incompatible major version"
+ it.minorVersion < MINIMUM_JACKSON_VERSION.minorVersion ->
+ it to "minor version too low"
+ it.minorVersion == MINIMUM_JACKSON_VERSION.minorVersion &&
+ it.patchLevel < MINIMUM_JACKSON_VERSION.patchLevel ->
+ it to "patch version too low"
+ else -> null
+ }
+ }
+ check(incompatibleJacksonVersions.isEmpty()) {
+ """
+This SDK depends on Jackson version $MINIMUM_JACKSON_VERSION, but the following incompatible Jackson versions were detected at runtime:
+
+${incompatibleJacksonVersions.asSequence().map { (version, incompatibilityReason) ->
+ "- `${version.toFullString().replace("/", ":")}` ($incompatibilityReason)"
+}.joinToString("\n")}
+
+This can happen if you are either:
+1. Directly depending on different Jackson versions
+2. Depending on some library that depends on different Jackson versions, potentially transitively
+
+Double-check that you are depending on compatible Jackson versions.
+ """
+ .trimIndent()
+ }
+}
+
+private val MINIMUM_JACKSON_VERSION: Version = VersionUtil.parseVersion("2.13.4", null, null)
+private val RUNTIME_JACKSON_VERSIONS: List =
+ listOf(
+ com.fasterxml.jackson.core.json.PackageVersion.VERSION,
+ com.fasterxml.jackson.databind.cfg.PackageVersion.VERSION,
+ com.fasterxml.jackson.datatype.jdk8.PackageVersion.VERSION,
+ com.fasterxml.jackson.datatype.jsr310.PackageVersion.VERSION,
+ com.fasterxml.jackson.module.kotlin.PackageVersion.VERSION,
+ )
diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/ClientOptions.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/ClientOptions.kt
index 876728e4..8fc681ad 100644
--- a/orb-java-core/src/main/kotlin/com/withorb/api/core/ClientOptions.kt
+++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/ClientOptions.kt
@@ -16,6 +16,7 @@ class ClientOptions
private constructor(
private val originalHttpClient: HttpClient,
@get:JvmName("httpClient") val httpClient: HttpClient,
+ @get:JvmName("checkJacksonVersionCompatibility") val checkJacksonVersionCompatibility: Boolean,
@get:JvmName("jsonMapper") val jsonMapper: JsonMapper,
@get:JvmName("clock") val clock: Clock,
@get:JvmName("baseUrl") val baseUrl: String,
@@ -28,6 +29,12 @@ private constructor(
private val webhookSecret: String?,
) {
+ init {
+ if (checkJacksonVersionCompatibility) {
+ checkJacksonVersionCompatibility()
+ }
+ }
+
fun webhookSecret(): Optional = Optional.ofNullable(webhookSecret)
fun toBuilder() = Builder().from(this)
@@ -54,6 +61,7 @@ private constructor(
class Builder internal constructor() {
private var httpClient: HttpClient? = null
+ private var checkJacksonVersionCompatibility: Boolean = true
private var jsonMapper: JsonMapper = jsonMapper()
private var clock: Clock = Clock.systemUTC()
private var baseUrl: String = PRODUCTION_URL
@@ -68,6 +76,7 @@ private constructor(
@JvmSynthetic
internal fun from(clientOptions: ClientOptions) = apply {
httpClient = clientOptions.originalHttpClient
+ checkJacksonVersionCompatibility = clientOptions.checkJacksonVersionCompatibility
jsonMapper = clientOptions.jsonMapper
clock = clientOptions.clock
baseUrl = clientOptions.baseUrl
@@ -82,6 +91,10 @@ private constructor(
fun httpClient(httpClient: HttpClient) = apply { this.httpClient = httpClient }
+ fun checkJacksonVersionCompatibility(checkJacksonVersionCompatibility: Boolean) = apply {
+ this.checkJacksonVersionCompatibility = checkJacksonVersionCompatibility
+ }
+
fun jsonMapper(jsonMapper: JsonMapper) = apply { this.jsonMapper = jsonMapper }
fun clock(clock: Clock) = apply { this.clock = clock }
@@ -233,6 +246,7 @@ private constructor(
.idempotencyHeader("Idempotency-Key")
.build()
),
+ checkJacksonVersionCompatibility,
jsonMapper,
clock,
baseUrl,
diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/ObjectMappers.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/ObjectMappers.kt
index 45bc6ad7..26311c69 100644
--- a/orb-java-core/src/main/kotlin/com/withorb/api/core/ObjectMappers.kt
+++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/ObjectMappers.kt
@@ -5,23 +5,19 @@ package com.withorb.api.core
import com.fasterxml.jackson.annotation.JsonInclude
import com.fasterxml.jackson.core.JsonGenerator
import com.fasterxml.jackson.databind.DeserializationFeature
+import com.fasterxml.jackson.databind.MapperFeature
import com.fasterxml.jackson.databind.SerializationFeature
import com.fasterxml.jackson.databind.SerializerProvider
-import com.fasterxml.jackson.databind.cfg.CoercionAction.Fail
-import com.fasterxml.jackson.databind.cfg.CoercionInputShape.Integer
-import com.fasterxml.jackson.databind.exc.InvalidDefinitionException
-import com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException
import com.fasterxml.jackson.databind.json.JsonMapper
import com.fasterxml.jackson.databind.module.SimpleModule
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule
-import com.fasterxml.jackson.module.kotlin.jacksonMapperBuilder
-import com.withorb.api.errors.OrbException
-import com.withorb.api.errors.OrbInvalidDataException
+import com.fasterxml.jackson.module.kotlin.kotlinModule
import java.io.InputStream
fun jsonMapper(): JsonMapper =
- jacksonMapperBuilder()
+ JsonMapper.builder()
+ .addModule(kotlinModule())
.addModule(Jdk8Module())
.addModule(JavaTimeModule())
.addModule(SimpleModule().addSerializer(InputStreamJsonSerializer))
@@ -30,7 +26,12 @@ fun jsonMapper(): JsonMapper =
.disable(SerializationFeature.FLUSH_AFTER_WRITE_VALUE)
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
.disable(SerializationFeature.WRITE_DURATIONS_AS_TIMESTAMPS)
- .withCoercionConfig(String::class.java) { it.setCoercion(Integer, Fail) }
+ .disable(MapperFeature.ALLOW_COERCION_OF_SCALARS)
+ .disable(MapperFeature.AUTO_DETECT_CREATORS)
+ .disable(MapperFeature.AUTO_DETECT_FIELDS)
+ .disable(MapperFeature.AUTO_DETECT_GETTERS)
+ .disable(MapperFeature.AUTO_DETECT_IS_GETTERS)
+ .disable(MapperFeature.AUTO_DETECT_SETTERS)
.build()
private object InputStreamJsonSerializer : BaseSerializer(InputStream::class) {
@@ -47,38 +48,3 @@ private object InputStreamJsonSerializer : BaseSerializer(InputStre
}
}
}
-
-@JvmSynthetic
-internal fun enhanceJacksonException(fallbackMessage: String, e: Exception): Exception {
- // These exceptions should only happen if our code is wrong OR if the user is using a binary
- // incompatible version of `com.fasterxml.jackson.core:jackson-databind`:
- // https://javadoc.io/static/com.fasterxml.jackson.core/jackson-databind/2.18.1/index.html
- val isUnexpectedException =
- e is UnrecognizedPropertyException || e is InvalidDefinitionException
- if (!isUnexpectedException) {
- return OrbInvalidDataException(fallbackMessage, e)
- }
-
- val jacksonVersion = JsonMapper::class.java.`package`.implementationVersion
- if (jacksonVersion.isNullOrEmpty() || jacksonVersion == COMPILED_JACKSON_VERSION) {
- return OrbInvalidDataException(fallbackMessage, e)
- }
-
- return OrbException(
- """
- Jackson threw an unexpected exception and its runtime version ($jacksonVersion) mismatches the version the SDK was compiled with ($COMPILED_JACKSON_VERSION).
-
- You may be using a version of `com.fasterxml.jackson.core:jackson-databind` that's not binary compatible with the SDK.
-
- This can happen if you are either:
- 1. Directly depending on a different Jackson version
- 2. Depending on some library that depends on a different Jackson version, potentially transitively
-
- Double-check that you are depending on a compatible Jackson version.
- """
- .trimIndent(),
- e,
- )
-}
-
-const val COMPILED_JACKSON_VERSION = "2.18.1"
diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/Values.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/Values.kt
index e4d17630..f3ff66db 100644
--- a/orb-java-core/src/main/kotlin/com/withorb/api/core/Values.kt
+++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/Values.kt
@@ -1,8 +1,6 @@
package com.withorb.api.core
import com.fasterxml.jackson.annotation.JacksonAnnotationsInside
-import com.fasterxml.jackson.annotation.JsonAutoDetect
-import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility
import com.fasterxml.jackson.annotation.JsonCreator
import com.fasterxml.jackson.annotation.JsonInclude
import com.fasterxml.jackson.core.JsonGenerator
@@ -451,19 +449,9 @@ private constructor(
@JsonInclude(JsonInclude.Include.CUSTOM, valueFilter = JsonField.IsMissing::class)
annotation class ExcludeMissing
-@JacksonAnnotationsInside
-@JsonAutoDetect(
- getterVisibility = Visibility.NONE,
- isGetterVisibility = Visibility.NONE,
- setterVisibility = Visibility.NONE,
- creatorVisibility = Visibility.NONE,
- fieldVisibility = Visibility.NONE,
-)
-annotation class NoAutoDetect
-
class MultipartField
private constructor(
- @get:JvmName("value") val value: JsonField,
+ @get:com.fasterxml.jackson.annotation.JsonValue @get:JvmName("value") val value: JsonField,
@get:JvmName("contentType") val contentType: String,
private val filename: String?,
) {
@@ -481,11 +469,7 @@ private constructor(
@JvmSynthetic
internal fun map(transform: (T) -> R): MultipartField =
- MultipartField.builder()
- .value(value.map(transform))
- .contentType(contentType)
- .filename(filename)
- .build()
+ builder().value(value.map(transform)).contentType(contentType).filename(filename).build()
/** A builder for [MultipartField]. */
class Builder internal constructor() {
diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/handlers/JsonHandler.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/handlers/JsonHandler.kt
index b96bd9d7..199e5bd5 100644
--- a/orb-java-core/src/main/kotlin/com/withorb/api/core/handlers/JsonHandler.kt
+++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/handlers/JsonHandler.kt
@@ -4,9 +4,9 @@ package com.withorb.api.core.handlers
import com.fasterxml.jackson.databind.json.JsonMapper
import com.fasterxml.jackson.module.kotlin.jacksonTypeRef
-import com.withorb.api.core.enhanceJacksonException
import com.withorb.api.core.http.HttpResponse
import com.withorb.api.core.http.HttpResponse.Handler
+import com.withorb.api.errors.OrbInvalidDataException
@JvmSynthetic
internal inline fun jsonHandler(jsonMapper: JsonMapper): Handler =
@@ -15,6 +15,6 @@ internal inline fun jsonHandler(jsonMapper: JsonMapper): Handler
try {
jsonMapper.readValue(response.body(), jacksonTypeRef())
} catch (e: Exception) {
- throw enhanceJacksonException("Error reading response", e)
+ throw OrbInvalidDataException("Error reading response", e)
}
}
diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/http/HttpRequestBodies.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/http/HttpRequestBodies.kt
index d0a1330b..3463de9e 100644
--- a/orb-java-core/src/main/kotlin/com/withorb/api/core/http/HttpRequestBodies.kt
+++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/http/HttpRequestBodies.kt
@@ -9,7 +9,6 @@ import com.fasterxml.jackson.databind.json.JsonMapper
import com.fasterxml.jackson.databind.node.JsonNodeType
import com.withorb.api.core.MultipartField
import com.withorb.api.errors.OrbInvalidDataException
-import java.io.ByteArrayInputStream
import java.io.InputStream
import java.io.OutputStream
import kotlin.jvm.optionals.getOrNull
@@ -74,12 +73,12 @@ internal fun multipartFormData(
when (node.nodeType) {
JsonNodeType.MISSING,
JsonNodeType.NULL -> emptySequence()
- JsonNodeType.BINARY -> sequenceOf(name to ByteArrayInputStream(node.binaryValue()))
- JsonNodeType.STRING -> sequenceOf(name to node.textValue().toInputStream())
+ JsonNodeType.BINARY -> sequenceOf(name to node.binaryValue().inputStream())
+ JsonNodeType.STRING -> sequenceOf(name to node.textValue().inputStream())
JsonNodeType.BOOLEAN ->
- sequenceOf(name to node.booleanValue().toString().toInputStream())
+ sequenceOf(name to node.booleanValue().toString().inputStream())
JsonNodeType.NUMBER ->
- sequenceOf(name to node.numberValue().toString().toInputStream())
+ sequenceOf(name to node.numberValue().toString().inputStream())
JsonNodeType.ARRAY ->
node.elements().asSequence().flatMap { element ->
serializePart("$name[]", element)
@@ -92,7 +91,7 @@ internal fun multipartFormData(
null -> throw OrbInvalidDataException("Unexpected JsonNode type: ${node.nodeType}")
}
- private fun String.toInputStream(): InputStream = ByteArrayInputStream(toByteArray())
+ private fun String.inputStream(): InputStream = toByteArray().inputStream()
override fun writeTo(outputStream: OutputStream) = entity.writeTo(outputStream)
diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/http/HttpResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/http/HttpResponse.kt
index 36480e16..1ab0ed96 100644
--- a/orb-java-core/src/main/kotlin/com/withorb/api/core/http/HttpResponse.kt
+++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/http/HttpResponse.kt
@@ -1,7 +1,8 @@
+// File generated from our OpenAPI spec by Stainless.
+
package com.withorb.api.core.http
import java.io.InputStream
-import java.lang.AutoCloseable
interface HttpResponse : AutoCloseable {
diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/errors/BadRequestException.kt b/orb-java-core/src/main/kotlin/com/withorb/api/errors/BadRequestException.kt
index b9d3acfc..157ea6dd 100644
--- a/orb-java-core/src/main/kotlin/com/withorb/api/errors/BadRequestException.kt
+++ b/orb-java-core/src/main/kotlin/com/withorb/api/errors/BadRequestException.kt
@@ -12,12 +12,12 @@ class BadRequestException
private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) :
OrbServiceException("400: $body", cause) {
+ override fun statusCode(): Int = 400
+
override fun headers(): Headers = headers
override fun body(): JsonValue = body
- override fun statusCode(): Int = 400
-
fun toBuilder() = Builder().from(this)
companion object {
diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/errors/NotFoundException.kt b/orb-java-core/src/main/kotlin/com/withorb/api/errors/NotFoundException.kt
index 752cb1f9..f059ba10 100644
--- a/orb-java-core/src/main/kotlin/com/withorb/api/errors/NotFoundException.kt
+++ b/orb-java-core/src/main/kotlin/com/withorb/api/errors/NotFoundException.kt
@@ -12,12 +12,12 @@ class NotFoundException
private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) :
OrbServiceException("404: $body", cause) {
+ override fun statusCode(): Int = 404
+
override fun headers(): Headers = headers
override fun body(): JsonValue = body
- override fun statusCode(): Int = 404
-
fun toBuilder() = Builder().from(this)
companion object {
diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/errors/PermissionDeniedException.kt b/orb-java-core/src/main/kotlin/com/withorb/api/errors/PermissionDeniedException.kt
index 12dd216c..774d2ae3 100644
--- a/orb-java-core/src/main/kotlin/com/withorb/api/errors/PermissionDeniedException.kt
+++ b/orb-java-core/src/main/kotlin/com/withorb/api/errors/PermissionDeniedException.kt
@@ -12,12 +12,12 @@ class PermissionDeniedException
private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) :
OrbServiceException("403: $body", cause) {
+ override fun statusCode(): Int = 403
+
override fun headers(): Headers = headers
override fun body(): JsonValue = body
- override fun statusCode(): Int = 403
-
fun toBuilder() = Builder().from(this)
companion object {
diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/errors/RateLimitException.kt b/orb-java-core/src/main/kotlin/com/withorb/api/errors/RateLimitException.kt
index c354afb9..536ea6ed 100644
--- a/orb-java-core/src/main/kotlin/com/withorb/api/errors/RateLimitException.kt
+++ b/orb-java-core/src/main/kotlin/com/withorb/api/errors/RateLimitException.kt
@@ -12,12 +12,12 @@ class RateLimitException
private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) :
OrbServiceException("429: $body", cause) {
+ override fun statusCode(): Int = 429
+
override fun headers(): Headers = headers
override fun body(): JsonValue = body
- override fun statusCode(): Int = 429
-
fun toBuilder() = Builder().from(this)
companion object {
diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/errors/UnauthorizedException.kt b/orb-java-core/src/main/kotlin/com/withorb/api/errors/UnauthorizedException.kt
index 7148d476..6ac99c31 100644
--- a/orb-java-core/src/main/kotlin/com/withorb/api/errors/UnauthorizedException.kt
+++ b/orb-java-core/src/main/kotlin/com/withorb/api/errors/UnauthorizedException.kt
@@ -12,12 +12,12 @@ class UnauthorizedException
private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) :
OrbServiceException("401: $body", cause) {
+ override fun statusCode(): Int = 401
+
override fun headers(): Headers = headers
override fun body(): JsonValue = body
- override fun statusCode(): Int = 401
-
fun toBuilder() = Builder().from(this)
companion object {
diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/errors/UnprocessableEntityException.kt b/orb-java-core/src/main/kotlin/com/withorb/api/errors/UnprocessableEntityException.kt
index 5907a45b..51ad3846 100644
--- a/orb-java-core/src/main/kotlin/com/withorb/api/errors/UnprocessableEntityException.kt
+++ b/orb-java-core/src/main/kotlin/com/withorb/api/errors/UnprocessableEntityException.kt
@@ -12,12 +12,12 @@ class UnprocessableEntityException
private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) :
OrbServiceException("422: $body", cause) {
+ override fun statusCode(): Int = 422
+
override fun headers(): Headers = headers
override fun body(): JsonValue = body
- override fun statusCode(): Int = 422
-
fun toBuilder() = Builder().from(this)
companion object {
diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/Alert.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Alert.kt
index 59a2cfea..981f9010 100644
--- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Alert.kt
+++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Alert.kt
@@ -11,13 +11,12 @@ import com.withorb.api.core.ExcludeMissing
import com.withorb.api.core.JsonField
import com.withorb.api.core.JsonMissing
import com.withorb.api.core.JsonValue
-import com.withorb.api.core.NoAutoDetect
import com.withorb.api.core.checkKnown
import com.withorb.api.core.checkRequired
-import com.withorb.api.core.immutableEmptyMap
import com.withorb.api.core.toImmutable
import com.withorb.api.errors.OrbInvalidDataException
import java.time.OffsetDateTime
+import java.util.Collections
import java.util.Objects
import java.util.Optional
import kotlin.jvm.optionals.getOrNull
@@ -28,37 +27,53 @@ import kotlin.jvm.optionals.getOrNull
*
* Alerts created through the API can be scoped to either customers or subscriptions.
*/
-@NoAutoDetect
class Alert
-@JsonCreator
private constructor(
- @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(),
- @JsonProperty("created_at")
- @ExcludeMissing
- private val createdAt: JsonField = JsonMissing.of(),
- @JsonProperty("currency")
- @ExcludeMissing
- private val currency: JsonField = JsonMissing.of(),
- @JsonProperty("customer")
- @ExcludeMissing
- private val customer: JsonField = JsonMissing.of(),
- @JsonProperty("enabled")
- @ExcludeMissing
- private val enabled: JsonField = JsonMissing.of(),
- @JsonProperty("metric")
- @ExcludeMissing
- private val metric: JsonField = JsonMissing.of(),
- @JsonProperty("plan") @ExcludeMissing private val plan: JsonField = JsonMissing.of(),
- @JsonProperty("subscription")
- @ExcludeMissing
- private val subscription: JsonField = JsonMissing.of(),
- @JsonProperty("thresholds")
- @ExcludeMissing
- private val thresholds: JsonField> = JsonMissing.of(),
- @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(),
- @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(),
+ private val id: JsonField,
+ private val createdAt: JsonField,
+ private val currency: JsonField,
+ private val customer: JsonField,
+ private val enabled: JsonField,
+ private val metric: JsonField,
+ private val plan: JsonField,
+ private val subscription: JsonField,
+ private val thresholds: JsonField>,
+ private val type: JsonField,
+ private val additionalProperties: MutableMap,
) {
+ @JsonCreator
+ private constructor(
+ @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(),
+ @JsonProperty("created_at")
+ @ExcludeMissing
+ createdAt: JsonField = JsonMissing.of(),
+ @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(),
+ @JsonProperty("customer") @ExcludeMissing customer: JsonField = JsonMissing.of(),
+ @JsonProperty("enabled") @ExcludeMissing enabled: JsonField = JsonMissing.of(),
+ @JsonProperty("metric") @ExcludeMissing metric: JsonField = JsonMissing.of(),
+ @JsonProperty("plan") @ExcludeMissing plan: JsonField = JsonMissing.of(),
+ @JsonProperty("subscription")
+ @ExcludeMissing
+ subscription: JsonField = JsonMissing.of(),
+ @JsonProperty("thresholds")
+ @ExcludeMissing
+ thresholds: JsonField> = JsonMissing.of(),
+ @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(),
+ ) : this(
+ id,
+ createdAt,
+ currency,
+ customer,
+ enabled,
+ metric,
+ plan,
+ subscription,
+ thresholds,
+ type,
+ mutableMapOf(),
+ )
+
/**
* Also referred to as alert_id in this documentation.
*
@@ -217,29 +232,15 @@ private constructor(
*/
@JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type
+ @JsonAnySetter
+ private fun putAdditionalProperty(key: String, value: JsonValue) {
+ additionalProperties.put(key, value)
+ }
+
@JsonAnyGetter
@ExcludeMissing
- fun _additionalProperties(): Map = additionalProperties
-
- private var validated: Boolean = false
-
- fun validate(): Alert = apply {
- if (validated) {
- return@apply
- }
-
- id()
- createdAt()
- currency()
- customer().ifPresent { it.validate() }
- enabled()
- metric().ifPresent { it.validate() }
- plan().ifPresent { it.validate() }
- subscription().ifPresent { it.validate() }
- thresholds().ifPresent { it.forEach { it.validate() } }
- type()
- validated = true
- }
+ fun _additionalProperties(): Map =
+ Collections.unmodifiableMap(additionalProperties)
fun toBuilder() = Builder().from(this)
@@ -497,23 +498,46 @@ private constructor(
checkRequired("subscription", subscription),
checkRequired("thresholds", thresholds).map { it.toImmutable() },
checkRequired("type", type),
- additionalProperties.toImmutable(),
+ additionalProperties.toMutableMap(),
)
}
+ private var validated: Boolean = false
+
+ fun validate(): Alert = apply {
+ if (validated) {
+ return@apply
+ }
+
+ id()
+ createdAt()
+ currency()
+ customer().ifPresent { it.validate() }
+ enabled()
+ metric().ifPresent { it.validate() }
+ plan().ifPresent { it.validate() }
+ subscription().ifPresent { it.validate() }
+ thresholds().ifPresent { it.forEach { it.validate() } }
+ type()
+ validated = true
+ }
+
/** The customer the alert applies to. */
- @NoAutoDetect
class Customer
- @JsonCreator
private constructor(
- @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(),
- @JsonProperty("external_customer_id")
- @ExcludeMissing
- private val externalCustomerId: JsonField = JsonMissing.of(),
- @JsonAnySetter
- private val additionalProperties: Map = immutableEmptyMap(),
+ private val id: JsonField,
+ private val externalCustomerId: JsonField,
+ private val additionalProperties: MutableMap,
) {
+ @JsonCreator
+ private constructor(
+ @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(),
+ @JsonProperty("external_customer_id")
+ @ExcludeMissing
+ externalCustomerId: JsonField = JsonMissing.of(),
+ ) : this(id, externalCustomerId, mutableMapOf())
+
/**
* @throws OrbInvalidDataException if the JSON field has an unexpected type or is
* unexpectedly missing or null (e.g. if the server responded with an unexpected value).
@@ -544,21 +568,15 @@ private constructor(
@ExcludeMissing
fun _externalCustomerId(): JsonField = externalCustomerId
+ @JsonAnySetter
+ private fun putAdditionalProperty(key: String, value: JsonValue) {
+ additionalProperties.put(key, value)
+ }
+
@JsonAnyGetter
@ExcludeMissing
- fun _additionalProperties(): Map = additionalProperties
-
- private var validated: Boolean = false
-
- fun validate(): Customer = apply {
- if (validated) {
- return@apply
- }
-
- id()
- externalCustomerId()
- validated = true
- }
+ fun _additionalProperties(): Map =
+ Collections.unmodifiableMap(additionalProperties)
fun toBuilder() = Builder().from(this)
@@ -658,10 +676,22 @@ private constructor(
Customer(
checkRequired("id", id),
checkRequired("externalCustomerId", externalCustomerId),
- additionalProperties.toImmutable(),
+ additionalProperties.toMutableMap(),
)
}
+ private var validated: Boolean = false
+
+ fun validate(): Customer = apply {
+ if (validated) {
+ return@apply
+ }
+
+ id()
+ externalCustomerId()
+ validated = true
+ }
+
override fun equals(other: Any?): Boolean {
if (this === other) {
return true
@@ -681,15 +711,17 @@ private constructor(
}
/** The metric the alert applies to. */
- @NoAutoDetect
class Metric
- @JsonCreator
private constructor(
- @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(),
- @JsonAnySetter
- private val additionalProperties: Map = immutableEmptyMap(),
+ private val id: JsonField,
+ private val additionalProperties: MutableMap,
) {
+ @JsonCreator
+ private constructor(
+ @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of()
+ ) : this(id, mutableMapOf())
+
/**
* @throws OrbInvalidDataException if the JSON field has an unexpected type or is
* unexpectedly missing or null (e.g. if the server responded with an unexpected value).
@@ -703,20 +735,15 @@ private constructor(
*/
@JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id
+ @JsonAnySetter
+ private fun putAdditionalProperty(key: String, value: JsonValue) {
+ additionalProperties.put(key, value)
+ }
+
@JsonAnyGetter
@ExcludeMissing
- fun _additionalProperties(): Map = additionalProperties
-
- private var validated: Boolean = false
-
- fun validate(): Metric = apply {
- if (validated) {
- return@apply
- }
-
- id()
- validated = true
- }
+ fun _additionalProperties(): Map =
+ Collections.unmodifiableMap(additionalProperties)
fun toBuilder() = Builder().from(this)
@@ -788,7 +815,18 @@ private constructor(
* @throws IllegalStateException if any required field is unset.
*/
fun build(): Metric =
- Metric(checkRequired("id", id), additionalProperties.toImmutable())
+ Metric(checkRequired("id", id), additionalProperties.toMutableMap())
+ }
+
+ private var validated: Boolean = false
+
+ fun validate(): Metric = apply {
+ if (validated) {
+ return@apply
+ }
+
+ id()
+ validated = true
}
override fun equals(other: Any?): Boolean {
@@ -809,24 +847,27 @@ private constructor(
}
/** The plan the alert applies to. */
- @NoAutoDetect
class Plan
- @JsonCreator
private constructor(
- @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(),
- @JsonProperty("external_plan_id")
- @ExcludeMissing
- private val externalPlanId: JsonField = JsonMissing.of(),
- @JsonProperty("name")
- @ExcludeMissing
- private val name: JsonField = JsonMissing.of(),
- @JsonProperty("plan_version")
- @ExcludeMissing
- private val planVersion: JsonField = JsonMissing.of(),
- @JsonAnySetter
- private val additionalProperties: Map = immutableEmptyMap(),
+ private val id: JsonField,
+ private val externalPlanId: JsonField,
+ private val name: JsonField,
+ private val planVersion: JsonField,
+ private val additionalProperties: MutableMap,
) {
+ @JsonCreator
+ private constructor(
+ @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(),
+ @JsonProperty("external_plan_id")
+ @ExcludeMissing
+ externalPlanId: JsonField = JsonMissing.of(),
+ @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(),
+ @JsonProperty("plan_version")
+ @ExcludeMissing
+ planVersion: JsonField = JsonMissing.of(),
+ ) : this(id, externalPlanId, name, planVersion, mutableMapOf())
+
/**
* @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
@@ -889,23 +930,15 @@ private constructor(
@ExcludeMissing
fun _planVersion(): JsonField = planVersion
+ @JsonAnySetter
+ private fun putAdditionalProperty(key: String, value: JsonValue) {
+ additionalProperties.put(key, value)
+ }
+
@JsonAnyGetter
@ExcludeMissing
- fun _additionalProperties(): Map = additionalProperties
-
- private var validated: Boolean = false
-
- fun validate(): Plan = apply {
- if (validated) {
- return@apply
- }
-
- id()
- externalPlanId()
- name()
- planVersion()
- validated = true
- }
+ fun _additionalProperties(): Map =
+ Collections.unmodifiableMap(additionalProperties)
fun toBuilder() = Builder().from(this)
@@ -1047,10 +1080,24 @@ private constructor(
checkRequired("externalPlanId", externalPlanId),
checkRequired("name", name),
checkRequired("planVersion", planVersion),
- additionalProperties.toImmutable(),
+ additionalProperties.toMutableMap(),
)
}
+ private var validated: Boolean = false
+
+ fun validate(): Plan = apply {
+ if (validated) {
+ return@apply
+ }
+
+ id()
+ externalPlanId()
+ name()
+ planVersion()
+ validated = true
+ }
+
override fun equals(other: Any?): Boolean {
if (this === other) {
return true
@@ -1070,15 +1117,17 @@ private constructor(
}
/** The subscription the alert applies to. */
- @NoAutoDetect
class Subscription
- @JsonCreator
private constructor(
- @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(),
- @JsonAnySetter
- private val additionalProperties: Map = immutableEmptyMap(),
+ private val id: JsonField,
+ private val additionalProperties: MutableMap,
) {
+ @JsonCreator
+ private constructor(
+ @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of()
+ ) : this(id, mutableMapOf())
+
/**
* @throws OrbInvalidDataException if the JSON field has an unexpected type or is
* unexpectedly missing or null (e.g. if the server responded with an unexpected value).
@@ -1092,20 +1141,15 @@ private constructor(
*/
@JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id
+ @JsonAnySetter
+ private fun putAdditionalProperty(key: String, value: JsonValue) {
+ additionalProperties.put(key, value)
+ }
+
@JsonAnyGetter
@ExcludeMissing
- fun _additionalProperties(): Map = additionalProperties
-
- private var validated: Boolean = false
-
- fun validate(): Subscription = apply {
- if (validated) {
- return@apply
- }
-
- id()
- validated = true
- }
+ fun _additionalProperties(): Map =
+ Collections.unmodifiableMap(additionalProperties)
fun toBuilder() = Builder().from(this)
@@ -1177,7 +1221,18 @@ private constructor(
* @throws IllegalStateException if any required field is unset.
*/
fun build(): Subscription =
- Subscription(checkRequired("id", id), additionalProperties.toImmutable())
+ Subscription(checkRequired("id", id), additionalProperties.toMutableMap())
+ }
+
+ private var validated: Boolean = false
+
+ fun validate(): Subscription = apply {
+ if (validated) {
+ return@apply
+ }
+
+ id()
+ validated = true
}
override fun equals(other: Any?): Boolean {
@@ -1198,17 +1253,17 @@ private constructor(
}
/** Thresholds are used to define the conditions under which an alert will be triggered. */
- @NoAutoDetect
class Threshold
- @JsonCreator
private constructor(
- @JsonProperty("value")
- @ExcludeMissing
- private val value: JsonField = JsonMissing.of(),
- @JsonAnySetter
- private val additionalProperties: Map = immutableEmptyMap(),
+ private val value: JsonField,
+ private val additionalProperties: MutableMap,
) {
+ @JsonCreator
+ private constructor(
+ @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of()
+ ) : this(value, mutableMapOf())
+
/**
* The value at which an alert will fire. For credit balance alerts, the alert will fire at
* or below this value. For usage and cost alerts, the alert will fire at or above this
@@ -1226,20 +1281,15 @@ private constructor(
*/
@JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value
+ @JsonAnySetter
+ private fun putAdditionalProperty(key: String, value: JsonValue) {
+ additionalProperties.put(key, value)
+ }
+
@JsonAnyGetter
@ExcludeMissing
- fun _additionalProperties(): Map = additionalProperties
-
- private var validated: Boolean = false
-
- fun validate(): Threshold = apply {
- if (validated) {
- return@apply
- }
-
- value()
- validated = true
- }
+ fun _additionalProperties(): Map =
+ Collections.unmodifiableMap(additionalProperties)
fun toBuilder() = Builder().from(this)
@@ -1316,7 +1366,18 @@ private constructor(
* @throws IllegalStateException if any required field is unset.
*/
fun build(): Threshold =
- Threshold(checkRequired("value", value), additionalProperties.toImmutable())
+ Threshold(checkRequired("value", value), additionalProperties.toMutableMap())
+ }
+
+ private var validated: Boolean = false
+
+ fun validate(): Threshold = apply {
+ if (validated) {
+ return@apply
+ }
+
+ value()
+ validated = true
}
override fun equals(other: Any?): Boolean {
diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForCustomerParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForCustomerParams.kt
index e3d15865..ab06c22b 100644
--- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForCustomerParams.kt
+++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForCustomerParams.kt
@@ -11,15 +11,14 @@ import com.withorb.api.core.ExcludeMissing
import com.withorb.api.core.JsonField
import com.withorb.api.core.JsonMissing
import com.withorb.api.core.JsonValue
-import com.withorb.api.core.NoAutoDetect
import com.withorb.api.core.Params
import com.withorb.api.core.checkKnown
import com.withorb.api.core.checkRequired
import com.withorb.api.core.http.Headers
import com.withorb.api.core.http.QueryParams
-import com.withorb.api.core.immutableEmptyMap
import com.withorb.api.core.toImmutable
import com.withorb.api.errors.OrbInvalidDataException
+import java.util.Collections
import java.util.Objects
import java.util.Optional
import kotlin.jvm.optionals.getOrNull
@@ -93,244 +92,6 @@ private constructor(
fun _additionalQueryParams(): QueryParams = additionalQueryParams
- @JvmSynthetic internal fun _body(): Body = body
-
- fun _pathParam(index: Int): String =
- when (index) {
- 0 -> customerId
- else -> ""
- }
-
- override fun _headers(): Headers = additionalHeaders
-
- override fun _queryParams(): QueryParams = additionalQueryParams
-
- @NoAutoDetect
- class Body
- @JsonCreator
- private constructor(
- @JsonProperty("currency")
- @ExcludeMissing
- private val currency: JsonField = JsonMissing.of(),
- @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(),
- @JsonProperty("thresholds")
- @ExcludeMissing
- private val thresholds: JsonField> = JsonMissing.of(),
- @JsonAnySetter
- private val additionalProperties: Map = immutableEmptyMap(),
- ) {
-
- /**
- * The case sensitive currency or custom pricing unit to use for this alert.
- *
- * @throws OrbInvalidDataException if the JSON field has an unexpected type or is
- * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
- */
- fun currency(): String = currency.getRequired("currency")
-
- /**
- * The type of alert to create. This must be a valid alert type.
- *
- * @throws OrbInvalidDataException if the JSON field has an unexpected type or is
- * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
- */
- fun type(): Type = type.getRequired("type")
-
- /**
- * The thresholds that define the values at which the alert will be triggered.
- *
- * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the
- * server responded with an unexpected value).
- */
- fun thresholds(): Optional> =
- Optional.ofNullable(thresholds.getNullable("thresholds"))
-
- /**
- * Returns the raw JSON value of [currency].
- *
- * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type.
- */
- @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency
-
- /**
- * Returns the raw JSON value of [type].
- *
- * Unlike [type], this method doesn't throw if the JSON field has an unexpected type.
- */
- @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type
-
- /**
- * Returns the raw JSON value of [thresholds].
- *
- * Unlike [thresholds], this method doesn't throw if the JSON field has an unexpected type.
- */
- @JsonProperty("thresholds")
- @ExcludeMissing
- fun _thresholds(): JsonField> = thresholds
-
- @JsonAnyGetter
- @ExcludeMissing
- fun _additionalProperties(): Map = additionalProperties
-
- private var validated: Boolean = false
-
- fun validate(): Body = apply {
- if (validated) {
- return@apply
- }
-
- currency()
- type()
- thresholds().ifPresent { it.forEach { it.validate() } }
- validated = true
- }
-
- fun toBuilder() = Builder().from(this)
-
- companion object {
-
- /**
- * Returns a mutable builder for constructing an instance of [Body].
- *
- * The following fields are required:
- * ```java
- * .currency()
- * .type()
- * ```
- */
- @JvmStatic fun builder() = Builder()
- }
-
- /** A builder for [Body]. */
- class Builder internal constructor() {
-
- private var currency: JsonField? = null
- private var type: JsonField? = null
- private var thresholds: JsonField>? = null
- private var additionalProperties: MutableMap = mutableMapOf()
-
- @JvmSynthetic
- internal fun from(body: Body) = apply {
- currency = body.currency
- type = body.type
- thresholds = body.thresholds.map { it.toMutableList() }
- additionalProperties = body.additionalProperties.toMutableMap()
- }
-
- /** The case sensitive currency or custom pricing unit to use for this alert. */
- fun currency(currency: String) = currency(JsonField.of(currency))
-
- /**
- * Sets [Builder.currency] to an arbitrary JSON value.
- *
- * You should usually call [Builder.currency] with a well-typed [String] value instead.
- * This method is primarily for setting the field to an undocumented or not yet
- * supported value.
- */
- fun currency(currency: JsonField) = apply { this.currency = currency }
-
- /** The type of alert to create. This must be a valid alert type. */
- fun type(type: Type) = type(JsonField.of(type))
-
- /**
- * Sets [Builder.type] to an arbitrary JSON value.
- *
- * You should usually call [Builder.type] with a well-typed [Type] value instead. This
- * method is primarily for setting the field to an undocumented or not yet supported
- * value.
- */
- fun type(type: JsonField) = apply { this.type = type }
-
- /** The thresholds that define the values at which the alert will be triggered. */
- fun thresholds(thresholds: List?) =
- thresholds(JsonField.ofNullable(thresholds))
-
- /** Alias for calling [Builder.thresholds] with `thresholds.orElse(null)`. */
- fun thresholds(thresholds: Optional>) =
- thresholds(thresholds.getOrNull())
-
- /**
- * Sets [Builder.thresholds] to an arbitrary JSON value.
- *
- * You should usually call [Builder.thresholds] with a well-typed `List`
- * value instead. This method is primarily for setting the field to an undocumented or
- * not yet supported value.
- */
- fun thresholds(thresholds: JsonField>) = apply {
- this.thresholds = thresholds.map { it.toMutableList() }
- }
-
- /**
- * Adds a single [Threshold] to [thresholds].
- *
- * @throws IllegalStateException if the field was previously set to a non-list.
- */
- fun addThreshold(threshold: Threshold) = apply {
- thresholds =
- (thresholds ?: JsonField.of(mutableListOf())).also {
- checkKnown("thresholds", it).add(threshold)
- }
- }
-
- fun additionalProperties(additionalProperties: Map) = apply {
- this.additionalProperties.clear()
- putAllAdditionalProperties(additionalProperties)
- }
-
- fun putAdditionalProperty(key: String, value: JsonValue) = apply {
- additionalProperties.put(key, value)
- }
-
- fun putAllAdditionalProperties(additionalProperties: Map) = apply {
- this.additionalProperties.putAll(additionalProperties)
- }
-
- fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) }
-
- fun removeAllAdditionalProperties(keys: Set) = apply {
- keys.forEach(::removeAdditionalProperty)
- }
-
- /**
- * Returns an immutable instance of [Body].
- *
- * Further updates to this [Builder] will not mutate the returned instance.
- *
- * The following fields are required:
- * ```java
- * .currency()
- * .type()
- * ```
- *
- * @throws IllegalStateException if any required field is unset.
- */
- fun build(): Body =
- Body(
- checkRequired("currency", currency),
- checkRequired("type", type),
- (thresholds ?: JsonMissing.of()).map { it.toImmutable() },
- additionalProperties.toImmutable(),
- )
- }
-
- override fun equals(other: Any?): Boolean {
- if (this === other) {
- return true
- }
-
- return /* spotless:off */ other is Body && currency == other.currency && type == other.type && thresholds == other.thresholds && additionalProperties == other.additionalProperties /* spotless:on */
- }
-
- /* spotless:off */
- private val hashCode: Int by lazy { Objects.hash(currency, type, thresholds, additionalProperties) }
- /* spotless:on */
-
- override fun hashCode(): Int = hashCode
-
- override fun toString() =
- "Body{currency=$currency, type=$type, thresholds=$thresholds, additionalProperties=$additionalProperties}"
- }
-
fun toBuilder() = Builder().from(this)
companion object {
@@ -349,7 +110,6 @@ private constructor(
}
/** A builder for [AlertCreateForCustomerParams]. */
- @NoAutoDetect
class Builder internal constructor() {
private var customerId: String? = null
@@ -553,6 +313,254 @@ private constructor(
)
}
+ @JvmSynthetic internal fun _body(): Body = body
+
+ fun _pathParam(index: Int): String =
+ when (index) {
+ 0 -> customerId
+ else -> ""
+ }
+
+ override fun _headers(): Headers = additionalHeaders
+
+ override fun _queryParams(): QueryParams = additionalQueryParams
+
+ class Body
+ private constructor(
+ private val currency: JsonField,
+ private val type: JsonField,
+ private val thresholds: JsonField>,
+ private val additionalProperties: MutableMap,
+ ) {
+
+ @JsonCreator
+ private constructor(
+ @JsonProperty("currency")
+ @ExcludeMissing
+ currency: JsonField = JsonMissing.of(),
+ @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(),
+ @JsonProperty("thresholds")
+ @ExcludeMissing
+ thresholds: JsonField> = JsonMissing.of(),
+ ) : this(currency, type, thresholds, mutableMapOf())
+
+ /**
+ * The case sensitive currency or custom pricing unit to use for this alert.
+ *
+ * @throws OrbInvalidDataException if the JSON field has an unexpected type or is
+ * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
+ */
+ fun currency(): String = currency.getRequired("currency")
+
+ /**
+ * The type of alert to create. This must be a valid alert type.
+ *
+ * @throws OrbInvalidDataException if the JSON field has an unexpected type or is
+ * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
+ */
+ fun type(): Type = type.getRequired("type")
+
+ /**
+ * The thresholds that define the values at which the alert will be triggered.
+ *
+ * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
+ fun thresholds(): Optional> =
+ Optional.ofNullable(thresholds.getNullable("thresholds"))
+
+ /**
+ * Returns the raw JSON value of [currency].
+ *
+ * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency
+
+ /**
+ * Returns the raw JSON value of [type].
+ *
+ * Unlike [type], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type
+
+ /**
+ * Returns the raw JSON value of [thresholds].
+ *
+ * Unlike [thresholds], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("thresholds")
+ @ExcludeMissing
+ fun _thresholds(): JsonField> = thresholds
+
+ @JsonAnySetter
+ private fun putAdditionalProperty(key: String, value: JsonValue) {
+ additionalProperties.put(key, value)
+ }
+
+ @JsonAnyGetter
+ @ExcludeMissing
+ fun _additionalProperties(): Map =
+ Collections.unmodifiableMap(additionalProperties)
+
+ fun toBuilder() = Builder().from(this)
+
+ companion object {
+
+ /**
+ * Returns a mutable builder for constructing an instance of [Body].
+ *
+ * The following fields are required:
+ * ```java
+ * .currency()
+ * .type()
+ * ```
+ */
+ @JvmStatic fun builder() = Builder()
+ }
+
+ /** A builder for [Body]. */
+ class Builder internal constructor() {
+
+ private var currency: JsonField? = null
+ private var type: JsonField? = null
+ private var thresholds: JsonField>? = null
+ private var additionalProperties: MutableMap = mutableMapOf()
+
+ @JvmSynthetic
+ internal fun from(body: Body) = apply {
+ currency = body.currency
+ type = body.type
+ thresholds = body.thresholds.map { it.toMutableList() }
+ additionalProperties = body.additionalProperties.toMutableMap()
+ }
+
+ /** The case sensitive currency or custom pricing unit to use for this alert. */
+ fun currency(currency: String) = currency(JsonField.of(currency))
+
+ /**
+ * Sets [Builder.currency] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.currency] with a well-typed [String] value instead.
+ * This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun currency(currency: JsonField) = apply { this.currency = currency }
+
+ /** The type of alert to create. This must be a valid alert type. */
+ fun type(type: Type) = type(JsonField.of(type))
+
+ /**
+ * Sets [Builder.type] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.type] with a well-typed [Type] value instead. This
+ * method is primarily for setting the field to an undocumented or not yet supported
+ * value.
+ */
+ fun type(type: JsonField) = apply { this.type = type }
+
+ /** The thresholds that define the values at which the alert will be triggered. */
+ fun thresholds(thresholds: List?) =
+ thresholds(JsonField.ofNullable(thresholds))
+
+ /** Alias for calling [Builder.thresholds] with `thresholds.orElse(null)`. */
+ fun thresholds(thresholds: Optional>) =
+ thresholds(thresholds.getOrNull())
+
+ /**
+ * Sets [Builder.thresholds] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.thresholds] with a well-typed `List`
+ * value instead. This method is primarily for setting the field to an undocumented or
+ * not yet supported value.
+ */
+ fun thresholds(thresholds: JsonField>) = apply {
+ this.thresholds = thresholds.map { it.toMutableList() }
+ }
+
+ /**
+ * Adds a single [Threshold] to [thresholds].
+ *
+ * @throws IllegalStateException if the field was previously set to a non-list.
+ */
+ fun addThreshold(threshold: Threshold) = apply {
+ thresholds =
+ (thresholds ?: JsonField.of(mutableListOf())).also {
+ checkKnown("thresholds", it).add(threshold)
+ }
+ }
+
+ fun additionalProperties(additionalProperties: Map) = apply {
+ this.additionalProperties.clear()
+ putAllAdditionalProperties(additionalProperties)
+ }
+
+ fun putAdditionalProperty(key: String, value: JsonValue) = apply {
+ additionalProperties.put(key, value)
+ }
+
+ fun putAllAdditionalProperties(additionalProperties: Map) = apply {
+ this.additionalProperties.putAll(additionalProperties)
+ }
+
+ fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) }
+
+ fun removeAllAdditionalProperties(keys: Set) = apply {
+ keys.forEach(::removeAdditionalProperty)
+ }
+
+ /**
+ * Returns an immutable instance of [Body].
+ *
+ * Further updates to this [Builder] will not mutate the returned instance.
+ *
+ * The following fields are required:
+ * ```java
+ * .currency()
+ * .type()
+ * ```
+ *
+ * @throws IllegalStateException if any required field is unset.
+ */
+ fun build(): Body =
+ Body(
+ checkRequired("currency", currency),
+ checkRequired("type", type),
+ (thresholds ?: JsonMissing.of()).map { it.toImmutable() },
+ additionalProperties.toMutableMap(),
+ )
+ }
+
+ private var validated: Boolean = false
+
+ fun validate(): Body = apply {
+ if (validated) {
+ return@apply
+ }
+
+ currency()
+ type()
+ thresholds().ifPresent { it.forEach { it.validate() } }
+ validated = true
+ }
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
+
+ return /* spotless:off */ other is Body && currency == other.currency && type == other.type && thresholds == other.thresholds && additionalProperties == other.additionalProperties /* spotless:on */
+ }
+
+ /* spotless:off */
+ private val hashCode: Int by lazy { Objects.hash(currency, type, thresholds, additionalProperties) }
+ /* spotless:on */
+
+ override fun hashCode(): Int = hashCode
+
+ override fun toString() =
+ "Body{currency=$currency, type=$type, thresholds=$thresholds, additionalProperties=$additionalProperties}"
+ }
+
/** The type of alert to create. This must be a valid alert type. */
class Type @JsonCreator private constructor(private val value: JsonField) : Enum {
@@ -658,17 +666,17 @@ private constructor(
}
/** Thresholds are used to define the conditions under which an alert will be triggered. */
- @NoAutoDetect
class Threshold
- @JsonCreator
private constructor(
- @JsonProperty("value")
- @ExcludeMissing
- private val value: JsonField = JsonMissing.of(),
- @JsonAnySetter
- private val additionalProperties: Map = immutableEmptyMap(),
+ private val value: JsonField,
+ private val additionalProperties: MutableMap,
) {
+ @JsonCreator
+ private constructor(
+ @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of()
+ ) : this(value, mutableMapOf())
+
/**
* The value at which an alert will fire. For credit balance alerts, the alert will fire at
* or below this value. For usage and cost alerts, the alert will fire at or above this
@@ -686,20 +694,15 @@ private constructor(
*/
@JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value
+ @JsonAnySetter
+ private fun putAdditionalProperty(key: String, value: JsonValue) {
+ additionalProperties.put(key, value)
+ }
+
@JsonAnyGetter
@ExcludeMissing
- fun _additionalProperties(): Map = additionalProperties
-
- private var validated: Boolean = false
-
- fun validate(): Threshold = apply {
- if (validated) {
- return@apply
- }
-
- value()
- validated = true
- }
+ fun _additionalProperties(): Map =
+ Collections.unmodifiableMap(additionalProperties)
fun toBuilder() = Builder().from(this)
@@ -776,7 +779,18 @@ private constructor(
* @throws IllegalStateException if any required field is unset.
*/
fun build(): Threshold =
- Threshold(checkRequired("value", value), additionalProperties.toImmutable())
+ Threshold(checkRequired("value", value), additionalProperties.toMutableMap())
+ }
+
+ private var validated: Boolean = false
+
+ fun validate(): Threshold = apply {
+ if (validated) {
+ return@apply
+ }
+
+ value()
+ validated = true
}
override fun equals(other: Any?): Boolean {
diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForExternalCustomerParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForExternalCustomerParams.kt
index 727c9b24..caa76db5 100644
--- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForExternalCustomerParams.kt
+++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForExternalCustomerParams.kt
@@ -11,15 +11,14 @@ import com.withorb.api.core.ExcludeMissing
import com.withorb.api.core.JsonField
import com.withorb.api.core.JsonMissing
import com.withorb.api.core.JsonValue
-import com.withorb.api.core.NoAutoDetect
import com.withorb.api.core.Params
import com.withorb.api.core.checkKnown
import com.withorb.api.core.checkRequired
import com.withorb.api.core.http.Headers
import com.withorb.api.core.http.QueryParams
-import com.withorb.api.core.immutableEmptyMap
import com.withorb.api.core.toImmutable
import com.withorb.api.errors.OrbInvalidDataException
+import java.util.Collections
import java.util.Objects
import java.util.Optional
import kotlin.jvm.optionals.getOrNull
@@ -93,244 +92,6 @@ private constructor(
fun _additionalQueryParams(): QueryParams = additionalQueryParams
- @JvmSynthetic internal fun _body(): Body = body
-
- fun _pathParam(index: Int): String =
- when (index) {
- 0 -> externalCustomerId
- else -> ""
- }
-
- override fun _headers(): Headers = additionalHeaders
-
- override fun _queryParams(): QueryParams = additionalQueryParams
-
- @NoAutoDetect
- class Body
- @JsonCreator
- private constructor(
- @JsonProperty("currency")
- @ExcludeMissing
- private val currency: JsonField = JsonMissing.of(),
- @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(),
- @JsonProperty("thresholds")
- @ExcludeMissing
- private val thresholds: JsonField> = JsonMissing.of(),
- @JsonAnySetter
- private val additionalProperties: Map = immutableEmptyMap(),
- ) {
-
- /**
- * The case sensitive currency or custom pricing unit to use for this alert.
- *
- * @throws OrbInvalidDataException if the JSON field has an unexpected type or is
- * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
- */
- fun currency(): String = currency.getRequired("currency")
-
- /**
- * The type of alert to create. This must be a valid alert type.
- *
- * @throws OrbInvalidDataException if the JSON field has an unexpected type or is
- * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
- */
- fun type(): Type = type.getRequired("type")
-
- /**
- * The thresholds that define the values at which the alert will be triggered.
- *
- * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the
- * server responded with an unexpected value).
- */
- fun thresholds(): Optional> =
- Optional.ofNullable(thresholds.getNullable("thresholds"))
-
- /**
- * Returns the raw JSON value of [currency].
- *
- * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type.
- */
- @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency
-
- /**
- * Returns the raw JSON value of [type].
- *
- * Unlike [type], this method doesn't throw if the JSON field has an unexpected type.
- */
- @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type
-
- /**
- * Returns the raw JSON value of [thresholds].
- *
- * Unlike [thresholds], this method doesn't throw if the JSON field has an unexpected type.
- */
- @JsonProperty("thresholds")
- @ExcludeMissing
- fun _thresholds(): JsonField> = thresholds
-
- @JsonAnyGetter
- @ExcludeMissing
- fun _additionalProperties(): Map = additionalProperties
-
- private var validated: Boolean = false
-
- fun validate(): Body = apply {
- if (validated) {
- return@apply
- }
-
- currency()
- type()
- thresholds().ifPresent { it.forEach { it.validate() } }
- validated = true
- }
-
- fun toBuilder() = Builder().from(this)
-
- companion object {
-
- /**
- * Returns a mutable builder for constructing an instance of [Body].
- *
- * The following fields are required:
- * ```java
- * .currency()
- * .type()
- * ```
- */
- @JvmStatic fun builder() = Builder()
- }
-
- /** A builder for [Body]. */
- class Builder internal constructor() {
-
- private var currency: JsonField? = null
- private var type: JsonField? = null
- private var thresholds: JsonField>? = null
- private var additionalProperties: MutableMap = mutableMapOf()
-
- @JvmSynthetic
- internal fun from(body: Body) = apply {
- currency = body.currency
- type = body.type
- thresholds = body.thresholds.map { it.toMutableList() }
- additionalProperties = body.additionalProperties.toMutableMap()
- }
-
- /** The case sensitive currency or custom pricing unit to use for this alert. */
- fun currency(currency: String) = currency(JsonField.of(currency))
-
- /**
- * Sets [Builder.currency] to an arbitrary JSON value.
- *
- * You should usually call [Builder.currency] with a well-typed [String] value instead.
- * This method is primarily for setting the field to an undocumented or not yet
- * supported value.
- */
- fun currency(currency: JsonField) = apply { this.currency = currency }
-
- /** The type of alert to create. This must be a valid alert type. */
- fun type(type: Type) = type(JsonField.of(type))
-
- /**
- * Sets [Builder.type] to an arbitrary JSON value.
- *
- * You should usually call [Builder.type] with a well-typed [Type] value instead. This
- * method is primarily for setting the field to an undocumented or not yet supported
- * value.
- */
- fun type(type: JsonField) = apply { this.type = type }
-
- /** The thresholds that define the values at which the alert will be triggered. */
- fun thresholds(thresholds: List?) =
- thresholds(JsonField.ofNullable(thresholds))
-
- /** Alias for calling [Builder.thresholds] with `thresholds.orElse(null)`. */
- fun thresholds(thresholds: Optional>) =
- thresholds(thresholds.getOrNull())
-
- /**
- * Sets [Builder.thresholds] to an arbitrary JSON value.
- *
- * You should usually call [Builder.thresholds] with a well-typed `List`
- * value instead. This method is primarily for setting the field to an undocumented or
- * not yet supported value.
- */
- fun thresholds(thresholds: JsonField>) = apply {
- this.thresholds = thresholds.map { it.toMutableList() }
- }
-
- /**
- * Adds a single [Threshold] to [thresholds].
- *
- * @throws IllegalStateException if the field was previously set to a non-list.
- */
- fun addThreshold(threshold: Threshold) = apply {
- thresholds =
- (thresholds ?: JsonField.of(mutableListOf())).also {
- checkKnown("thresholds", it).add(threshold)
- }
- }
-
- fun additionalProperties(additionalProperties: Map) = apply {
- this.additionalProperties.clear()
- putAllAdditionalProperties(additionalProperties)
- }
-
- fun putAdditionalProperty(key: String, value: JsonValue) = apply {
- additionalProperties.put(key, value)
- }
-
- fun putAllAdditionalProperties(additionalProperties: Map) = apply {
- this.additionalProperties.putAll(additionalProperties)
- }
-
- fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) }
-
- fun removeAllAdditionalProperties(keys: Set) = apply {
- keys.forEach(::removeAdditionalProperty)
- }
-
- /**
- * Returns an immutable instance of [Body].
- *
- * Further updates to this [Builder] will not mutate the returned instance.
- *
- * The following fields are required:
- * ```java
- * .currency()
- * .type()
- * ```
- *
- * @throws IllegalStateException if any required field is unset.
- */
- fun build(): Body =
- Body(
- checkRequired("currency", currency),
- checkRequired("type", type),
- (thresholds ?: JsonMissing.of()).map { it.toImmutable() },
- additionalProperties.toImmutable(),
- )
- }
-
- override fun equals(other: Any?): Boolean {
- if (this === other) {
- return true
- }
-
- return /* spotless:off */ other is Body && currency == other.currency && type == other.type && thresholds == other.thresholds && additionalProperties == other.additionalProperties /* spotless:on */
- }
-
- /* spotless:off */
- private val hashCode: Int by lazy { Objects.hash(currency, type, thresholds, additionalProperties) }
- /* spotless:on */
-
- override fun hashCode(): Int = hashCode
-
- override fun toString() =
- "Body{currency=$currency, type=$type, thresholds=$thresholds, additionalProperties=$additionalProperties}"
- }
-
fun toBuilder() = Builder().from(this)
companion object {
@@ -350,7 +111,6 @@ private constructor(
}
/** A builder for [AlertCreateForExternalCustomerParams]. */
- @NoAutoDetect
class Builder internal constructor() {
private var externalCustomerId: String? = null
@@ -559,6 +319,254 @@ private constructor(
)
}
+ @JvmSynthetic internal fun _body(): Body = body
+
+ fun _pathParam(index: Int): String =
+ when (index) {
+ 0 -> externalCustomerId
+ else -> ""
+ }
+
+ override fun _headers(): Headers = additionalHeaders
+
+ override fun _queryParams(): QueryParams = additionalQueryParams
+
+ class Body
+ private constructor(
+ private val currency: JsonField,
+ private val type: JsonField,
+ private val thresholds: JsonField>,
+ private val additionalProperties: MutableMap,
+ ) {
+
+ @JsonCreator
+ private constructor(
+ @JsonProperty("currency")
+ @ExcludeMissing
+ currency: JsonField = JsonMissing.of(),
+ @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(),
+ @JsonProperty("thresholds")
+ @ExcludeMissing
+ thresholds: JsonField> = JsonMissing.of(),
+ ) : this(currency, type, thresholds, mutableMapOf())
+
+ /**
+ * The case sensitive currency or custom pricing unit to use for this alert.
+ *
+ * @throws OrbInvalidDataException if the JSON field has an unexpected type or is
+ * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
+ */
+ fun currency(): String = currency.getRequired("currency")
+
+ /**
+ * The type of alert to create. This must be a valid alert type.
+ *
+ * @throws OrbInvalidDataException if the JSON field has an unexpected type or is
+ * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
+ */
+ fun type(): Type = type.getRequired("type")
+
+ /**
+ * The thresholds that define the values at which the alert will be triggered.
+ *
+ * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
+ fun thresholds(): Optional> =
+ Optional.ofNullable(thresholds.getNullable("thresholds"))
+
+ /**
+ * Returns the raw JSON value of [currency].
+ *
+ * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency
+
+ /**
+ * Returns the raw JSON value of [type].
+ *
+ * Unlike [type], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type
+
+ /**
+ * Returns the raw JSON value of [thresholds].
+ *
+ * Unlike [thresholds], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("thresholds")
+ @ExcludeMissing
+ fun _thresholds(): JsonField> = thresholds
+
+ @JsonAnySetter
+ private fun putAdditionalProperty(key: String, value: JsonValue) {
+ additionalProperties.put(key, value)
+ }
+
+ @JsonAnyGetter
+ @ExcludeMissing
+ fun _additionalProperties(): Map =
+ Collections.unmodifiableMap(additionalProperties)
+
+ fun toBuilder() = Builder().from(this)
+
+ companion object {
+
+ /**
+ * Returns a mutable builder for constructing an instance of [Body].
+ *
+ * The following fields are required:
+ * ```java
+ * .currency()
+ * .type()
+ * ```
+ */
+ @JvmStatic fun builder() = Builder()
+ }
+
+ /** A builder for [Body]. */
+ class Builder internal constructor() {
+
+ private var currency: JsonField? = null
+ private var type: JsonField? = null
+ private var thresholds: JsonField>? = null
+ private var additionalProperties: MutableMap = mutableMapOf()
+
+ @JvmSynthetic
+ internal fun from(body: Body) = apply {
+ currency = body.currency
+ type = body.type
+ thresholds = body.thresholds.map { it.toMutableList() }
+ additionalProperties = body.additionalProperties.toMutableMap()
+ }
+
+ /** The case sensitive currency or custom pricing unit to use for this alert. */
+ fun currency(currency: String) = currency(JsonField.of(currency))
+
+ /**
+ * Sets [Builder.currency] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.currency] with a well-typed [String] value instead.
+ * This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun currency(currency: JsonField) = apply { this.currency = currency }
+
+ /** The type of alert to create. This must be a valid alert type. */
+ fun type(type: Type) = type(JsonField.of(type))
+
+ /**
+ * Sets [Builder.type] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.type] with a well-typed [Type] value instead. This
+ * method is primarily for setting the field to an undocumented or not yet supported
+ * value.
+ */
+ fun type(type: JsonField) = apply { this.type = type }
+
+ /** The thresholds that define the values at which the alert will be triggered. */
+ fun thresholds(thresholds: List?) =
+ thresholds(JsonField.ofNullable(thresholds))
+
+ /** Alias for calling [Builder.thresholds] with `thresholds.orElse(null)`. */
+ fun thresholds(thresholds: Optional>) =
+ thresholds(thresholds.getOrNull())
+
+ /**
+ * Sets [Builder.thresholds] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.thresholds] with a well-typed `List`
+ * value instead. This method is primarily for setting the field to an undocumented or
+ * not yet supported value.
+ */
+ fun thresholds(thresholds: JsonField>) = apply {
+ this.thresholds = thresholds.map { it.toMutableList() }
+ }
+
+ /**
+ * Adds a single [Threshold] to [thresholds].
+ *
+ * @throws IllegalStateException if the field was previously set to a non-list.
+ */
+ fun addThreshold(threshold: Threshold) = apply {
+ thresholds =
+ (thresholds ?: JsonField.of(mutableListOf())).also {
+ checkKnown("thresholds", it).add(threshold)
+ }
+ }
+
+ fun additionalProperties(additionalProperties: Map) = apply {
+ this.additionalProperties.clear()
+ putAllAdditionalProperties(additionalProperties)
+ }
+
+ fun putAdditionalProperty(key: String, value: JsonValue) = apply {
+ additionalProperties.put(key, value)
+ }
+
+ fun putAllAdditionalProperties(additionalProperties: Map) = apply {
+ this.additionalProperties.putAll(additionalProperties)
+ }
+
+ fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) }
+
+ fun removeAllAdditionalProperties(keys: Set) = apply {
+ keys.forEach(::removeAdditionalProperty)
+ }
+
+ /**
+ * Returns an immutable instance of [Body].
+ *
+ * Further updates to this [Builder] will not mutate the returned instance.
+ *
+ * The following fields are required:
+ * ```java
+ * .currency()
+ * .type()
+ * ```
+ *
+ * @throws IllegalStateException if any required field is unset.
+ */
+ fun build(): Body =
+ Body(
+ checkRequired("currency", currency),
+ checkRequired("type", type),
+ (thresholds ?: JsonMissing.of()).map { it.toImmutable() },
+ additionalProperties.toMutableMap(),
+ )
+ }
+
+ private var validated: Boolean = false
+
+ fun validate(): Body = apply {
+ if (validated) {
+ return@apply
+ }
+
+ currency()
+ type()
+ thresholds().ifPresent { it.forEach { it.validate() } }
+ validated = true
+ }
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
+
+ return /* spotless:off */ other is Body && currency == other.currency && type == other.type && thresholds == other.thresholds && additionalProperties == other.additionalProperties /* spotless:on */
+ }
+
+ /* spotless:off */
+ private val hashCode: Int by lazy { Objects.hash(currency, type, thresholds, additionalProperties) }
+ /* spotless:on */
+
+ override fun hashCode(): Int = hashCode
+
+ override fun toString() =
+ "Body{currency=$currency, type=$type, thresholds=$thresholds, additionalProperties=$additionalProperties}"
+ }
+
/** The type of alert to create. This must be a valid alert type. */
class Type @JsonCreator private constructor(private val value: JsonField) : Enum {
@@ -664,17 +672,17 @@ private constructor(
}
/** Thresholds are used to define the conditions under which an alert will be triggered. */
- @NoAutoDetect
class Threshold
- @JsonCreator
private constructor(
- @JsonProperty("value")
- @ExcludeMissing
- private val value: JsonField = JsonMissing.of(),
- @JsonAnySetter
- private val additionalProperties: Map = immutableEmptyMap(),
+ private val value: JsonField,
+ private val additionalProperties: MutableMap,
) {
+ @JsonCreator
+ private constructor(
+ @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of()
+ ) : this(value, mutableMapOf())
+
/**
* The value at which an alert will fire. For credit balance alerts, the alert will fire at
* or below this value. For usage and cost alerts, the alert will fire at or above this
@@ -692,20 +700,15 @@ private constructor(
*/
@JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value
+ @JsonAnySetter
+ private fun putAdditionalProperty(key: String, value: JsonValue) {
+ additionalProperties.put(key, value)
+ }
+
@JsonAnyGetter
@ExcludeMissing
- fun _additionalProperties(): Map = additionalProperties
-
- private var validated: Boolean = false
-
- fun validate(): Threshold = apply {
- if (validated) {
- return@apply
- }
-
- value()
- validated = true
- }
+ fun _additionalProperties(): Map =
+ Collections.unmodifiableMap(additionalProperties)
fun toBuilder() = Builder().from(this)
@@ -782,7 +785,18 @@ private constructor(
* @throws IllegalStateException if any required field is unset.
*/
fun build(): Threshold =
- Threshold(checkRequired("value", value), additionalProperties.toImmutable())
+ Threshold(checkRequired("value", value), additionalProperties.toMutableMap())
+ }
+
+ private var validated: Boolean = false
+
+ fun validate(): Threshold = apply {
+ if (validated) {
+ return@apply
+ }
+
+ value()
+ validated = true
}
override fun equals(other: Any?): Boolean {
diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForSubscriptionParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForSubscriptionParams.kt
index 594ca94d..5aa2c875 100644
--- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForSubscriptionParams.kt
+++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForSubscriptionParams.kt
@@ -11,15 +11,14 @@ import com.withorb.api.core.ExcludeMissing
import com.withorb.api.core.JsonField
import com.withorb.api.core.JsonMissing
import com.withorb.api.core.JsonValue
-import com.withorb.api.core.NoAutoDetect
import com.withorb.api.core.Params
import com.withorb.api.core.checkKnown
import com.withorb.api.core.checkRequired
import com.withorb.api.core.http.Headers
import com.withorb.api.core.http.QueryParams
-import com.withorb.api.core.immutableEmptyMap
import com.withorb.api.core.toImmutable
import com.withorb.api.errors.OrbInvalidDataException
+import java.util.Collections
import java.util.Objects
import java.util.Optional
import kotlin.jvm.optionals.getOrNull
@@ -97,241 +96,6 @@ private constructor(
fun _additionalQueryParams(): QueryParams = additionalQueryParams
- @JvmSynthetic internal fun _body(): Body = body
-
- fun _pathParam(index: Int): String =
- when (index) {
- 0 -> subscriptionId
- else -> ""
- }
-
- override fun _headers(): Headers = additionalHeaders
-
- override fun _queryParams(): QueryParams = additionalQueryParams
-
- @NoAutoDetect
- class Body
- @JsonCreator
- private constructor(
- @JsonProperty("thresholds")
- @ExcludeMissing
- private val thresholds: JsonField> = JsonMissing.of(),
- @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(),
- @JsonProperty("metric_id")
- @ExcludeMissing
- private val metricId: JsonField = JsonMissing.of(),
- @JsonAnySetter
- private val additionalProperties: Map = immutableEmptyMap(),
- ) {
-
- /**
- * The thresholds that define the values at which the alert will be triggered.
- *
- * @throws OrbInvalidDataException if the JSON field has an unexpected type or is
- * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
- */
- fun thresholds(): List = thresholds.getRequired("thresholds")
-
- /**
- * The type of alert to create. This must be a valid alert type.
- *
- * @throws OrbInvalidDataException if the JSON field has an unexpected type or is
- * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
- */
- fun type(): Type = type.getRequired("type")
-
- /**
- * The metric to track usage for.
- *
- * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the
- * server responded with an unexpected value).
- */
- fun metricId(): Optional = Optional.ofNullable(metricId.getNullable("metric_id"))
-
- /**
- * Returns the raw JSON value of [thresholds].
- *
- * Unlike [thresholds], this method doesn't throw if the JSON field has an unexpected type.
- */
- @JsonProperty("thresholds")
- @ExcludeMissing
- fun _thresholds(): JsonField> = thresholds
-
- /**
- * Returns the raw JSON value of [type].
- *
- * Unlike [type], this method doesn't throw if the JSON field has an unexpected type.
- */
- @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type
-
- /**
- * Returns the raw JSON value of [metricId].
- *
- * Unlike [metricId], this method doesn't throw if the JSON field has an unexpected type.
- */
- @JsonProperty("metric_id") @ExcludeMissing fun _metricId(): JsonField = metricId
-
- @JsonAnyGetter
- @ExcludeMissing
- fun _additionalProperties(): Map = additionalProperties
-
- private var validated: Boolean = false
-
- fun validate(): Body = apply {
- if (validated) {
- return@apply
- }
-
- thresholds().forEach { it.validate() }
- type()
- metricId()
- validated = true
- }
-
- fun toBuilder() = Builder().from(this)
-
- companion object {
-
- /**
- * Returns a mutable builder for constructing an instance of [Body].
- *
- * The following fields are required:
- * ```java
- * .thresholds()
- * .type()
- * ```
- */
- @JvmStatic fun builder() = Builder()
- }
-
- /** A builder for [Body]. */
- class Builder internal constructor() {
-
- private var thresholds: JsonField>? = null
- private var type: JsonField? = null
- private var metricId: JsonField = JsonMissing.of()
- private var additionalProperties: MutableMap = mutableMapOf()
-
- @JvmSynthetic
- internal fun from(body: Body) = apply {
- thresholds = body.thresholds.map { it.toMutableList() }
- type = body.type
- metricId = body.metricId
- additionalProperties = body.additionalProperties.toMutableMap()
- }
-
- /** The thresholds that define the values at which the alert will be triggered. */
- fun thresholds(thresholds: List) = thresholds(JsonField.of(thresholds))
-
- /**
- * Sets [Builder.thresholds] to an arbitrary JSON value.
- *
- * You should usually call [Builder.thresholds] with a well-typed `List`
- * value instead. This method is primarily for setting the field to an undocumented or
- * not yet supported value.
- */
- fun thresholds(thresholds: JsonField>) = apply {
- this.thresholds = thresholds.map { it.toMutableList() }
- }
-
- /**
- * Adds a single [Threshold] to [thresholds].
- *
- * @throws IllegalStateException if the field was previously set to a non-list.
- */
- fun addThreshold(threshold: Threshold) = apply {
- thresholds =
- (thresholds ?: JsonField.of(mutableListOf())).also {
- checkKnown("thresholds", it).add(threshold)
- }
- }
-
- /** The type of alert to create. This must be a valid alert type. */
- fun type(type: Type) = type(JsonField.of(type))
-
- /**
- * Sets [Builder.type] to an arbitrary JSON value.
- *
- * You should usually call [Builder.type] with a well-typed [Type] value instead. This
- * method is primarily for setting the field to an undocumented or not yet supported
- * value.
- */
- fun type(type: JsonField) = apply { this.type = type }
-
- /** The metric to track usage for. */
- fun metricId(metricId: String?) = metricId(JsonField.ofNullable(metricId))
-
- /** Alias for calling [Builder.metricId] with `metricId.orElse(null)`. */
- fun metricId(metricId: Optional) = metricId(metricId.getOrNull())
-
- /**
- * Sets [Builder.metricId] to an arbitrary JSON value.
- *
- * You should usually call [Builder.metricId] with a well-typed [String] value instead.
- * This method is primarily for setting the field to an undocumented or not yet
- * supported value.
- */
- fun metricId(metricId: JsonField) = apply { this.metricId = metricId }
-
- fun additionalProperties(additionalProperties: Map) = apply {
- this.additionalProperties.clear()
- putAllAdditionalProperties(additionalProperties)
- }
-
- fun putAdditionalProperty(key: String, value: JsonValue) = apply {
- additionalProperties.put(key, value)
- }
-
- fun putAllAdditionalProperties(additionalProperties: Map) = apply {
- this.additionalProperties.putAll(additionalProperties)
- }
-
- fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) }
-
- fun removeAllAdditionalProperties(keys: Set) = apply {
- keys.forEach(::removeAdditionalProperty)
- }
-
- /**
- * Returns an immutable instance of [Body].
- *
- * Further updates to this [Builder] will not mutate the returned instance.
- *
- * The following fields are required:
- * ```java
- * .thresholds()
- * .type()
- * ```
- *
- * @throws IllegalStateException if any required field is unset.
- */
- fun build(): Body =
- Body(
- checkRequired("thresholds", thresholds).map { it.toImmutable() },
- checkRequired("type", type),
- metricId,
- additionalProperties.toImmutable(),
- )
- }
-
- override fun equals(other: Any?): Boolean {
- if (this === other) {
- return true
- }
-
- return /* spotless:off */ other is Body && thresholds == other.thresholds && type == other.type && metricId == other.metricId && additionalProperties == other.additionalProperties /* spotless:on */
- }
-
- /* spotless:off */
- private val hashCode: Int by lazy { Objects.hash(thresholds, type, metricId, additionalProperties) }
- /* spotless:on */
-
- override fun hashCode(): Int = hashCode
-
- override fun toString() =
- "Body{thresholds=$thresholds, type=$type, metricId=$metricId, additionalProperties=$additionalProperties}"
- }
-
fun toBuilder() = Builder().from(this)
companion object {
@@ -351,7 +115,6 @@ private constructor(
}
/** A builder for [AlertCreateForSubscriptionParams]. */
- @NoAutoDetect
class Builder internal constructor() {
private var subscriptionId: String? = null
@@ -557,50 +320,290 @@ private constructor(
)
}
- /** Thresholds are used to define the conditions under which an alert will be triggered. */
- @NoAutoDetect
- class Threshold
- @JsonCreator
+ @JvmSynthetic internal fun _body(): Body = body
+
+ fun _pathParam(index: Int): String =
+ when (index) {
+ 0 -> subscriptionId
+ else -> ""
+ }
+
+ override fun _headers(): Headers = additionalHeaders
+
+ override fun _queryParams(): QueryParams = additionalQueryParams
+
+ class Body
private constructor(
- @JsonProperty("value")
- @ExcludeMissing
- private val value: JsonField = JsonMissing.of(),
- @JsonAnySetter
- private val additionalProperties: Map = immutableEmptyMap(),
+ private val thresholds: JsonField>,
+ private val type: JsonField,
+ private val metricId: JsonField,
+ private val additionalProperties: MutableMap,
) {
+ @JsonCreator
+ private constructor(
+ @JsonProperty("thresholds")
+ @ExcludeMissing
+ thresholds: JsonField> = JsonMissing.of(),
+ @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(),
+ @JsonProperty("metric_id")
+ @ExcludeMissing
+ metricId: JsonField = JsonMissing.of(),
+ ) : this(thresholds, type, metricId, mutableMapOf())
+
/**
- * The value at which an alert will fire. For credit balance alerts, the alert will fire at
- * or below this value. For usage and cost alerts, the alert will fire at or above this
- * value.
+ * The thresholds that define the values at which the alert will be triggered.
*
* @throws OrbInvalidDataException if the JSON field has an unexpected type or is
* unexpectedly missing or null (e.g. if the server responded with an unexpected value).
*/
- fun value(): Double = value.getRequired("value")
+ fun thresholds(): List = thresholds.getRequired("thresholds")
/**
- * Returns the raw JSON value of [value].
+ * The type of alert to create. This must be a valid alert type.
*
- * Unlike [value], this method doesn't throw if the JSON field has an unexpected type.
+ * @throws OrbInvalidDataException if the JSON field has an unexpected type or is
+ * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
*/
- @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value
+ fun type(): Type = type.getRequired("type")
+
+ /**
+ * The metric to track usage for.
+ *
+ * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
+ fun metricId(): Optional = Optional.ofNullable(metricId.getNullable("metric_id"))
+
+ /**
+ * Returns the raw JSON value of [thresholds].
+ *
+ * Unlike [thresholds], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("thresholds")
+ @ExcludeMissing
+ fun _thresholds(): JsonField> = thresholds
+
+ /**
+ * Returns the raw JSON value of [type].
+ *
+ * Unlike [type], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type
+
+ /**
+ * Returns the raw JSON value of [metricId].
+ *
+ * Unlike [metricId], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("metric_id") @ExcludeMissing fun _metricId(): JsonField = metricId
+
+ @JsonAnySetter
+ private fun putAdditionalProperty(key: String, value: JsonValue) {
+ additionalProperties.put(key, value)
+ }
@JsonAnyGetter
@ExcludeMissing
- fun _additionalProperties(): Map