Skip to content

Commit 037dbcd

Browse files
feat(api): api update
1 parent 014ce03 commit 037dbcd

File tree

8 files changed

+281
-7
lines changed

8 files changed

+281
-7
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 139
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-87e16688d40cde735bc36efd40d8c12a7918919b18268d9c40b46d0cdf2f6251.yml
3-
openapi_spec_hash: 83f1f5a6fa7a07db4af09426232d0786
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-d6a851f21804170f796637f1911c3382f1c57f5ed6b9b77cd7d0c6f74c06e174.yml
3+
openapi_spec_hash: 82df33badf54d0c7087a61145d379f58
44
config_hash: 3279841440b02d4e8303c961d6983492

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

Lines changed: 65 additions & 1 deletion
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 groupingKeys: JsonField<List<String>>,
4445
private val licenseType: JsonField<LicenseType>,
4546
private val additionalProperties: MutableMap<String, JsonValue>,
4647
) {
@@ -68,6 +69,9 @@ private constructor(
6869
@JsonProperty("balance_alert_status")
6970
@ExcludeMissing
7071
balanceAlertStatus: JsonField<List<BalanceAlertStatus>> = JsonMissing.of(),
72+
@JsonProperty("grouping_keys")
73+
@ExcludeMissing
74+
groupingKeys: JsonField<List<String>> = JsonMissing.of(),
7175
@JsonProperty("license_type")
7276
@ExcludeMissing
7377
licenseType: JsonField<LicenseType> = JsonMissing.of(),
@@ -83,6 +87,7 @@ private constructor(
8387
thresholds,
8488
type,
8589
balanceAlertStatus,
90+
groupingKeys,
8691
licenseType,
8792
mutableMapOf(),
8893
)
@@ -176,6 +181,15 @@ private constructor(
176181
fun balanceAlertStatus(): Optional<List<BalanceAlertStatus>> =
177182
balanceAlertStatus.getOptional("balance_alert_status")
178183

184+
/**
185+
* The property keys to group cost alerts by. Only present for cost alerts with grouping
186+
* enabled.
187+
*
188+
* @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server
189+
* responded with an unexpected value).
190+
*/
191+
fun groupingKeys(): Optional<List<String>> = groupingKeys.getOptional("grouping_keys")
192+
179193
/**
180194
* Minified license type for alert serialization.
181195
*
@@ -272,6 +286,15 @@ private constructor(
272286
@ExcludeMissing
273287
fun _balanceAlertStatus(): JsonField<List<BalanceAlertStatus>> = balanceAlertStatus
274288

289+
/**
290+
* Returns the raw JSON value of [groupingKeys].
291+
*
292+
* Unlike [groupingKeys], this method doesn't throw if the JSON field has an unexpected type.
293+
*/
294+
@JsonProperty("grouping_keys")
295+
@ExcludeMissing
296+
fun _groupingKeys(): JsonField<List<String>> = groupingKeys
297+
275298
/**
276299
* Returns the raw JSON value of [licenseType].
277300
*
@@ -329,6 +352,7 @@ private constructor(
329352
private var thresholds: JsonField<MutableList<Threshold>>? = null
330353
private var type: JsonField<Type>? = null
331354
private var balanceAlertStatus: JsonField<MutableList<BalanceAlertStatus>>? = null
355+
private var groupingKeys: JsonField<MutableList<String>>? = null
332356
private var licenseType: JsonField<LicenseType> = JsonMissing.of()
333357
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()
334358

@@ -345,6 +369,7 @@ private constructor(
345369
thresholds = alert.thresholds.map { it.toMutableList() }
346370
type = alert.type
347371
balanceAlertStatus = alert.balanceAlertStatus.map { it.toMutableList() }
372+
groupingKeys = alert.groupingKeys.map { it.toMutableList() }
348373
licenseType = alert.licenseType
349374
additionalProperties = alert.additionalProperties.toMutableMap()
350375
}
@@ -534,6 +559,40 @@ private constructor(
534559
}
535560
}
536561

562+
/**
563+
* The property keys to group cost alerts by. Only present for cost alerts with grouping
564+
* enabled.
565+
*/
566+
fun groupingKeys(groupingKeys: List<String>?) =
567+
groupingKeys(JsonField.ofNullable(groupingKeys))
568+
569+
/** Alias for calling [Builder.groupingKeys] with `groupingKeys.orElse(null)`. */
570+
fun groupingKeys(groupingKeys: Optional<List<String>>) =
571+
groupingKeys(groupingKeys.getOrNull())
572+
573+
/**
574+
* Sets [Builder.groupingKeys] to an arbitrary JSON value.
575+
*
576+
* You should usually call [Builder.groupingKeys] with a well-typed `List<String>` value
577+
* instead. This method is primarily for setting the field to an undocumented or not yet
578+
* supported value.
579+
*/
580+
fun groupingKeys(groupingKeys: JsonField<List<String>>) = apply {
581+
this.groupingKeys = groupingKeys.map { it.toMutableList() }
582+
}
583+
584+
/**
585+
* Adds a single [String] to [groupingKeys].
586+
*
587+
* @throws IllegalStateException if the field was previously set to a non-list.
588+
*/
589+
fun addGroupingKey(groupingKey: String) = apply {
590+
groupingKeys =
591+
(groupingKeys ?: JsonField.of(mutableListOf())).also {
592+
checkKnown("groupingKeys", it).add(groupingKey)
593+
}
594+
}
595+
537596
/** Minified license type for alert serialization. */
538597
fun licenseType(licenseType: LicenseType?) = licenseType(JsonField.ofNullable(licenseType))
539598

@@ -604,6 +663,7 @@ private constructor(
604663
checkRequired("thresholds", thresholds).map { it.toImmutable() },
605664
checkRequired("type", type),
606665
(balanceAlertStatus ?: JsonMissing.of()).map { it.toImmutable() },
666+
(groupingKeys ?: JsonMissing.of()).map { it.toImmutable() },
607667
licenseType,
608668
additionalProperties.toMutableMap(),
609669
)
@@ -627,6 +687,7 @@ private constructor(
627687
thresholds().ifPresent { it.forEach { it.validate() } }
628688
type().validate()
629689
balanceAlertStatus().ifPresent { it.forEach { it.validate() } }
690+
groupingKeys()
630691
licenseType().ifPresent { it.validate() }
631692
validated = true
632693
}
@@ -657,6 +718,7 @@ private constructor(
657718
(thresholds.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) +
658719
(type.asKnown().getOrNull()?.validity() ?: 0) +
659720
(balanceAlertStatus.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) +
721+
(groupingKeys.asKnown().getOrNull()?.size ?: 0) +
660722
(licenseType.asKnown().getOrNull()?.validity() ?: 0)
661723

662724
/** The metric the alert applies to. */
@@ -1639,6 +1701,7 @@ private constructor(
16391701
thresholds == other.thresholds &&
16401702
type == other.type &&
16411703
balanceAlertStatus == other.balanceAlertStatus &&
1704+
groupingKeys == other.groupingKeys &&
16421705
licenseType == other.licenseType &&
16431706
additionalProperties == other.additionalProperties
16441707
}
@@ -1656,6 +1719,7 @@ private constructor(
16561719
thresholds,
16571720
type,
16581721
balanceAlertStatus,
1722+
groupingKeys,
16591723
licenseType,
16601724
additionalProperties,
16611725
)
@@ -1664,5 +1728,5 @@ private constructor(
16641728
override fun hashCode(): Int = hashCode
16651729

16661730
override fun toString() =
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}"
1731+
"Alert{id=$id, createdAt=$createdAt, currency=$currency, customer=$customer, enabled=$enabled, metric=$metric, plan=$plan, subscription=$subscription, thresholds=$thresholds, type=$type, balanceAlertStatus=$balanceAlertStatus, groupingKeys=$groupingKeys, licenseType=$licenseType, additionalProperties=$additionalProperties}"
16681732
}

0 commit comments

Comments
 (0)