@@ -31,6 +31,7 @@ private constructor(
3131 private val filters: JsonField <List <Filter >>,
3232 private val itemId: JsonField <String >,
3333 private val licenseTypeId: JsonField <String >,
34+ private val metadata: JsonField <Metadata >,
3435 private val perUnitCostBasis: JsonField <String >,
3536 private val additionalProperties: MutableMap <String , JsonValue >,
3637) {
@@ -53,6 +54,7 @@ private constructor(
5354 @JsonProperty(" license_type_id" )
5455 @ExcludeMissing
5556 licenseTypeId: JsonField <String > = JsonMissing .of(),
57+ @JsonProperty(" metadata" ) @ExcludeMissing metadata: JsonField <Metadata > = JsonMissing .of(),
5658 @JsonProperty(" per_unit_cost_basis" )
5759 @ExcludeMissing
5860 perUnitCostBasis: JsonField <String > = JsonMissing .of(),
@@ -65,6 +67,7 @@ private constructor(
6567 filters,
6668 itemId,
6769 licenseTypeId,
70+ metadata,
6871 perUnitCostBasis,
6972 mutableMapOf (),
7073 )
@@ -138,6 +141,16 @@ private constructor(
138141 */
139142 fun licenseTypeId (): Optional <String > = licenseTypeId.getOptional(" license_type_id" )
140143
144+ /* *
145+ * User-specified key/value pairs for the resource. Individual keys can be removed by setting
146+ * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to
147+ * `null`.
148+ *
149+ * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server
150+ * responded with an unexpected value).
151+ */
152+ fun metadata (): Optional <Metadata > = metadata.getOptional(" metadata" )
153+
141154 /* *
142155 * The (per-unit) cost basis of each created block. If non-zero, a customer will be invoiced
143156 * according to the quantity and per unit cost basis specified for the allocation each cadence.
@@ -211,6 +224,13 @@ private constructor(
211224 @ExcludeMissing
212225 fun _licenseTypeId (): JsonField <String > = licenseTypeId
213226
227+ /* *
228+ * Returns the raw JSON value of [metadata].
229+ *
230+ * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type.
231+ */
232+ @JsonProperty(" metadata" ) @ExcludeMissing fun _metadata (): JsonField <Metadata > = metadata
233+
214234 /* *
215235 * Returns the raw JSON value of [perUnitCostBasis].
216236 *
@@ -259,6 +279,7 @@ private constructor(
259279 private var filters: JsonField <MutableList <Filter >>? = null
260280 private var itemId: JsonField <String > = JsonMissing .of()
261281 private var licenseTypeId: JsonField <String > = JsonMissing .of()
282+ private var metadata: JsonField <Metadata > = JsonMissing .of()
262283 private var perUnitCostBasis: JsonField <String > = JsonMissing .of()
263284 private var additionalProperties: MutableMap <String , JsonValue > = mutableMapOf ()
264285
@@ -272,6 +293,7 @@ private constructor(
272293 filters = newAllocationPrice.filters.map { it.toMutableList() }
273294 itemId = newAllocationPrice.itemId
274295 licenseTypeId = newAllocationPrice.licenseTypeId
296+ metadata = newAllocationPrice.metadata
275297 perUnitCostBasis = newAllocationPrice.perUnitCostBasis
276298 additionalProperties = newAllocationPrice.additionalProperties.toMutableMap()
277299 }
@@ -430,6 +452,25 @@ private constructor(
430452 this .licenseTypeId = licenseTypeId
431453 }
432454
455+ /* *
456+ * User-specified key/value pairs for the resource. Individual keys can be removed by
457+ * setting the value to `null`, and the entire metadata mapping can be cleared by setting
458+ * `metadata` to `null`.
459+ */
460+ fun metadata (metadata : Metadata ? ) = metadata(JsonField .ofNullable(metadata))
461+
462+ /* * Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */
463+ fun metadata (metadata : Optional <Metadata >) = metadata(metadata.getOrNull())
464+
465+ /* *
466+ * Sets [Builder.metadata] to an arbitrary JSON value.
467+ *
468+ * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead.
469+ * This method is primarily for setting the field to an undocumented or not yet supported
470+ * value.
471+ */
472+ fun metadata (metadata : JsonField <Metadata >) = apply { this .metadata = metadata }
473+
433474 /* *
434475 * The (per-unit) cost basis of each created block. If non-zero, a customer will be invoiced
435476 * according to the quantity and per unit cost basis specified for the allocation each
@@ -492,6 +533,7 @@ private constructor(
492533 (filters ? : JsonMissing .of()).map { it.toImmutable() },
493534 itemId,
494535 licenseTypeId,
536+ metadata,
495537 perUnitCostBasis,
496538 additionalProperties.toMutableMap(),
497539 )
@@ -512,6 +554,7 @@ private constructor(
512554 filters().ifPresent { it.forEach { it.validate() } }
513555 itemId()
514556 licenseTypeId()
557+ metadata().ifPresent { it.validate() }
515558 perUnitCostBasis()
516559 validated = true
517560 }
@@ -539,6 +582,7 @@ private constructor(
539582 (filters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ? : 0 ) +
540583 (if (itemId.asKnown().isPresent) 1 else 0 ) +
541584 (if (licenseTypeId.asKnown().isPresent) 1 else 0 ) +
585+ (metadata.asKnown().getOrNull()?.validity() ? : 0 ) +
542586 (if (perUnitCostBasis.asKnown().isPresent) 1 else 0 )
543587
544588 /* * The cadence at which to allocate the amount to the customer. */
@@ -1191,6 +1235,110 @@ private constructor(
11911235 " Filter{field=$field , operator=$operator , values=$values , additionalProperties=$additionalProperties }"
11921236 }
11931237
1238+ /* *
1239+ * User-specified key/value pairs for the resource. Individual keys can be removed by setting
1240+ * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to
1241+ * `null`.
1242+ */
1243+ class Metadata
1244+ @JsonCreator
1245+ private constructor (
1246+ @com.fasterxml.jackson.annotation.JsonValue
1247+ private val additionalProperties: Map <String , JsonValue >
1248+ ) {
1249+
1250+ @JsonAnyGetter
1251+ @ExcludeMissing
1252+ fun _additionalProperties (): Map <String , JsonValue > = additionalProperties
1253+
1254+ fun toBuilder () = Builder ().from(this )
1255+
1256+ companion object {
1257+
1258+ /* * Returns a mutable builder for constructing an instance of [Metadata]. */
1259+ @JvmStatic fun builder () = Builder ()
1260+ }
1261+
1262+ /* * A builder for [Metadata]. */
1263+ class Builder internal constructor() {
1264+
1265+ private var additionalProperties: MutableMap <String , JsonValue > = mutableMapOf ()
1266+
1267+ @JvmSynthetic
1268+ internal fun from (metadata : Metadata ) = apply {
1269+ additionalProperties = metadata.additionalProperties.toMutableMap()
1270+ }
1271+
1272+ fun additionalProperties (additionalProperties : Map <String , JsonValue >) = apply {
1273+ this .additionalProperties.clear()
1274+ putAllAdditionalProperties(additionalProperties)
1275+ }
1276+
1277+ fun putAdditionalProperty (key : String , value : JsonValue ) = apply {
1278+ additionalProperties.put(key, value)
1279+ }
1280+
1281+ fun putAllAdditionalProperties (additionalProperties : Map <String , JsonValue >) = apply {
1282+ this .additionalProperties.putAll(additionalProperties)
1283+ }
1284+
1285+ fun removeAdditionalProperty (key : String ) = apply { additionalProperties.remove(key) }
1286+
1287+ fun removeAllAdditionalProperties (keys : Set <String >) = apply {
1288+ keys.forEach(::removeAdditionalProperty)
1289+ }
1290+
1291+ /* *
1292+ * Returns an immutable instance of [Metadata].
1293+ *
1294+ * Further updates to this [Builder] will not mutate the returned instance.
1295+ */
1296+ fun build (): Metadata = Metadata (additionalProperties.toImmutable())
1297+ }
1298+
1299+ private var validated: Boolean = false
1300+
1301+ fun validate (): Metadata = apply {
1302+ if (validated) {
1303+ return @apply
1304+ }
1305+
1306+ validated = true
1307+ }
1308+
1309+ fun isValid (): Boolean =
1310+ try {
1311+ validate()
1312+ true
1313+ } catch (e: OrbInvalidDataException ) {
1314+ false
1315+ }
1316+
1317+ /* *
1318+ * Returns a score indicating how many valid values are contained in this object
1319+ * recursively.
1320+ *
1321+ * Used for best match union deserialization.
1322+ */
1323+ @JvmSynthetic
1324+ internal fun validity (): Int =
1325+ additionalProperties.count { (_, value) -> ! value.isNull() && ! value.isMissing() }
1326+
1327+ override fun equals (other : Any? ): Boolean {
1328+ if (this == = other) {
1329+ return true
1330+ }
1331+
1332+ return other is Metadata && additionalProperties == other.additionalProperties
1333+ }
1334+
1335+ private val hashCode: Int by lazy { Objects .hash(additionalProperties) }
1336+
1337+ override fun hashCode (): Int = hashCode
1338+
1339+ override fun toString () = " Metadata{additionalProperties=$additionalProperties }"
1340+ }
1341+
11941342 override fun equals (other : Any? ): Boolean {
11951343 if (this == = other) {
11961344 return true
@@ -1205,6 +1353,7 @@ private constructor(
12051353 filters == other.filters &&
12061354 itemId == other.itemId &&
12071355 licenseTypeId == other.licenseTypeId &&
1356+ metadata == other.metadata &&
12081357 perUnitCostBasis == other.perUnitCostBasis &&
12091358 additionalProperties == other.additionalProperties
12101359 }
@@ -1219,6 +1368,7 @@ private constructor(
12191368 filters,
12201369 itemId,
12211370 licenseTypeId,
1371+ metadata,
12221372 perUnitCostBasis,
12231373 additionalProperties,
12241374 )
@@ -1227,5 +1377,5 @@ private constructor(
12271377 override fun hashCode (): Int = hashCode
12281378
12291379 override fun toString () =
1230- " NewAllocationPrice{amount=$amount , cadence=$cadence , currency=$currency , customExpiration=$customExpiration , expiresAtEndOfCadence=$expiresAtEndOfCadence , filters=$filters , itemId=$itemId , licenseTypeId=$licenseTypeId , perUnitCostBasis=$perUnitCostBasis , additionalProperties=$additionalProperties }"
1380+ " NewAllocationPrice{amount=$amount , cadence=$cadence , currency=$currency , customExpiration=$customExpiration , expiresAtEndOfCadence=$expiresAtEndOfCadence , filters=$filters , itemId=$itemId , licenseTypeId=$licenseTypeId , metadata= $metadata , perUnitCostBasis=$perUnitCostBasis , additionalProperties=$additionalProperties }"
12311381}
0 commit comments