diff --git a/.release-please-manifest.json b/.release-please-manifest.json
index a26ebfc1..8f3e0a49 100644
--- a/.release-please-manifest.json
+++ b/.release-please-manifest.json
@@ -1,3 +1,3 @@
{
- ".": "0.14.0"
+ ".": "0.15.0"
}
\ No newline at end of file
diff --git a/.stats.yml b/.stats.yml
index 09794c42..0b824ed2 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,2 +1,2 @@
-configured_endpoints: 97
-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-77f4e8cf0fc3b3f18c894408f322af7988ae90606235fe5058442409142a33e1.yml
+configured_endpoints: 101
+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-c5fe55b056b10d6581c877beb0639a8f0a623e52fd9778e56fab8a86439bd31b.yml
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 866c7e38..37514f77 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,13 @@
# Changelog
+## 0.15.0 (2025-01-02)
+
+Full Changelog: [v0.14.0...v0.15.0](https://github.com/orbcorp/orb-java/compare/v0.14.0...v0.15.0)
+
+### Features
+
+* **api:** api update ([#161](https://github.com/orbcorp/orb-java/issues/161)) ([d035cba](https://github.com/orbcorp/orb-java/commit/d035cbaf1d1d98117ed800b746e969b1c6b368cc))
+
## 0.14.0 (2024-12-23)
Full Changelog: [v0.13.0...v0.14.0](https://github.com/orbcorp/orb-java/compare/v0.13.0...v0.14.0)
diff --git a/README.md b/README.md
index adfbe079..89816dcf 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
-[](https://central.sonatype.com/artifact/com.withorb.api/orb-java/0.14.0)
+[](https://central.sonatype.com/artifact/com.withorb.api/orb-java/0.15.0)
@@ -25,7 +25,7 @@ The REST API documentation can be foundĀ on [docs.withorb.com](https://docs.with
```kotlin
-implementation("com.withorb.api:orb-java:0.14.0")
+implementation("com.withorb.api:orb-java:0.15.0")
```
#### Maven
@@ -34,7 +34,7 @@ implementation("com.withorb.api:orb-java:0.14.0")
com.withorb.api
orb-java
- 0.14.0
+ 0.15.0
```
@@ -346,7 +346,7 @@ This library is typed for convenient access to the documented API. If you need t
To make requests using undocumented parameters, you can provide or override parameters on the params object while building it.
-```kotlin
+```java
FooCreateParams address = FooCreateParams.builder()
.id("my_id")
.putAdditionalProperty("secret_prop", JsonValue.from("hello"))
diff --git a/build.gradle.kts b/build.gradle.kts
index bc8fff11..7d153221 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -4,7 +4,7 @@ plugins {
allprojects {
group = "com.withorb.api"
- version = "0.14.0" // x-release-please-version
+ version = "0.15.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 caf3d2a8..61da295b 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
@@ -130,7 +130,7 @@ class OrbOkHttpClient private constructor() {
fun apiKey(apiKey: String) = apply { clientOptions.apiKey(apiKey) }
- fun webhookSecret(webhookSecret: String?) = apply {
+ fun webhookSecret(webhookSecret: String) = apply {
clientOptions.webhookSecret(webhookSecret)
}
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 4c7bfd71..7ccb5cea 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
@@ -130,7 +130,7 @@ class OrbOkHttpClientAsync private constructor() {
fun apiKey(apiKey: String) = apply { clientOptions.apiKey(apiKey) }
- fun webhookSecret(webhookSecret: String?) = apply {
+ fun webhookSecret(webhookSecret: String) = apply {
clientOptions.webhookSecret(webhookSecret)
}
diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClient.kt b/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClient.kt
index 943832f3..8f4221f3 100644
--- a/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClient.kt
+++ b/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClient.kt
@@ -6,6 +6,7 @@ import com.withorb.api.services.blocking.AlertService
import com.withorb.api.services.blocking.CouponService
import com.withorb.api.services.blocking.CreditNoteService
import com.withorb.api.services.blocking.CustomerService
+import com.withorb.api.services.blocking.DimensionalPriceGroupService
import com.withorb.api.services.blocking.EventService
import com.withorb.api.services.blocking.InvoiceLineItemService
import com.withorb.api.services.blocking.InvoiceService
@@ -15,6 +16,7 @@ import com.withorb.api.services.blocking.PlanService
import com.withorb.api.services.blocking.PriceService
import com.withorb.api.services.blocking.SubscriptionService
import com.withorb.api.services.blocking.TopLevelService
+import com.withorb.api.services.blocking.WebhookService
interface OrbClient {
@@ -46,5 +48,7 @@ interface OrbClient {
fun alerts(): AlertService
+ fun dimensionalPriceGroups(): DimensionalPriceGroupService
+
fun webhooks(): WebhookService
}
diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientAsync.kt
index 88d26dd0..161df6c8 100644
--- a/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientAsync.kt
+++ b/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientAsync.kt
@@ -6,6 +6,7 @@ import com.withorb.api.services.async.AlertServiceAsync
import com.withorb.api.services.async.CouponServiceAsync
import com.withorb.api.services.async.CreditNoteServiceAsync
import com.withorb.api.services.async.CustomerServiceAsync
+import com.withorb.api.services.async.DimensionalPriceGroupServiceAsync
import com.withorb.api.services.async.EventServiceAsync
import com.withorb.api.services.async.InvoiceLineItemServiceAsync
import com.withorb.api.services.async.InvoiceServiceAsync
@@ -45,4 +46,6 @@ interface OrbClientAsync {
fun subscriptions(): SubscriptionServiceAsync
fun alerts(): AlertServiceAsync
+
+ fun dimensionalPriceGroups(): DimensionalPriceGroupServiceAsync
}
diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientAsyncImpl.kt
index 1de69a55..ba6efc41 100644
--- a/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientAsyncImpl.kt
+++ b/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientAsyncImpl.kt
@@ -12,6 +12,8 @@ import com.withorb.api.services.async.CreditNoteServiceAsync
import com.withorb.api.services.async.CreditNoteServiceAsyncImpl
import com.withorb.api.services.async.CustomerServiceAsync
import com.withorb.api.services.async.CustomerServiceAsyncImpl
+import com.withorb.api.services.async.DimensionalPriceGroupServiceAsync
+import com.withorb.api.services.async.DimensionalPriceGroupServiceAsyncImpl
import com.withorb.api.services.async.EventServiceAsync
import com.withorb.api.services.async.EventServiceAsyncImpl
import com.withorb.api.services.async.InvoiceLineItemServiceAsync
@@ -95,6 +97,10 @@ constructor(
AlertServiceAsyncImpl(clientOptionsWithUserAgent)
}
+ private val dimensionalPriceGroups: DimensionalPriceGroupServiceAsync by lazy {
+ DimensionalPriceGroupServiceAsyncImpl(clientOptionsWithUserAgent)
+ }
+
override fun sync(): OrbClient = sync
override fun topLevel(): TopLevelServiceAsync = topLevel
@@ -122,4 +128,7 @@ constructor(
override fun subscriptions(): SubscriptionServiceAsync = subscriptions
override fun alerts(): AlertServiceAsync = alerts
+
+ override fun dimensionalPriceGroups(): DimensionalPriceGroupServiceAsync =
+ dimensionalPriceGroups
}
diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientImpl.kt
index 895d5af3..f1c01fee 100644
--- a/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientImpl.kt
+++ b/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientImpl.kt
@@ -12,6 +12,10 @@ import com.withorb.api.services.blocking.CreditNoteService
import com.withorb.api.services.blocking.CreditNoteServiceImpl
import com.withorb.api.services.blocking.CustomerService
import com.withorb.api.services.blocking.CustomerServiceImpl
+import com.withorb.api.services.blocking.DimensionalPriceGroupService
+import com.withorb.api.services.blocking.DimensionalPriceGroupServiceImpl
+import com.withorb.api.services.blocking.WebhookService
+import com.withorb.api.services.blocking.WebhookServiceImpl
import com.withorb.api.services.blocking.EventService
import com.withorb.api.services.blocking.EventServiceImpl
import com.withorb.api.services.blocking.InvoiceLineItemService
@@ -83,6 +87,10 @@ constructor(
private val alerts: AlertService by lazy { AlertServiceImpl(clientOptionsWithUserAgent) }
+ private val dimensionalPriceGroups: DimensionalPriceGroupService by lazy {
+ DimensionalPriceGroupServiceImpl(clientOptionsWithUserAgent)
+ }
+
private val webhooks: WebhookService by lazy { WebhookServiceImpl(clientOptions) }
override fun async(): OrbClientAsync = async
@@ -113,5 +121,7 @@ constructor(
override fun alerts(): AlertService = alerts
+ override fun dimensionalPriceGroups(): DimensionalPriceGroupService = dimensionalPriceGroups
+
override fun webhooks(): WebhookService = webhooks
}
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 8a27a863..31d980e0 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
@@ -159,7 +159,7 @@ private constructor(
fun apiKey(apiKey: String) = apply { this.apiKey = apiKey }
- fun webhookSecret(webhookSecret: String?) = apply { this.webhookSecret = webhookSecret }
+ fun webhookSecret(webhookSecret: String) = apply { this.webhookSecret = webhookSecret }
fun fromEnv() = apply {
System.getenv("ORB_API_KEY")?.let { apiKey(it) }
diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/Utils.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/Utils.kt
index 9ce4bcd8..b1dbf27a 100644
--- a/orb-java-core/src/main/kotlin/com/withorb/api/core/Utils.kt
+++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/Utils.kt
@@ -17,7 +17,9 @@ internal fun List.toImmutable(): List =
@JvmSynthetic
internal fun Map.toImmutable(): Map =
- if (isEmpty()) Collections.emptyMap() else Collections.unmodifiableMap(toMap())
+ if (isEmpty()) immutableEmptyMap() else Collections.unmodifiableMap(toMap())
+
+@JvmSynthetic internal fun immutableEmptyMap(): Map = Collections.emptyMap()
@JvmSynthetic
internal fun , V> SortedMap.toImmutable(): SortedMap =
diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/errors/OrbError.kt b/orb-java-core/src/main/kotlin/com/withorb/api/errors/OrbError.kt
index e84d496a..50c17f36 100644
--- a/orb-java-core/src/main/kotlin/com/withorb/api/errors/OrbError.kt
+++ b/orb-java-core/src/main/kotlin/com/withorb/api/errors/OrbError.kt
@@ -4,19 +4,23 @@ package com.withorb.api.errors
import com.fasterxml.jackson.annotation.JsonAnyGetter
import com.fasterxml.jackson.annotation.JsonAnySetter
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize
+import com.fasterxml.jackson.annotation.JsonCreator
+import com.withorb.api.core.ExcludeMissing
import com.withorb.api.core.JsonValue
import com.withorb.api.core.NoAutoDetect
+import com.withorb.api.core.immutableEmptyMap
import com.withorb.api.core.toImmutable
import java.util.Objects
-@JsonDeserialize(builder = OrbError.Builder::class)
@NoAutoDetect
class OrbError
+@JsonCreator
private constructor(
@JsonAnyGetter
+ @ExcludeMissing
+ @JsonAnySetter
@get:JvmName("additionalProperties")
- val additionalProperties: Map,
+ val additionalProperties: Map = immutableEmptyMap(),
) {
fun toBuilder() = Builder().from(this)
@@ -40,7 +44,6 @@ private constructor(
putAllAdditionalProperties(additionalProperties)
}
- @JsonAnySetter
fun putAdditionalProperty(key: String, value: JsonValue) = apply {
additionalProperties.put(key, value)
}
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 0d379278..e33c7d7e 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
@@ -6,13 +6,13 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter
import com.fasterxml.jackson.annotation.JsonAnySetter
import com.fasterxml.jackson.annotation.JsonCreator
import com.fasterxml.jackson.annotation.JsonProperty
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import com.withorb.api.core.Enum
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.immutableEmptyMap
import com.withorb.api.core.toImmutable
import com.withorb.api.errors.OrbInvalidDataException
import java.time.OffsetDateTime
@@ -30,25 +30,37 @@ import java.util.Optional
* |Customer |A customer's credit balance |`credit_balance_depleted`, `credit_balance_recovered`, and `credit_balance_dropped`|
* |Subscription|A subscription's usage or cost|`usage_exceeded` and `cost_exceeded` |
*/
-@JsonDeserialize(builder = Alert.Builder::class)
@NoAutoDetect
class Alert
+@JsonCreator
private constructor(
- private val id: JsonField,
- private val type: JsonField,
- private val createdAt: JsonField,
- private val enabled: JsonField,
- private val thresholds: JsonField>,
- private val customer: JsonField,
- private val plan: JsonField,
- private val subscription: JsonField,
- private val metric: JsonField,
- private val currency: JsonField,
- private val additionalProperties: Map,
+ @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(),
+ @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(),
+ @JsonProperty("created_at")
+ @ExcludeMissing
+ private val createdAt: JsonField = JsonMissing.of(),
+ @JsonProperty("enabled")
+ @ExcludeMissing
+ private val enabled: JsonField = JsonMissing.of(),
+ @JsonProperty("thresholds")
+ @ExcludeMissing
+ private val thresholds: JsonField> = JsonMissing.of(),
+ @JsonProperty("customer")
+ @ExcludeMissing
+ private val customer: JsonField = JsonMissing.of(),
+ @JsonProperty("plan") @ExcludeMissing private val plan: JsonField = JsonMissing.of(),
+ @JsonProperty("subscription")
+ @ExcludeMissing
+ private val subscription: JsonField = JsonMissing.of(),
+ @JsonProperty("metric")
+ @ExcludeMissing
+ private val metric: JsonField = JsonMissing.of(),
+ @JsonProperty("currency")
+ @ExcludeMissing
+ private val currency: JsonField = JsonMissing.of(),
+ @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(),
) {
- private var validated: Boolean = false
-
/** Also referred to as alert_id in this documentation. */
fun id(): String = id.getRequired("id")
@@ -115,6 +127,8 @@ private constructor(
@ExcludeMissing
fun _additionalProperties(): Map = additionalProperties
+ private var validated: Boolean = false
+
fun validate(): Alert = apply {
if (!validated) {
id()
@@ -154,55 +168,47 @@ private constructor(
@JvmSynthetic
internal fun from(alert: Alert) = apply {
- this.id = alert.id
- this.type = alert.type
- this.createdAt = alert.createdAt
- this.enabled = alert.enabled
- this.thresholds = alert.thresholds
- this.customer = alert.customer
- this.plan = alert.plan
- this.subscription = alert.subscription
- this.metric = alert.metric
- this.currency = alert.currency
- additionalProperties(alert.additionalProperties)
+ id = alert.id
+ type = alert.type
+ createdAt = alert.createdAt
+ enabled = alert.enabled
+ thresholds = alert.thresholds
+ customer = alert.customer
+ plan = alert.plan
+ subscription = alert.subscription
+ metric = alert.metric
+ currency = alert.currency
+ additionalProperties = alert.additionalProperties.toMutableMap()
}
/** Also referred to as alert_id in this documentation. */
fun id(id: String) = id(JsonField.of(id))
/** Also referred to as alert_id in this documentation. */
- @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id }
+ fun id(id: JsonField) = apply { this.id = id }
/** The type of alert. This must be a valid alert type. */
fun type(type: Type) = type(JsonField.of(type))
/** The type of alert. This must be a valid alert type. */
- @JsonProperty("type")
- @ExcludeMissing
fun type(type: JsonField) = apply { this.type = type }
/** The creation time of the resource in Orb. */
fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt))
/** The creation time of the resource in Orb. */
- @JsonProperty("created_at")
- @ExcludeMissing
fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt }
/** Whether the alert is enabled or disabled. */
fun enabled(enabled: Boolean) = enabled(JsonField.of(enabled))
/** Whether the alert is enabled or disabled. */
- @JsonProperty("enabled")
- @ExcludeMissing
fun enabled(enabled: JsonField) = apply { this.enabled = enabled }
/** The thresholds that define the conditions under which the alert will be triggered. */
fun thresholds(thresholds: List) = thresholds(JsonField.of(thresholds))
/** The thresholds that define the conditions under which the alert will be triggered. */
- @JsonProperty("thresholds")
- @ExcludeMissing
fun thresholds(thresholds: JsonField>) = apply {
this.thresholds = thresholds
}
@@ -211,24 +217,18 @@ private constructor(
fun customer(customer: Customer) = customer(JsonField.of(customer))
/** The customer the alert applies to. */
- @JsonProperty("customer")
- @ExcludeMissing
fun customer(customer: JsonField) = apply { this.customer = customer }
/** The plan the alert applies to. */
fun plan(plan: Plan) = plan(JsonField.of(plan))
/** The plan the alert applies to. */
- @JsonProperty("plan")
- @ExcludeMissing
fun plan(plan: JsonField) = apply { this.plan = plan }
/** The subscription the alert applies to. */
fun subscription(subscription: Subscription) = subscription(JsonField.of(subscription))
/** The subscription the alert applies to. */
- @JsonProperty("subscription")
- @ExcludeMissing
fun subscription(subscription: JsonField) = apply {
this.subscription = subscription
}
@@ -237,32 +237,33 @@ private constructor(
fun metric(metric: Metric) = metric(JsonField.of(metric))
/** The metric the alert applies to. */
- @JsonProperty("metric")
- @ExcludeMissing
fun metric(metric: JsonField) = apply { this.metric = metric }
/** The name of the currency the credit balance or invoice cost is denominated in. */
fun currency(currency: String) = currency(JsonField.of(currency))
/** The name of the currency the credit balance or invoice cost is denominated in. */
- @JsonProperty("currency")
- @ExcludeMissing
fun currency(currency: JsonField) = apply { this.currency = currency }
fun additionalProperties(additionalProperties: Map) = apply {
this.additionalProperties.clear()
- this.additionalProperties.putAll(additionalProperties)
+ putAllAdditionalProperties(additionalProperties)
}
- @JsonAnySetter
fun putAdditionalProperty(key: String, value: JsonValue) = apply {
- this.additionalProperties.put(key, value)
+ 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)
+ }
+
fun build(): Alert =
Alert(
id,
@@ -280,19 +281,20 @@ private constructor(
}
/** The customer the alert applies to. */
- @JsonDeserialize(builder = Customer.Builder::class)
@NoAutoDetect
class Customer
+ @JsonCreator
private constructor(
- private val additionalProperties: Map,
+ @JsonAnySetter
+ private val additionalProperties: Map = immutableEmptyMap(),
) {
- private var validated: Boolean = false
-
@JsonAnyGetter
@ExcludeMissing
fun _additionalProperties(): Map = additionalProperties
+ private var validated: Boolean = false
+
fun validate(): Customer = apply {
if (!validated) {
validated = true
@@ -312,23 +314,28 @@ private constructor(
@JvmSynthetic
internal fun from(customer: Customer) = apply {
- additionalProperties(customer.additionalProperties)
+ additionalProperties = customer.additionalProperties.toMutableMap()
}
fun additionalProperties(additionalProperties: Map) = apply {
this.additionalProperties.clear()
- this.additionalProperties.putAll(additionalProperties)
+ putAllAdditionalProperties(additionalProperties)
}
- @JsonAnySetter
fun putAdditionalProperty(key: String, value: JsonValue) = apply {
- this.additionalProperties.put(key, value)
+ 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)
+ }
+
fun build(): Customer = Customer(additionalProperties.toImmutable())
}
@@ -350,19 +357,20 @@ private constructor(
}
/** The metric the alert applies to. */
- @JsonDeserialize(builder = Metric.Builder::class)
@NoAutoDetect
class Metric
+ @JsonCreator
private constructor(
- private val additionalProperties: Map,
+ @JsonAnySetter
+ private val additionalProperties: Map = immutableEmptyMap(),
) {
- private var validated: Boolean = false
-
@JsonAnyGetter
@ExcludeMissing
fun _additionalProperties(): Map = additionalProperties
+ private var validated: Boolean = false
+
fun validate(): Metric = apply {
if (!validated) {
validated = true
@@ -382,23 +390,28 @@ private constructor(
@JvmSynthetic
internal fun from(metric: Metric) = apply {
- additionalProperties(metric.additionalProperties)
+ additionalProperties = metric.additionalProperties.toMutableMap()
}
fun additionalProperties(additionalProperties: Map) = apply {
this.additionalProperties.clear()
- this.additionalProperties.putAll(additionalProperties)
+ putAllAdditionalProperties(additionalProperties)
}
- @JsonAnySetter
fun putAdditionalProperty(key: String, value: JsonValue) = apply {
- this.additionalProperties.put(key, value)
+ 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)
+ }
+
fun build(): Metric = Metric(additionalProperties.toImmutable())
}
@@ -420,19 +433,20 @@ private constructor(
}
/** The plan the alert applies to. */
- @JsonDeserialize(builder = Plan.Builder::class)
@NoAutoDetect
class Plan
+ @JsonCreator
private constructor(
- private val additionalProperties: Map,
+ @JsonAnySetter
+ private val additionalProperties: Map = immutableEmptyMap(),
) {
- private var validated: Boolean = false
-
@JsonAnyGetter
@ExcludeMissing
fun _additionalProperties(): Map = additionalProperties
+ private var validated: Boolean = false
+
fun validate(): Plan = apply {
if (!validated) {
validated = true
@@ -452,23 +466,28 @@ private constructor(
@JvmSynthetic
internal fun from(plan: Plan) = apply {
- additionalProperties(plan.additionalProperties)
+ additionalProperties = plan.additionalProperties.toMutableMap()
}
fun additionalProperties(additionalProperties: Map) = apply {
this.additionalProperties.clear()
- this.additionalProperties.putAll(additionalProperties)
+ putAllAdditionalProperties(additionalProperties)
}
- @JsonAnySetter
fun putAdditionalProperty(key: String, value: JsonValue) = apply {
- this.additionalProperties.put(key, value)
+ 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)
+ }
+
fun build(): Plan = Plan(additionalProperties.toImmutable())
}
@@ -490,19 +509,20 @@ private constructor(
}
/** The subscription the alert applies to. */
- @JsonDeserialize(builder = Subscription.Builder::class)
@NoAutoDetect
class Subscription
+ @JsonCreator
private constructor(
- private val additionalProperties: Map,
+ @JsonAnySetter
+ private val additionalProperties: Map = immutableEmptyMap(),
) {
- private var validated: Boolean = false
-
@JsonAnyGetter
@ExcludeMissing
fun _additionalProperties(): Map = additionalProperties
+ private var validated: Boolean = false
+
fun validate(): Subscription = apply {
if (!validated) {
validated = true
@@ -522,23 +542,28 @@ private constructor(
@JvmSynthetic
internal fun from(subscription: Subscription) = apply {
- additionalProperties(subscription.additionalProperties)
+ additionalProperties = subscription.additionalProperties.toMutableMap()
}
fun additionalProperties(additionalProperties: Map) = apply {
this.additionalProperties.clear()
- this.additionalProperties.putAll(additionalProperties)
+ putAllAdditionalProperties(additionalProperties)
}
- @JsonAnySetter
fun putAdditionalProperty(key: String, value: JsonValue) = apply {
- this.additionalProperties.put(key, value)
+ 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)
+ }
+
fun build(): Subscription = Subscription(additionalProperties.toImmutable())
}
@@ -560,16 +585,17 @@ private constructor(
}
/** Thresholds are used to define the conditions under which an alert will be triggered. */
- @JsonDeserialize(builder = Threshold.Builder::class)
@NoAutoDetect
class Threshold
+ @JsonCreator
private constructor(
- private val value: JsonField,
- private val additionalProperties: Map,
+ @JsonProperty("value")
+ @ExcludeMissing
+ private val value: JsonField = JsonMissing.of(),
+ @JsonAnySetter
+ private val additionalProperties: Map = immutableEmptyMap(),
) {
- private var validated: Boolean = false
-
/**
* 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
@@ -588,6 +614,8 @@ private constructor(
@ExcludeMissing
fun _additionalProperties(): Map = additionalProperties
+ private var validated: Boolean = false
+
fun validate(): Threshold = apply {
if (!validated) {
value()
@@ -609,8 +637,8 @@ private constructor(
@JvmSynthetic
internal fun from(threshold: Threshold) = apply {
- this.value = threshold.value
- additionalProperties(threshold.additionalProperties)
+ value = threshold.value
+ additionalProperties = threshold.additionalProperties.toMutableMap()
}
/**
@@ -625,24 +653,27 @@ private constructor(
* at or below this value. For usage and cost alerts, the alert will fire at or above
* this value.
*/
- @JsonProperty("value")
- @ExcludeMissing
fun value(value: JsonField) = apply { this.value = value }
fun additionalProperties(additionalProperties: Map) = apply {
this.additionalProperties.clear()
- this.additionalProperties.putAll(additionalProperties)
+ putAllAdditionalProperties(additionalProperties)
}
- @JsonAnySetter
fun putAdditionalProperty(key: String, value: JsonValue) = apply {
- this.additionalProperties.put(key, value)
+ 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)
+ }
+
fun build(): Threshold = Threshold(value, additionalProperties.toImmutable())
}
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 5965c62e..e2f067e5 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
@@ -6,7 +6,6 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter
import com.fasterxml.jackson.annotation.JsonAnySetter
import com.fasterxml.jackson.annotation.JsonCreator
import com.fasterxml.jackson.annotation.JsonProperty
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import com.withorb.api.core.Enum
import com.withorb.api.core.ExcludeMissing
import com.withorb.api.core.JsonField
@@ -14,6 +13,7 @@ import com.withorb.api.core.JsonValue
import com.withorb.api.core.NoAutoDetect
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.Objects
@@ -65,24 +65,26 @@ constructor(
}
}
- @JsonDeserialize(builder = AlertCreateForCustomerBody.Builder::class)
@NoAutoDetect
class AlertCreateForCustomerBody
+ @JsonCreator
internal constructor(
- private val currency: String?,
- private val type: Type?,
- private val thresholds: List?,
- private val additionalProperties: Map,
+ @JsonProperty("currency") private val currency: String,
+ @JsonProperty("type") private val type: Type,
+ @JsonProperty("thresholds") private val thresholds: List?,
+ @JsonAnySetter
+ private val additionalProperties: Map = immutableEmptyMap(),
) {
/** The case sensitive currency or custom pricing unit to use for this alert. */
- @JsonProperty("currency") fun currency(): String? = currency
+ @JsonProperty("currency") fun currency(): String = currency
/** The type of alert to create. This must be a valid alert type. */
- @JsonProperty("type") fun type(): Type? = type
+ @JsonProperty("type") fun type(): Type = type
/** The thresholds that define the values at which the alert will be triggered. */
- @JsonProperty("thresholds") fun thresholds(): List? = thresholds
+ @JsonProperty("thresholds")
+ fun thresholds(): Optional> = Optional.ofNullable(thresholds)
@JsonAnyGetter
@ExcludeMissing
@@ -104,37 +106,41 @@ constructor(
@JvmSynthetic
internal fun from(alertCreateForCustomerBody: AlertCreateForCustomerBody) = apply {
- this.currency = alertCreateForCustomerBody.currency
- this.type = alertCreateForCustomerBody.type
- this.thresholds = alertCreateForCustomerBody.thresholds
- additionalProperties(alertCreateForCustomerBody.additionalProperties)
+ currency = alertCreateForCustomerBody.currency
+ type = alertCreateForCustomerBody.type
+ thresholds = alertCreateForCustomerBody.thresholds?.toMutableList()
+ additionalProperties =
+ alertCreateForCustomerBody.additionalProperties.toMutableMap()
}
/** The case sensitive currency or custom pricing unit to use for this alert. */
- @JsonProperty("currency")
fun currency(currency: String) = apply { this.currency = currency }
/** The type of alert to create. This must be a valid alert type. */
- @JsonProperty("type") fun type(type: Type) = apply { this.type = type }
+ fun type(type: Type) = apply { this.type = type }
/** The thresholds that define the values at which the alert will be triggered. */
- @JsonProperty("thresholds")
fun thresholds(thresholds: List) = apply { this.thresholds = thresholds }
fun additionalProperties(additionalProperties: Map) = apply {
this.additionalProperties.clear()
- this.additionalProperties.putAll(additionalProperties)
+ putAllAdditionalProperties(additionalProperties)
}
- @JsonAnySetter
fun putAdditionalProperty(key: String, value: JsonValue) = apply {
- this.additionalProperties.put(key, value)
+ 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)
+ }
+
fun build(): AlertCreateForCustomerBody =
AlertCreateForCustomerBody(
checkNotNull(currency) { "`currency` is required but was not set" },
@@ -417,12 +423,13 @@ constructor(
}
/** Thresholds are used to define the conditions under which an alert will be triggered. */
- @JsonDeserialize(builder = Threshold.Builder::class)
@NoAutoDetect
class Threshold
+ @JsonCreator
private constructor(
- private val value: Double?,
- private val additionalProperties: Map,
+ @JsonProperty("value") private val value: Double,
+ @JsonAnySetter
+ private val additionalProperties: Map = immutableEmptyMap(),
) {
/**
@@ -430,7 +437,7 @@ constructor(
* or below this value. For usage and cost alerts, the alert will fire at or above this
* value.
*/
- @JsonProperty("value") fun value(): Double? = value
+ @JsonProperty("value") fun value(): Double = value
@JsonAnyGetter
@ExcludeMissing
@@ -450,8 +457,8 @@ constructor(
@JvmSynthetic
internal fun from(threshold: Threshold) = apply {
- this.value = threshold.value
- additionalProperties(threshold.additionalProperties)
+ value = threshold.value
+ additionalProperties = threshold.additionalProperties.toMutableMap()
}
/**
@@ -459,22 +466,27 @@ constructor(
* at or below this value. For usage and cost alerts, the alert will fire at or above
* this value.
*/
- @JsonProperty("value") fun value(value: Double) = apply { this.value = value }
+ fun value(value: Double) = apply { this.value = value }
fun additionalProperties(additionalProperties: Map) = apply {
this.additionalProperties.clear()
- this.additionalProperties.putAll(additionalProperties)
+ putAllAdditionalProperties(additionalProperties)
}
- @JsonAnySetter
fun putAdditionalProperty(key: String, value: JsonValue) = apply {
- this.additionalProperties.put(key, value)
+ 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)
+ }
+
fun build(): Threshold =
Threshold(
checkNotNull(value) { "`value` is required but was not set" },
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 7dba34ee..f76e2f71 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
@@ -6,7 +6,6 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter
import com.fasterxml.jackson.annotation.JsonAnySetter
import com.fasterxml.jackson.annotation.JsonCreator
import com.fasterxml.jackson.annotation.JsonProperty
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import com.withorb.api.core.Enum
import com.withorb.api.core.ExcludeMissing
import com.withorb.api.core.JsonField
@@ -14,6 +13,7 @@ import com.withorb.api.core.JsonValue
import com.withorb.api.core.NoAutoDetect
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.Objects
@@ -65,24 +65,26 @@ constructor(
}
}
- @JsonDeserialize(builder = AlertCreateForExternalCustomerBody.Builder::class)
@NoAutoDetect
class AlertCreateForExternalCustomerBody
+ @JsonCreator
internal constructor(
- private val currency: String?,
- private val type: Type?,
- private val thresholds: List?,
- private val additionalProperties: Map,
+ @JsonProperty("currency") private val currency: String,
+ @JsonProperty("type") private val type: Type,
+ @JsonProperty("thresholds") private val thresholds: List?,
+ @JsonAnySetter
+ private val additionalProperties: Map = immutableEmptyMap(),
) {
/** The case sensitive currency or custom pricing unit to use for this alert. */
- @JsonProperty("currency") fun currency(): String? = currency
+ @JsonProperty("currency") fun currency(): String = currency
/** The type of alert to create. This must be a valid alert type. */
- @JsonProperty("type") fun type(): Type? = type
+ @JsonProperty("type") fun type(): Type = type
/** The thresholds that define the values at which the alert will be triggered. */
- @JsonProperty("thresholds") fun thresholds(): List? = thresholds
+ @JsonProperty("thresholds")
+ fun thresholds(): Optional> = Optional.ofNullable(thresholds)
@JsonAnyGetter
@ExcludeMissing
@@ -106,37 +108,41 @@ constructor(
internal fun from(
alertCreateForExternalCustomerBody: AlertCreateForExternalCustomerBody
) = apply {
- this.currency = alertCreateForExternalCustomerBody.currency
- this.type = alertCreateForExternalCustomerBody.type
- this.thresholds = alertCreateForExternalCustomerBody.thresholds
- additionalProperties(alertCreateForExternalCustomerBody.additionalProperties)
+ currency = alertCreateForExternalCustomerBody.currency
+ type = alertCreateForExternalCustomerBody.type
+ thresholds = alertCreateForExternalCustomerBody.thresholds?.toMutableList()
+ additionalProperties =
+ alertCreateForExternalCustomerBody.additionalProperties.toMutableMap()
}
/** The case sensitive currency or custom pricing unit to use for this alert. */
- @JsonProperty("currency")
fun currency(currency: String) = apply { this.currency = currency }
/** The type of alert to create. This must be a valid alert type. */
- @JsonProperty("type") fun type(type: Type) = apply { this.type = type }
+ fun type(type: Type) = apply { this.type = type }
/** The thresholds that define the values at which the alert will be triggered. */
- @JsonProperty("thresholds")
fun thresholds(thresholds: List) = apply { this.thresholds = thresholds }
fun additionalProperties(additionalProperties: Map) = apply {
this.additionalProperties.clear()
- this.additionalProperties.putAll(additionalProperties)
+ putAllAdditionalProperties(additionalProperties)
}
- @JsonAnySetter
fun putAdditionalProperty(key: String, value: JsonValue) = apply {
- this.additionalProperties.put(key, value)
+ 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)
+ }
+
fun build(): AlertCreateForExternalCustomerBody =
AlertCreateForExternalCustomerBody(
checkNotNull(currency) { "`currency` is required but was not set" },
@@ -427,12 +433,13 @@ constructor(
}
/** Thresholds are used to define the conditions under which an alert will be triggered. */
- @JsonDeserialize(builder = Threshold.Builder::class)
@NoAutoDetect
class Threshold
+ @JsonCreator
private constructor(
- private val value: Double?,
- private val additionalProperties: Map,
+ @JsonProperty("value") private val value: Double,
+ @JsonAnySetter
+ private val additionalProperties: Map = immutableEmptyMap(),
) {
/**
@@ -440,7 +447,7 @@ constructor(
* or below this value. For usage and cost alerts, the alert will fire at or above this
* value.
*/
- @JsonProperty("value") fun value(): Double? = value
+ @JsonProperty("value") fun value(): Double = value
@JsonAnyGetter
@ExcludeMissing
@@ -460,8 +467,8 @@ constructor(
@JvmSynthetic
internal fun from(threshold: Threshold) = apply {
- this.value = threshold.value
- additionalProperties(threshold.additionalProperties)
+ value = threshold.value
+ additionalProperties = threshold.additionalProperties.toMutableMap()
}
/**
@@ -469,22 +476,27 @@ constructor(
* at or below this value. For usage and cost alerts, the alert will fire at or above
* this value.
*/
- @JsonProperty("value") fun value(value: Double) = apply { this.value = value }
+ fun value(value: Double) = apply { this.value = value }
fun additionalProperties(additionalProperties: Map) = apply {
this.additionalProperties.clear()
- this.additionalProperties.putAll(additionalProperties)
+ putAllAdditionalProperties(additionalProperties)
}
- @JsonAnySetter
fun putAdditionalProperty(key: String, value: JsonValue) = apply {
- this.additionalProperties.put(key, value)
+ 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)
+ }
+
fun build(): Threshold =
Threshold(
checkNotNull(value) { "`value` is required but was not set" },
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 38e71a40..b043feac 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
@@ -6,7 +6,6 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter
import com.fasterxml.jackson.annotation.JsonAnySetter
import com.fasterxml.jackson.annotation.JsonCreator
import com.fasterxml.jackson.annotation.JsonProperty
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import com.withorb.api.core.Enum
import com.withorb.api.core.ExcludeMissing
import com.withorb.api.core.JsonField
@@ -14,6 +13,7 @@ import com.withorb.api.core.JsonValue
import com.withorb.api.core.NoAutoDetect
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.Objects
@@ -65,24 +65,25 @@ constructor(
}
}
- @JsonDeserialize(builder = AlertCreateForSubscriptionBody.Builder::class)
@NoAutoDetect
class AlertCreateForSubscriptionBody
+ @JsonCreator
internal constructor(
- private val thresholds: List?,
- private val type: Type?,
- private val metricId: String?,
- private val additionalProperties: Map,
+ @JsonProperty("thresholds") private val thresholds: List,
+ @JsonProperty("type") private val type: Type,
+ @JsonProperty("metric_id") private val metricId: String?,
+ @JsonAnySetter
+ private val additionalProperties: Map = immutableEmptyMap(),
) {
/** The thresholds that define the values at which the alert will be triggered. */
- @JsonProperty("thresholds") fun thresholds(): List? = thresholds
+ @JsonProperty("thresholds") fun thresholds(): List = thresholds
/** The type of alert to create. This must be a valid alert type. */
- @JsonProperty("type") fun type(): Type? = type
+ @JsonProperty("type") fun type(): Type = type
/** The metric to track usage for. */
- @JsonProperty("metric_id") fun metricId(): String? = metricId
+ @JsonProperty("metric_id") fun metricId(): Optional = Optional.ofNullable(metricId)
@JsonAnyGetter
@ExcludeMissing
@@ -105,37 +106,41 @@ constructor(
@JvmSynthetic
internal fun from(alertCreateForSubscriptionBody: AlertCreateForSubscriptionBody) =
apply {
- this.thresholds = alertCreateForSubscriptionBody.thresholds
- this.type = alertCreateForSubscriptionBody.type
- this.metricId = alertCreateForSubscriptionBody.metricId
- additionalProperties(alertCreateForSubscriptionBody.additionalProperties)
+ thresholds = alertCreateForSubscriptionBody.thresholds.toMutableList()
+ type = alertCreateForSubscriptionBody.type
+ metricId = alertCreateForSubscriptionBody.metricId
+ additionalProperties =
+ alertCreateForSubscriptionBody.additionalProperties.toMutableMap()
}
/** The thresholds that define the values at which the alert will be triggered. */
- @JsonProperty("thresholds")
fun thresholds(thresholds: List) = apply { this.thresholds = thresholds }
/** The type of alert to create. This must be a valid alert type. */
- @JsonProperty("type") fun type(type: Type) = apply { this.type = type }
+ fun type(type: Type) = apply { this.type = type }
/** The metric to track usage for. */
- @JsonProperty("metric_id")
fun metricId(metricId: String) = apply { this.metricId = metricId }
fun additionalProperties(additionalProperties: Map) = apply {
this.additionalProperties.clear()
- this.additionalProperties.putAll(additionalProperties)
+ putAllAdditionalProperties(additionalProperties)
}
- @JsonAnySetter
fun putAdditionalProperty(key: String, value: JsonValue) = apply {
- this.additionalProperties.put(key, value)
+ 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)
+ }
+
fun build(): AlertCreateForSubscriptionBody =
AlertCreateForSubscriptionBody(
checkNotNull(thresholds) { "`thresholds` is required but was not set" }
@@ -346,12 +351,13 @@ constructor(
}
/** Thresholds are used to define the conditions under which an alert will be triggered. */
- @JsonDeserialize(builder = Threshold.Builder::class)
@NoAutoDetect
class Threshold
+ @JsonCreator
private constructor(
- private val value: Double?,
- private val additionalProperties: Map,
+ @JsonProperty("value") private val value: Double,
+ @JsonAnySetter
+ private val additionalProperties: Map = immutableEmptyMap(),
) {
/**
@@ -359,7 +365,7 @@ constructor(
* or below this value. For usage and cost alerts, the alert will fire at or above this
* value.
*/
- @JsonProperty("value") fun value(): Double? = value
+ @JsonProperty("value") fun value(): Double = value
@JsonAnyGetter
@ExcludeMissing
@@ -379,8 +385,8 @@ constructor(
@JvmSynthetic
internal fun from(threshold: Threshold) = apply {
- this.value = threshold.value
- additionalProperties(threshold.additionalProperties)
+ value = threshold.value
+ additionalProperties = threshold.additionalProperties.toMutableMap()
}
/**
@@ -388,22 +394,27 @@ constructor(
* at or below this value. For usage and cost alerts, the alert will fire at or above
* this value.
*/
- @JsonProperty("value") fun value(value: Double) = apply { this.value = value }
+ fun value(value: Double) = apply { this.value = value }
fun additionalProperties(additionalProperties: Map) = apply {
this.additionalProperties.clear()
- this.additionalProperties.putAll(additionalProperties)
+ putAllAdditionalProperties(additionalProperties)
}
- @JsonAnySetter
fun putAdditionalProperty(key: String, value: JsonValue) = apply {
- this.additionalProperties.put(key, value)
+ 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)
+ }
+
fun build(): Threshold =
Threshold(
checkNotNull(value) { "`value` is required but was not set" },
diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListPage.kt
index 6e54cd5c..24b482c4 100644
--- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListPage.kt
+++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListPage.kt
@@ -4,13 +4,14 @@ package com.withorb.api.models
import com.fasterxml.jackson.annotation.JsonAnyGetter
import com.fasterxml.jackson.annotation.JsonAnySetter
+import com.fasterxml.jackson.annotation.JsonCreator
import com.fasterxml.jackson.annotation.JsonProperty
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize
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.immutableEmptyMap
import com.withorb.api.core.toImmutable
import com.withorb.api.services.blocking.AlertService
import java.util.Objects
@@ -82,13 +83,15 @@ private constructor(
)
}
- @JsonDeserialize(builder = Response.Builder::class)
@NoAutoDetect
class Response
+ @JsonCreator
constructor(
- private val data: JsonField>,
- private val paginationMetadata: JsonField,
- private val additionalProperties: Map,
+ @JsonProperty("data") private val data: JsonField> = JsonMissing.of(),
+ @JsonProperty("pagination_metadata")
+ private val paginationMetadata: JsonField = JsonMissing.of(),
+ @JsonAnySetter
+ private val additionalProperties: Map = immutableEmptyMap(),
) {
private var validated: Boolean = false
@@ -152,18 +155,15 @@ private constructor(
fun data(data: List) = data(JsonField.of(data))
- @JsonProperty("data")
fun data(data: JsonField>) = apply { this.data = data }
fun paginationMetadata(paginationMetadata: PaginationMetadata) =
paginationMetadata(JsonField.of(paginationMetadata))
- @JsonProperty("pagination_metadata")
fun paginationMetadata(paginationMetadata: JsonField) = apply {
this.paginationMetadata = paginationMetadata
}
- @JsonAnySetter
fun putAdditionalProperty(key: String, value: JsonValue) = apply {
this.additionalProperties.put(key, value)
}
diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListPageAsync.kt
index 4efbceae..190622b2 100644
--- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListPageAsync.kt
+++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListPageAsync.kt
@@ -4,13 +4,14 @@ package com.withorb.api.models
import com.fasterxml.jackson.annotation.JsonAnyGetter
import com.fasterxml.jackson.annotation.JsonAnySetter
+import com.fasterxml.jackson.annotation.JsonCreator
import com.fasterxml.jackson.annotation.JsonProperty
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize
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.immutableEmptyMap
import com.withorb.api.core.toImmutable
import com.withorb.api.services.async.AlertServiceAsync
import java.util.Objects
@@ -85,13 +86,15 @@ private constructor(
)
}
- @JsonDeserialize(builder = Response.Builder::class)
@NoAutoDetect
class Response
+ @JsonCreator
constructor(
- private val data: JsonField>,
- private val paginationMetadata: JsonField,
- private val additionalProperties: Map,
+ @JsonProperty("data") private val data: JsonField> = JsonMissing.of(),
+ @JsonProperty("pagination_metadata")
+ private val paginationMetadata: JsonField = JsonMissing.of(),
+ @JsonAnySetter
+ private val additionalProperties: Map = immutableEmptyMap(),
) {
private var validated: Boolean = false
@@ -155,18 +158,15 @@ private constructor(
fun data(data: List) = data(JsonField.of(data))
- @JsonProperty("data")
fun data(data: JsonField>) = apply { this.data = data }
fun paginationMetadata(paginationMetadata: PaginationMetadata) =
paginationMetadata(JsonField.of(paginationMetadata))
- @JsonProperty("pagination_metadata")
fun paginationMetadata(paginationMetadata: JsonField) = apply {
this.paginationMetadata = paginationMetadata
}
- @JsonAnySetter
fun putAdditionalProperty(key: String, value: JsonValue) = apply {
this.additionalProperties.put(key, value)
}
diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertUpdateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertUpdateParams.kt
index 3420df46..64939f67 100644
--- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertUpdateParams.kt
+++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertUpdateParams.kt
@@ -4,13 +4,14 @@ package com.withorb.api.models
import com.fasterxml.jackson.annotation.JsonAnyGetter
import com.fasterxml.jackson.annotation.JsonAnySetter
+import com.fasterxml.jackson.annotation.JsonCreator
import com.fasterxml.jackson.annotation.JsonProperty
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import com.withorb.api.core.ExcludeMissing
import com.withorb.api.core.JsonValue
import com.withorb.api.core.NoAutoDetect
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 java.util.Objects
@@ -49,16 +50,17 @@ constructor(
}
}
- @JsonDeserialize(builder = AlertUpdateBody.Builder::class)
@NoAutoDetect
class AlertUpdateBody
+ @JsonCreator
internal constructor(
- private val thresholds: List?,
- private val additionalProperties: Map,
+ @JsonProperty("thresholds") private val thresholds: List,
+ @JsonAnySetter
+ private val additionalProperties: Map = immutableEmptyMap(),
) {
/** The thresholds that define the values at which the alert will be triggered. */
- @JsonProperty("thresholds") fun thresholds(): List? = thresholds
+ @JsonProperty("thresholds") fun thresholds(): List = thresholds
@JsonAnyGetter
@ExcludeMissing
@@ -78,28 +80,32 @@ constructor(
@JvmSynthetic
internal fun from(alertUpdateBody: AlertUpdateBody) = apply {
- this.thresholds = alertUpdateBody.thresholds
- additionalProperties(alertUpdateBody.additionalProperties)
+ thresholds = alertUpdateBody.thresholds.toMutableList()
+ additionalProperties = alertUpdateBody.additionalProperties.toMutableMap()
}
/** The thresholds that define the values at which the alert will be triggered. */
- @JsonProperty("thresholds")
fun thresholds(thresholds: List) = apply { this.thresholds = thresholds }
fun additionalProperties(additionalProperties: Map) = apply {
this.additionalProperties.clear()
- this.additionalProperties.putAll(additionalProperties)
+ putAllAdditionalProperties(additionalProperties)
}
- @JsonAnySetter
fun putAdditionalProperty(key: String, value: JsonValue) = apply {
- this.additionalProperties.put(key, value)
+ 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)
+ }
+
fun build(): AlertUpdateBody =
AlertUpdateBody(
checkNotNull(thresholds) { "`thresholds` is required but was not set" }
@@ -297,12 +303,13 @@ constructor(
}
/** Thresholds are used to define the conditions under which an alert will be triggered. */
- @JsonDeserialize(builder = Threshold.Builder::class)
@NoAutoDetect
class Threshold
+ @JsonCreator
private constructor(
- private val value: Double?,
- private val additionalProperties: Map,
+ @JsonProperty("value") private val value: Double,
+ @JsonAnySetter
+ private val additionalProperties: Map = immutableEmptyMap(),
) {
/**
@@ -310,7 +317,7 @@ constructor(
* or below this value. For usage and cost alerts, the alert will fire at or above this
* value.
*/
- @JsonProperty("value") fun value(): Double? = value
+ @JsonProperty("value") fun value(): Double = value
@JsonAnyGetter
@ExcludeMissing
@@ -330,8 +337,8 @@ constructor(
@JvmSynthetic
internal fun from(threshold: Threshold) = apply {
- this.value = threshold.value
- additionalProperties(threshold.additionalProperties)
+ value = threshold.value
+ additionalProperties = threshold.additionalProperties.toMutableMap()
}
/**
@@ -339,22 +346,27 @@ constructor(
* at or below this value. For usage and cost alerts, the alert will fire at or above
* this value.
*/
- @JsonProperty("value") fun value(value: Double) = apply { this.value = value }
+ fun value(value: Double) = apply { this.value = value }
fun additionalProperties(additionalProperties: Map) = apply {
this.additionalProperties.clear()
- this.additionalProperties.putAll(additionalProperties)
+ putAllAdditionalProperties(additionalProperties)
}
- @JsonAnySetter
fun putAdditionalProperty(key: String, value: JsonValue) = apply {
- this.additionalProperties.put(key, value)
+ 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)
+ }
+
fun build(): Threshold =
Threshold(
checkNotNull(value) { "`value` is required but was not set" },
diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AmountDiscount.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AmountDiscount.kt
index 26969bca..1f28e47d 100644
--- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AmountDiscount.kt
+++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AmountDiscount.kt
@@ -6,31 +6,37 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter
import com.fasterxml.jackson.annotation.JsonAnySetter
import com.fasterxml.jackson.annotation.JsonCreator
import com.fasterxml.jackson.annotation.JsonProperty
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import com.withorb.api.core.Enum
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.immutableEmptyMap
import com.withorb.api.core.toImmutable
import com.withorb.api.errors.OrbInvalidDataException
import java.util.Objects
import java.util.Optional
-@JsonDeserialize(builder = AmountDiscount.Builder::class)
@NoAutoDetect
class AmountDiscount
+@JsonCreator
private constructor(
- private val discountType: JsonField,
- private val appliesToPriceIds: JsonField>,
- private val reason: JsonField,
- private val amountDiscount: JsonField,
- private val additionalProperties: Map,
+ @JsonProperty("discount_type")
+ @ExcludeMissing
+ private val discountType: JsonField = JsonMissing.of(),
+ @JsonProperty("applies_to_price_ids")
+ @ExcludeMissing
+ private val appliesToPriceIds: JsonField> = JsonMissing.of(),
+ @JsonProperty("reason")
+ @ExcludeMissing
+ private val reason: JsonField = JsonMissing.of(),
+ @JsonProperty("amount_discount")
+ @ExcludeMissing
+ private val amountDiscount: JsonField = JsonMissing.of(),
+ @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(),
) {
- private var validated: Boolean = false
-
fun discountType(): DiscountType = discountType.getRequired("discount_type")
/**
@@ -63,6 +69,8 @@ private constructor(
@ExcludeMissing
fun _additionalProperties(): Map = additionalProperties
+ private var validated: Boolean = false
+
fun validate(): AmountDiscount = apply {
if (!validated) {
discountType()
@@ -90,17 +98,15 @@ private constructor(
@JvmSynthetic
internal fun from(amountDiscount: AmountDiscount) = apply {
- this.discountType = amountDiscount.discountType
- this.appliesToPriceIds = amountDiscount.appliesToPriceIds
- this.reason = amountDiscount.reason
+ discountType = amountDiscount.discountType
+ appliesToPriceIds = amountDiscount.appliesToPriceIds
+ reason = amountDiscount.reason
this.amountDiscount = amountDiscount.amountDiscount
- additionalProperties(amountDiscount.additionalProperties)
+ additionalProperties = amountDiscount.additionalProperties.toMutableMap()
}
fun discountType(discountType: DiscountType) = discountType(JsonField.of(discountType))
- @JsonProperty("discount_type")
- @ExcludeMissing
fun discountType(discountType: JsonField) = apply {
this.discountType = discountType
}
@@ -116,42 +122,41 @@ private constructor(
* List of price_ids that this discount applies to. For plan/plan phase discounts, this can
* be a subset of prices.
*/
- @JsonProperty("applies_to_price_ids")
- @ExcludeMissing
fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply {
this.appliesToPriceIds = appliesToPriceIds
}
fun reason(reason: String) = reason(JsonField.of(reason))
- @JsonProperty("reason")
- @ExcludeMissing
fun reason(reason: JsonField) = apply { this.reason = reason }
/** Only available if discount_type is `amount`. */
fun amountDiscount(amountDiscount: String) = amountDiscount(JsonField.of(amountDiscount))
/** Only available if discount_type is `amount`. */
- @JsonProperty("amount_discount")
- @ExcludeMissing
fun amountDiscount(amountDiscount: JsonField) = apply {
this.amountDiscount = amountDiscount
}
fun additionalProperties(additionalProperties: Map) = apply {
this.additionalProperties.clear()
- this.additionalProperties.putAll(additionalProperties)
+ putAllAdditionalProperties(additionalProperties)
}
- @JsonAnySetter
fun putAdditionalProperty(key: String, value: JsonValue) = apply {
- this.additionalProperties.put(key, value)
+ 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)
+ }
+
fun build(): AmountDiscount =
AmountDiscount(
discountType,
diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/BillableMetric.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/BillableMetric.kt
index 98a0e68c..f663634e 100644
--- a/orb-java-core/src/main/kotlin/com/withorb/api/models/BillableMetric.kt
+++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/BillableMetric.kt
@@ -6,13 +6,13 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter
import com.fasterxml.jackson.annotation.JsonAnySetter
import com.fasterxml.jackson.annotation.JsonCreator
import com.fasterxml.jackson.annotation.JsonProperty
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import com.withorb.api.core.Enum
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.immutableEmptyMap
import com.withorb.api.core.toImmutable
import com.withorb.api.errors.OrbInvalidDataException
import java.util.Objects
@@ -22,21 +22,25 @@ import java.util.Optional
* The Metric resource represents a calculation of a quantity based on events. Metrics are defined
* by the query that transforms raw usage events into meaningful values for your customers.
*/
-@JsonDeserialize(builder = BillableMetric.Builder::class)
@NoAutoDetect
class BillableMetric
+@JsonCreator
private constructor(
- private val metadata: JsonField,
- private val id: JsonField,
- private val name: JsonField,
- private val description: JsonField,
- private val status: JsonField,
- private val item: JsonField- ,
- private val additionalProperties: Map,
+ @JsonProperty("metadata")
+ @ExcludeMissing
+ private val metadata: JsonField = JsonMissing.of(),
+ @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(),
+ @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(),
+ @JsonProperty("description")
+ @ExcludeMissing
+ private val description: JsonField = JsonMissing.of(),
+ @JsonProperty("status")
+ @ExcludeMissing
+ private val status: JsonField = JsonMissing.of(),
+ @JsonProperty("item") @ExcludeMissing private val item: JsonField
- = JsonMissing.of(),
+ @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(),
) {
- private var validated: Boolean = false
-
/**
* User specified key-value pairs for the resource. If not present, this defaults to an empty
* dictionary. Individual keys can be removed by setting the value to `null`, and the entire
@@ -86,6 +90,8 @@ private constructor(
@ExcludeMissing
fun _additionalProperties(): Map = additionalProperties
+ private var validated: Boolean = false
+
fun validate(): BillableMetric = apply {
if (!validated) {
metadata().validate()
@@ -117,13 +123,13 @@ private constructor(
@JvmSynthetic
internal fun from(billableMetric: BillableMetric) = apply {
- this.metadata = billableMetric.metadata
- this.id = billableMetric.id
- this.name = billableMetric.name
- this.description = billableMetric.description
- this.status = billableMetric.status
- this.item = billableMetric.item
- additionalProperties(billableMetric.additionalProperties)
+ metadata = billableMetric.metadata
+ id = billableMetric.id
+ name = billableMetric.name
+ description = billableMetric.description
+ status = billableMetric.status
+ item = billableMetric.item
+ additionalProperties = billableMetric.additionalProperties.toMutableMap()
}
/**
@@ -138,30 +144,22 @@ private constructor(
* empty dictionary. Individual keys can be removed by setting the value to `null`, and the
* entire metadata mapping can be cleared by setting `metadata` to `null`.
*/
- @JsonProperty("metadata")
- @ExcludeMissing
fun metadata(metadata: JsonField) = apply { this.metadata = metadata }
fun id(id: String) = id(JsonField.of(id))
- @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id }
+ fun id(id: JsonField) = apply { this.id = id }
fun name(name: String) = name(JsonField.of(name))
- @JsonProperty("name")
- @ExcludeMissing
fun name(name: JsonField) = apply { this.name = name }
fun description(description: String) = description(JsonField.of(description))
- @JsonProperty("description")
- @ExcludeMissing
fun description(description: JsonField) = apply { this.description = description }
fun status(status: Status) = status(JsonField.of(status))
- @JsonProperty("status")
- @ExcludeMissing
fun status(status: JsonField) = apply { this.status = status }
/**
@@ -176,24 +174,27 @@ private constructor(
* line items, billable metrics, and prices and are used for defining external sync behavior
* for invoices and tax calculation purposes.
*/
- @JsonProperty("item")
- @ExcludeMissing
fun item(item: JsonField
- ) = apply { this.item = item }
fun additionalProperties(additionalProperties: Map) = apply {
this.additionalProperties.clear()
- this.additionalProperties.putAll(additionalProperties)
+ putAllAdditionalProperties(additionalProperties)
}
- @JsonAnySetter
fun putAdditionalProperty(key: String, value: JsonValue) = apply {
- this.additionalProperties.put(key, value)
+ 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)
+ }
+
fun build(): BillableMetric =
BillableMetric(
metadata,
@@ -211,19 +212,20 @@ private constructor(
* dictionary. Individual keys can be removed by setting the value to `null`, and the entire
* metadata mapping can be cleared by setting `metadata` to `null`.
*/
- @JsonDeserialize(builder = Metadata.Builder::class)
@NoAutoDetect
class Metadata
+ @JsonCreator
private constructor(
- private val additionalProperties: Map,
+ @JsonAnySetter
+ private val additionalProperties: Map = immutableEmptyMap(),
) {
- private var validated: Boolean = false
-
@JsonAnyGetter
@ExcludeMissing
fun _additionalProperties(): Map = additionalProperties
+ private var validated: Boolean = false
+
fun validate(): Metadata = apply {
if (!validated) {
validated = true
@@ -243,23 +245,28 @@ private constructor(
@JvmSynthetic
internal fun from(metadata: Metadata) = apply {
- additionalProperties(metadata.additionalProperties)
+ additionalProperties = metadata.additionalProperties.toMutableMap()
}
fun additionalProperties(additionalProperties: Map) = apply {
this.additionalProperties.clear()
- this.additionalProperties.putAll(additionalProperties)
+ putAllAdditionalProperties(additionalProperties)
}
- @JsonAnySetter
fun putAdditionalProperty(key: String, value: JsonValue) = apply {
- this.additionalProperties.put(key, value)
+ 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)
+ }
+
fun build(): Metadata = Metadata(additionalProperties.toImmutable())
}
diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/Coupon.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Coupon.kt
index baa472c4..f46e0c52 100644
--- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Coupon.kt
+++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Coupon.kt
@@ -4,6 +4,7 @@ package com.withorb.api.models
import com.fasterxml.jackson.annotation.JsonAnyGetter
import com.fasterxml.jackson.annotation.JsonAnySetter
+import com.fasterxml.jackson.annotation.JsonCreator
import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.core.JsonGenerator
import com.fasterxml.jackson.core.ObjectCodec
@@ -20,6 +21,7 @@ import com.withorb.api.core.JsonMissing
import com.withorb.api.core.JsonValue
import com.withorb.api.core.NoAutoDetect
import com.withorb.api.core.getOrThrow
+import com.withorb.api.core.immutableEmptyMap
import com.withorb.api.core.toImmutable
import com.withorb.api.errors.OrbInvalidDataException
import java.time.OffsetDateTime
@@ -64,22 +66,32 @@ import kotlin.jvm.optionals.getOrNull
* at the time of the migration that includes the newly added prices you'd like the coupon to apply
* to.
*/
-@JsonDeserialize(builder = Coupon.Builder::class)
@NoAutoDetect
class Coupon
+@JsonCreator
private constructor(
- private val id: JsonField,
- private val redemptionCode: JsonField,
- private val discount: JsonField,
- private val timesRedeemed: JsonField,
- private val durationInMonths: JsonField,
- private val maxRedemptions: JsonField,
- private val archivedAt: JsonField,
- private val additionalProperties: Map,
+ @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(),
+ @JsonProperty("redemption_code")
+ @ExcludeMissing
+ private val redemptionCode: JsonField = JsonMissing.of(),
+ @JsonProperty("discount")
+ @ExcludeMissing
+ private val discount: JsonField = JsonMissing.of(),
+ @JsonProperty("times_redeemed")
+ @ExcludeMissing
+ private val timesRedeemed: JsonField = JsonMissing.of(),
+ @JsonProperty("duration_in_months")
+ @ExcludeMissing
+ private val durationInMonths: JsonField = JsonMissing.of(),
+ @JsonProperty("max_redemptions")
+ @ExcludeMissing
+ private val maxRedemptions: JsonField = JsonMissing.of(),
+ @JsonProperty("archived_at")
+ @ExcludeMissing
+ private val archivedAt: JsonField = JsonMissing.of(),
+ @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(),
) {
- private var validated: Boolean = false
-
/** Also referred to as coupon_id in this documentation. */
fun id(): String = id.getRequired("id")
@@ -145,6 +157,8 @@ private constructor(
@ExcludeMissing
fun _additionalProperties(): Map = additionalProperties
+ private var validated: Boolean = false
+
fun validate(): Coupon = apply {
if (!validated) {
id()
@@ -178,44 +192,38 @@ private constructor(
@JvmSynthetic
internal fun from(coupon: Coupon) = apply {
- this.id = coupon.id
- this.redemptionCode = coupon.redemptionCode
- this.discount = coupon.discount
- this.timesRedeemed = coupon.timesRedeemed
- this.durationInMonths = coupon.durationInMonths
- this.maxRedemptions = coupon.maxRedemptions
- this.archivedAt = coupon.archivedAt
- additionalProperties(coupon.additionalProperties)
+ id = coupon.id
+ redemptionCode = coupon.redemptionCode
+ discount = coupon.discount
+ timesRedeemed = coupon.timesRedeemed
+ durationInMonths = coupon.durationInMonths
+ maxRedemptions = coupon.maxRedemptions
+ archivedAt = coupon.archivedAt
+ additionalProperties = coupon.additionalProperties.toMutableMap()
}
/** Also referred to as coupon_id in this documentation. */
fun id(id: String) = id(JsonField.of(id))
/** Also referred to as coupon_id in this documentation. */
- @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id }
+ fun id(id: JsonField) = apply { this.id = id }
/** This string can be used to redeem this coupon for a given subscription. */
fun redemptionCode(redemptionCode: String) = redemptionCode(JsonField.of(redemptionCode))
/** This string can be used to redeem this coupon for a given subscription. */
- @JsonProperty("redemption_code")
- @ExcludeMissing
fun redemptionCode(redemptionCode: JsonField) = apply {
this.redemptionCode = redemptionCode
}
fun discount(discount: Discount) = discount(JsonField.of(discount))
- @JsonProperty("discount")
- @ExcludeMissing
fun discount(discount: JsonField) = apply { this.discount = discount }
/** The number of times this coupon has been redeemed. */
fun timesRedeemed(timesRedeemed: Long) = timesRedeemed(JsonField.of(timesRedeemed))
/** The number of times this coupon has been redeemed. */
- @JsonProperty("times_redeemed")
- @ExcludeMissing
fun timesRedeemed(timesRedeemed: JsonField) = apply {
this.timesRedeemed = timesRedeemed
}
@@ -231,8 +239,6 @@ private constructor(
* This allows for a coupon's discount to apply for a limited time (determined in months); a
* `null` value here means "unlimited time".
*/
- @JsonProperty("duration_in_months")
- @ExcludeMissing
fun durationInMonths(durationInMonths: JsonField) = apply {
this.durationInMonths = durationInMonths
}
@@ -247,8 +253,6 @@ private constructor(
* The maximum number of redemptions allowed for this coupon before it is exhausted; `null`
* here means "unlimited".
*/
- @JsonProperty("max_redemptions")
- @ExcludeMissing
fun maxRedemptions(maxRedemptions: JsonField) = apply {
this.maxRedemptions = maxRedemptions
}
@@ -263,26 +267,29 @@ private constructor(
* An archived coupon can no longer be redeemed. Active coupons will have a value of null
* for `archived_at`; this field will be non-null for archived coupons.
*/
- @JsonProperty("archived_at")
- @ExcludeMissing
fun archivedAt(archivedAt: JsonField) = apply {
this.archivedAt = archivedAt
}
fun additionalProperties(additionalProperties: Map) = apply {
this.additionalProperties.clear()
- this.additionalProperties.putAll(additionalProperties)
+ putAllAdditionalProperties(additionalProperties)
}
- @JsonAnySetter
fun putAdditionalProperty(key: String, value: JsonValue) = apply {
- this.additionalProperties.put(key, value)
+ 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)
+ }
+
fun build(): Coupon =
Coupon(
id,
diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponCreateParams.kt
index c4125c79..847b5794 100644
--- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponCreateParams.kt
+++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponCreateParams.kt
@@ -18,12 +18,12 @@ import com.withorb.api.core.BaseSerializer
import com.withorb.api.core.Enum
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.getOrThrow
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.Objects
@@ -70,33 +70,36 @@ constructor(
@JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams
- @JsonDeserialize(builder = CouponCreateBody.Builder::class)
@NoAutoDetect
class CouponCreateBody
+ @JsonCreator
internal constructor(
- private val discount: Discount?,
- private val redemptionCode: String?,
- private val durationInMonths: Long?,
- private val maxRedemptions: Long?,
- private val additionalProperties: Map,
+ @JsonProperty("discount") private val discount: Discount,
+ @JsonProperty("redemption_code") private val redemptionCode: String,
+ @JsonProperty("duration_in_months") private val durationInMonths: Long?,
+ @JsonProperty("max_redemptions") private val maxRedemptions: Long?,
+ @JsonAnySetter
+ private val additionalProperties: Map = immutableEmptyMap(),
) {
- @JsonProperty("discount") fun discount(): Discount? = discount
+ @JsonProperty("discount") fun discount(): Discount = discount
/** This string can be used to redeem this coupon for a given subscription. */
- @JsonProperty("redemption_code") fun redemptionCode(): String? = redemptionCode
+ @JsonProperty("redemption_code") fun redemptionCode(): String = redemptionCode
/**
* This allows for a coupon's discount to apply for a limited time (determined in months); a
* `null` value here means "unlimited time".
*/
- @JsonProperty("duration_in_months") fun durationInMonths(): Long? = durationInMonths
+ @JsonProperty("duration_in_months")
+ fun durationInMonths(): Optional = Optional.ofNullable(durationInMonths)
/**
* The maximum number of redemptions allowed for this coupon before it is exhausted;`null`
* here means "unlimited".
*/
- @JsonProperty("max_redemptions") fun maxRedemptions(): Long? = maxRedemptions
+ @JsonProperty("max_redemptions")
+ fun maxRedemptions(): Optional = Optional.ofNullable(maxRedemptions)
@JsonAnyGetter
@ExcludeMissing
@@ -119,18 +122,16 @@ constructor(
@JvmSynthetic
internal fun from(couponCreateBody: CouponCreateBody) = apply {
- this.discount = couponCreateBody.discount
- this.redemptionCode = couponCreateBody.redemptionCode
- this.durationInMonths = couponCreateBody.durationInMonths
- this.maxRedemptions = couponCreateBody.maxRedemptions
- additionalProperties(couponCreateBody.additionalProperties)
+ discount = couponCreateBody.discount
+ redemptionCode = couponCreateBody.redemptionCode
+ durationInMonths = couponCreateBody.durationInMonths
+ maxRedemptions = couponCreateBody.maxRedemptions
+ additionalProperties = couponCreateBody.additionalProperties.toMutableMap()
}
- @JsonProperty("discount")
fun discount(discount: Discount) = apply { this.discount = discount }
/** This string can be used to redeem this coupon for a given subscription. */
- @JsonProperty("redemption_code")
fun redemptionCode(redemptionCode: String) = apply {
this.redemptionCode = redemptionCode
}
@@ -139,7 +140,6 @@ constructor(
* This allows for a coupon's discount to apply for a limited time (determined in
* months); a `null` value here means "unlimited time".
*/
- @JsonProperty("duration_in_months")
fun durationInMonths(durationInMonths: Long) = apply {
this.durationInMonths = durationInMonths
}
@@ -148,25 +148,29 @@ constructor(
* The maximum number of redemptions allowed for this coupon before it is
* exhausted;`null` here means "unlimited".
*/
- @JsonProperty("max_redemptions")
fun maxRedemptions(maxRedemptions: Long) = apply {
this.maxRedemptions = maxRedemptions
}
fun additionalProperties(additionalProperties: Map) = apply {
this.additionalProperties.clear()
- this.additionalProperties.putAll(additionalProperties)
+ putAllAdditionalProperties(additionalProperties)
}
- @JsonAnySetter
fun putAdditionalProperty(key: String, value: JsonValue) = apply {
- this.additionalProperties.put(key, value)
+ 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)
+ }
+
fun build(): CouponCreateBody =
CouponCreateBody(
checkNotNull(discount) { "`discount` is required but was not set" },
@@ -392,8 +396,6 @@ constructor(
private val _json: JsonValue? = null,
) {
- private var validated: Boolean = false
-
fun newCouponPercentageDiscount(): Optional =
Optional.ofNullable(newCouponPercentageDiscount)
@@ -422,17 +424,6 @@ constructor(
}
}
- fun validate(): Discount = apply {
- if (!validated) {
- if (newCouponPercentageDiscount == null && newCouponAmountDiscount == null) {
- throw OrbInvalidDataException("Unknown Discount: $_json")
- }
- newCouponPercentageDiscount?.validate()
- newCouponAmountDiscount?.validate()
- validated = true
- }
- }
-
override fun equals(other: Any?): Boolean {
if (this === other) {
return true
@@ -487,20 +478,14 @@ constructor(
when (discountType) {
"percentage" -> {
- tryDeserialize(node, jacksonTypeRef()) {
- it.validate()
- }
- ?.let {
- return Discount(newCouponPercentageDiscount = it, _json = json)
- }
+ tryDeserialize(node, jacksonTypeRef())?.let {
+ return Discount(newCouponPercentageDiscount = it, _json = json)
+ }
}
"amount" -> {
- tryDeserialize(node, jacksonTypeRef()) {
- it.validate()
- }
- ?.let {
- return Discount(newCouponAmountDiscount = it, _json = json)
- }
+ tryDeserialize(node, jacksonTypeRef())?.let {
+ return Discount(newCouponAmountDiscount = it, _json = json)
+ }
}
}
@@ -526,39 +511,25 @@ constructor(
}
}
- @JsonDeserialize(builder = NewCouponPercentageDiscount.Builder::class)
@NoAutoDetect
class NewCouponPercentageDiscount
+ @JsonCreator
private constructor(
- private val discountType: JsonField,
- private val percentageDiscount: JsonField,
- private val additionalProperties: Map