Skip to content

Commit 49d56e2

Browse files
feat(api): api update
1 parent ffbc747 commit 49d56e2

4 files changed

Lines changed: 216 additions & 4 deletions

File tree

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 126
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-9f1a41612765cb08d100b2c9e85080e93306e8d0942d535f16052c3eb18d9b8b.yml
3-
openapi_spec_hash: 6dd28f36adc7e7d6a9245585eaf9b9c1
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-931771ff4ab183044ee50ce43ea794ac0a15bfafbaf7df61ac0344af3ff08944.yml
3+
openapi_spec_hash: 71371804e373f662585284bf5d93cc62
44
config_hash: bcf82bddb691f6be773ac6cae8c03b9a

orb-java-core/src/main/kotlin/com/withorb/api/models/Alert.kt

Lines changed: 208 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ private constructor(
4141
private val thresholds: JsonField<List<Threshold>>,
4242
private val type: JsonField<Type>,
4343
private val balanceAlertStatus: JsonField<List<BalanceAlertStatus>>,
44+
private val licenseType: JsonField<LicenseType>,
4445
private val additionalProperties: MutableMap<String, JsonValue>,
4546
) {
4647

@@ -67,6 +68,9 @@ private constructor(
6768
@JsonProperty("balance_alert_status")
6869
@ExcludeMissing
6970
balanceAlertStatus: JsonField<List<BalanceAlertStatus>> = JsonMissing.of(),
71+
@JsonProperty("license_type")
72+
@ExcludeMissing
73+
licenseType: JsonField<LicenseType> = JsonMissing.of(),
7074
) : this(
7175
id,
7276
createdAt,
@@ -79,6 +83,7 @@ private constructor(
7983
thresholds,
8084
type,
8185
balanceAlertStatus,
86+
licenseType,
8287
mutableMapOf(),
8388
)
8489

@@ -171,6 +176,14 @@ private constructor(
171176
fun balanceAlertStatus(): Optional<List<BalanceAlertStatus>> =
172177
balanceAlertStatus.getOptional("balance_alert_status")
173178

179+
/**
180+
* Minified license type for alert serialization.
181+
*
182+
* @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server
183+
* responded with an unexpected value).
184+
*/
185+
fun licenseType(): Optional<LicenseType> = licenseType.getOptional("license_type")
186+
174187
/**
175188
* Returns the raw JSON value of [id].
176189
*
@@ -259,6 +272,15 @@ private constructor(
259272
@ExcludeMissing
260273
fun _balanceAlertStatus(): JsonField<List<BalanceAlertStatus>> = balanceAlertStatus
261274

275+
/**
276+
* Returns the raw JSON value of [licenseType].
277+
*
278+
* Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type.
279+
*/
280+
@JsonProperty("license_type")
281+
@ExcludeMissing
282+
fun _licenseType(): JsonField<LicenseType> = licenseType
283+
262284
@JsonAnySetter
263285
private fun putAdditionalProperty(key: String, value: JsonValue) {
264286
additionalProperties.put(key, value)
@@ -307,6 +329,7 @@ private constructor(
307329
private var thresholds: JsonField<MutableList<Threshold>>? = null
308330
private var type: JsonField<Type>? = null
309331
private var balanceAlertStatus: JsonField<MutableList<BalanceAlertStatus>>? = null
332+
private var licenseType: JsonField<LicenseType> = JsonMissing.of()
310333
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()
311334

312335
@JvmSynthetic
@@ -322,6 +345,7 @@ private constructor(
322345
thresholds = alert.thresholds.map { it.toMutableList() }
323346
type = alert.type
324347
balanceAlertStatus = alert.balanceAlertStatus.map { it.toMutableList() }
348+
licenseType = alert.licenseType
325349
additionalProperties = alert.additionalProperties.toMutableMap()
326350
}
327351

@@ -510,6 +534,23 @@ private constructor(
510534
}
511535
}
512536

537+
/** Minified license type for alert serialization. */
538+
fun licenseType(licenseType: LicenseType?) = licenseType(JsonField.ofNullable(licenseType))
539+
540+
/** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */
541+
fun licenseType(licenseType: Optional<LicenseType>) = licenseType(licenseType.getOrNull())
542+
543+
/**
544+
* Sets [Builder.licenseType] to an arbitrary JSON value.
545+
*
546+
* You should usually call [Builder.licenseType] with a well-typed [LicenseType] value
547+
* instead. This method is primarily for setting the field to an undocumented or not yet
548+
* supported value.
549+
*/
550+
fun licenseType(licenseType: JsonField<LicenseType>) = apply {
551+
this.licenseType = licenseType
552+
}
553+
513554
fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply {
514555
this.additionalProperties.clear()
515556
putAllAdditionalProperties(additionalProperties)
@@ -563,6 +604,7 @@ private constructor(
563604
checkRequired("thresholds", thresholds).map { it.toImmutable() },
564605
checkRequired("type", type),
565606
(balanceAlertStatus ?: JsonMissing.of()).map { it.toImmutable() },
607+
licenseType,
566608
additionalProperties.toMutableMap(),
567609
)
568610
}
@@ -585,6 +627,7 @@ private constructor(
585627
thresholds().ifPresent { it.forEach { it.validate() } }
586628
type().validate()
587629
balanceAlertStatus().ifPresent { it.forEach { it.validate() } }
630+
licenseType().ifPresent { it.validate() }
588631
validated = true
589632
}
590633

@@ -613,7 +656,8 @@ private constructor(
613656
(subscription.asKnown().getOrNull()?.validity() ?: 0) +
614657
(thresholds.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) +
615658
(type.asKnown().getOrNull()?.validity() ?: 0) +
616-
(balanceAlertStatus.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0)
659+
(balanceAlertStatus.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) +
660+
(licenseType.asKnown().getOrNull()?.validity() ?: 0)
617661

618662
/** The metric the alert applies to. */
619663
class Metric
@@ -1089,6 +1133,9 @@ private constructor(
10891133

10901134
@JvmField val COST_EXCEEDED = of("cost_exceeded")
10911135

1136+
@JvmField
1137+
val LICENSE_BALANCE_THRESHOLD_REACHED = of("license_balance_threshold_reached")
1138+
10921139
@JvmStatic fun of(value: String) = Type(JsonField.of(value))
10931140
}
10941141

@@ -1099,6 +1146,7 @@ private constructor(
10991146
CREDIT_BALANCE_RECOVERED,
11001147
USAGE_EXCEEDED,
11011148
COST_EXCEEDED,
1149+
LICENSE_BALANCE_THRESHOLD_REACHED,
11021150
}
11031151

11041152
/**
@@ -1116,6 +1164,7 @@ private constructor(
11161164
CREDIT_BALANCE_RECOVERED,
11171165
USAGE_EXCEEDED,
11181166
COST_EXCEEDED,
1167+
LICENSE_BALANCE_THRESHOLD_REACHED,
11191168
/** An enum member indicating that [Type] was instantiated with an unknown value. */
11201169
_UNKNOWN,
11211170
}
@@ -1134,6 +1183,7 @@ private constructor(
11341183
CREDIT_BALANCE_RECOVERED -> Value.CREDIT_BALANCE_RECOVERED
11351184
USAGE_EXCEEDED -> Value.USAGE_EXCEEDED
11361185
COST_EXCEEDED -> Value.COST_EXCEEDED
1186+
LICENSE_BALANCE_THRESHOLD_REACHED -> Value.LICENSE_BALANCE_THRESHOLD_REACHED
11371187
else -> Value._UNKNOWN
11381188
}
11391189

@@ -1152,6 +1202,7 @@ private constructor(
11521202
CREDIT_BALANCE_RECOVERED -> Known.CREDIT_BALANCE_RECOVERED
11531203
USAGE_EXCEEDED -> Known.USAGE_EXCEEDED
11541204
COST_EXCEEDED -> Known.COST_EXCEEDED
1205+
LICENSE_BALANCE_THRESHOLD_REACHED -> Known.LICENSE_BALANCE_THRESHOLD_REACHED
11551206
else -> throw OrbInvalidDataException("Unknown Type: $value")
11561207
}
11571208

@@ -1418,6 +1469,159 @@ private constructor(
14181469
"BalanceAlertStatus{inAlert=$inAlert, thresholdValue=$thresholdValue, additionalProperties=$additionalProperties}"
14191470
}
14201471

1472+
/** Minified license type for alert serialization. */
1473+
class LicenseType
1474+
@JsonCreator(mode = JsonCreator.Mode.DISABLED)
1475+
private constructor(
1476+
private val id: JsonField<String>,
1477+
private val additionalProperties: MutableMap<String, JsonValue>,
1478+
) {
1479+
1480+
@JsonCreator
1481+
private constructor(
1482+
@JsonProperty("id") @ExcludeMissing id: JsonField<String> = JsonMissing.of()
1483+
) : this(id, mutableMapOf())
1484+
1485+
/**
1486+
* @throws OrbInvalidDataException if the JSON field has an unexpected type or is
1487+
* unexpectedly missing or null (e.g. if the server responded with an unexpected value).
1488+
*/
1489+
fun id(): String = id.getRequired("id")
1490+
1491+
/**
1492+
* Returns the raw JSON value of [id].
1493+
*
1494+
* Unlike [id], this method doesn't throw if the JSON field has an unexpected type.
1495+
*/
1496+
@JsonProperty("id") @ExcludeMissing fun _id(): JsonField<String> = id
1497+
1498+
@JsonAnySetter
1499+
private fun putAdditionalProperty(key: String, value: JsonValue) {
1500+
additionalProperties.put(key, value)
1501+
}
1502+
1503+
@JsonAnyGetter
1504+
@ExcludeMissing
1505+
fun _additionalProperties(): Map<String, JsonValue> =
1506+
Collections.unmodifiableMap(additionalProperties)
1507+
1508+
fun toBuilder() = Builder().from(this)
1509+
1510+
companion object {
1511+
1512+
/**
1513+
* Returns a mutable builder for constructing an instance of [LicenseType].
1514+
*
1515+
* The following fields are required:
1516+
* ```java
1517+
* .id()
1518+
* ```
1519+
*/
1520+
@JvmStatic fun builder() = Builder()
1521+
}
1522+
1523+
/** A builder for [LicenseType]. */
1524+
class Builder internal constructor() {
1525+
1526+
private var id: JsonField<String>? = null
1527+
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()
1528+
1529+
@JvmSynthetic
1530+
internal fun from(licenseType: LicenseType) = apply {
1531+
id = licenseType.id
1532+
additionalProperties = licenseType.additionalProperties.toMutableMap()
1533+
}
1534+
1535+
fun id(id: String) = id(JsonField.of(id))
1536+
1537+
/**
1538+
* Sets [Builder.id] to an arbitrary JSON value.
1539+
*
1540+
* You should usually call [Builder.id] with a well-typed [String] value instead. This
1541+
* method is primarily for setting the field to an undocumented or not yet supported
1542+
* value.
1543+
*/
1544+
fun id(id: JsonField<String>) = apply { this.id = id }
1545+
1546+
fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply {
1547+
this.additionalProperties.clear()
1548+
putAllAdditionalProperties(additionalProperties)
1549+
}
1550+
1551+
fun putAdditionalProperty(key: String, value: JsonValue) = apply {
1552+
additionalProperties.put(key, value)
1553+
}
1554+
1555+
fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply {
1556+
this.additionalProperties.putAll(additionalProperties)
1557+
}
1558+
1559+
fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) }
1560+
1561+
fun removeAllAdditionalProperties(keys: Set<String>) = apply {
1562+
keys.forEach(::removeAdditionalProperty)
1563+
}
1564+
1565+
/**
1566+
* Returns an immutable instance of [LicenseType].
1567+
*
1568+
* Further updates to this [Builder] will not mutate the returned instance.
1569+
*
1570+
* The following fields are required:
1571+
* ```java
1572+
* .id()
1573+
* ```
1574+
*
1575+
* @throws IllegalStateException if any required field is unset.
1576+
*/
1577+
fun build(): LicenseType =
1578+
LicenseType(checkRequired("id", id), additionalProperties.toMutableMap())
1579+
}
1580+
1581+
private var validated: Boolean = false
1582+
1583+
fun validate(): LicenseType = apply {
1584+
if (validated) {
1585+
return@apply
1586+
}
1587+
1588+
id()
1589+
validated = true
1590+
}
1591+
1592+
fun isValid(): Boolean =
1593+
try {
1594+
validate()
1595+
true
1596+
} catch (e: OrbInvalidDataException) {
1597+
false
1598+
}
1599+
1600+
/**
1601+
* Returns a score indicating how many valid values are contained in this object
1602+
* recursively.
1603+
*
1604+
* Used for best match union deserialization.
1605+
*/
1606+
@JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0)
1607+
1608+
override fun equals(other: Any?): Boolean {
1609+
if (this === other) {
1610+
return true
1611+
}
1612+
1613+
return other is LicenseType &&
1614+
id == other.id &&
1615+
additionalProperties == other.additionalProperties
1616+
}
1617+
1618+
private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) }
1619+
1620+
override fun hashCode(): Int = hashCode
1621+
1622+
override fun toString() = "LicenseType{id=$id, additionalProperties=$additionalProperties}"
1623+
}
1624+
14211625
override fun equals(other: Any?): Boolean {
14221626
if (this === other) {
14231627
return true
@@ -1435,6 +1639,7 @@ private constructor(
14351639
thresholds == other.thresholds &&
14361640
type == other.type &&
14371641
balanceAlertStatus == other.balanceAlertStatus &&
1642+
licenseType == other.licenseType &&
14381643
additionalProperties == other.additionalProperties
14391644
}
14401645

@@ -1451,12 +1656,13 @@ private constructor(
14511656
thresholds,
14521657
type,
14531658
balanceAlertStatus,
1659+
licenseType,
14541660
additionalProperties,
14551661
)
14561662
}
14571663

14581664
override fun hashCode(): Int = hashCode
14591665

14601666
override fun toString() =
1461-
"Alert{id=$id, createdAt=$createdAt, currency=$currency, customer=$customer, enabled=$enabled, metric=$metric, plan=$plan, subscription=$subscription, thresholds=$thresholds, type=$type, balanceAlertStatus=$balanceAlertStatus, additionalProperties=$additionalProperties}"
1667+
"Alert{id=$id, createdAt=$createdAt, currency=$currency, customer=$customer, enabled=$enabled, metric=$metric, plan=$plan, subscription=$subscription, thresholds=$thresholds, type=$type, balanceAlertStatus=$balanceAlertStatus, licenseType=$licenseType, additionalProperties=$additionalProperties}"
14621668
}

orb-java-core/src/test/kotlin/com/withorb/api/models/AlertListPageResponseTest.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ internal class AlertListPageResponseTest {
4444
.thresholdValue(0.0)
4545
.build()
4646
)
47+
.licenseType(Alert.LicenseType.builder().id("id").build())
4748
.build()
4849
)
4950
.paginationMetadata(
@@ -79,6 +80,7 @@ internal class AlertListPageResponseTest {
7980
.addBalanceAlertStatus(
8081
Alert.BalanceAlertStatus.builder().inAlert(true).thresholdValue(0.0).build()
8182
)
83+
.licenseType(Alert.LicenseType.builder().id("id").build())
8284
.build()
8385
)
8486
assertThat(alertListPageResponse.paginationMetadata())
@@ -120,6 +122,7 @@ internal class AlertListPageResponseTest {
120122
.thresholdValue(0.0)
121123
.build()
122124
)
125+
.licenseType(Alert.LicenseType.builder().id("id").build())
123126
.build()
124127
)
125128
.paginationMetadata(

0 commit comments

Comments
 (0)