diff --git a/.release-please-manifest.json b/.release-please-manifest.json index fe045cce..cae2247f 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0-beta.40" + ".": "0.1.0-beta.41" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index b12bc4d0..d68dad1e 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 115 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/stigg/stigg-95d84a1adc011f81086082cfbec6796bae04f4cba0c226965bfd40c53a65d321.yml -openapi_spec_hash: 1937e480aaa2d33272faa8df909df9f3 -config_hash: 3d43e5c6ff8bf447a1b4c1922a13119f +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/stigg/stigg-a75c09ac63a990956e295213c537c7c7aae6f08012d817e41bf91953f9199b92.yml +openapi_spec_hash: 742a2a900b833f5e48aa5723bc5ec953 +config_hash: 931244a505ec1f13e536ee9ed7133ebc diff --git a/CHANGELOG.md b/CHANGELOG.md index 81631caf..90ca1d4f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +## 0.1.0-beta.41 (2026-07-26) + +Full Changelog: [v0.1.0-beta.40...v0.1.0-beta.41](https://github.com/stiggio/stigg-java/compare/v0.1.0-beta.40...v0.1.0-beta.41) + +### Features + +* **api:** add creditEntitlement field to addon/plan overage pricing ([fc6460e](https://github.com/stiggio/stigg-java/commit/fc6460e5a7e1efcb95c14cdb6fed1a42a2d4e4dc)) + + +### Chores + +* **internal:** regenerate SDK with no functional changes ([dd164e0](https://github.com/stiggio/stigg-java/commit/dd164e04deb902319aba95c7e6562bd258dbdd20)) + ## 0.1.0-beta.40 (2026-07-21) Full Changelog: [v0.1.0-beta.39...v0.1.0-beta.40](https://github.com/stiggio/stigg-java/compare/v0.1.0-beta.39...v0.1.0-beta.40) diff --git a/README.md b/README.md index 64b58aa5..2584c66d 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ -[![Maven Central](https://img.shields.io/maven-central/v/io.stigg/stigg-java)](https://central.sonatype.com/artifact/io.stigg/stigg-java/0.1.0-beta.40) -[![javadoc](https://javadoc.io/badge2/io.stigg/stigg-java/0.1.0-beta.40/javadoc.svg)](https://javadoc.io/doc/io.stigg/stigg-java/0.1.0-beta.40) +[![Maven Central](https://img.shields.io/maven-central/v/io.stigg/stigg-java)](https://central.sonatype.com/artifact/io.stigg/stigg-java/0.1.0-beta.41) +[![javadoc](https://javadoc.io/badge2/io.stigg/stigg-java/0.1.0-beta.41/javadoc.svg)](https://javadoc.io/doc/io.stigg/stigg-java/0.1.0-beta.41) @@ -22,7 +22,7 @@ Use the Stigg MCP Server to enable AI assistants to interact with this API, allo -Javadocs are available on [javadoc.io](https://javadoc.io/doc/io.stigg/stigg-java/0.1.0-beta.40). +Javadocs are available on [javadoc.io](https://javadoc.io/doc/io.stigg/stigg-java/0.1.0-beta.41). @@ -33,7 +33,7 @@ Javadocs are available on [javadoc.io](https://javadoc.io/doc/io.stigg/stigg-jav ### Gradle ```kotlin -implementation("io.stigg:stigg-java:0.1.0-beta.40") +implementation("io.stigg:stigg-java:0.1.0-beta.41") ``` ### Maven @@ -42,7 +42,7 @@ implementation("io.stigg:stigg-java:0.1.0-beta.40") io.stigg stigg-java - 0.1.0-beta.40 + 0.1.0-beta.41 ``` @@ -107,10 +107,10 @@ StiggClient client = StiggOkHttpClient.builder() See this table for the available options: -| Setter | System property | Environment variable | Required | Default value | -| --------- | --------------- | -------------------- | -------- | ----------------------------- | -| `apiKey` | `stigg.apiKey` | `STIGG_API_KEY` | true | - | -| `baseUrl` | `stigg.baseUrl` | `STIGG_BASE_URL` | true | `"https://edge.api.stigg.io"` | +| Setter | System property | Environment variable | Required | Default value | +| --------- | --------------- | -------------------- | -------- | ------------------------ | +| `apiKey` | `stigg.apiKey` | `STIGG_API_KEY` | true | - | +| `baseUrl` | `stigg.baseUrl` | `STIGG_BASE_URL` | true | `"https://api.stigg.io"` | System properties take precedence over environment variables. diff --git a/build.gradle.kts b/build.gradle.kts index b2953ef9..a183d54b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "io.stigg" - version = "0.1.0-beta.40" // x-release-please-version + version = "0.1.0-beta.41" // x-release-please-version } subprojects { diff --git a/stigg-java-client-okhttp/src/main/kotlin/io/stigg/client/okhttp/StiggOkHttpClient.kt b/stigg-java-client-okhttp/src/main/kotlin/io/stigg/client/okhttp/StiggOkHttpClient.kt index 2236c294..ee3abb41 100644 --- a/stigg-java-client-okhttp/src/main/kotlin/io/stigg/client/okhttp/StiggOkHttpClient.kt +++ b/stigg-java-client-okhttp/src/main/kotlin/io/stigg/client/okhttp/StiggOkHttpClient.kt @@ -237,7 +237,7 @@ class StiggOkHttpClient private constructor() { /** * The base URL to use for every request. * - * Defaults to the production environment: `https://edge.api.stigg.io`. + * Defaults to the production environment: `https://api.stigg.io`. */ fun baseUrl(baseUrl: String?) = apply { clientOptions.baseUrl(baseUrl) } diff --git a/stigg-java-client-okhttp/src/main/kotlin/io/stigg/client/okhttp/StiggOkHttpClientAsync.kt b/stigg-java-client-okhttp/src/main/kotlin/io/stigg/client/okhttp/StiggOkHttpClientAsync.kt index 31cea541..48b96ced 100644 --- a/stigg-java-client-okhttp/src/main/kotlin/io/stigg/client/okhttp/StiggOkHttpClientAsync.kt +++ b/stigg-java-client-okhttp/src/main/kotlin/io/stigg/client/okhttp/StiggOkHttpClientAsync.kt @@ -237,7 +237,7 @@ class StiggOkHttpClientAsync private constructor() { /** * The base URL to use for every request. * - * Defaults to the production environment: `https://edge.api.stigg.io`. + * Defaults to the production environment: `https://api.stigg.io`. */ fun baseUrl(baseUrl: String?) = apply { clientOptions.baseUrl(baseUrl) } diff --git a/stigg-java-core/src/main/kotlin/io/stigg/core/ClientOptions.kt b/stigg-java-core/src/main/kotlin/io/stigg/core/ClientOptions.kt index b49c917b..995e7ffc 100644 --- a/stigg-java-core/src/main/kotlin/io/stigg/core/ClientOptions.kt +++ b/stigg-java-core/src/main/kotlin/io/stigg/core/ClientOptions.kt @@ -131,7 +131,7 @@ private constructor( /** * The base URL to use for every request. * - * Defaults to the production environment: `https://edge.api.stigg.io`. + * Defaults to the production environment: `https://api.stigg.io`. */ fun baseUrl(): String = baseUrl ?: PRODUCTION_URL @@ -139,7 +139,7 @@ private constructor( companion object { - const val PRODUCTION_URL = "https://edge.api.stigg.io" + const val PRODUCTION_URL = "https://api.stigg.io" /** * Returns a mutable builder for constructing an instance of [ClientOptions]. @@ -263,7 +263,7 @@ private constructor( /** * The base URL to use for every request. * - * Defaults to the production environment: `https://edge.api.stigg.io`. + * Defaults to the production environment: `https://api.stigg.io`. */ fun baseUrl(baseUrl: String?) = apply { this.baseUrl = baseUrl } @@ -415,10 +415,10 @@ private constructor( * * See this table for the available options: * - * |Setter |System property|Environment variable|Required|Default value | - * |---------|---------------|--------------------|--------|-----------------------------| - * |`apiKey` |`stigg.apiKey` |`STIGG_API_KEY` |true |- | - * |`baseUrl`|`stigg.baseUrl`|`STIGG_BASE_URL` |true |`"https://edge.api.stigg.io"`| + * | Setter | System property | Environment variable | Required | Default value | + * |-----------|-----------------|----------------------|----------|--------------------------| + * | `apiKey` | `stigg.apiKey` | `STIGG_API_KEY` | true | - | + * | `baseUrl` | `stigg.baseUrl` | `STIGG_BASE_URL` | true | `"https://api.stigg.io"` | * * System properties take precedence over environment variables. */ diff --git a/stigg-java-core/src/main/kotlin/io/stigg/models/v1/addons/AddonUpdateParams.kt b/stigg-java-core/src/main/kotlin/io/stigg/models/v1/addons/AddonUpdateParams.kt index ea7ca03a..76035df8 100644 --- a/stigg-java-core/src/main/kotlin/io/stigg/models/v1/addons/AddonUpdateParams.kt +++ b/stigg-java-core/src/main/kotlin/io/stigg/models/v1/addons/AddonUpdateParams.kt @@ -3124,9 +3124,10 @@ private constructor( private val billingModel: JsonField, private val pricePeriods: JsonField>, private val billingCadence: JsonField, + private val creditEntitlement: JsonField, + private val currencyId: JsonField, private val entitlement: JsonField, private val featureId: JsonField, - private val topUpCustomCurrencyId: JsonField, private val additionalProperties: MutableMap, ) { @@ -3141,22 +3142,26 @@ private constructor( @JsonProperty("billingCadence") @ExcludeMissing billingCadence: JsonField = JsonMissing.of(), + @JsonProperty("creditEntitlement") + @ExcludeMissing + creditEntitlement: JsonField = JsonMissing.of(), + @JsonProperty("currencyId") + @ExcludeMissing + currencyId: JsonField = JsonMissing.of(), @JsonProperty("entitlement") @ExcludeMissing entitlement: JsonField = JsonMissing.of(), @JsonProperty("featureId") @ExcludeMissing featureId: JsonField = JsonMissing.of(), - @JsonProperty("topUpCustomCurrencyId") - @ExcludeMissing - topUpCustomCurrencyId: JsonField = JsonMissing.of(), ) : this( billingModel, pricePeriods, billingCadence, + creditEntitlement, + currencyId, entitlement, featureId, - topUpCustomCurrencyId, mutableMapOf(), ) @@ -3188,29 +3193,38 @@ private constructor( billingCadence.getOptional("billingCadence") /** - * Entitlement configuration for the overage feature + * Credit entitlement to grant when a credit overage targets a currency not yet granted + * on the plan * * @throws StiggInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun entitlement(): Optional = entitlement.getOptional("entitlement") + fun creditEntitlement(): Optional = + creditEntitlement.getOptional("creditEntitlement") /** - * The feature ID for overage pricing + * The refId of the custom currency this credit overage applies to * * @throws StiggInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun featureId(): Optional = featureId.getOptional("featureId") + fun currencyId(): Optional = currencyId.getOptional("currencyId") /** - * Custom currency ID for overage top-up + * Entitlement configuration for the overage feature * * @throws StiggInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun topUpCustomCurrencyId(): Optional = - topUpCustomCurrencyId.getOptional("topUpCustomCurrencyId") + fun entitlement(): Optional = entitlement.getOptional("entitlement") + + /** + * The feature ID for overage pricing + * + * @throws StiggInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun featureId(): Optional = featureId.getOptional("featureId") /** * Returns the raw JSON value of [billingModel]. @@ -3242,6 +3256,26 @@ private constructor( @ExcludeMissing fun _billingCadence(): JsonField = billingCadence + /** + * Returns the raw JSON value of [creditEntitlement]. + * + * Unlike [creditEntitlement], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("creditEntitlement") + @ExcludeMissing + fun _creditEntitlement(): JsonField = creditEntitlement + + /** + * Returns the raw JSON value of [currencyId]. + * + * Unlike [currencyId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currencyId") + @ExcludeMissing + fun _currencyId(): JsonField = currencyId + /** * Returns the raw JSON value of [entitlement]. * @@ -3262,16 +3296,6 @@ private constructor( @ExcludeMissing fun _featureId(): JsonField = featureId - /** - * Returns the raw JSON value of [topUpCustomCurrencyId]. - * - * Unlike [topUpCustomCurrencyId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("topUpCustomCurrencyId") - @ExcludeMissing - fun _topUpCustomCurrencyId(): JsonField = topUpCustomCurrencyId - @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -3304,9 +3328,10 @@ private constructor( private var billingModel: JsonField? = null private var pricePeriods: JsonField>? = null private var billingCadence: JsonField = JsonMissing.of() + private var creditEntitlement: JsonField = JsonMissing.of() + private var currencyId: JsonField = JsonMissing.of() private var entitlement: JsonField = JsonMissing.of() private var featureId: JsonField = JsonMissing.of() - private var topUpCustomCurrencyId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -3314,9 +3339,10 @@ private constructor( billingModel = overagePricingModel.billingModel pricePeriods = overagePricingModel.pricePeriods.map { it.toMutableList() } billingCadence = overagePricingModel.billingCadence + creditEntitlement = overagePricingModel.creditEntitlement + currencyId = overagePricingModel.currencyId entitlement = overagePricingModel.entitlement featureId = overagePricingModel.featureId - topUpCustomCurrencyId = overagePricingModel.topUpCustomCurrencyId additionalProperties = overagePricingModel.additionalProperties.toMutableMap() } @@ -3377,6 +3403,38 @@ private constructor( this.billingCadence = billingCadence } + /** + * Credit entitlement to grant when a credit overage targets a currency not yet + * granted on the plan + */ + fun creditEntitlement(creditEntitlement: CreditEntitlement) = + creditEntitlement(JsonField.of(creditEntitlement)) + + /** + * Sets [Builder.creditEntitlement] to an arbitrary JSON value. + * + * You should usually call [Builder.creditEntitlement] with a well-typed + * [CreditEntitlement] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun creditEntitlement(creditEntitlement: JsonField) = apply { + this.creditEntitlement = creditEntitlement + } + + /** The refId of the custom currency this credit overage applies to */ + fun currencyId(currencyId: String) = currencyId(JsonField.of(currencyId)) + + /** + * Sets [Builder.currencyId] to an arbitrary JSON value. + * + * You should usually call [Builder.currencyId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun currencyId(currencyId: JsonField) = apply { + this.currencyId = currencyId + } + /** Entitlement configuration for the overage feature */ fun entitlement(entitlement: Entitlement) = entitlement(JsonField.of(entitlement)) @@ -3403,21 +3461,6 @@ private constructor( */ fun featureId(featureId: JsonField) = apply { this.featureId = featureId } - /** Custom currency ID for overage top-up */ - fun topUpCustomCurrencyId(topUpCustomCurrencyId: String) = - topUpCustomCurrencyId(JsonField.of(topUpCustomCurrencyId)) - - /** - * Sets [Builder.topUpCustomCurrencyId] to an arbitrary JSON value. - * - * You should usually call [Builder.topUpCustomCurrencyId] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun topUpCustomCurrencyId(topUpCustomCurrencyId: JsonField) = apply { - this.topUpCustomCurrencyId = topUpCustomCurrencyId - } - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -3458,9 +3501,10 @@ private constructor( checkRequired("billingModel", billingModel), checkRequired("pricePeriods", pricePeriods).map { it.toImmutable() }, billingCadence, + creditEntitlement, + currencyId, entitlement, featureId, - topUpCustomCurrencyId, additionalProperties.toMutableMap(), ) } @@ -3485,9 +3529,10 @@ private constructor( billingModel().validate() pricePeriods().forEach { it.validate() } billingCadence().ifPresent { it.validate() } + creditEntitlement().ifPresent { it.validate() } + currencyId() entitlement().ifPresent { it.validate() } featureId() - topUpCustomCurrencyId() validated = true } @@ -3510,9 +3555,10 @@ private constructor( (billingModel.asKnown().getOrNull()?.validity() ?: 0) + (pricePeriods.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (billingCadence.asKnown().getOrNull()?.validity() ?: 0) + + (creditEntitlement.asKnown().getOrNull()?.validity() ?: 0) + + (if (currencyId.asKnown().isPresent) 1 else 0) + (entitlement.asKnown().getOrNull()?.validity() ?: 0) + - (if (featureId.asKnown().isPresent) 1 else 0) + - (if (topUpCustomCurrencyId.asKnown().isPresent) 1 else 0) + (if (featureId.asKnown().isPresent) 1 else 0) /** The billing model for overages */ class BillingModel @@ -8283,6 +8329,425 @@ private constructor( override fun toString() = value.toString() } + /** + * Credit entitlement to grant when a credit overage targets a currency not yet granted + * on the plan + */ + class CreditEntitlement + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val cadence: JsonField, + private val customCurrencyId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("customCurrencyId") + @ExcludeMissing + customCurrencyId: JsonField = JsonMissing.of(), + ) : this(amount, cadence, customCurrencyId, mutableMapOf()) + + /** + * The base credit balance granted per cadence + * + * @throws StiggInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun amount(): Double = amount.getRequired("amount") + + /** + * The credit grant cadence (MONTH or YEAR) + * + * @throws StiggInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The refId of the custom currency to grant + * + * @throws StiggInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun customCurrencyId(): String = customCurrencyId.getRequired("customCurrencyId") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [customCurrencyId]. + * + * Unlike [customCurrencyId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("customCurrencyId") + @ExcludeMissing + fun _customCurrencyId(): JsonField = customCurrencyId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CreditEntitlement]. + * + * The following fields are required: + * ```java + * .amount() + * .cadence() + * .customCurrencyId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CreditEntitlement]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var cadence: JsonField? = null + private var customCurrencyId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(creditEntitlement: CreditEntitlement) = apply { + amount = creditEntitlement.amount + cadence = creditEntitlement.cadence + customCurrencyId = creditEntitlement.customCurrencyId + additionalProperties = creditEntitlement.additionalProperties.toMutableMap() + } + + /** The base credit balance granted per cadence */ + fun amount(amount: Double) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The credit grant cadence (MONTH or YEAR) */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The refId of the custom currency to grant */ + fun customCurrencyId(customCurrencyId: String) = + customCurrencyId(JsonField.of(customCurrencyId)) + + /** + * Sets [Builder.customCurrencyId] to an arbitrary JSON value. + * + * You should usually call [Builder.customCurrencyId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun customCurrencyId(customCurrencyId: JsonField) = apply { + this.customCurrencyId = customCurrencyId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CreditEntitlement]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .cadence() + * .customCurrencyId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CreditEntitlement = + CreditEntitlement( + checkRequired("amount", amount), + checkRequired("cadence", cadence), + checkRequired("customCurrencyId", customCurrencyId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws StiggInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): CreditEntitlement = apply { + if (validated) { + return@apply + } + + amount() + cadence().validate() + customCurrencyId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: StiggInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (customCurrencyId.asKnown().isPresent) 1 else 0) + + /** The credit grant cadence (MONTH or YEAR) */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val MONTH = of("MONTH") + + @JvmField val YEAR = of("YEAR") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + MONTH, + YEAR, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MONTH, + YEAR, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MONTH -> Value.MONTH + YEAR -> Value.YEAR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws StiggInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + MONTH -> Known.MONTH + YEAR -> Known.YEAR + else -> throw StiggInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws StiggInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + StiggInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws StiggInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: StiggInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CreditEntitlement && + amount == other.amount && + cadence == other.cadence && + customCurrencyId == other.customCurrencyId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, cadence, customCurrencyId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CreditEntitlement{amount=$amount, cadence=$cadence, customCurrencyId=$customCurrencyId, additionalProperties=$additionalProperties}" + } + /** Entitlement configuration for the overage feature */ class Entitlement @JsonCreator(mode = JsonCreator.Mode.DISABLED) @@ -10044,9 +10509,10 @@ private constructor( billingModel == other.billingModel && pricePeriods == other.pricePeriods && billingCadence == other.billingCadence && + creditEntitlement == other.creditEntitlement && + currencyId == other.currencyId && entitlement == other.entitlement && featureId == other.featureId && - topUpCustomCurrencyId == other.topUpCustomCurrencyId && additionalProperties == other.additionalProperties } @@ -10055,9 +10521,10 @@ private constructor( billingModel, pricePeriods, billingCadence, + creditEntitlement, + currencyId, entitlement, featureId, - topUpCustomCurrencyId, additionalProperties, ) } @@ -10065,7 +10532,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "OveragePricingModel{billingModel=$billingModel, pricePeriods=$pricePeriods, billingCadence=$billingCadence, entitlement=$entitlement, featureId=$featureId, topUpCustomCurrencyId=$topUpCustomCurrencyId, additionalProperties=$additionalProperties}" + "OveragePricingModel{billingModel=$billingModel, pricePeriods=$pricePeriods, billingCadence=$billingCadence, creditEntitlement=$creditEntitlement, currencyId=$currencyId, entitlement=$entitlement, featureId=$featureId, additionalProperties=$additionalProperties}" } /** A pricing model configuration with billing details and price periods. */ diff --git a/stigg-java-core/src/main/kotlin/io/stigg/models/v1/credits/grants/CreditGrantResponse.kt b/stigg-java-core/src/main/kotlin/io/stigg/models/v1/credits/grants/CreditGrantResponse.kt index e201de9c..2b58a157 100644 --- a/stigg-java-core/src/main/kotlin/io/stigg/models/v1/credits/grants/CreditGrantResponse.kt +++ b/stigg-java-core/src/main/kotlin/io/stigg/models/v1/credits/grants/CreditGrantResponse.kt @@ -373,7 +373,7 @@ private constructor( fun expireAt(): Optional = expireAt.getOptional("expireAt") /** - * The type of credit grant (PAID, PROMOTIONAL, RECURRING) + * The type of credit grant (PAID, PROMOTIONAL, RECURRING, OVERDRAFT) * * @throws StiggInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -913,7 +913,7 @@ private constructor( */ fun expireAt(expireAt: JsonField) = apply { this.expireAt = expireAt } - /** The type of credit grant (PAID, PROMOTIONAL, RECURRING) */ + /** The type of credit grant (PAID, PROMOTIONAL, RECURRING, OVERDRAFT) */ fun grantType(grantType: GrantType) = grantType(JsonField.of(grantType)) /** @@ -1487,7 +1487,7 @@ private constructor( "Cost{amount=$amount, currency=$currency, additionalProperties=$additionalProperties}" } - /** The type of credit grant (PAID, PROMOTIONAL, RECURRING) */ + /** The type of credit grant (PAID, PROMOTIONAL, RECURRING, OVERDRAFT) */ class GrantType @JsonCreator private constructor(private val value: JsonField) : Enum { diff --git a/stigg-java-core/src/main/kotlin/io/stigg/models/v1/credits/grants/GrantListResponse.kt b/stigg-java-core/src/main/kotlin/io/stigg/models/v1/credits/grants/GrantListResponse.kt index b0d78390..5411f24a 100644 --- a/stigg-java-core/src/main/kotlin/io/stigg/models/v1/credits/grants/GrantListResponse.kt +++ b/stigg-java-core/src/main/kotlin/io/stigg/models/v1/credits/grants/GrantListResponse.kt @@ -222,7 +222,7 @@ private constructor( fun expireAt(): Optional = expireAt.getOptional("expireAt") /** - * The type of credit grant (PAID, PROMOTIONAL, RECURRING) + * The type of credit grant (PAID, PROMOTIONAL, RECURRING, OVERDRAFT) * * @throws StiggInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). @@ -736,7 +736,7 @@ private constructor( */ fun expireAt(expireAt: JsonField) = apply { this.expireAt = expireAt } - /** The type of credit grant (PAID, PROMOTIONAL, RECURRING) */ + /** The type of credit grant (PAID, PROMOTIONAL, RECURRING, OVERDRAFT) */ fun grantType(grantType: GrantType) = grantType(JsonField.of(grantType)) /** @@ -1287,7 +1287,7 @@ private constructor( "Cost{amount=$amount, currency=$currency, additionalProperties=$additionalProperties}" } - /** The type of credit grant (PAID, PROMOTIONAL, RECURRING) */ + /** The type of credit grant (PAID, PROMOTIONAL, RECURRING, OVERDRAFT) */ class GrantType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/stigg-java-core/src/main/kotlin/io/stigg/models/v1/events/EventEstimateCostParams.kt b/stigg-java-core/src/main/kotlin/io/stigg/models/v1/events/EventEstimateParams.kt similarity index 96% rename from stigg-java-core/src/main/kotlin/io/stigg/models/v1/events/EventEstimateCostParams.kt rename to stigg-java-core/src/main/kotlin/io/stigg/models/v1/events/EventEstimateParams.kt index b0e4ee9c..44e6dafe 100644 --- a/stigg-java-core/src/main/kotlin/io/stigg/models/v1/events/EventEstimateCostParams.kt +++ b/stigg-java-core/src/main/kotlin/io/stigg/models/v1/events/EventEstimateParams.kt @@ -25,7 +25,7 @@ import kotlin.jvm.optionals.getOrNull * Estimates the credit cost of a usage event without ingesting it. Returns the estimated cost per * credit currency, the current balance, and the balance after the estimated consumption. */ -class EventEstimateCostParams +class EventEstimateParams private constructor( private val xAccountId: String?, private val xEnvironmentId: String?, @@ -111,7 +111,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [EventEstimateCostParams]. + * Returns a mutable builder for constructing an instance of [EventEstimateParams]. * * The following fields are required: * ```java @@ -122,7 +122,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [EventEstimateCostParams]. */ + /** A builder for [EventEstimateParams]. */ class Builder internal constructor() { private var xAccountId: String? = null @@ -132,12 +132,12 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(eventEstimateCostParams: EventEstimateCostParams) = apply { - xAccountId = eventEstimateCostParams.xAccountId - xEnvironmentId = eventEstimateCostParams.xEnvironmentId - body = eventEstimateCostParams.body.toBuilder() - additionalHeaders = eventEstimateCostParams.additionalHeaders.toBuilder() - additionalQueryParams = eventEstimateCostParams.additionalQueryParams.toBuilder() + internal fun from(eventEstimateParams: EventEstimateParams) = apply { + xAccountId = eventEstimateParams.xAccountId + xEnvironmentId = eventEstimateParams.xEnvironmentId + body = eventEstimateParams.body.toBuilder() + additionalHeaders = eventEstimateParams.additionalHeaders.toBuilder() + additionalQueryParams = eventEstimateParams.additionalQueryParams.toBuilder() } fun xAccountId(xAccountId: String?) = apply { this.xAccountId = xAccountId } @@ -332,7 +332,7 @@ private constructor( } /** - * Returns an immutable instance of [EventEstimateCostParams]. + * Returns an immutable instance of [EventEstimateParams]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -344,8 +344,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): EventEstimateCostParams = - EventEstimateCostParams( + fun build(): EventEstimateParams = + EventEstimateParams( xAccountId, xEnvironmentId, body.build(), @@ -780,7 +780,7 @@ private constructor( return true } - return other is EventEstimateCostParams && + return other is EventEstimateParams && xAccountId == other.xAccountId && xEnvironmentId == other.xEnvironmentId && body == other.body && @@ -792,5 +792,5 @@ private constructor( Objects.hash(xAccountId, xEnvironmentId, body, additionalHeaders, additionalQueryParams) override fun toString() = - "EventEstimateCostParams{xAccountId=$xAccountId, xEnvironmentId=$xEnvironmentId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "EventEstimateParams{xAccountId=$xAccountId, xEnvironmentId=$xEnvironmentId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/stigg-java-core/src/main/kotlin/io/stigg/models/v1/events/EventEstimateCostResponse.kt b/stigg-java-core/src/main/kotlin/io/stigg/models/v1/events/EventEstimateResponse.kt similarity index 98% rename from stigg-java-core/src/main/kotlin/io/stigg/models/v1/events/EventEstimateCostResponse.kt rename to stigg-java-core/src/main/kotlin/io/stigg/models/v1/events/EventEstimateResponse.kt index 09dd8e35..b192115d 100644 --- a/stigg-java-core/src/main/kotlin/io/stigg/models/v1/events/EventEstimateCostResponse.kt +++ b/stigg-java-core/src/main/kotlin/io/stigg/models/v1/events/EventEstimateResponse.kt @@ -21,7 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** Response object */ -class EventEstimateCostResponse +class EventEstimateResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField, @@ -63,7 +63,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [EventEstimateCostResponse]. + * Returns a mutable builder for constructing an instance of [EventEstimateResponse]. * * The following fields are required: * ```java @@ -73,16 +73,16 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [EventEstimateCostResponse]. */ + /** A builder for [EventEstimateResponse]. */ class Builder internal constructor() { private var data: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(eventEstimateCostResponse: EventEstimateCostResponse) = apply { - data = eventEstimateCostResponse.data - additionalProperties = eventEstimateCostResponse.additionalProperties.toMutableMap() + internal fun from(eventEstimateResponse: EventEstimateResponse) = apply { + data = eventEstimateResponse.data + additionalProperties = eventEstimateResponse.additionalProperties.toMutableMap() } /** Estimated credit cost, current balance and balance after */ @@ -116,7 +116,7 @@ private constructor( } /** - * Returns an immutable instance of [EventEstimateCostResponse]. + * Returns an immutable instance of [EventEstimateResponse]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -127,11 +127,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): EventEstimateCostResponse = - EventEstimateCostResponse( - checkRequired("data", data), - additionalProperties.toMutableMap(), - ) + fun build(): EventEstimateResponse = + EventEstimateResponse(checkRequired("data", data), additionalProperties.toMutableMap()) } private var validated: Boolean = false @@ -144,7 +141,7 @@ private constructor( * @throws StiggInvalidDataException if any value type in this object doesn't match its expected * type. */ - fun validate(): EventEstimateCostResponse = apply { + fun validate(): EventEstimateResponse = apply { if (validated) { return@apply } @@ -1423,7 +1420,7 @@ private constructor( return true } - return other is EventEstimateCostResponse && + return other is EventEstimateResponse && data == other.data && additionalProperties == other.additionalProperties } @@ -1433,5 +1430,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EventEstimateCostResponse{data=$data, additionalProperties=$additionalProperties}" + "EventEstimateResponse{data=$data, additionalProperties=$additionalProperties}" } diff --git a/stigg-java-core/src/main/kotlin/io/stigg/models/v1beta/customers/CustomerRetrieveGovernanceParams.kt b/stigg-java-core/src/main/kotlin/io/stigg/models/v1/events/beta/customers/CustomerRetrieveGovernanceParams.kt similarity index 99% rename from stigg-java-core/src/main/kotlin/io/stigg/models/v1beta/customers/CustomerRetrieveGovernanceParams.kt rename to stigg-java-core/src/main/kotlin/io/stigg/models/v1/events/beta/customers/CustomerRetrieveGovernanceParams.kt index fba36f5f..d4396f82 100644 --- a/stigg-java-core/src/main/kotlin/io/stigg/models/v1beta/customers/CustomerRetrieveGovernanceParams.kt +++ b/stigg-java-core/src/main/kotlin/io/stigg/models/v1/events/beta/customers/CustomerRetrieveGovernanceParams.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.stigg.models.v1beta.customers +package io.stigg.models.v1.events.beta.customers import com.fasterxml.jackson.annotation.JsonCreator import io.stigg.core.Enum diff --git a/stigg-java-core/src/main/kotlin/io/stigg/models/v1beta/customers/CustomerRetrieveGovernanceResponse.kt b/stigg-java-core/src/main/kotlin/io/stigg/models/v1/events/beta/customers/CustomerRetrieveGovernanceResponse.kt similarity index 99% rename from stigg-java-core/src/main/kotlin/io/stigg/models/v1beta/customers/CustomerRetrieveGovernanceResponse.kt rename to stigg-java-core/src/main/kotlin/io/stigg/models/v1/events/beta/customers/CustomerRetrieveGovernanceResponse.kt index 1b006058..592b47c0 100644 --- a/stigg-java-core/src/main/kotlin/io/stigg/models/v1beta/customers/CustomerRetrieveGovernanceResponse.kt +++ b/stigg-java-core/src/main/kotlin/io/stigg/models/v1/events/beta/customers/CustomerRetrieveGovernanceResponse.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.stigg.models.v1beta.customers +package io.stigg.models.v1.events.beta.customers import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter diff --git a/stigg-java-core/src/main/kotlin/io/stigg/models/v1/events/dataexport/destinations/DestinationUpdateParams.kt b/stigg-java-core/src/main/kotlin/io/stigg/models/v1/events/dataexport/destinations/DestinationUpdateSelectionParams.kt similarity index 94% rename from stigg-java-core/src/main/kotlin/io/stigg/models/v1/events/dataexport/destinations/DestinationUpdateParams.kt rename to stigg-java-core/src/main/kotlin/io/stigg/models/v1/events/dataexport/destinations/DestinationUpdateSelectionParams.kt index 9cc0ca49..40c451ef 100644 --- a/stigg-java-core/src/main/kotlin/io/stigg/models/v1/events/dataexport/destinations/DestinationUpdateParams.kt +++ b/stigg-java-core/src/main/kotlin/io/stigg/models/v1/events/dataexport/destinations/DestinationUpdateSelectionParams.kt @@ -26,7 +26,7 @@ import kotlin.jvm.optionals.getOrNull * Update a destination's entity selection. Pushes the new enabled_models to the provider first, * then persists the selection. Applies on the next scheduled transfer. */ -class DestinationUpdateParams +class DestinationUpdateSelectionParams private constructor( private val destinationId: String?, private val xAccountId: String?, @@ -83,7 +83,8 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [DestinationUpdateParams]. + * Returns a mutable builder for constructing an instance of + * [DestinationUpdateSelectionParams]. * * The following fields are required: * ```java @@ -94,7 +95,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [DestinationUpdateParams]. */ + /** A builder for [DestinationUpdateSelectionParams]. */ class Builder internal constructor() { private var destinationId: String? = null @@ -105,14 +106,16 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(destinationUpdateParams: DestinationUpdateParams) = apply { - destinationId = destinationUpdateParams.destinationId - xAccountId = destinationUpdateParams.xAccountId - xEnvironmentId = destinationUpdateParams.xEnvironmentId - body = destinationUpdateParams.body.toBuilder() - additionalHeaders = destinationUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = destinationUpdateParams.additionalQueryParams.toBuilder() - } + internal fun from(destinationUpdateSelectionParams: DestinationUpdateSelectionParams) = + apply { + destinationId = destinationUpdateSelectionParams.destinationId + xAccountId = destinationUpdateSelectionParams.xAccountId + xEnvironmentId = destinationUpdateSelectionParams.xEnvironmentId + body = destinationUpdateSelectionParams.body.toBuilder() + additionalHeaders = destinationUpdateSelectionParams.additionalHeaders.toBuilder() + additionalQueryParams = + destinationUpdateSelectionParams.additionalQueryParams.toBuilder() + } fun destinationId(destinationId: String?) = apply { this.destinationId = destinationId } @@ -293,7 +296,7 @@ private constructor( } /** - * Returns an immutable instance of [DestinationUpdateParams]. + * Returns an immutable instance of [DestinationUpdateSelectionParams]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -305,8 +308,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): DestinationUpdateParams = - DestinationUpdateParams( + fun build(): DestinationUpdateSelectionParams = + DestinationUpdateSelectionParams( destinationId, xAccountId, xEnvironmentId, @@ -574,7 +577,7 @@ private constructor( return true } - return other is DestinationUpdateParams && + return other is DestinationUpdateSelectionParams && destinationId == other.destinationId && xAccountId == other.xAccountId && xEnvironmentId == other.xEnvironmentId && @@ -594,5 +597,5 @@ private constructor( ) override fun toString() = - "DestinationUpdateParams{destinationId=$destinationId, xAccountId=$xAccountId, xEnvironmentId=$xEnvironmentId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "DestinationUpdateSelectionParams{destinationId=$destinationId, xAccountId=$xAccountId, xEnvironmentId=$xEnvironmentId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/stigg-java-core/src/main/kotlin/io/stigg/models/v1/events/dataexport/destinations/DestinationUpdateResponse.kt b/stigg-java-core/src/main/kotlin/io/stigg/models/v1/events/dataexport/destinations/DestinationUpdateSelectionResponse.kt similarity index 98% rename from stigg-java-core/src/main/kotlin/io/stigg/models/v1/events/dataexport/destinations/DestinationUpdateResponse.kt rename to stigg-java-core/src/main/kotlin/io/stigg/models/v1/events/dataexport/destinations/DestinationUpdateSelectionResponse.kt index 3c5aac41..dc1a38e0 100644 --- a/stigg-java-core/src/main/kotlin/io/stigg/models/v1/events/dataexport/destinations/DestinationUpdateResponse.kt +++ b/stigg-java-core/src/main/kotlin/io/stigg/models/v1/events/dataexport/destinations/DestinationUpdateSelectionResponse.kt @@ -20,7 +20,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** Response object */ -class DestinationUpdateResponse +class DestinationUpdateSelectionResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField, @@ -62,7 +62,8 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [DestinationUpdateResponse]. + * Returns a mutable builder for constructing an instance of + * [DestinationUpdateSelectionResponse]. * * The following fields are required: * ```java @@ -72,17 +73,19 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [DestinationUpdateResponse]. */ + /** A builder for [DestinationUpdateSelectionResponse]. */ class Builder internal constructor() { private var data: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(destinationUpdateResponse: DestinationUpdateResponse) = apply { - data = destinationUpdateResponse.data - additionalProperties = destinationUpdateResponse.additionalProperties.toMutableMap() - } + internal fun from(destinationUpdateSelectionResponse: DestinationUpdateSelectionResponse) = + apply { + data = destinationUpdateSelectionResponse.data + additionalProperties = + destinationUpdateSelectionResponse.additionalProperties.toMutableMap() + } /** Current destinations under the DATA_EXPORT integration. */ fun data(data: Data) = data(JsonField.of(data)) @@ -115,7 +118,7 @@ private constructor( } /** - * Returns an immutable instance of [DestinationUpdateResponse]. + * Returns an immutable instance of [DestinationUpdateSelectionResponse]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -126,8 +129,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): DestinationUpdateResponse = - DestinationUpdateResponse( + fun build(): DestinationUpdateSelectionResponse = + DestinationUpdateSelectionResponse( checkRequired("data", data), additionalProperties.toMutableMap(), ) @@ -143,7 +146,7 @@ private constructor( * @throws StiggInvalidDataException if any value type in this object doesn't match its expected * type. */ - fun validate(): DestinationUpdateResponse = apply { + fun validate(): DestinationUpdateSelectionResponse = apply { if (validated) { return@apply } @@ -1207,7 +1210,7 @@ private constructor( return true } - return other is DestinationUpdateResponse && + return other is DestinationUpdateSelectionResponse && data == other.data && additionalProperties == other.additionalProperties } @@ -1217,5 +1220,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "DestinationUpdateResponse{data=$data, additionalProperties=$additionalProperties}" + "DestinationUpdateSelectionResponse{data=$data, additionalProperties=$additionalProperties}" } diff --git a/stigg-java-core/src/main/kotlin/io/stigg/models/v1/plans/PlanUpdateParams.kt b/stigg-java-core/src/main/kotlin/io/stigg/models/v1/plans/PlanUpdateParams.kt index 19b1b13e..1b0e52d9 100644 --- a/stigg-java-core/src/main/kotlin/io/stigg/models/v1/plans/PlanUpdateParams.kt +++ b/stigg-java-core/src/main/kotlin/io/stigg/models/v1/plans/PlanUpdateParams.kt @@ -3150,9 +3150,10 @@ private constructor( private val billingModel: JsonField, private val pricePeriods: JsonField>, private val billingCadence: JsonField, + private val creditEntitlement: JsonField, + private val currencyId: JsonField, private val entitlement: JsonField, private val featureId: JsonField, - private val topUpCustomCurrencyId: JsonField, private val additionalProperties: MutableMap, ) { @@ -3167,22 +3168,26 @@ private constructor( @JsonProperty("billingCadence") @ExcludeMissing billingCadence: JsonField = JsonMissing.of(), + @JsonProperty("creditEntitlement") + @ExcludeMissing + creditEntitlement: JsonField = JsonMissing.of(), + @JsonProperty("currencyId") + @ExcludeMissing + currencyId: JsonField = JsonMissing.of(), @JsonProperty("entitlement") @ExcludeMissing entitlement: JsonField = JsonMissing.of(), @JsonProperty("featureId") @ExcludeMissing featureId: JsonField = JsonMissing.of(), - @JsonProperty("topUpCustomCurrencyId") - @ExcludeMissing - topUpCustomCurrencyId: JsonField = JsonMissing.of(), ) : this( billingModel, pricePeriods, billingCadence, + creditEntitlement, + currencyId, entitlement, featureId, - topUpCustomCurrencyId, mutableMapOf(), ) @@ -3214,29 +3219,38 @@ private constructor( billingCadence.getOptional("billingCadence") /** - * Entitlement configuration for the overage feature + * Credit entitlement to grant when a credit overage targets a currency not yet granted + * on the plan * * @throws StiggInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun entitlement(): Optional = entitlement.getOptional("entitlement") + fun creditEntitlement(): Optional = + creditEntitlement.getOptional("creditEntitlement") /** - * The feature ID for overage pricing + * The refId of the custom currency this credit overage applies to * * @throws StiggInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun featureId(): Optional = featureId.getOptional("featureId") + fun currencyId(): Optional = currencyId.getOptional("currencyId") /** - * Custom currency ID for overage top-up + * Entitlement configuration for the overage feature * * @throws StiggInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun topUpCustomCurrencyId(): Optional = - topUpCustomCurrencyId.getOptional("topUpCustomCurrencyId") + fun entitlement(): Optional = entitlement.getOptional("entitlement") + + /** + * The feature ID for overage pricing + * + * @throws StiggInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun featureId(): Optional = featureId.getOptional("featureId") /** * Returns the raw JSON value of [billingModel]. @@ -3268,6 +3282,26 @@ private constructor( @ExcludeMissing fun _billingCadence(): JsonField = billingCadence + /** + * Returns the raw JSON value of [creditEntitlement]. + * + * Unlike [creditEntitlement], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("creditEntitlement") + @ExcludeMissing + fun _creditEntitlement(): JsonField = creditEntitlement + + /** + * Returns the raw JSON value of [currencyId]. + * + * Unlike [currencyId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currencyId") + @ExcludeMissing + fun _currencyId(): JsonField = currencyId + /** * Returns the raw JSON value of [entitlement]. * @@ -3288,16 +3322,6 @@ private constructor( @ExcludeMissing fun _featureId(): JsonField = featureId - /** - * Returns the raw JSON value of [topUpCustomCurrencyId]. - * - * Unlike [topUpCustomCurrencyId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("topUpCustomCurrencyId") - @ExcludeMissing - fun _topUpCustomCurrencyId(): JsonField = topUpCustomCurrencyId - @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -3330,9 +3354,10 @@ private constructor( private var billingModel: JsonField? = null private var pricePeriods: JsonField>? = null private var billingCadence: JsonField = JsonMissing.of() + private var creditEntitlement: JsonField = JsonMissing.of() + private var currencyId: JsonField = JsonMissing.of() private var entitlement: JsonField = JsonMissing.of() private var featureId: JsonField = JsonMissing.of() - private var topUpCustomCurrencyId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -3340,9 +3365,10 @@ private constructor( billingModel = overagePricingModel.billingModel pricePeriods = overagePricingModel.pricePeriods.map { it.toMutableList() } billingCadence = overagePricingModel.billingCadence + creditEntitlement = overagePricingModel.creditEntitlement + currencyId = overagePricingModel.currencyId entitlement = overagePricingModel.entitlement featureId = overagePricingModel.featureId - topUpCustomCurrencyId = overagePricingModel.topUpCustomCurrencyId additionalProperties = overagePricingModel.additionalProperties.toMutableMap() } @@ -3403,6 +3429,38 @@ private constructor( this.billingCadence = billingCadence } + /** + * Credit entitlement to grant when a credit overage targets a currency not yet + * granted on the plan + */ + fun creditEntitlement(creditEntitlement: CreditEntitlement) = + creditEntitlement(JsonField.of(creditEntitlement)) + + /** + * Sets [Builder.creditEntitlement] to an arbitrary JSON value. + * + * You should usually call [Builder.creditEntitlement] with a well-typed + * [CreditEntitlement] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun creditEntitlement(creditEntitlement: JsonField) = apply { + this.creditEntitlement = creditEntitlement + } + + /** The refId of the custom currency this credit overage applies to */ + fun currencyId(currencyId: String) = currencyId(JsonField.of(currencyId)) + + /** + * Sets [Builder.currencyId] to an arbitrary JSON value. + * + * You should usually call [Builder.currencyId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun currencyId(currencyId: JsonField) = apply { + this.currencyId = currencyId + } + /** Entitlement configuration for the overage feature */ fun entitlement(entitlement: Entitlement) = entitlement(JsonField.of(entitlement)) @@ -3429,21 +3487,6 @@ private constructor( */ fun featureId(featureId: JsonField) = apply { this.featureId = featureId } - /** Custom currency ID for overage top-up */ - fun topUpCustomCurrencyId(topUpCustomCurrencyId: String) = - topUpCustomCurrencyId(JsonField.of(topUpCustomCurrencyId)) - - /** - * Sets [Builder.topUpCustomCurrencyId] to an arbitrary JSON value. - * - * You should usually call [Builder.topUpCustomCurrencyId] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun topUpCustomCurrencyId(topUpCustomCurrencyId: JsonField) = apply { - this.topUpCustomCurrencyId = topUpCustomCurrencyId - } - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -3484,9 +3527,10 @@ private constructor( checkRequired("billingModel", billingModel), checkRequired("pricePeriods", pricePeriods).map { it.toImmutable() }, billingCadence, + creditEntitlement, + currencyId, entitlement, featureId, - topUpCustomCurrencyId, additionalProperties.toMutableMap(), ) } @@ -3511,9 +3555,10 @@ private constructor( billingModel().validate() pricePeriods().forEach { it.validate() } billingCadence().ifPresent { it.validate() } + creditEntitlement().ifPresent { it.validate() } + currencyId() entitlement().ifPresent { it.validate() } featureId() - topUpCustomCurrencyId() validated = true } @@ -3536,9 +3581,10 @@ private constructor( (billingModel.asKnown().getOrNull()?.validity() ?: 0) + (pricePeriods.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (billingCadence.asKnown().getOrNull()?.validity() ?: 0) + + (creditEntitlement.asKnown().getOrNull()?.validity() ?: 0) + + (if (currencyId.asKnown().isPresent) 1 else 0) + (entitlement.asKnown().getOrNull()?.validity() ?: 0) + - (if (featureId.asKnown().isPresent) 1 else 0) + - (if (topUpCustomCurrencyId.asKnown().isPresent) 1 else 0) + (if (featureId.asKnown().isPresent) 1 else 0) /** The billing model for overages */ class BillingModel @@ -8309,6 +8355,425 @@ private constructor( override fun toString() = value.toString() } + /** + * Credit entitlement to grant when a credit overage targets a currency not yet granted + * on the plan + */ + class CreditEntitlement + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val cadence: JsonField, + private val customCurrencyId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("customCurrencyId") + @ExcludeMissing + customCurrencyId: JsonField = JsonMissing.of(), + ) : this(amount, cadence, customCurrencyId, mutableMapOf()) + + /** + * The base credit balance granted per cadence + * + * @throws StiggInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun amount(): Double = amount.getRequired("amount") + + /** + * The credit grant cadence (MONTH or YEAR) + * + * @throws StiggInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The refId of the custom currency to grant + * + * @throws StiggInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun customCurrencyId(): String = customCurrencyId.getRequired("customCurrencyId") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [customCurrencyId]. + * + * Unlike [customCurrencyId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("customCurrencyId") + @ExcludeMissing + fun _customCurrencyId(): JsonField = customCurrencyId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CreditEntitlement]. + * + * The following fields are required: + * ```java + * .amount() + * .cadence() + * .customCurrencyId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CreditEntitlement]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var cadence: JsonField? = null + private var customCurrencyId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(creditEntitlement: CreditEntitlement) = apply { + amount = creditEntitlement.amount + cadence = creditEntitlement.cadence + customCurrencyId = creditEntitlement.customCurrencyId + additionalProperties = creditEntitlement.additionalProperties.toMutableMap() + } + + /** The base credit balance granted per cadence */ + fun amount(amount: Double) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The credit grant cadence (MONTH or YEAR) */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The refId of the custom currency to grant */ + fun customCurrencyId(customCurrencyId: String) = + customCurrencyId(JsonField.of(customCurrencyId)) + + /** + * Sets [Builder.customCurrencyId] to an arbitrary JSON value. + * + * You should usually call [Builder.customCurrencyId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun customCurrencyId(customCurrencyId: JsonField) = apply { + this.customCurrencyId = customCurrencyId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CreditEntitlement]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .cadence() + * .customCurrencyId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CreditEntitlement = + CreditEntitlement( + checkRequired("amount", amount), + checkRequired("cadence", cadence), + checkRequired("customCurrencyId", customCurrencyId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws StiggInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): CreditEntitlement = apply { + if (validated) { + return@apply + } + + amount() + cadence().validate() + customCurrencyId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: StiggInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (customCurrencyId.asKnown().isPresent) 1 else 0) + + /** The credit grant cadence (MONTH or YEAR) */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val MONTH = of("MONTH") + + @JvmField val YEAR = of("YEAR") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + MONTH, + YEAR, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MONTH, + YEAR, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MONTH -> Value.MONTH + YEAR -> Value.YEAR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws StiggInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + MONTH -> Known.MONTH + YEAR -> Known.YEAR + else -> throw StiggInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws StiggInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + StiggInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws StiggInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: StiggInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CreditEntitlement && + amount == other.amount && + cadence == other.cadence && + customCurrencyId == other.customCurrencyId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, cadence, customCurrencyId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CreditEntitlement{amount=$amount, cadence=$cadence, customCurrencyId=$customCurrencyId, additionalProperties=$additionalProperties}" + } + /** Entitlement configuration for the overage feature */ class Entitlement @JsonCreator(mode = JsonCreator.Mode.DISABLED) @@ -10070,9 +10535,10 @@ private constructor( billingModel == other.billingModel && pricePeriods == other.pricePeriods && billingCadence == other.billingCadence && + creditEntitlement == other.creditEntitlement && + currencyId == other.currencyId && entitlement == other.entitlement && featureId == other.featureId && - topUpCustomCurrencyId == other.topUpCustomCurrencyId && additionalProperties == other.additionalProperties } @@ -10081,9 +10547,10 @@ private constructor( billingModel, pricePeriods, billingCadence, + creditEntitlement, + currencyId, entitlement, featureId, - topUpCustomCurrencyId, additionalProperties, ) } @@ -10091,7 +10558,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "OveragePricingModel{billingModel=$billingModel, pricePeriods=$pricePeriods, billingCadence=$billingCadence, entitlement=$entitlement, featureId=$featureId, topUpCustomCurrencyId=$topUpCustomCurrencyId, additionalProperties=$additionalProperties}" + "OveragePricingModel{billingModel=$billingModel, pricePeriods=$pricePeriods, billingCadence=$billingCadence, creditEntitlement=$creditEntitlement, currencyId=$currencyId, entitlement=$entitlement, featureId=$featureId, additionalProperties=$additionalProperties}" } /** A pricing model configuration with billing details and price periods. */ diff --git a/stigg-java-core/src/main/kotlin/io/stigg/models/v1/usage/UsageEstimateCostParams.kt b/stigg-java-core/src/main/kotlin/io/stigg/models/v1/usage/UsageEstimateParams.kt similarity index 97% rename from stigg-java-core/src/main/kotlin/io/stigg/models/v1/usage/UsageEstimateCostParams.kt rename to stigg-java-core/src/main/kotlin/io/stigg/models/v1/usage/UsageEstimateParams.kt index 494564fc..bec979cb 100644 --- a/stigg-java-core/src/main/kotlin/io/stigg/models/v1/usage/UsageEstimateCostParams.kt +++ b/stigg-java-core/src/main/kotlin/io/stigg/models/v1/usage/UsageEstimateParams.kt @@ -26,7 +26,7 @@ import kotlin.jvm.optionals.getOrNull * Estimates the credit cost of a usage report without recording it. Returns the estimated cost per * credit currency, the current balance, and the balance after the estimated consumption. */ -class UsageEstimateCostParams +class UsageEstimateParams private constructor( private val xAccountId: String?, private val xEnvironmentId: String?, @@ -142,7 +142,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [UsageEstimateCostParams]. + * Returns a mutable builder for constructing an instance of [UsageEstimateParams]. * * The following fields are required: * ```java @@ -154,7 +154,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [UsageEstimateCostParams]. */ + /** A builder for [UsageEstimateParams]. */ class Builder internal constructor() { private var xAccountId: String? = null @@ -164,12 +164,12 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(usageEstimateCostParams: UsageEstimateCostParams) = apply { - xAccountId = usageEstimateCostParams.xAccountId - xEnvironmentId = usageEstimateCostParams.xEnvironmentId - body = usageEstimateCostParams.body.toBuilder() - additionalHeaders = usageEstimateCostParams.additionalHeaders.toBuilder() - additionalQueryParams = usageEstimateCostParams.additionalQueryParams.toBuilder() + internal fun from(usageEstimateParams: UsageEstimateParams) = apply { + xAccountId = usageEstimateParams.xAccountId + xEnvironmentId = usageEstimateParams.xEnvironmentId + body = usageEstimateParams.body.toBuilder() + additionalHeaders = usageEstimateParams.additionalHeaders.toBuilder() + additionalQueryParams = usageEstimateParams.additionalQueryParams.toBuilder() } fun xAccountId(xAccountId: String?) = apply { this.xAccountId = xAccountId } @@ -393,7 +393,7 @@ private constructor( } /** - * Returns an immutable instance of [UsageEstimateCostParams]. + * Returns an immutable instance of [UsageEstimateParams]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -406,8 +406,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): UsageEstimateCostParams = - UsageEstimateCostParams( + fun build(): UsageEstimateParams = + UsageEstimateParams( xAccountId, xEnvironmentId, body.build(), @@ -1077,7 +1077,7 @@ private constructor( return true } - return other is UsageEstimateCostParams && + return other is UsageEstimateParams && xAccountId == other.xAccountId && xEnvironmentId == other.xEnvironmentId && body == other.body && @@ -1089,5 +1089,5 @@ private constructor( Objects.hash(xAccountId, xEnvironmentId, body, additionalHeaders, additionalQueryParams) override fun toString() = - "UsageEstimateCostParams{xAccountId=$xAccountId, xEnvironmentId=$xEnvironmentId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "UsageEstimateParams{xAccountId=$xAccountId, xEnvironmentId=$xEnvironmentId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/stigg-java-core/src/main/kotlin/io/stigg/models/v1/usage/UsageEstimateCostResponse.kt b/stigg-java-core/src/main/kotlin/io/stigg/models/v1/usage/UsageEstimateResponse.kt similarity index 98% rename from stigg-java-core/src/main/kotlin/io/stigg/models/v1/usage/UsageEstimateCostResponse.kt rename to stigg-java-core/src/main/kotlin/io/stigg/models/v1/usage/UsageEstimateResponse.kt index 4599c21f..7edf7237 100644 --- a/stigg-java-core/src/main/kotlin/io/stigg/models/v1/usage/UsageEstimateCostResponse.kt +++ b/stigg-java-core/src/main/kotlin/io/stigg/models/v1/usage/UsageEstimateResponse.kt @@ -21,7 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** Response object */ -class UsageEstimateCostResponse +class UsageEstimateResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField, @@ -63,7 +63,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [UsageEstimateCostResponse]. + * Returns a mutable builder for constructing an instance of [UsageEstimateResponse]. * * The following fields are required: * ```java @@ -73,16 +73,16 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [UsageEstimateCostResponse]. */ + /** A builder for [UsageEstimateResponse]. */ class Builder internal constructor() { private var data: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(usageEstimateCostResponse: UsageEstimateCostResponse) = apply { - data = usageEstimateCostResponse.data - additionalProperties = usageEstimateCostResponse.additionalProperties.toMutableMap() + internal fun from(usageEstimateResponse: UsageEstimateResponse) = apply { + data = usageEstimateResponse.data + additionalProperties = usageEstimateResponse.additionalProperties.toMutableMap() } /** Estimated credit cost, current balance and balance after */ @@ -116,7 +116,7 @@ private constructor( } /** - * Returns an immutable instance of [UsageEstimateCostResponse]. + * Returns an immutable instance of [UsageEstimateResponse]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -127,11 +127,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): UsageEstimateCostResponse = - UsageEstimateCostResponse( - checkRequired("data", data), - additionalProperties.toMutableMap(), - ) + fun build(): UsageEstimateResponse = + UsageEstimateResponse(checkRequired("data", data), additionalProperties.toMutableMap()) } private var validated: Boolean = false @@ -144,7 +141,7 @@ private constructor( * @throws StiggInvalidDataException if any value type in this object doesn't match its expected * type. */ - fun validate(): UsageEstimateCostResponse = apply { + fun validate(): UsageEstimateResponse = apply { if (validated) { return@apply } @@ -1423,7 +1420,7 @@ private constructor( return true } - return other is UsageEstimateCostResponse && + return other is UsageEstimateResponse && data == other.data && additionalProperties == other.additionalProperties } @@ -1433,5 +1430,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "UsageEstimateCostResponse{data=$data, additionalProperties=$additionalProperties}" + "UsageEstimateResponse{data=$data, additionalProperties=$additionalProperties}" } diff --git a/stigg-java-core/src/main/kotlin/io/stigg/services/async/v1/EventServiceAsync.kt b/stigg-java-core/src/main/kotlin/io/stigg/services/async/v1/EventServiceAsync.kt index b246499d..c4d975db 100644 --- a/stigg-java-core/src/main/kotlin/io/stigg/services/async/v1/EventServiceAsync.kt +++ b/stigg-java-core/src/main/kotlin/io/stigg/services/async/v1/EventServiceAsync.kt @@ -5,10 +5,11 @@ package io.stigg.services.async.v1 import io.stigg.core.ClientOptions import io.stigg.core.RequestOptions import io.stigg.core.http.HttpResponseFor -import io.stigg.models.v1.events.EventEstimateCostParams -import io.stigg.models.v1.events.EventEstimateCostResponse +import io.stigg.models.v1.events.EventEstimateParams +import io.stigg.models.v1.events.EventEstimateResponse import io.stigg.models.v1.events.EventReportParams import io.stigg.models.v1.events.EventReportResponse +import io.stigg.services.async.v1.events.BetaServiceAsync import io.stigg.services.async.v1.events.DataExportServiceAsync import java.util.concurrent.CompletableFuture import java.util.function.Consumer @@ -30,19 +31,20 @@ interface EventServiceAsync { fun dataExport(): DataExportServiceAsync + fun beta(): BetaServiceAsync + /** * Estimates the credit cost of a usage event without ingesting it. Returns the estimated cost * per credit currency, the current balance, and the balance after the estimated consumption. */ - fun estimateCost( - params: EventEstimateCostParams - ): CompletableFuture = estimateCost(params, RequestOptions.none()) + fun estimate(params: EventEstimateParams): CompletableFuture = + estimate(params, RequestOptions.none()) - /** @see estimateCost */ - fun estimateCost( - params: EventEstimateCostParams, + /** @see estimate */ + fun estimate( + params: EventEstimateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * Reports raw usage events for event-based metering. Events are ingested asynchronously and @@ -71,20 +73,22 @@ interface EventServiceAsync { fun dataExport(): DataExportServiceAsync.WithRawResponse + fun beta(): BetaServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /api/v1/events/estimate`, but is otherwise the same - * as [EventServiceAsync.estimateCost]. + * as [EventServiceAsync.estimate]. */ - fun estimateCost( - params: EventEstimateCostParams - ): CompletableFuture> = - estimateCost(params, RequestOptions.none()) - - /** @see estimateCost */ - fun estimateCost( - params: EventEstimateCostParams, + fun estimate( + params: EventEstimateParams + ): CompletableFuture> = + estimate(params, RequestOptions.none()) + + /** @see estimate */ + fun estimate( + params: EventEstimateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture> /** * Returns a raw HTTP response for `post /api/v1/events`, but is otherwise the same as diff --git a/stigg-java-core/src/main/kotlin/io/stigg/services/async/v1/EventServiceAsyncImpl.kt b/stigg-java-core/src/main/kotlin/io/stigg/services/async/v1/EventServiceAsyncImpl.kt index 076f3343..d1090bc4 100644 --- a/stigg-java-core/src/main/kotlin/io/stigg/services/async/v1/EventServiceAsyncImpl.kt +++ b/stigg-java-core/src/main/kotlin/io/stigg/services/async/v1/EventServiceAsyncImpl.kt @@ -15,10 +15,12 @@ import io.stigg.core.http.HttpResponseFor import io.stigg.core.http.json import io.stigg.core.http.parseable import io.stigg.core.prepareAsync -import io.stigg.models.v1.events.EventEstimateCostParams -import io.stigg.models.v1.events.EventEstimateCostResponse +import io.stigg.models.v1.events.EventEstimateParams +import io.stigg.models.v1.events.EventEstimateResponse import io.stigg.models.v1.events.EventReportParams import io.stigg.models.v1.events.EventReportResponse +import io.stigg.services.async.v1.events.BetaServiceAsync +import io.stigg.services.async.v1.events.BetaServiceAsyncImpl import io.stigg.services.async.v1.events.DataExportServiceAsync import io.stigg.services.async.v1.events.DataExportServiceAsyncImpl import java.util.concurrent.CompletableFuture @@ -36,6 +38,8 @@ class EventServiceAsyncImpl internal constructor(private val clientOptions: Clie DataExportServiceAsyncImpl(clientOptions) } + private val beta: BetaServiceAsync by lazy { BetaServiceAsyncImpl(clientOptions) } + override fun withRawResponse(): EventServiceAsync.WithRawResponse = withRawResponse override fun withOptions(modifier: Consumer): EventServiceAsync = @@ -43,12 +47,14 @@ class EventServiceAsyncImpl internal constructor(private val clientOptions: Clie override fun dataExport(): DataExportServiceAsync = dataExport - override fun estimateCost( - params: EventEstimateCostParams, + override fun beta(): BetaServiceAsync = beta + + override fun estimate( + params: EventEstimateParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // post /api/v1/events/estimate - withRawResponse().estimateCost(params, requestOptions).thenApply { it.parse() } + withRawResponse().estimate(params, requestOptions).thenApply { it.parse() } override fun report( params: EventReportParams, @@ -67,6 +73,10 @@ class EventServiceAsyncImpl internal constructor(private val clientOptions: Clie DataExportServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val beta: BetaServiceAsync.WithRawResponse by lazy { + BetaServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + override fun withOptions( modifier: Consumer ): EventServiceAsync.WithRawResponse = @@ -76,13 +86,15 @@ class EventServiceAsyncImpl internal constructor(private val clientOptions: Clie override fun dataExport(): DataExportServiceAsync.WithRawResponse = dataExport - private val estimateCostHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + override fun beta(): BetaServiceAsync.WithRawResponse = beta + + private val estimateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) - override fun estimateCost( - params: EventEstimateCostParams, + override fun estimate( + params: EventEstimateParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -97,7 +109,7 @@ class EventServiceAsyncImpl internal constructor(private val clientOptions: Clie .thenApply { response -> errorHandler.handle(response).parseable { response - .use { estimateCostHandler.handle(it) } + .use { estimateHandler.handle(it) } .also { if (requestOptions.responseValidation!!) { it.validate() diff --git a/stigg-java-core/src/main/kotlin/io/stigg/services/async/v1/UsageServiceAsync.kt b/stigg-java-core/src/main/kotlin/io/stigg/services/async/v1/UsageServiceAsync.kt index b095a013..a201e5b2 100644 --- a/stigg-java-core/src/main/kotlin/io/stigg/services/async/v1/UsageServiceAsync.kt +++ b/stigg-java-core/src/main/kotlin/io/stigg/services/async/v1/UsageServiceAsync.kt @@ -5,8 +5,8 @@ package io.stigg.services.async.v1 import io.stigg.core.ClientOptions import io.stigg.core.RequestOptions import io.stigg.core.http.HttpResponseFor -import io.stigg.models.v1.usage.UsageEstimateCostParams -import io.stigg.models.v1.usage.UsageEstimateCostResponse +import io.stigg.models.v1.usage.UsageEstimateParams +import io.stigg.models.v1.usage.UsageEstimateResponse import io.stigg.models.v1.usage.UsageHistoryParams import io.stigg.models.v1.usage.UsageHistoryResponse import io.stigg.models.v1.usage.UsageReportParams @@ -33,15 +33,14 @@ interface UsageServiceAsync { * Estimates the credit cost of a usage report without recording it. Returns the estimated cost * per credit currency, the current balance, and the balance after the estimated consumption. */ - fun estimateCost( - params: UsageEstimateCostParams - ): CompletableFuture = estimateCost(params, RequestOptions.none()) + fun estimate(params: UsageEstimateParams): CompletableFuture = + estimate(params, RequestOptions.none()) - /** @see estimateCost */ - fun estimateCost( - params: UsageEstimateCostParams, + /** @see estimate */ + fun estimate( + params: UsageEstimateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** Retrieves historical usage data for a customer's metered feature over time. */ fun history( @@ -94,18 +93,18 @@ interface UsageServiceAsync { /** * Returns a raw HTTP response for `post /api/v1/usage/estimate`, but is otherwise the same - * as [UsageServiceAsync.estimateCost]. + * as [UsageServiceAsync.estimate]. */ - fun estimateCost( - params: UsageEstimateCostParams - ): CompletableFuture> = - estimateCost(params, RequestOptions.none()) - - /** @see estimateCost */ - fun estimateCost( - params: UsageEstimateCostParams, + fun estimate( + params: UsageEstimateParams + ): CompletableFuture> = + estimate(params, RequestOptions.none()) + + /** @see estimate */ + fun estimate( + params: UsageEstimateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture> /** * Returns a raw HTTP response for `get /api/v1/usage/{customerId}/history/{featureId}`, but diff --git a/stigg-java-core/src/main/kotlin/io/stigg/services/async/v1/UsageServiceAsyncImpl.kt b/stigg-java-core/src/main/kotlin/io/stigg/services/async/v1/UsageServiceAsyncImpl.kt index 55a1487c..bb4ee9fa 100644 --- a/stigg-java-core/src/main/kotlin/io/stigg/services/async/v1/UsageServiceAsyncImpl.kt +++ b/stigg-java-core/src/main/kotlin/io/stigg/services/async/v1/UsageServiceAsyncImpl.kt @@ -16,8 +16,8 @@ import io.stigg.core.http.HttpResponseFor import io.stigg.core.http.json import io.stigg.core.http.parseable import io.stigg.core.prepareAsync -import io.stigg.models.v1.usage.UsageEstimateCostParams -import io.stigg.models.v1.usage.UsageEstimateCostResponse +import io.stigg.models.v1.usage.UsageEstimateParams +import io.stigg.models.v1.usage.UsageEstimateResponse import io.stigg.models.v1.usage.UsageHistoryParams import io.stigg.models.v1.usage.UsageHistoryResponse import io.stigg.models.v1.usage.UsageReportParams @@ -39,12 +39,12 @@ class UsageServiceAsyncImpl internal constructor(private val clientOptions: Clie override fun withOptions(modifier: Consumer): UsageServiceAsync = UsageServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - override fun estimateCost( - params: UsageEstimateCostParams, + override fun estimate( + params: UsageEstimateParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // post /api/v1/usage/estimate - withRawResponse().estimateCost(params, requestOptions).thenApply { it.parse() } + withRawResponse().estimate(params, requestOptions).thenApply { it.parse() } override fun history( params: UsageHistoryParams, @@ -73,13 +73,13 @@ class UsageServiceAsyncImpl internal constructor(private val clientOptions: Clie clientOptions.toBuilder().apply(modifier::accept).build() ) - private val estimateCostHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val estimateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) - override fun estimateCost( - params: UsageEstimateCostParams, + override fun estimate( + params: UsageEstimateParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -94,7 +94,7 @@ class UsageServiceAsyncImpl internal constructor(private val clientOptions: Clie .thenApply { response -> errorHandler.handle(response).parseable { response - .use { estimateCostHandler.handle(it) } + .use { estimateHandler.handle(it) } .also { if (requestOptions.responseValidation!!) { it.validate() diff --git a/stigg-java-core/src/main/kotlin/io/stigg/services/async/v1/events/BetaServiceAsync.kt b/stigg-java-core/src/main/kotlin/io/stigg/services/async/v1/events/BetaServiceAsync.kt new file mode 100644 index 00000000..15c1b40f --- /dev/null +++ b/stigg-java-core/src/main/kotlin/io/stigg/services/async/v1/events/BetaServiceAsync.kt @@ -0,0 +1,37 @@ +// File generated from our OpenAPI spec by Stainless. + +package io.stigg.services.async.v1.events + +import io.stigg.core.ClientOptions +import io.stigg.services.async.v1.events.beta.CustomerServiceAsync +import java.util.function.Consumer + +interface BetaServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): BetaServiceAsync + + fun customers(): CustomerServiceAsync + + /** A view of [BetaServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): BetaServiceAsync.WithRawResponse + + fun customers(): CustomerServiceAsync.WithRawResponse + } +} diff --git a/stigg-java-core/src/main/kotlin/io/stigg/services/async/v1/events/BetaServiceAsyncImpl.kt b/stigg-java-core/src/main/kotlin/io/stigg/services/async/v1/events/BetaServiceAsyncImpl.kt new file mode 100644 index 00000000..e964b922 --- /dev/null +++ b/stigg-java-core/src/main/kotlin/io/stigg/services/async/v1/events/BetaServiceAsyncImpl.kt @@ -0,0 +1,42 @@ +// File generated from our OpenAPI spec by Stainless. + +package io.stigg.services.async.v1.events + +import io.stigg.core.ClientOptions +import io.stigg.services.async.v1.events.beta.CustomerServiceAsync +import io.stigg.services.async.v1.events.beta.CustomerServiceAsyncImpl +import java.util.function.Consumer + +class BetaServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + BetaServiceAsync { + + private val withRawResponse: BetaServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val customers: CustomerServiceAsync by lazy { CustomerServiceAsyncImpl(clientOptions) } + + override fun withRawResponse(): BetaServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): BetaServiceAsync = + BetaServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun customers(): CustomerServiceAsync = customers + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + BetaServiceAsync.WithRawResponse { + + private val customers: CustomerServiceAsync.WithRawResponse by lazy { + CustomerServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer + ): BetaServiceAsync.WithRawResponse = + BetaServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun customers(): CustomerServiceAsync.WithRawResponse = customers + } +} diff --git a/stigg-java-core/src/main/kotlin/io/stigg/services/async/v1/events/beta/CustomerServiceAsync.kt b/stigg-java-core/src/main/kotlin/io/stigg/services/async/v1/events/beta/CustomerServiceAsync.kt new file mode 100644 index 00000000..866a44e7 --- /dev/null +++ b/stigg-java-core/src/main/kotlin/io/stigg/services/async/v1/events/beta/CustomerServiceAsync.kt @@ -0,0 +1,127 @@ +// File generated from our OpenAPI spec by Stainless. + +package io.stigg.services.async.v1.events.beta + +import io.stigg.core.ClientOptions +import io.stigg.core.RequestOptions +import io.stigg.core.http.HttpResponseFor +import io.stigg.models.v1.events.beta.customers.CustomerRetrieveGovernanceParams +import io.stigg.models.v1.events.beta.customers.CustomerRetrieveGovernanceResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface CustomerServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CustomerServiceAsync + + /** + * Queries the customer's governance hierarchy tree, returning a cursor-paginated list of nodes + * with their usage configuration (limit, cadence, scope) and current usage, sortable and + * filterable by usage. Each node carries `parentId` so the tree can be rebuilt client-side. + * Usage is read from a periodically-refreshed read model and never gates access. + */ + fun retrieveGovernance(id: String): CompletableFuture = + retrieveGovernance(id, CustomerRetrieveGovernanceParams.none()) + + /** @see retrieveGovernance */ + fun retrieveGovernance( + id: String, + params: CustomerRetrieveGovernanceParams = CustomerRetrieveGovernanceParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieveGovernance(params.toBuilder().id(id).build(), requestOptions) + + /** @see retrieveGovernance */ + fun retrieveGovernance( + id: String, + params: CustomerRetrieveGovernanceParams = CustomerRetrieveGovernanceParams.none(), + ): CompletableFuture = + retrieveGovernance(id, params, RequestOptions.none()) + + /** @see retrieveGovernance */ + fun retrieveGovernance( + params: CustomerRetrieveGovernanceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see retrieveGovernance */ + fun retrieveGovernance( + params: CustomerRetrieveGovernanceParams + ): CompletableFuture = + retrieveGovernance(params, RequestOptions.none()) + + /** @see retrieveGovernance */ + fun retrieveGovernance( + id: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieveGovernance(id, CustomerRetrieveGovernanceParams.none(), requestOptions) + + /** + * A view of [CustomerServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): CustomerServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1-beta/customers/{id}/governance`, but is + * otherwise the same as [CustomerServiceAsync.retrieveGovernance]. + */ + fun retrieveGovernance( + id: String + ): CompletableFuture> = + retrieveGovernance(id, CustomerRetrieveGovernanceParams.none()) + + /** @see retrieveGovernance */ + fun retrieveGovernance( + id: String, + params: CustomerRetrieveGovernanceParams = CustomerRetrieveGovernanceParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieveGovernance(params.toBuilder().id(id).build(), requestOptions) + + /** @see retrieveGovernance */ + fun retrieveGovernance( + id: String, + params: CustomerRetrieveGovernanceParams = CustomerRetrieveGovernanceParams.none(), + ): CompletableFuture> = + retrieveGovernance(id, params, RequestOptions.none()) + + /** @see retrieveGovernance */ + fun retrieveGovernance( + params: CustomerRetrieveGovernanceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see retrieveGovernance */ + fun retrieveGovernance( + params: CustomerRetrieveGovernanceParams + ): CompletableFuture> = + retrieveGovernance(params, RequestOptions.none()) + + /** @see retrieveGovernance */ + fun retrieveGovernance( + id: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieveGovernance(id, CustomerRetrieveGovernanceParams.none(), requestOptions) + } +} diff --git a/stigg-java-core/src/main/kotlin/io/stigg/services/async/v1/events/beta/CustomerServiceAsyncImpl.kt b/stigg-java-core/src/main/kotlin/io/stigg/services/async/v1/events/beta/CustomerServiceAsyncImpl.kt new file mode 100644 index 00000000..50ef86aa --- /dev/null +++ b/stigg-java-core/src/main/kotlin/io/stigg/services/async/v1/events/beta/CustomerServiceAsyncImpl.kt @@ -0,0 +1,95 @@ +// File generated from our OpenAPI spec by Stainless. + +package io.stigg.services.async.v1.events.beta + +import io.stigg.core.ClientOptions +import io.stigg.core.RequestOptions +import io.stigg.core.checkRequired +import io.stigg.core.handlers.errorBodyHandler +import io.stigg.core.handlers.errorHandler +import io.stigg.core.handlers.jsonHandler +import io.stigg.core.http.HttpMethod +import io.stigg.core.http.HttpRequest +import io.stigg.core.http.HttpResponse +import io.stigg.core.http.HttpResponse.Handler +import io.stigg.core.http.HttpResponseFor +import io.stigg.core.http.parseable +import io.stigg.core.prepareAsync +import io.stigg.models.v1.events.beta.customers.CustomerRetrieveGovernanceParams +import io.stigg.models.v1.events.beta.customers.CustomerRetrieveGovernanceResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class CustomerServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + CustomerServiceAsync { + + private val withRawResponse: CustomerServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): CustomerServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): CustomerServiceAsync = + CustomerServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieveGovernance( + params: CustomerRetrieveGovernanceParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/v1-beta/customers/{id}/governance + withRawResponse().retrieveGovernance(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CustomerServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): CustomerServiceAsync.WithRawResponse = + CustomerServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveGovernanceHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieveGovernance( + params: CustomerRetrieveGovernanceParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("id", params.id().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1-beta", + "customers", + params._pathParam(0), + "governance", + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveGovernanceHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/stigg-java-core/src/main/kotlin/io/stigg/services/async/v1/events/dataexport/DestinationServiceAsync.kt b/stigg-java-core/src/main/kotlin/io/stigg/services/async/v1/events/dataexport/DestinationServiceAsync.kt index 9e44c15a..e24d552b 100644 --- a/stigg-java-core/src/main/kotlin/io/stigg/services/async/v1/events/dataexport/DestinationServiceAsync.kt +++ b/stigg-java-core/src/main/kotlin/io/stigg/services/async/v1/events/dataexport/DestinationServiceAsync.kt @@ -9,8 +9,8 @@ import io.stigg.models.v1.events.dataexport.destinations.DestinationCreateParams import io.stigg.models.v1.events.dataexport.destinations.DestinationCreateResponse import io.stigg.models.v1.events.dataexport.destinations.DestinationDeleteParams import io.stigg.models.v1.events.dataexport.destinations.DestinationDeleteResponse -import io.stigg.models.v1.events.dataexport.destinations.DestinationUpdateParams -import io.stigg.models.v1.events.dataexport.destinations.DestinationUpdateResponse +import io.stigg.models.v1.events.dataexport.destinations.DestinationUpdateSelectionParams +import io.stigg.models.v1.events.dataexport.destinations.DestinationUpdateSelectionResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer @@ -41,34 +41,6 @@ interface DestinationServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** - * Update a destination's entity selection. Pushes the new enabled_models to the provider first, - * then persists the selection. Applies on the next scheduled transfer. - */ - fun update( - destinationId: String, - params: DestinationUpdateParams, - ): CompletableFuture = - update(destinationId, params, RequestOptions.none()) - - /** @see update */ - fun update( - destinationId: String, - params: DestinationUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - update(params.toBuilder().destinationId(destinationId).build(), requestOptions) - - /** @see update */ - fun update(params: DestinationUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) - - /** @see update */ - fun update( - params: DestinationUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - /** * Disconnect a destination: stops the provider sync (deletes the provider destination) and * removes it from the DATA_EXPORT integration. Non-destructive — the warehouse table is left @@ -109,6 +81,36 @@ interface DestinationServiceAsync { ): CompletableFuture = delete(destinationId, DestinationDeleteParams.none(), requestOptions) + /** + * Update a destination's entity selection. Pushes the new enabled_models to the provider first, + * then persists the selection. Applies on the next scheduled transfer. + */ + fun updateSelection( + destinationId: String, + params: DestinationUpdateSelectionParams, + ): CompletableFuture = + updateSelection(destinationId, params, RequestOptions.none()) + + /** @see updateSelection */ + fun updateSelection( + destinationId: String, + params: DestinationUpdateSelectionParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + updateSelection(params.toBuilder().destinationId(destinationId).build(), requestOptions) + + /** @see updateSelection */ + fun updateSelection( + params: DestinationUpdateSelectionParams + ): CompletableFuture = + updateSelection(params, RequestOptions.none()) + + /** @see updateSelection */ + fun updateSelection( + params: DestinationUpdateSelectionParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + /** * A view of [DestinationServiceAsync] that provides access to raw HTTP responses for each * method. @@ -139,36 +141,6 @@ interface DestinationServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** - * Returns a raw HTTP response for `patch /api/v1/data-export/destinations/{destinationId}`, - * but is otherwise the same as [DestinationServiceAsync.update]. - */ - fun update( - destinationId: String, - params: DestinationUpdateParams, - ): CompletableFuture> = - update(destinationId, params, RequestOptions.none()) - - /** @see update */ - fun update( - destinationId: String, - params: DestinationUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - update(params.toBuilder().destinationId(destinationId).build(), requestOptions) - - /** @see update */ - fun update( - params: DestinationUpdateParams - ): CompletableFuture> = - update(params, RequestOptions.none()) - - /** @see update */ - fun update( - params: DestinationUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - /** * Returns a raw HTTP response for `delete * /api/v1/data-export/destinations/{destinationId}`, but is otherwise the same as @@ -212,5 +184,35 @@ interface DestinationServiceAsync { requestOptions: RequestOptions, ): CompletableFuture> = delete(destinationId, DestinationDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `patch /api/v1/data-export/destinations/{destinationId}`, + * but is otherwise the same as [DestinationServiceAsync.updateSelection]. + */ + fun updateSelection( + destinationId: String, + params: DestinationUpdateSelectionParams, + ): CompletableFuture> = + updateSelection(destinationId, params, RequestOptions.none()) + + /** @see updateSelection */ + fun updateSelection( + destinationId: String, + params: DestinationUpdateSelectionParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + updateSelection(params.toBuilder().destinationId(destinationId).build(), requestOptions) + + /** @see updateSelection */ + fun updateSelection( + params: DestinationUpdateSelectionParams + ): CompletableFuture> = + updateSelection(params, RequestOptions.none()) + + /** @see updateSelection */ + fun updateSelection( + params: DestinationUpdateSelectionParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> } } diff --git a/stigg-java-core/src/main/kotlin/io/stigg/services/async/v1/events/dataexport/DestinationServiceAsyncImpl.kt b/stigg-java-core/src/main/kotlin/io/stigg/services/async/v1/events/dataexport/DestinationServiceAsyncImpl.kt index 318a0ee1..ac1f6f06 100644 --- a/stigg-java-core/src/main/kotlin/io/stigg/services/async/v1/events/dataexport/DestinationServiceAsyncImpl.kt +++ b/stigg-java-core/src/main/kotlin/io/stigg/services/async/v1/events/dataexport/DestinationServiceAsyncImpl.kt @@ -20,8 +20,8 @@ import io.stigg.models.v1.events.dataexport.destinations.DestinationCreateParams import io.stigg.models.v1.events.dataexport.destinations.DestinationCreateResponse import io.stigg.models.v1.events.dataexport.destinations.DestinationDeleteParams import io.stigg.models.v1.events.dataexport.destinations.DestinationDeleteResponse -import io.stigg.models.v1.events.dataexport.destinations.DestinationUpdateParams -import io.stigg.models.v1.events.dataexport.destinations.DestinationUpdateResponse +import io.stigg.models.v1.events.dataexport.destinations.DestinationUpdateSelectionParams +import io.stigg.models.v1.events.dataexport.destinations.DestinationUpdateSelectionResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull @@ -45,13 +45,6 @@ class DestinationServiceAsyncImpl internal constructor(private val clientOptions // post /api/v1/data-export/destinations withRawResponse().create(params, requestOptions).thenApply { it.parse() } - override fun update( - params: DestinationUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // patch /api/v1/data-export/destinations/{destinationId} - withRawResponse().update(params, requestOptions).thenApply { it.parse() } - override fun delete( params: DestinationDeleteParams, requestOptions: RequestOptions, @@ -59,6 +52,13 @@ class DestinationServiceAsyncImpl internal constructor(private val clientOptions // delete /api/v1/data-export/destinations/{destinationId} withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + override fun updateSelection( + params: DestinationUpdateSelectionParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // patch /api/v1/data-export/destinations/{destinationId} + withRawResponse().updateSelection(params, requestOptions).thenApply { it.parse() } + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : DestinationServiceAsync.WithRawResponse { @@ -103,19 +103,19 @@ class DestinationServiceAsyncImpl internal constructor(private val clientOptions } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper) - override fun update( - params: DestinationUpdateParams, + override fun delete( + params: DestinationDeleteParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("destinationId", params.destinationId().getOrNull()) val request = HttpRequest.builder() - .method(HttpMethod.PATCH) + .method(HttpMethod.DELETE) .baseUrl(clientOptions.baseUrl()) .addPathSegments( "api", @@ -124,7 +124,7 @@ class DestinationServiceAsyncImpl internal constructor(private val clientOptions "destinations", params._pathParam(0), ) - .body(json(clientOptions.jsonMapper, params._body())) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() .prepareAsync(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) @@ -133,7 +133,7 @@ class DestinationServiceAsyncImpl internal constructor(private val clientOptions .thenApply { response -> errorHandler.handle(response).parseable { response - .use { updateHandler.handle(it) } + .use { deleteHandler.handle(it) } .also { if (requestOptions.responseValidation!!) { it.validate() @@ -143,19 +143,19 @@ class DestinationServiceAsyncImpl internal constructor(private val clientOptions } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val updateSelectionHandler: Handler = + jsonHandler(clientOptions.jsonMapper) - override fun delete( - params: DestinationDeleteParams, + override fun updateSelection( + params: DestinationUpdateSelectionParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("destinationId", params.destinationId().getOrNull()) val request = HttpRequest.builder() - .method(HttpMethod.DELETE) + .method(HttpMethod.PATCH) .baseUrl(clientOptions.baseUrl()) .addPathSegments( "api", @@ -164,7 +164,7 @@ class DestinationServiceAsyncImpl internal constructor(private val clientOptions "destinations", params._pathParam(0), ) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) @@ -173,7 +173,7 @@ class DestinationServiceAsyncImpl internal constructor(private val clientOptions .thenApply { response -> errorHandler.handle(response).parseable { response - .use { deleteHandler.handle(it) } + .use { updateSelectionHandler.handle(it) } .also { if (requestOptions.responseValidation!!) { it.validate() diff --git a/stigg-java-core/src/main/kotlin/io/stigg/services/async/v1beta/CustomerServiceAsync.kt b/stigg-java-core/src/main/kotlin/io/stigg/services/async/v1beta/CustomerServiceAsync.kt index 5acd1f4b..cc76106d 100644 --- a/stigg-java-core/src/main/kotlin/io/stigg/services/async/v1beta/CustomerServiceAsync.kt +++ b/stigg-java-core/src/main/kotlin/io/stigg/services/async/v1beta/CustomerServiceAsync.kt @@ -3,14 +3,9 @@ package io.stigg.services.async.v1beta import io.stigg.core.ClientOptions -import io.stigg.core.RequestOptions -import io.stigg.core.http.HttpResponseFor -import io.stigg.models.v1beta.customers.CustomerRetrieveGovernanceParams -import io.stigg.models.v1beta.customers.CustomerRetrieveGovernanceResponse import io.stigg.services.async.v1beta.customers.AssignmentServiceAsync import io.stigg.services.async.v1beta.customers.EntitlementServiceAsync import io.stigg.services.async.v1beta.customers.EntityServiceAsync -import java.util.concurrent.CompletableFuture import java.util.function.Consumer interface CustomerServiceAsync { @@ -33,49 +28,6 @@ interface CustomerServiceAsync { fun assignments(): AssignmentServiceAsync - /** - * Queries the customer's governance hierarchy tree, returning a cursor-paginated list of nodes - * with their usage configuration (limit, cadence, scope) and current usage, sortable and - * filterable by usage. Each node carries `parentId` so the tree can be rebuilt client-side. - * Usage is read from a periodically-refreshed read model and never gates access. - */ - fun retrieveGovernance(id: String): CompletableFuture = - retrieveGovernance(id, CustomerRetrieveGovernanceParams.none()) - - /** @see retrieveGovernance */ - fun retrieveGovernance( - id: String, - params: CustomerRetrieveGovernanceParams = CustomerRetrieveGovernanceParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - retrieveGovernance(params.toBuilder().id(id).build(), requestOptions) - - /** @see retrieveGovernance */ - fun retrieveGovernance( - id: String, - params: CustomerRetrieveGovernanceParams = CustomerRetrieveGovernanceParams.none(), - ): CompletableFuture = - retrieveGovernance(id, params, RequestOptions.none()) - - /** @see retrieveGovernance */ - fun retrieveGovernance( - params: CustomerRetrieveGovernanceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see retrieveGovernance */ - fun retrieveGovernance( - params: CustomerRetrieveGovernanceParams - ): CompletableFuture = - retrieveGovernance(params, RequestOptions.none()) - - /** @see retrieveGovernance */ - fun retrieveGovernance( - id: String, - requestOptions: RequestOptions, - ): CompletableFuture = - retrieveGovernance(id, CustomerRetrieveGovernanceParams.none(), requestOptions) - /** * A view of [CustomerServiceAsync] that provides access to raw HTTP responses for each method. */ @@ -95,48 +47,5 @@ interface CustomerServiceAsync { fun entities(): EntityServiceAsync.WithRawResponse fun assignments(): AssignmentServiceAsync.WithRawResponse - - /** - * Returns a raw HTTP response for `get /api/v1-beta/customers/{id}/governance`, but is - * otherwise the same as [CustomerServiceAsync.retrieveGovernance]. - */ - fun retrieveGovernance( - id: String - ): CompletableFuture> = - retrieveGovernance(id, CustomerRetrieveGovernanceParams.none()) - - /** @see retrieveGovernance */ - fun retrieveGovernance( - id: String, - params: CustomerRetrieveGovernanceParams = CustomerRetrieveGovernanceParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - retrieveGovernance(params.toBuilder().id(id).build(), requestOptions) - - /** @see retrieveGovernance */ - fun retrieveGovernance( - id: String, - params: CustomerRetrieveGovernanceParams = CustomerRetrieveGovernanceParams.none(), - ): CompletableFuture> = - retrieveGovernance(id, params, RequestOptions.none()) - - /** @see retrieveGovernance */ - fun retrieveGovernance( - params: CustomerRetrieveGovernanceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see retrieveGovernance */ - fun retrieveGovernance( - params: CustomerRetrieveGovernanceParams - ): CompletableFuture> = - retrieveGovernance(params, RequestOptions.none()) - - /** @see retrieveGovernance */ - fun retrieveGovernance( - id: String, - requestOptions: RequestOptions, - ): CompletableFuture> = - retrieveGovernance(id, CustomerRetrieveGovernanceParams.none(), requestOptions) } } diff --git a/stigg-java-core/src/main/kotlin/io/stigg/services/async/v1beta/CustomerServiceAsyncImpl.kt b/stigg-java-core/src/main/kotlin/io/stigg/services/async/v1beta/CustomerServiceAsyncImpl.kt index ba51b17b..9b3f7bb7 100644 --- a/stigg-java-core/src/main/kotlin/io/stigg/services/async/v1beta/CustomerServiceAsyncImpl.kt +++ b/stigg-java-core/src/main/kotlin/io/stigg/services/async/v1beta/CustomerServiceAsyncImpl.kt @@ -3,29 +3,13 @@ package io.stigg.services.async.v1beta import io.stigg.core.ClientOptions -import io.stigg.core.RequestOptions -import io.stigg.core.checkRequired -import io.stigg.core.handlers.errorBodyHandler -import io.stigg.core.handlers.errorHandler -import io.stigg.core.handlers.jsonHandler -import io.stigg.core.http.HttpMethod -import io.stigg.core.http.HttpRequest -import io.stigg.core.http.HttpResponse -import io.stigg.core.http.HttpResponse.Handler -import io.stigg.core.http.HttpResponseFor -import io.stigg.core.http.parseable -import io.stigg.core.prepareAsync -import io.stigg.models.v1beta.customers.CustomerRetrieveGovernanceParams -import io.stigg.models.v1beta.customers.CustomerRetrieveGovernanceResponse import io.stigg.services.async.v1beta.customers.AssignmentServiceAsync import io.stigg.services.async.v1beta.customers.AssignmentServiceAsyncImpl import io.stigg.services.async.v1beta.customers.EntitlementServiceAsync import io.stigg.services.async.v1beta.customers.EntitlementServiceAsyncImpl import io.stigg.services.async.v1beta.customers.EntityServiceAsync import io.stigg.services.async.v1beta.customers.EntityServiceAsyncImpl -import java.util.concurrent.CompletableFuture import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull class CustomerServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : CustomerServiceAsync { @@ -55,19 +39,9 @@ class CustomerServiceAsyncImpl internal constructor(private val clientOptions: C override fun assignments(): AssignmentServiceAsync = assignments - override fun retrieveGovernance( - params: CustomerRetrieveGovernanceParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // get /api/v1-beta/customers/{id}/governance - withRawResponse().retrieveGovernance(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : CustomerServiceAsync.WithRawResponse { - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - private val entitlements: EntitlementServiceAsync.WithRawResponse by lazy { EntitlementServiceAsyncImpl.WithRawResponseImpl(clientOptions) } @@ -92,44 +66,5 @@ class CustomerServiceAsyncImpl internal constructor(private val clientOptions: C override fun entities(): EntityServiceAsync.WithRawResponse = entities override fun assignments(): AssignmentServiceAsync.WithRawResponse = assignments - - private val retrieveGovernanceHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun retrieveGovernance( - params: CustomerRetrieveGovernanceParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("id", params.id().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments( - "api", - "v1-beta", - "customers", - params._pathParam(0), - "governance", - ) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { retrieveGovernanceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } } } diff --git a/stigg-java-core/src/main/kotlin/io/stigg/services/blocking/v1/EventService.kt b/stigg-java-core/src/main/kotlin/io/stigg/services/blocking/v1/EventService.kt index 9fc81dec..9ebda4f6 100644 --- a/stigg-java-core/src/main/kotlin/io/stigg/services/blocking/v1/EventService.kt +++ b/stigg-java-core/src/main/kotlin/io/stigg/services/blocking/v1/EventService.kt @@ -6,10 +6,11 @@ import com.google.errorprone.annotations.MustBeClosed import io.stigg.core.ClientOptions import io.stigg.core.RequestOptions import io.stigg.core.http.HttpResponseFor -import io.stigg.models.v1.events.EventEstimateCostParams -import io.stigg.models.v1.events.EventEstimateCostResponse +import io.stigg.models.v1.events.EventEstimateParams +import io.stigg.models.v1.events.EventEstimateResponse import io.stigg.models.v1.events.EventReportParams import io.stigg.models.v1.events.EventReportResponse +import io.stigg.services.blocking.v1.events.BetaService import io.stigg.services.blocking.v1.events.DataExportService import java.util.function.Consumer @@ -30,18 +31,20 @@ interface EventService { fun dataExport(): DataExportService + fun beta(): BetaService + /** * Estimates the credit cost of a usage event without ingesting it. Returns the estimated cost * per credit currency, the current balance, and the balance after the estimated consumption. */ - fun estimateCost(params: EventEstimateCostParams): EventEstimateCostResponse = - estimateCost(params, RequestOptions.none()) + fun estimate(params: EventEstimateParams): EventEstimateResponse = + estimate(params, RequestOptions.none()) - /** @see estimateCost */ - fun estimateCost( - params: EventEstimateCostParams, + /** @see estimate */ + fun estimate( + params: EventEstimateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): EventEstimateCostResponse + ): EventEstimateResponse /** * Reports raw usage events for event-based metering. Events are ingested asynchronously and @@ -68,21 +71,22 @@ interface EventService { fun dataExport(): DataExportService.WithRawResponse + fun beta(): BetaService.WithRawResponse + /** * Returns a raw HTTP response for `post /api/v1/events/estimate`, but is otherwise the same - * as [EventService.estimateCost]. + * as [EventService.estimate]. */ @MustBeClosed - fun estimateCost( - params: EventEstimateCostParams - ): HttpResponseFor = estimateCost(params, RequestOptions.none()) + fun estimate(params: EventEstimateParams): HttpResponseFor = + estimate(params, RequestOptions.none()) - /** @see estimateCost */ + /** @see estimate */ @MustBeClosed - fun estimateCost( - params: EventEstimateCostParams, + fun estimate( + params: EventEstimateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): HttpResponseFor /** * Returns a raw HTTP response for `post /api/v1/events`, but is otherwise the same as diff --git a/stigg-java-core/src/main/kotlin/io/stigg/services/blocking/v1/EventServiceImpl.kt b/stigg-java-core/src/main/kotlin/io/stigg/services/blocking/v1/EventServiceImpl.kt index b5e418b5..4c48eefb 100644 --- a/stigg-java-core/src/main/kotlin/io/stigg/services/blocking/v1/EventServiceImpl.kt +++ b/stigg-java-core/src/main/kotlin/io/stigg/services/blocking/v1/EventServiceImpl.kt @@ -15,10 +15,12 @@ import io.stigg.core.http.HttpResponseFor import io.stigg.core.http.json import io.stigg.core.http.parseable import io.stigg.core.prepare -import io.stigg.models.v1.events.EventEstimateCostParams -import io.stigg.models.v1.events.EventEstimateCostResponse +import io.stigg.models.v1.events.EventEstimateParams +import io.stigg.models.v1.events.EventEstimateResponse import io.stigg.models.v1.events.EventReportParams import io.stigg.models.v1.events.EventReportResponse +import io.stigg.services.blocking.v1.events.BetaService +import io.stigg.services.blocking.v1.events.BetaServiceImpl import io.stigg.services.blocking.v1.events.DataExportService import io.stigg.services.blocking.v1.events.DataExportServiceImpl import java.util.function.Consumer @@ -33,6 +35,8 @@ class EventServiceImpl internal constructor(private val clientOptions: ClientOpt private val dataExport: DataExportService by lazy { DataExportServiceImpl(clientOptions) } + private val beta: BetaService by lazy { BetaServiceImpl(clientOptions) } + override fun withRawResponse(): EventService.WithRawResponse = withRawResponse override fun withOptions(modifier: Consumer): EventService = @@ -40,12 +44,14 @@ class EventServiceImpl internal constructor(private val clientOptions: ClientOpt override fun dataExport(): DataExportService = dataExport - override fun estimateCost( - params: EventEstimateCostParams, + override fun beta(): BetaService = beta + + override fun estimate( + params: EventEstimateParams, requestOptions: RequestOptions, - ): EventEstimateCostResponse = + ): EventEstimateResponse = // post /api/v1/events/estimate - withRawResponse().estimateCost(params, requestOptions).parse() + withRawResponse().estimate(params, requestOptions).parse() override fun report( params: EventReportParams, @@ -64,6 +70,10 @@ class EventServiceImpl internal constructor(private val clientOptions: ClientOpt DataExportServiceImpl.WithRawResponseImpl(clientOptions) } + private val beta: BetaService.WithRawResponse by lazy { + BetaServiceImpl.WithRawResponseImpl(clientOptions) + } + override fun withOptions( modifier: Consumer ): EventService.WithRawResponse = @@ -73,13 +83,15 @@ class EventServiceImpl internal constructor(private val clientOptions: ClientOpt override fun dataExport(): DataExportService.WithRawResponse = dataExport - private val estimateCostHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + override fun beta(): BetaService.WithRawResponse = beta + + private val estimateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) - override fun estimateCost( - params: EventEstimateCostParams, + override fun estimate( + params: EventEstimateParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -92,7 +104,7 @@ class EventServiceImpl internal constructor(private val clientOptions: ClientOpt val response = clientOptions.httpClient.execute(request, requestOptions) return errorHandler.handle(response).parseable { response - .use { estimateCostHandler.handle(it) } + .use { estimateHandler.handle(it) } .also { if (requestOptions.responseValidation!!) { it.validate() diff --git a/stigg-java-core/src/main/kotlin/io/stigg/services/blocking/v1/UsageService.kt b/stigg-java-core/src/main/kotlin/io/stigg/services/blocking/v1/UsageService.kt index a58a19bf..e70adf7d 100644 --- a/stigg-java-core/src/main/kotlin/io/stigg/services/blocking/v1/UsageService.kt +++ b/stigg-java-core/src/main/kotlin/io/stigg/services/blocking/v1/UsageService.kt @@ -6,8 +6,8 @@ import com.google.errorprone.annotations.MustBeClosed import io.stigg.core.ClientOptions import io.stigg.core.RequestOptions import io.stigg.core.http.HttpResponseFor -import io.stigg.models.v1.usage.UsageEstimateCostParams -import io.stigg.models.v1.usage.UsageEstimateCostResponse +import io.stigg.models.v1.usage.UsageEstimateParams +import io.stigg.models.v1.usage.UsageEstimateResponse import io.stigg.models.v1.usage.UsageHistoryParams import io.stigg.models.v1.usage.UsageHistoryResponse import io.stigg.models.v1.usage.UsageReportParams @@ -33,14 +33,14 @@ interface UsageService { * Estimates the credit cost of a usage report without recording it. Returns the estimated cost * per credit currency, the current balance, and the balance after the estimated consumption. */ - fun estimateCost(params: UsageEstimateCostParams): UsageEstimateCostResponse = - estimateCost(params, RequestOptions.none()) + fun estimate(params: UsageEstimateParams): UsageEstimateResponse = + estimate(params, RequestOptions.none()) - /** @see estimateCost */ - fun estimateCost( - params: UsageEstimateCostParams, + /** @see estimate */ + fun estimate( + params: UsageEstimateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): UsageEstimateCostResponse + ): UsageEstimateResponse /** Retrieves historical usage data for a customer's metered feature over time. */ fun history(featureId: String, params: UsageHistoryParams): UsageHistoryResponse = @@ -89,19 +89,18 @@ interface UsageService { /** * Returns a raw HTTP response for `post /api/v1/usage/estimate`, but is otherwise the same - * as [UsageService.estimateCost]. + * as [UsageService.estimate]. */ @MustBeClosed - fun estimateCost( - params: UsageEstimateCostParams - ): HttpResponseFor = estimateCost(params, RequestOptions.none()) + fun estimate(params: UsageEstimateParams): HttpResponseFor = + estimate(params, RequestOptions.none()) - /** @see estimateCost */ + /** @see estimate */ @MustBeClosed - fun estimateCost( - params: UsageEstimateCostParams, + fun estimate( + params: UsageEstimateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): HttpResponseFor /** * Returns a raw HTTP response for `get /api/v1/usage/{customerId}/history/{featureId}`, but diff --git a/stigg-java-core/src/main/kotlin/io/stigg/services/blocking/v1/UsageServiceImpl.kt b/stigg-java-core/src/main/kotlin/io/stigg/services/blocking/v1/UsageServiceImpl.kt index 36961aa1..c48ae3f8 100644 --- a/stigg-java-core/src/main/kotlin/io/stigg/services/blocking/v1/UsageServiceImpl.kt +++ b/stigg-java-core/src/main/kotlin/io/stigg/services/blocking/v1/UsageServiceImpl.kt @@ -16,8 +16,8 @@ import io.stigg.core.http.HttpResponseFor import io.stigg.core.http.json import io.stigg.core.http.parseable import io.stigg.core.prepare -import io.stigg.models.v1.usage.UsageEstimateCostParams -import io.stigg.models.v1.usage.UsageEstimateCostResponse +import io.stigg.models.v1.usage.UsageEstimateParams +import io.stigg.models.v1.usage.UsageEstimateResponse import io.stigg.models.v1.usage.UsageHistoryParams import io.stigg.models.v1.usage.UsageHistoryResponse import io.stigg.models.v1.usage.UsageReportParams @@ -38,12 +38,12 @@ class UsageServiceImpl internal constructor(private val clientOptions: ClientOpt override fun withOptions(modifier: Consumer): UsageService = UsageServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - override fun estimateCost( - params: UsageEstimateCostParams, + override fun estimate( + params: UsageEstimateParams, requestOptions: RequestOptions, - ): UsageEstimateCostResponse = + ): UsageEstimateResponse = // post /api/v1/usage/estimate - withRawResponse().estimateCost(params, requestOptions).parse() + withRawResponse().estimate(params, requestOptions).parse() override fun history( params: UsageHistoryParams, @@ -72,13 +72,13 @@ class UsageServiceImpl internal constructor(private val clientOptions: ClientOpt clientOptions.toBuilder().apply(modifier::accept).build() ) - private val estimateCostHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val estimateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) - override fun estimateCost( - params: UsageEstimateCostParams, + override fun estimate( + params: UsageEstimateParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -91,7 +91,7 @@ class UsageServiceImpl internal constructor(private val clientOptions: ClientOpt val response = clientOptions.httpClient.execute(request, requestOptions) return errorHandler.handle(response).parseable { response - .use { estimateCostHandler.handle(it) } + .use { estimateHandler.handle(it) } .also { if (requestOptions.responseValidation!!) { it.validate() diff --git a/stigg-java-core/src/main/kotlin/io/stigg/services/blocking/v1/events/BetaService.kt b/stigg-java-core/src/main/kotlin/io/stigg/services/blocking/v1/events/BetaService.kt new file mode 100644 index 00000000..cdd5dad6 --- /dev/null +++ b/stigg-java-core/src/main/kotlin/io/stigg/services/blocking/v1/events/BetaService.kt @@ -0,0 +1,37 @@ +// File generated from our OpenAPI spec by Stainless. + +package io.stigg.services.blocking.v1.events + +import io.stigg.core.ClientOptions +import io.stigg.services.blocking.v1.events.beta.CustomerService +import java.util.function.Consumer + +interface BetaService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): BetaService + + fun customers(): CustomerService + + /** A view of [BetaService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): BetaService.WithRawResponse + + fun customers(): CustomerService.WithRawResponse + } +} diff --git a/stigg-java-core/src/main/kotlin/io/stigg/services/blocking/v1/events/BetaServiceImpl.kt b/stigg-java-core/src/main/kotlin/io/stigg/services/blocking/v1/events/BetaServiceImpl.kt new file mode 100644 index 00000000..4d9be41c --- /dev/null +++ b/stigg-java-core/src/main/kotlin/io/stigg/services/blocking/v1/events/BetaServiceImpl.kt @@ -0,0 +1,41 @@ +// File generated from our OpenAPI spec by Stainless. + +package io.stigg.services.blocking.v1.events + +import io.stigg.core.ClientOptions +import io.stigg.services.blocking.v1.events.beta.CustomerService +import io.stigg.services.blocking.v1.events.beta.CustomerServiceImpl +import java.util.function.Consumer + +class BetaServiceImpl internal constructor(private val clientOptions: ClientOptions) : BetaService { + + private val withRawResponse: BetaService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val customers: CustomerService by lazy { CustomerServiceImpl(clientOptions) } + + override fun withRawResponse(): BetaService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): BetaService = + BetaServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun customers(): CustomerService = customers + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + BetaService.WithRawResponse { + + private val customers: CustomerService.WithRawResponse by lazy { + CustomerServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer + ): BetaService.WithRawResponse = + BetaServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun customers(): CustomerService.WithRawResponse = customers + } +} diff --git a/stigg-java-core/src/main/kotlin/io/stigg/services/blocking/v1/events/beta/CustomerService.kt b/stigg-java-core/src/main/kotlin/io/stigg/services/blocking/v1/events/beta/CustomerService.kt new file mode 100644 index 00000000..25fc8007 --- /dev/null +++ b/stigg-java-core/src/main/kotlin/io/stigg/services/blocking/v1/events/beta/CustomerService.kt @@ -0,0 +1,125 @@ +// File generated from our OpenAPI spec by Stainless. + +package io.stigg.services.blocking.v1.events.beta + +import com.google.errorprone.annotations.MustBeClosed +import io.stigg.core.ClientOptions +import io.stigg.core.RequestOptions +import io.stigg.core.http.HttpResponseFor +import io.stigg.models.v1.events.beta.customers.CustomerRetrieveGovernanceParams +import io.stigg.models.v1.events.beta.customers.CustomerRetrieveGovernanceResponse +import java.util.function.Consumer + +interface CustomerService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CustomerService + + /** + * Queries the customer's governance hierarchy tree, returning a cursor-paginated list of nodes + * with their usage configuration (limit, cadence, scope) and current usage, sortable and + * filterable by usage. Each node carries `parentId` so the tree can be rebuilt client-side. + * Usage is read from a periodically-refreshed read model and never gates access. + */ + fun retrieveGovernance(id: String): CustomerRetrieveGovernanceResponse = + retrieveGovernance(id, CustomerRetrieveGovernanceParams.none()) + + /** @see retrieveGovernance */ + fun retrieveGovernance( + id: String, + params: CustomerRetrieveGovernanceParams = CustomerRetrieveGovernanceParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CustomerRetrieveGovernanceResponse = + retrieveGovernance(params.toBuilder().id(id).build(), requestOptions) + + /** @see retrieveGovernance */ + fun retrieveGovernance( + id: String, + params: CustomerRetrieveGovernanceParams = CustomerRetrieveGovernanceParams.none(), + ): CustomerRetrieveGovernanceResponse = retrieveGovernance(id, params, RequestOptions.none()) + + /** @see retrieveGovernance */ + fun retrieveGovernance( + params: CustomerRetrieveGovernanceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CustomerRetrieveGovernanceResponse + + /** @see retrieveGovernance */ + fun retrieveGovernance( + params: CustomerRetrieveGovernanceParams + ): CustomerRetrieveGovernanceResponse = retrieveGovernance(params, RequestOptions.none()) + + /** @see retrieveGovernance */ + fun retrieveGovernance( + id: String, + requestOptions: RequestOptions, + ): CustomerRetrieveGovernanceResponse = + retrieveGovernance(id, CustomerRetrieveGovernanceParams.none(), requestOptions) + + /** A view of [CustomerService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CustomerService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1-beta/customers/{id}/governance`, but is + * otherwise the same as [CustomerService.retrieveGovernance]. + */ + @MustBeClosed + fun retrieveGovernance(id: String): HttpResponseFor = + retrieveGovernance(id, CustomerRetrieveGovernanceParams.none()) + + /** @see retrieveGovernance */ + @MustBeClosed + fun retrieveGovernance( + id: String, + params: CustomerRetrieveGovernanceParams = CustomerRetrieveGovernanceParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieveGovernance(params.toBuilder().id(id).build(), requestOptions) + + /** @see retrieveGovernance */ + @MustBeClosed + fun retrieveGovernance( + id: String, + params: CustomerRetrieveGovernanceParams = CustomerRetrieveGovernanceParams.none(), + ): HttpResponseFor = + retrieveGovernance(id, params, RequestOptions.none()) + + /** @see retrieveGovernance */ + @MustBeClosed + fun retrieveGovernance( + params: CustomerRetrieveGovernanceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see retrieveGovernance */ + @MustBeClosed + fun retrieveGovernance( + params: CustomerRetrieveGovernanceParams + ): HttpResponseFor = + retrieveGovernance(params, RequestOptions.none()) + + /** @see retrieveGovernance */ + @MustBeClosed + fun retrieveGovernance( + id: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieveGovernance(id, CustomerRetrieveGovernanceParams.none(), requestOptions) + } +} diff --git a/stigg-java-core/src/main/kotlin/io/stigg/services/blocking/v1/events/beta/CustomerServiceImpl.kt b/stigg-java-core/src/main/kotlin/io/stigg/services/blocking/v1/events/beta/CustomerServiceImpl.kt new file mode 100644 index 00000000..14e407b8 --- /dev/null +++ b/stigg-java-core/src/main/kotlin/io/stigg/services/blocking/v1/events/beta/CustomerServiceImpl.kt @@ -0,0 +1,91 @@ +// File generated from our OpenAPI spec by Stainless. + +package io.stigg.services.blocking.v1.events.beta + +import io.stigg.core.ClientOptions +import io.stigg.core.RequestOptions +import io.stigg.core.checkRequired +import io.stigg.core.handlers.errorBodyHandler +import io.stigg.core.handlers.errorHandler +import io.stigg.core.handlers.jsonHandler +import io.stigg.core.http.HttpMethod +import io.stigg.core.http.HttpRequest +import io.stigg.core.http.HttpResponse +import io.stigg.core.http.HttpResponse.Handler +import io.stigg.core.http.HttpResponseFor +import io.stigg.core.http.parseable +import io.stigg.core.prepare +import io.stigg.models.v1.events.beta.customers.CustomerRetrieveGovernanceParams +import io.stigg.models.v1.events.beta.customers.CustomerRetrieveGovernanceResponse +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class CustomerServiceImpl internal constructor(private val clientOptions: ClientOptions) : + CustomerService { + + private val withRawResponse: CustomerService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): CustomerService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): CustomerService = + CustomerServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieveGovernance( + params: CustomerRetrieveGovernanceParams, + requestOptions: RequestOptions, + ): CustomerRetrieveGovernanceResponse = + // get /api/v1-beta/customers/{id}/governance + withRawResponse().retrieveGovernance(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CustomerService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): CustomerService.WithRawResponse = + CustomerServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveGovernanceHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieveGovernance( + params: CustomerRetrieveGovernanceParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("id", params.id().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1-beta", + "customers", + params._pathParam(0), + "governance", + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveGovernanceHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/stigg-java-core/src/main/kotlin/io/stigg/services/blocking/v1/events/dataexport/DestinationService.kt b/stigg-java-core/src/main/kotlin/io/stigg/services/blocking/v1/events/dataexport/DestinationService.kt index 8225db65..18298f17 100644 --- a/stigg-java-core/src/main/kotlin/io/stigg/services/blocking/v1/events/dataexport/DestinationService.kt +++ b/stigg-java-core/src/main/kotlin/io/stigg/services/blocking/v1/events/dataexport/DestinationService.kt @@ -10,8 +10,8 @@ import io.stigg.models.v1.events.dataexport.destinations.DestinationCreateParams import io.stigg.models.v1.events.dataexport.destinations.DestinationCreateResponse import io.stigg.models.v1.events.dataexport.destinations.DestinationDeleteParams import io.stigg.models.v1.events.dataexport.destinations.DestinationDeleteResponse -import io.stigg.models.v1.events.dataexport.destinations.DestinationUpdateParams -import io.stigg.models.v1.events.dataexport.destinations.DestinationUpdateResponse +import io.stigg.models.v1.events.dataexport.destinations.DestinationUpdateSelectionParams +import io.stigg.models.v1.events.dataexport.destinations.DestinationUpdateSelectionResponse import java.util.function.Consumer interface DestinationService { @@ -41,31 +41,6 @@ interface DestinationService { requestOptions: RequestOptions = RequestOptions.none(), ): DestinationCreateResponse - /** - * Update a destination's entity selection. Pushes the new enabled_models to the provider first, - * then persists the selection. Applies on the next scheduled transfer. - */ - fun update(destinationId: String, params: DestinationUpdateParams): DestinationUpdateResponse = - update(destinationId, params, RequestOptions.none()) - - /** @see update */ - fun update( - destinationId: String, - params: DestinationUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): DestinationUpdateResponse = - update(params.toBuilder().destinationId(destinationId).build(), requestOptions) - - /** @see update */ - fun update(params: DestinationUpdateParams): DestinationUpdateResponse = - update(params, RequestOptions.none()) - - /** @see update */ - fun update( - params: DestinationUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): DestinationUpdateResponse - /** * Disconnect a destination: stops the provider sync (deletes the provider destination) and * removes it from the DATA_EXPORT integration. Non-destructive — the warehouse table is left @@ -102,6 +77,35 @@ interface DestinationService { fun delete(destinationId: String, requestOptions: RequestOptions): DestinationDeleteResponse = delete(destinationId, DestinationDeleteParams.none(), requestOptions) + /** + * Update a destination's entity selection. Pushes the new enabled_models to the provider first, + * then persists the selection. Applies on the next scheduled transfer. + */ + fun updateSelection( + destinationId: String, + params: DestinationUpdateSelectionParams, + ): DestinationUpdateSelectionResponse = + updateSelection(destinationId, params, RequestOptions.none()) + + /** @see updateSelection */ + fun updateSelection( + destinationId: String, + params: DestinationUpdateSelectionParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): DestinationUpdateSelectionResponse = + updateSelection(params.toBuilder().destinationId(destinationId).build(), requestOptions) + + /** @see updateSelection */ + fun updateSelection( + params: DestinationUpdateSelectionParams + ): DestinationUpdateSelectionResponse = updateSelection(params, RequestOptions.none()) + + /** @see updateSelection */ + fun updateSelection( + params: DestinationUpdateSelectionParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): DestinationUpdateSelectionResponse + /** * A view of [DestinationService] that provides access to raw HTTP responses for each method. */ @@ -131,38 +135,6 @@ interface DestinationService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** - * Returns a raw HTTP response for `patch /api/v1/data-export/destinations/{destinationId}`, - * but is otherwise the same as [DestinationService.update]. - */ - @MustBeClosed - fun update( - destinationId: String, - params: DestinationUpdateParams, - ): HttpResponseFor = - update(destinationId, params, RequestOptions.none()) - - /** @see update */ - @MustBeClosed - fun update( - destinationId: String, - params: DestinationUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - update(params.toBuilder().destinationId(destinationId).build(), requestOptions) - - /** @see update */ - @MustBeClosed - fun update(params: DestinationUpdateParams): HttpResponseFor = - update(params, RequestOptions.none()) - - /** @see update */ - @MustBeClosed - fun update( - params: DestinationUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - /** * Returns a raw HTTP response for `delete * /api/v1/data-export/destinations/{destinationId}`, but is otherwise the same as @@ -208,5 +180,39 @@ interface DestinationService { requestOptions: RequestOptions, ): HttpResponseFor = delete(destinationId, DestinationDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `patch /api/v1/data-export/destinations/{destinationId}`, + * but is otherwise the same as [DestinationService.updateSelection]. + */ + @MustBeClosed + fun updateSelection( + destinationId: String, + params: DestinationUpdateSelectionParams, + ): HttpResponseFor = + updateSelection(destinationId, params, RequestOptions.none()) + + /** @see updateSelection */ + @MustBeClosed + fun updateSelection( + destinationId: String, + params: DestinationUpdateSelectionParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + updateSelection(params.toBuilder().destinationId(destinationId).build(), requestOptions) + + /** @see updateSelection */ + @MustBeClosed + fun updateSelection( + params: DestinationUpdateSelectionParams + ): HttpResponseFor = + updateSelection(params, RequestOptions.none()) + + /** @see updateSelection */ + @MustBeClosed + fun updateSelection( + params: DestinationUpdateSelectionParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor } } diff --git a/stigg-java-core/src/main/kotlin/io/stigg/services/blocking/v1/events/dataexport/DestinationServiceImpl.kt b/stigg-java-core/src/main/kotlin/io/stigg/services/blocking/v1/events/dataexport/DestinationServiceImpl.kt index a6cad8da..83e509d2 100644 --- a/stigg-java-core/src/main/kotlin/io/stigg/services/blocking/v1/events/dataexport/DestinationServiceImpl.kt +++ b/stigg-java-core/src/main/kotlin/io/stigg/services/blocking/v1/events/dataexport/DestinationServiceImpl.kt @@ -20,8 +20,8 @@ import io.stigg.models.v1.events.dataexport.destinations.DestinationCreateParams import io.stigg.models.v1.events.dataexport.destinations.DestinationCreateResponse import io.stigg.models.v1.events.dataexport.destinations.DestinationDeleteParams import io.stigg.models.v1.events.dataexport.destinations.DestinationDeleteResponse -import io.stigg.models.v1.events.dataexport.destinations.DestinationUpdateParams -import io.stigg.models.v1.events.dataexport.destinations.DestinationUpdateResponse +import io.stigg.models.v1.events.dataexport.destinations.DestinationUpdateSelectionParams +import io.stigg.models.v1.events.dataexport.destinations.DestinationUpdateSelectionResponse import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull @@ -44,13 +44,6 @@ class DestinationServiceImpl internal constructor(private val clientOptions: Cli // post /api/v1/data-export/destinations withRawResponse().create(params, requestOptions).parse() - override fun update( - params: DestinationUpdateParams, - requestOptions: RequestOptions, - ): DestinationUpdateResponse = - // patch /api/v1/data-export/destinations/{destinationId} - withRawResponse().update(params, requestOptions).parse() - override fun delete( params: DestinationDeleteParams, requestOptions: RequestOptions, @@ -58,6 +51,13 @@ class DestinationServiceImpl internal constructor(private val clientOptions: Cli // delete /api/v1/data-export/destinations/{destinationId} withRawResponse().delete(params, requestOptions).parse() + override fun updateSelection( + params: DestinationUpdateSelectionParams, + requestOptions: RequestOptions, + ): DestinationUpdateSelectionResponse = + // patch /api/v1/data-export/destinations/{destinationId} + withRawResponse().updateSelection(params, requestOptions).parse() + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : DestinationService.WithRawResponse { @@ -99,19 +99,19 @@ class DestinationServiceImpl internal constructor(private val clientOptions: Cli } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper) - override fun update( - params: DestinationUpdateParams, + override fun delete( + params: DestinationDeleteParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("destinationId", params.destinationId().getOrNull()) val request = HttpRequest.builder() - .method(HttpMethod.PATCH) + .method(HttpMethod.DELETE) .baseUrl(clientOptions.baseUrl()) .addPathSegments( "api", @@ -120,14 +120,14 @@ class DestinationServiceImpl internal constructor(private val clientOptions: Cli "destinations", params._pathParam(0), ) - .body(json(clientOptions.jsonMapper, params._body())) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return errorHandler.handle(response).parseable { response - .use { updateHandler.handle(it) } + .use { deleteHandler.handle(it) } .also { if (requestOptions.responseValidation!!) { it.validate() @@ -136,19 +136,19 @@ class DestinationServiceImpl internal constructor(private val clientOptions: Cli } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val updateSelectionHandler: Handler = + jsonHandler(clientOptions.jsonMapper) - override fun delete( - params: DestinationDeleteParams, + override fun updateSelection( + params: DestinationUpdateSelectionParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("destinationId", params.destinationId().getOrNull()) val request = HttpRequest.builder() - .method(HttpMethod.DELETE) + .method(HttpMethod.PATCH) .baseUrl(clientOptions.baseUrl()) .addPathSegments( "api", @@ -157,14 +157,14 @@ class DestinationServiceImpl internal constructor(private val clientOptions: Cli "destinations", params._pathParam(0), ) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return errorHandler.handle(response).parseable { response - .use { deleteHandler.handle(it) } + .use { updateSelectionHandler.handle(it) } .also { if (requestOptions.responseValidation!!) { it.validate() diff --git a/stigg-java-core/src/main/kotlin/io/stigg/services/blocking/v1beta/CustomerService.kt b/stigg-java-core/src/main/kotlin/io/stigg/services/blocking/v1beta/CustomerService.kt index c47c1eec..b8022a8c 100644 --- a/stigg-java-core/src/main/kotlin/io/stigg/services/blocking/v1beta/CustomerService.kt +++ b/stigg-java-core/src/main/kotlin/io/stigg/services/blocking/v1beta/CustomerService.kt @@ -2,12 +2,7 @@ package io.stigg.services.blocking.v1beta -import com.google.errorprone.annotations.MustBeClosed import io.stigg.core.ClientOptions -import io.stigg.core.RequestOptions -import io.stigg.core.http.HttpResponseFor -import io.stigg.models.v1beta.customers.CustomerRetrieveGovernanceParams -import io.stigg.models.v1beta.customers.CustomerRetrieveGovernanceResponse import io.stigg.services.blocking.v1beta.customers.AssignmentService import io.stigg.services.blocking.v1beta.customers.EntitlementService import io.stigg.services.blocking.v1beta.customers.EntityService @@ -33,47 +28,6 @@ interface CustomerService { fun assignments(): AssignmentService - /** - * Queries the customer's governance hierarchy tree, returning a cursor-paginated list of nodes - * with their usage configuration (limit, cadence, scope) and current usage, sortable and - * filterable by usage. Each node carries `parentId` so the tree can be rebuilt client-side. - * Usage is read from a periodically-refreshed read model and never gates access. - */ - fun retrieveGovernance(id: String): CustomerRetrieveGovernanceResponse = - retrieveGovernance(id, CustomerRetrieveGovernanceParams.none()) - - /** @see retrieveGovernance */ - fun retrieveGovernance( - id: String, - params: CustomerRetrieveGovernanceParams = CustomerRetrieveGovernanceParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CustomerRetrieveGovernanceResponse = - retrieveGovernance(params.toBuilder().id(id).build(), requestOptions) - - /** @see retrieveGovernance */ - fun retrieveGovernance( - id: String, - params: CustomerRetrieveGovernanceParams = CustomerRetrieveGovernanceParams.none(), - ): CustomerRetrieveGovernanceResponse = retrieveGovernance(id, params, RequestOptions.none()) - - /** @see retrieveGovernance */ - fun retrieveGovernance( - params: CustomerRetrieveGovernanceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CustomerRetrieveGovernanceResponse - - /** @see retrieveGovernance */ - fun retrieveGovernance( - params: CustomerRetrieveGovernanceParams - ): CustomerRetrieveGovernanceResponse = retrieveGovernance(params, RequestOptions.none()) - - /** @see retrieveGovernance */ - fun retrieveGovernance( - id: String, - requestOptions: RequestOptions, - ): CustomerRetrieveGovernanceResponse = - retrieveGovernance(id, CustomerRetrieveGovernanceParams.none(), requestOptions) - /** A view of [CustomerService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -89,52 +43,5 @@ interface CustomerService { fun entities(): EntityService.WithRawResponse fun assignments(): AssignmentService.WithRawResponse - - /** - * Returns a raw HTTP response for `get /api/v1-beta/customers/{id}/governance`, but is - * otherwise the same as [CustomerService.retrieveGovernance]. - */ - @MustBeClosed - fun retrieveGovernance(id: String): HttpResponseFor = - retrieveGovernance(id, CustomerRetrieveGovernanceParams.none()) - - /** @see retrieveGovernance */ - @MustBeClosed - fun retrieveGovernance( - id: String, - params: CustomerRetrieveGovernanceParams = CustomerRetrieveGovernanceParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - retrieveGovernance(params.toBuilder().id(id).build(), requestOptions) - - /** @see retrieveGovernance */ - @MustBeClosed - fun retrieveGovernance( - id: String, - params: CustomerRetrieveGovernanceParams = CustomerRetrieveGovernanceParams.none(), - ): HttpResponseFor = - retrieveGovernance(id, params, RequestOptions.none()) - - /** @see retrieveGovernance */ - @MustBeClosed - fun retrieveGovernance( - params: CustomerRetrieveGovernanceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see retrieveGovernance */ - @MustBeClosed - fun retrieveGovernance( - params: CustomerRetrieveGovernanceParams - ): HttpResponseFor = - retrieveGovernance(params, RequestOptions.none()) - - /** @see retrieveGovernance */ - @MustBeClosed - fun retrieveGovernance( - id: String, - requestOptions: RequestOptions, - ): HttpResponseFor = - retrieveGovernance(id, CustomerRetrieveGovernanceParams.none(), requestOptions) } } diff --git a/stigg-java-core/src/main/kotlin/io/stigg/services/blocking/v1beta/CustomerServiceImpl.kt b/stigg-java-core/src/main/kotlin/io/stigg/services/blocking/v1beta/CustomerServiceImpl.kt index a6056b81..b24f098f 100644 --- a/stigg-java-core/src/main/kotlin/io/stigg/services/blocking/v1beta/CustomerServiceImpl.kt +++ b/stigg-java-core/src/main/kotlin/io/stigg/services/blocking/v1beta/CustomerServiceImpl.kt @@ -3,20 +3,6 @@ package io.stigg.services.blocking.v1beta import io.stigg.core.ClientOptions -import io.stigg.core.RequestOptions -import io.stigg.core.checkRequired -import io.stigg.core.handlers.errorBodyHandler -import io.stigg.core.handlers.errorHandler -import io.stigg.core.handlers.jsonHandler -import io.stigg.core.http.HttpMethod -import io.stigg.core.http.HttpRequest -import io.stigg.core.http.HttpResponse -import io.stigg.core.http.HttpResponse.Handler -import io.stigg.core.http.HttpResponseFor -import io.stigg.core.http.parseable -import io.stigg.core.prepare -import io.stigg.models.v1beta.customers.CustomerRetrieveGovernanceParams -import io.stigg.models.v1beta.customers.CustomerRetrieveGovernanceResponse import io.stigg.services.blocking.v1beta.customers.AssignmentService import io.stigg.services.blocking.v1beta.customers.AssignmentServiceImpl import io.stigg.services.blocking.v1beta.customers.EntitlementService @@ -24,7 +10,6 @@ import io.stigg.services.blocking.v1beta.customers.EntitlementServiceImpl import io.stigg.services.blocking.v1beta.customers.EntityService import io.stigg.services.blocking.v1beta.customers.EntityServiceImpl import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull class CustomerServiceImpl internal constructor(private val clientOptions: ClientOptions) : CustomerService { @@ -50,19 +35,9 @@ class CustomerServiceImpl internal constructor(private val clientOptions: Client override fun assignments(): AssignmentService = assignments - override fun retrieveGovernance( - params: CustomerRetrieveGovernanceParams, - requestOptions: RequestOptions, - ): CustomerRetrieveGovernanceResponse = - // get /api/v1-beta/customers/{id}/governance - withRawResponse().retrieveGovernance(params, requestOptions).parse() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : CustomerService.WithRawResponse { - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - private val entitlements: EntitlementService.WithRawResponse by lazy { EntitlementServiceImpl.WithRawResponseImpl(clientOptions) } @@ -87,41 +62,5 @@ class CustomerServiceImpl internal constructor(private val clientOptions: Client override fun entities(): EntityService.WithRawResponse = entities override fun assignments(): AssignmentService.WithRawResponse = assignments - - private val retrieveGovernanceHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun retrieveGovernance( - params: CustomerRetrieveGovernanceParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("id", params.id().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments( - "api", - "v1-beta", - "customers", - params._pathParam(0), - "governance", - ) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { retrieveGovernanceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } } } diff --git a/stigg-java-core/src/test/kotlin/io/stigg/models/v1/addons/AddonUpdateParamsTest.kt b/stigg-java-core/src/test/kotlin/io/stigg/models/v1/addons/AddonUpdateParamsTest.kt index f70f25a5..45064348 100644 --- a/stigg-java-core/src/test/kotlin/io/stigg/models/v1/addons/AddonUpdateParamsTest.kt +++ b/stigg-java-core/src/test/kotlin/io/stigg/models/v1/addons/AddonUpdateParamsTest.kt @@ -130,6 +130,20 @@ internal class AddonUpdateParamsTest { AddonUpdateParams.Charges.OveragePricingModel.BillingCadence .RECURRING ) + .creditEntitlement( + AddonUpdateParams.Charges.OveragePricingModel.CreditEntitlement + .builder() + .amount(1.0) + .cadence( + AddonUpdateParams.Charges.OveragePricingModel + .CreditEntitlement + .Cadence + .MONTH + ) + .customCurrencyId("customCurrencyId") + .build() + ) + .currencyId("currencyId") .entitlement( AddonUpdateParams.Charges.OveragePricingModel.Entitlement.builder() .featureId("featureId") @@ -183,7 +197,6 @@ internal class AddonUpdateParamsTest { .build() ) .featureId("featureId") - .topUpCustomCurrencyId("topUpCustomCurrencyId") .build() ) .addPricingModel( @@ -466,6 +479,20 @@ internal class AddonUpdateParamsTest { AddonUpdateParams.Charges.OveragePricingModel.BillingCadence .RECURRING ) + .creditEntitlement( + AddonUpdateParams.Charges.OveragePricingModel.CreditEntitlement + .builder() + .amount(1.0) + .cadence( + AddonUpdateParams.Charges.OveragePricingModel + .CreditEntitlement + .Cadence + .MONTH + ) + .customCurrencyId("customCurrencyId") + .build() + ) + .currencyId("currencyId") .entitlement( AddonUpdateParams.Charges.OveragePricingModel.Entitlement .builder() @@ -524,7 +551,6 @@ internal class AddonUpdateParamsTest { .build() ) .featureId("featureId") - .topUpCustomCurrencyId("topUpCustomCurrencyId") .build() ) .addPricingModel( @@ -822,6 +848,20 @@ internal class AddonUpdateParamsTest { AddonUpdateParams.Charges.OveragePricingModel.BillingCadence .RECURRING ) + .creditEntitlement( + AddonUpdateParams.Charges.OveragePricingModel.CreditEntitlement + .builder() + .amount(1.0) + .cadence( + AddonUpdateParams.Charges.OveragePricingModel + .CreditEntitlement + .Cadence + .MONTH + ) + .customCurrencyId("customCurrencyId") + .build() + ) + .currencyId("currencyId") .entitlement( AddonUpdateParams.Charges.OveragePricingModel.Entitlement .builder() @@ -880,7 +920,6 @@ internal class AddonUpdateParamsTest { .build() ) .featureId("featureId") - .topUpCustomCurrencyId("topUpCustomCurrencyId") .build() ) .addPricingModel( @@ -1146,6 +1185,20 @@ internal class AddonUpdateParamsTest { AddonUpdateParams.Charges.OveragePricingModel.BillingCadence .RECURRING ) + .creditEntitlement( + AddonUpdateParams.Charges.OveragePricingModel.CreditEntitlement + .builder() + .amount(1.0) + .cadence( + AddonUpdateParams.Charges.OveragePricingModel + .CreditEntitlement + .Cadence + .MONTH + ) + .customCurrencyId("customCurrencyId") + .build() + ) + .currencyId("currencyId") .entitlement( AddonUpdateParams.Charges.OveragePricingModel.Entitlement.builder() .featureId("featureId") @@ -1199,7 +1252,6 @@ internal class AddonUpdateParamsTest { .build() ) .featureId("featureId") - .topUpCustomCurrencyId("topUpCustomCurrencyId") .build() ) .addPricingModel( diff --git a/stigg-java-core/src/test/kotlin/io/stigg/models/v1/events/EventEstimateCostParamsTest.kt b/stigg-java-core/src/test/kotlin/io/stigg/models/v1/events/EventEstimateParamsTest.kt similarity index 79% rename from stigg-java-core/src/test/kotlin/io/stigg/models/v1/events/EventEstimateCostParamsTest.kt rename to stigg-java-core/src/test/kotlin/io/stigg/models/v1/events/EventEstimateParamsTest.kt index 19a368a5..8e48d40c 100644 --- a/stigg-java-core/src/test/kotlin/io/stigg/models/v1/events/EventEstimateCostParamsTest.kt +++ b/stigg-java-core/src/test/kotlin/io/stigg/models/v1/events/EventEstimateParamsTest.kt @@ -7,17 +7,17 @@ import io.stigg.core.http.Headers import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class EventEstimateCostParamsTest { +internal class EventEstimateParamsTest { @Test fun create() { - EventEstimateCostParams.builder() + EventEstimateParams.builder() .xAccountId("X-ACCOUNT-ID") .xEnvironmentId("X-ENVIRONMENT-ID") .customerId("customerId") .eventName("x") .dimensions( - EventEstimateCostParams.Dimensions.builder() + EventEstimateParams.Dimensions.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -28,13 +28,13 @@ internal class EventEstimateCostParamsTest { @Test fun headers() { val params = - EventEstimateCostParams.builder() + EventEstimateParams.builder() .xAccountId("X-ACCOUNT-ID") .xEnvironmentId("X-ENVIRONMENT-ID") .customerId("customerId") .eventName("x") .dimensions( - EventEstimateCostParams.Dimensions.builder() + EventEstimateParams.Dimensions.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -54,8 +54,7 @@ internal class EventEstimateCostParamsTest { @Test fun headersWithoutOptionalFields() { - val params = - EventEstimateCostParams.builder().customerId("customerId").eventName("x").build() + val params = EventEstimateParams.builder().customerId("customerId").eventName("x").build() val headers = params._headers() @@ -65,13 +64,13 @@ internal class EventEstimateCostParamsTest { @Test fun body() { val params = - EventEstimateCostParams.builder() + EventEstimateParams.builder() .xAccountId("X-ACCOUNT-ID") .xEnvironmentId("X-ENVIRONMENT-ID") .customerId("customerId") .eventName("x") .dimensions( - EventEstimateCostParams.Dimensions.builder() + EventEstimateParams.Dimensions.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -84,7 +83,7 @@ internal class EventEstimateCostParamsTest { assertThat(body.eventName()).isEqualTo("x") assertThat(body.dimensions()) .contains( - EventEstimateCostParams.Dimensions.builder() + EventEstimateParams.Dimensions.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -93,8 +92,7 @@ internal class EventEstimateCostParamsTest { @Test fun bodyWithoutOptionalFields() { - val params = - EventEstimateCostParams.builder().customerId("customerId").eventName("x").build() + val params = EventEstimateParams.builder().customerId("customerId").eventName("x").build() val body = params._body() diff --git a/stigg-java-core/src/test/kotlin/io/stigg/models/v1/events/EventEstimateCostResponseTest.kt b/stigg-java-core/src/test/kotlin/io/stigg/models/v1/events/EventEstimateResponseTest.kt similarity index 64% rename from stigg-java-core/src/test/kotlin/io/stigg/models/v1/events/EventEstimateCostResponseTest.kt rename to stigg-java-core/src/test/kotlin/io/stigg/models/v1/events/EventEstimateResponseTest.kt index cfa4c460..346feaad 100644 --- a/stigg-java-core/src/test/kotlin/io/stigg/models/v1/events/EventEstimateCostResponseTest.kt +++ b/stigg-java-core/src/test/kotlin/io/stigg/models/v1/events/EventEstimateResponseTest.kt @@ -7,23 +7,23 @@ import io.stigg.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class EventEstimateCostResponseTest { +internal class EventEstimateResponseTest { @Test fun create() { - val eventEstimateCostResponse = - EventEstimateCostResponse.builder() + val eventEstimateResponse = + EventEstimateResponse.builder() .data( - EventEstimateCostResponse.Data.builder() + EventEstimateResponse.Data.builder() .addEstimate( - EventEstimateCostResponse.Data.Estimate.builder() + EventEstimateResponse.Data.Estimate.builder() .balanceAfterEstimate(0.0) .addBreakdown( - EventEstimateCostResponse.Data.Estimate.Breakdown.builder() + EventEstimateResponse.Data.Estimate.Breakdown.builder() .cost(0.0) .featureId("featureId") .warningCode( - EventEstimateCostResponse.Data.Estimate.Breakdown + EventEstimateResponse.Data.Estimate.Breakdown .WarningCode .UNSUPPORTED_AGGREGATION ) @@ -36,26 +36,24 @@ internal class EventEstimateCostResponseTest { .build() ) .addWarning( - EventEstimateCostResponse.Data.Warning - .RESOURCE_SCOPED_SUBSCRIPTION_EXISTS + EventEstimateResponse.Data.Warning.RESOURCE_SCOPED_SUBSCRIPTION_EXISTS ) .build() ) .build() - assertThat(eventEstimateCostResponse.data()) + assertThat(eventEstimateResponse.data()) .isEqualTo( - EventEstimateCostResponse.Data.builder() + EventEstimateResponse.Data.builder() .addEstimate( - EventEstimateCostResponse.Data.Estimate.builder() + EventEstimateResponse.Data.Estimate.builder() .balanceAfterEstimate(0.0) .addBreakdown( - EventEstimateCostResponse.Data.Estimate.Breakdown.builder() + EventEstimateResponse.Data.Estimate.Breakdown.builder() .cost(0.0) .featureId("featureId") .warningCode( - EventEstimateCostResponse.Data.Estimate.Breakdown - .WarningCode + EventEstimateResponse.Data.Estimate.Breakdown.WarningCode .UNSUPPORTED_AGGREGATION ) .build() @@ -67,7 +65,7 @@ internal class EventEstimateCostResponseTest { .build() ) .addWarning( - EventEstimateCostResponse.Data.Warning.RESOURCE_SCOPED_SUBSCRIPTION_EXISTS + EventEstimateResponse.Data.Warning.RESOURCE_SCOPED_SUBSCRIPTION_EXISTS ) .build() ) @@ -76,19 +74,19 @@ internal class EventEstimateCostResponseTest { @Test fun roundtrip() { val jsonMapper = jsonMapper() - val eventEstimateCostResponse = - EventEstimateCostResponse.builder() + val eventEstimateResponse = + EventEstimateResponse.builder() .data( - EventEstimateCostResponse.Data.builder() + EventEstimateResponse.Data.builder() .addEstimate( - EventEstimateCostResponse.Data.Estimate.builder() + EventEstimateResponse.Data.Estimate.builder() .balanceAfterEstimate(0.0) .addBreakdown( - EventEstimateCostResponse.Data.Estimate.Breakdown.builder() + EventEstimateResponse.Data.Estimate.Breakdown.builder() .cost(0.0) .featureId("featureId") .warningCode( - EventEstimateCostResponse.Data.Estimate.Breakdown + EventEstimateResponse.Data.Estimate.Breakdown .WarningCode .UNSUPPORTED_AGGREGATION ) @@ -101,19 +99,18 @@ internal class EventEstimateCostResponseTest { .build() ) .addWarning( - EventEstimateCostResponse.Data.Warning - .RESOURCE_SCOPED_SUBSCRIPTION_EXISTS + EventEstimateResponse.Data.Warning.RESOURCE_SCOPED_SUBSCRIPTION_EXISTS ) .build() ) .build() - val roundtrippedEventEstimateCostResponse = + val roundtrippedEventEstimateResponse = jsonMapper.readValue( - jsonMapper.writeValueAsString(eventEstimateCostResponse), - jacksonTypeRef(), + jsonMapper.writeValueAsString(eventEstimateResponse), + jacksonTypeRef(), ) - assertThat(roundtrippedEventEstimateCostResponse).isEqualTo(eventEstimateCostResponse) + assertThat(roundtrippedEventEstimateResponse).isEqualTo(eventEstimateResponse) } } diff --git a/stigg-java-core/src/test/kotlin/io/stigg/models/v1beta/customers/CustomerRetrieveGovernanceParamsTest.kt b/stigg-java-core/src/test/kotlin/io/stigg/models/v1/events/beta/customers/CustomerRetrieveGovernanceParamsTest.kt similarity index 98% rename from stigg-java-core/src/test/kotlin/io/stigg/models/v1beta/customers/CustomerRetrieveGovernanceParamsTest.kt rename to stigg-java-core/src/test/kotlin/io/stigg/models/v1/events/beta/customers/CustomerRetrieveGovernanceParamsTest.kt index 9a322439..5874f692 100644 --- a/stigg-java-core/src/test/kotlin/io/stigg/models/v1beta/customers/CustomerRetrieveGovernanceParamsTest.kt +++ b/stigg-java-core/src/test/kotlin/io/stigg/models/v1/events/beta/customers/CustomerRetrieveGovernanceParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.stigg.models.v1beta.customers +package io.stigg.models.v1.events.beta.customers import io.stigg.core.http.Headers import io.stigg.core.http.QueryParams diff --git a/stigg-java-core/src/test/kotlin/io/stigg/models/v1beta/customers/CustomerRetrieveGovernanceResponseTest.kt b/stigg-java-core/src/test/kotlin/io/stigg/models/v1/events/beta/customers/CustomerRetrieveGovernanceResponseTest.kt similarity index 98% rename from stigg-java-core/src/test/kotlin/io/stigg/models/v1beta/customers/CustomerRetrieveGovernanceResponseTest.kt rename to stigg-java-core/src/test/kotlin/io/stigg/models/v1/events/beta/customers/CustomerRetrieveGovernanceResponseTest.kt index 58bd286d..62aed7a5 100644 --- a/stigg-java-core/src/test/kotlin/io/stigg/models/v1beta/customers/CustomerRetrieveGovernanceResponseTest.kt +++ b/stigg-java-core/src/test/kotlin/io/stigg/models/v1/events/beta/customers/CustomerRetrieveGovernanceResponseTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.stigg.models.v1beta.customers +package io.stigg.models.v1.events.beta.customers import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import io.stigg.core.jsonMapper diff --git a/stigg-java-core/src/test/kotlin/io/stigg/models/v1/events/dataexport/destinations/DestinationUpdateParamsTest.kt b/stigg-java-core/src/test/kotlin/io/stigg/models/v1/events/dataexport/destinations/DestinationUpdateSelectionParamsTest.kt similarity index 86% rename from stigg-java-core/src/test/kotlin/io/stigg/models/v1/events/dataexport/destinations/DestinationUpdateParamsTest.kt rename to stigg-java-core/src/test/kotlin/io/stigg/models/v1/events/dataexport/destinations/DestinationUpdateSelectionParamsTest.kt index de9fffae..93bd4a8e 100644 --- a/stigg-java-core/src/test/kotlin/io/stigg/models/v1/events/dataexport/destinations/DestinationUpdateParamsTest.kt +++ b/stigg-java-core/src/test/kotlin/io/stigg/models/v1/events/dataexport/destinations/DestinationUpdateSelectionParamsTest.kt @@ -6,11 +6,11 @@ import io.stigg.core.http.Headers import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class DestinationUpdateParamsTest { +internal class DestinationUpdateSelectionParamsTest { @Test fun create() { - DestinationUpdateParams.builder() + DestinationUpdateSelectionParams.builder() .destinationId("x") .xAccountId("X-ACCOUNT-ID") .xEnvironmentId("X-ENVIRONMENT-ID") @@ -22,7 +22,7 @@ internal class DestinationUpdateParamsTest { @Test fun pathParams() { val params = - DestinationUpdateParams.builder() + DestinationUpdateSelectionParams.builder() .destinationId("x") .addEnabledModel("x") .integrationId("x") @@ -36,7 +36,7 @@ internal class DestinationUpdateParamsTest { @Test fun headers() { val params = - DestinationUpdateParams.builder() + DestinationUpdateSelectionParams.builder() .destinationId("x") .xAccountId("X-ACCOUNT-ID") .xEnvironmentId("X-ENVIRONMENT-ID") @@ -58,7 +58,7 @@ internal class DestinationUpdateParamsTest { @Test fun headersWithoutOptionalFields() { val params = - DestinationUpdateParams.builder() + DestinationUpdateSelectionParams.builder() .destinationId("x") .addEnabledModel("x") .integrationId("x") @@ -72,7 +72,7 @@ internal class DestinationUpdateParamsTest { @Test fun body() { val params = - DestinationUpdateParams.builder() + DestinationUpdateSelectionParams.builder() .destinationId("x") .xAccountId("X-ACCOUNT-ID") .xEnvironmentId("X-ENVIRONMENT-ID") @@ -89,7 +89,7 @@ internal class DestinationUpdateParamsTest { @Test fun bodyWithoutOptionalFields() { val params = - DestinationUpdateParams.builder() + DestinationUpdateSelectionParams.builder() .destinationId("x") .addEnabledModel("x") .integrationId("x") diff --git a/stigg-java-core/src/test/kotlin/io/stigg/models/v1/events/dataexport/destinations/DestinationUpdateResponseTest.kt b/stigg-java-core/src/test/kotlin/io/stigg/models/v1/events/dataexport/destinations/DestinationUpdateSelectionResponseTest.kt similarity index 69% rename from stigg-java-core/src/test/kotlin/io/stigg/models/v1/events/dataexport/destinations/DestinationUpdateResponseTest.kt rename to stigg-java-core/src/test/kotlin/io/stigg/models/v1/events/dataexport/destinations/DestinationUpdateSelectionResponseTest.kt index 9f2412b5..2d5d29ab 100644 --- a/stigg-java-core/src/test/kotlin/io/stigg/models/v1/events/dataexport/destinations/DestinationUpdateResponseTest.kt +++ b/stigg-java-core/src/test/kotlin/io/stigg/models/v1/events/dataexport/destinations/DestinationUpdateSelectionResponseTest.kt @@ -7,23 +7,24 @@ import io.stigg.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class DestinationUpdateResponseTest { +internal class DestinationUpdateSelectionResponseTest { @Test fun create() { - val destinationUpdateResponse = - DestinationUpdateResponse.builder() + val destinationUpdateSelectionResponse = + DestinationUpdateSelectionResponse.builder() .data( - DestinationUpdateResponse.Data.builder() + DestinationUpdateSelectionResponse.Data.builder() .addDestination( - DestinationUpdateResponse.Data.Destination.builder() + DestinationUpdateSelectionResponse.Data.Destination.builder() .connectedAt("connectedAt") .destinationId("destinationId") .type("type") .connectionStatus("connectionStatus") .addEnabledModel("string") .lastSyncStatus( - DestinationUpdateResponse.Data.Destination.LastSyncStatus + DestinationUpdateSelectionResponse.Data.Destination + .LastSyncStatus .builder() .finishedAt("finishedAt") .status("status") @@ -39,18 +40,19 @@ internal class DestinationUpdateResponseTest { ) .build() - assertThat(destinationUpdateResponse.data()) + assertThat(destinationUpdateSelectionResponse.data()) .isEqualTo( - DestinationUpdateResponse.Data.builder() + DestinationUpdateSelectionResponse.Data.builder() .addDestination( - DestinationUpdateResponse.Data.Destination.builder() + DestinationUpdateSelectionResponse.Data.Destination.builder() .connectedAt("connectedAt") .destinationId("destinationId") .type("type") .connectionStatus("connectionStatus") .addEnabledModel("string") .lastSyncStatus( - DestinationUpdateResponse.Data.Destination.LastSyncStatus.builder() + DestinationUpdateSelectionResponse.Data.Destination.LastSyncStatus + .builder() .finishedAt("finishedAt") .status("status") .transferId("transferId") @@ -68,19 +70,20 @@ internal class DestinationUpdateResponseTest { @Test fun roundtrip() { val jsonMapper = jsonMapper() - val destinationUpdateResponse = - DestinationUpdateResponse.builder() + val destinationUpdateSelectionResponse = + DestinationUpdateSelectionResponse.builder() .data( - DestinationUpdateResponse.Data.builder() + DestinationUpdateSelectionResponse.Data.builder() .addDestination( - DestinationUpdateResponse.Data.Destination.builder() + DestinationUpdateSelectionResponse.Data.Destination.builder() .connectedAt("connectedAt") .destinationId("destinationId") .type("type") .connectionStatus("connectionStatus") .addEnabledModel("string") .lastSyncStatus( - DestinationUpdateResponse.Data.Destination.LastSyncStatus + DestinationUpdateSelectionResponse.Data.Destination + .LastSyncStatus .builder() .finishedAt("finishedAt") .status("status") @@ -96,12 +99,13 @@ internal class DestinationUpdateResponseTest { ) .build() - val roundtrippedDestinationUpdateResponse = + val roundtrippedDestinationUpdateSelectionResponse = jsonMapper.readValue( - jsonMapper.writeValueAsString(destinationUpdateResponse), - jacksonTypeRef(), + jsonMapper.writeValueAsString(destinationUpdateSelectionResponse), + jacksonTypeRef(), ) - assertThat(roundtrippedDestinationUpdateResponse).isEqualTo(destinationUpdateResponse) + assertThat(roundtrippedDestinationUpdateSelectionResponse) + .isEqualTo(destinationUpdateSelectionResponse) } } diff --git a/stigg-java-core/src/test/kotlin/io/stigg/models/v1/plans/PlanUpdateParamsTest.kt b/stigg-java-core/src/test/kotlin/io/stigg/models/v1/plans/PlanUpdateParamsTest.kt index 1efa2cd6..7bacc8d5 100644 --- a/stigg-java-core/src/test/kotlin/io/stigg/models/v1/plans/PlanUpdateParamsTest.kt +++ b/stigg-java-core/src/test/kotlin/io/stigg/models/v1/plans/PlanUpdateParamsTest.kt @@ -128,6 +128,20 @@ internal class PlanUpdateParamsTest { PlanUpdateParams.Charges.OveragePricingModel.BillingCadence .RECURRING ) + .creditEntitlement( + PlanUpdateParams.Charges.OveragePricingModel.CreditEntitlement + .builder() + .amount(1.0) + .cadence( + PlanUpdateParams.Charges.OveragePricingModel + .CreditEntitlement + .Cadence + .MONTH + ) + .customCurrencyId("customCurrencyId") + .build() + ) + .currencyId("currencyId") .entitlement( PlanUpdateParams.Charges.OveragePricingModel.Entitlement.builder() .featureId("featureId") @@ -181,7 +195,6 @@ internal class PlanUpdateParamsTest { .build() ) .featureId("featureId") - .topUpCustomCurrencyId("topUpCustomCurrencyId") .build() ) .addPricingModel( @@ -470,6 +483,20 @@ internal class PlanUpdateParamsTest { PlanUpdateParams.Charges.OveragePricingModel.BillingCadence .RECURRING ) + .creditEntitlement( + PlanUpdateParams.Charges.OveragePricingModel.CreditEntitlement + .builder() + .amount(1.0) + .cadence( + PlanUpdateParams.Charges.OveragePricingModel + .CreditEntitlement + .Cadence + .MONTH + ) + .customCurrencyId("customCurrencyId") + .build() + ) + .currencyId("currencyId") .entitlement( PlanUpdateParams.Charges.OveragePricingModel.Entitlement .builder() @@ -524,7 +551,6 @@ internal class PlanUpdateParamsTest { .build() ) .featureId("featureId") - .topUpCustomCurrencyId("topUpCustomCurrencyId") .build() ) .addPricingModel( @@ -829,6 +855,20 @@ internal class PlanUpdateParamsTest { PlanUpdateParams.Charges.OveragePricingModel.BillingCadence .RECURRING ) + .creditEntitlement( + PlanUpdateParams.Charges.OveragePricingModel.CreditEntitlement + .builder() + .amount(1.0) + .cadence( + PlanUpdateParams.Charges.OveragePricingModel + .CreditEntitlement + .Cadence + .MONTH + ) + .customCurrencyId("customCurrencyId") + .build() + ) + .currencyId("currencyId") .entitlement( PlanUpdateParams.Charges.OveragePricingModel.Entitlement .builder() @@ -883,7 +923,6 @@ internal class PlanUpdateParamsTest { .build() ) .featureId("featureId") - .topUpCustomCurrencyId("topUpCustomCurrencyId") .build() ) .addPricingModel( @@ -1159,6 +1198,20 @@ internal class PlanUpdateParamsTest { PlanUpdateParams.Charges.OveragePricingModel.BillingCadence .RECURRING ) + .creditEntitlement( + PlanUpdateParams.Charges.OveragePricingModel.CreditEntitlement + .builder() + .amount(1.0) + .cadence( + PlanUpdateParams.Charges.OveragePricingModel + .CreditEntitlement + .Cadence + .MONTH + ) + .customCurrencyId("customCurrencyId") + .build() + ) + .currencyId("currencyId") .entitlement( PlanUpdateParams.Charges.OveragePricingModel.Entitlement.builder() .featureId("featureId") @@ -1212,7 +1265,6 @@ internal class PlanUpdateParamsTest { .build() ) .featureId("featureId") - .topUpCustomCurrencyId("topUpCustomCurrencyId") .build() ) .addPricingModel( diff --git a/stigg-java-core/src/test/kotlin/io/stigg/models/v1/usage/UsageEstimateCostParamsTest.kt b/stigg-java-core/src/test/kotlin/io/stigg/models/v1/usage/UsageEstimateParamsTest.kt similarity index 80% rename from stigg-java-core/src/test/kotlin/io/stigg/models/v1/usage/UsageEstimateCostParamsTest.kt rename to stigg-java-core/src/test/kotlin/io/stigg/models/v1/usage/UsageEstimateParamsTest.kt index 93013144..d7c654d4 100644 --- a/stigg-java-core/src/test/kotlin/io/stigg/models/v1/usage/UsageEstimateCostParamsTest.kt +++ b/stigg-java-core/src/test/kotlin/io/stigg/models/v1/usage/UsageEstimateParamsTest.kt @@ -7,42 +7,42 @@ import io.stigg.core.http.Headers import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class UsageEstimateCostParamsTest { +internal class UsageEstimateParamsTest { @Test fun create() { - UsageEstimateCostParams.builder() + UsageEstimateParams.builder() .xAccountId("X-ACCOUNT-ID") .xEnvironmentId("X-ENVIRONMENT-ID") .customerId("customerId") .featureId("featureId") .value(-9007199254740991L) .dimensions( - UsageEstimateCostParams.Dimensions.builder() + UsageEstimateParams.Dimensions.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .resourceId("resourceId") - .updateBehavior(UsageEstimateCostParams.UpdateBehavior.DELTA) + .updateBehavior(UsageEstimateParams.UpdateBehavior.DELTA) .build() } @Test fun headers() { val params = - UsageEstimateCostParams.builder() + UsageEstimateParams.builder() .xAccountId("X-ACCOUNT-ID") .xEnvironmentId("X-ENVIRONMENT-ID") .customerId("customerId") .featureId("featureId") .value(-9007199254740991L) .dimensions( - UsageEstimateCostParams.Dimensions.builder() + UsageEstimateParams.Dimensions.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .resourceId("resourceId") - .updateBehavior(UsageEstimateCostParams.UpdateBehavior.DELTA) + .updateBehavior(UsageEstimateParams.UpdateBehavior.DELTA) .build() val headers = params._headers() @@ -59,7 +59,7 @@ internal class UsageEstimateCostParamsTest { @Test fun headersWithoutOptionalFields() { val params = - UsageEstimateCostParams.builder() + UsageEstimateParams.builder() .customerId("customerId") .featureId("featureId") .value(-9007199254740991L) @@ -73,19 +73,19 @@ internal class UsageEstimateCostParamsTest { @Test fun body() { val params = - UsageEstimateCostParams.builder() + UsageEstimateParams.builder() .xAccountId("X-ACCOUNT-ID") .xEnvironmentId("X-ENVIRONMENT-ID") .customerId("customerId") .featureId("featureId") .value(-9007199254740991L) .dimensions( - UsageEstimateCostParams.Dimensions.builder() + UsageEstimateParams.Dimensions.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .resourceId("resourceId") - .updateBehavior(UsageEstimateCostParams.UpdateBehavior.DELTA) + .updateBehavior(UsageEstimateParams.UpdateBehavior.DELTA) .build() val body = params._body() @@ -95,18 +95,18 @@ internal class UsageEstimateCostParamsTest { assertThat(body.value()).isEqualTo(-9007199254740991L) assertThat(body.dimensions()) .contains( - UsageEstimateCostParams.Dimensions.builder() + UsageEstimateParams.Dimensions.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) assertThat(body.resourceId()).contains("resourceId") - assertThat(body.updateBehavior()).contains(UsageEstimateCostParams.UpdateBehavior.DELTA) + assertThat(body.updateBehavior()).contains(UsageEstimateParams.UpdateBehavior.DELTA) } @Test fun bodyWithoutOptionalFields() { val params = - UsageEstimateCostParams.builder() + UsageEstimateParams.builder() .customerId("customerId") .featureId("featureId") .value(-9007199254740991L) diff --git a/stigg-java-core/src/test/kotlin/io/stigg/models/v1/usage/UsageEstimateCostResponseTest.kt b/stigg-java-core/src/test/kotlin/io/stigg/models/v1/usage/UsageEstimateResponseTest.kt similarity index 64% rename from stigg-java-core/src/test/kotlin/io/stigg/models/v1/usage/UsageEstimateCostResponseTest.kt rename to stigg-java-core/src/test/kotlin/io/stigg/models/v1/usage/UsageEstimateResponseTest.kt index 6cce68cc..1ac3bf58 100644 --- a/stigg-java-core/src/test/kotlin/io/stigg/models/v1/usage/UsageEstimateCostResponseTest.kt +++ b/stigg-java-core/src/test/kotlin/io/stigg/models/v1/usage/UsageEstimateResponseTest.kt @@ -7,23 +7,23 @@ import io.stigg.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class UsageEstimateCostResponseTest { +internal class UsageEstimateResponseTest { @Test fun create() { - val usageEstimateCostResponse = - UsageEstimateCostResponse.builder() + val usageEstimateResponse = + UsageEstimateResponse.builder() .data( - UsageEstimateCostResponse.Data.builder() + UsageEstimateResponse.Data.builder() .addEstimate( - UsageEstimateCostResponse.Data.Estimate.builder() + UsageEstimateResponse.Data.Estimate.builder() .balanceAfterEstimate(0.0) .addBreakdown( - UsageEstimateCostResponse.Data.Estimate.Breakdown.builder() + UsageEstimateResponse.Data.Estimate.Breakdown.builder() .cost(0.0) .featureId("featureId") .warningCode( - UsageEstimateCostResponse.Data.Estimate.Breakdown + UsageEstimateResponse.Data.Estimate.Breakdown .WarningCode .UNSUPPORTED_AGGREGATION ) @@ -36,26 +36,24 @@ internal class UsageEstimateCostResponseTest { .build() ) .addWarning( - UsageEstimateCostResponse.Data.Warning - .RESOURCE_SCOPED_SUBSCRIPTION_EXISTS + UsageEstimateResponse.Data.Warning.RESOURCE_SCOPED_SUBSCRIPTION_EXISTS ) .build() ) .build() - assertThat(usageEstimateCostResponse.data()) + assertThat(usageEstimateResponse.data()) .isEqualTo( - UsageEstimateCostResponse.Data.builder() + UsageEstimateResponse.Data.builder() .addEstimate( - UsageEstimateCostResponse.Data.Estimate.builder() + UsageEstimateResponse.Data.Estimate.builder() .balanceAfterEstimate(0.0) .addBreakdown( - UsageEstimateCostResponse.Data.Estimate.Breakdown.builder() + UsageEstimateResponse.Data.Estimate.Breakdown.builder() .cost(0.0) .featureId("featureId") .warningCode( - UsageEstimateCostResponse.Data.Estimate.Breakdown - .WarningCode + UsageEstimateResponse.Data.Estimate.Breakdown.WarningCode .UNSUPPORTED_AGGREGATION ) .build() @@ -67,7 +65,7 @@ internal class UsageEstimateCostResponseTest { .build() ) .addWarning( - UsageEstimateCostResponse.Data.Warning.RESOURCE_SCOPED_SUBSCRIPTION_EXISTS + UsageEstimateResponse.Data.Warning.RESOURCE_SCOPED_SUBSCRIPTION_EXISTS ) .build() ) @@ -76,19 +74,19 @@ internal class UsageEstimateCostResponseTest { @Test fun roundtrip() { val jsonMapper = jsonMapper() - val usageEstimateCostResponse = - UsageEstimateCostResponse.builder() + val usageEstimateResponse = + UsageEstimateResponse.builder() .data( - UsageEstimateCostResponse.Data.builder() + UsageEstimateResponse.Data.builder() .addEstimate( - UsageEstimateCostResponse.Data.Estimate.builder() + UsageEstimateResponse.Data.Estimate.builder() .balanceAfterEstimate(0.0) .addBreakdown( - UsageEstimateCostResponse.Data.Estimate.Breakdown.builder() + UsageEstimateResponse.Data.Estimate.Breakdown.builder() .cost(0.0) .featureId("featureId") .warningCode( - UsageEstimateCostResponse.Data.Estimate.Breakdown + UsageEstimateResponse.Data.Estimate.Breakdown .WarningCode .UNSUPPORTED_AGGREGATION ) @@ -101,19 +99,18 @@ internal class UsageEstimateCostResponseTest { .build() ) .addWarning( - UsageEstimateCostResponse.Data.Warning - .RESOURCE_SCOPED_SUBSCRIPTION_EXISTS + UsageEstimateResponse.Data.Warning.RESOURCE_SCOPED_SUBSCRIPTION_EXISTS ) .build() ) .build() - val roundtrippedUsageEstimateCostResponse = + val roundtrippedUsageEstimateResponse = jsonMapper.readValue( - jsonMapper.writeValueAsString(usageEstimateCostResponse), - jacksonTypeRef(), + jsonMapper.writeValueAsString(usageEstimateResponse), + jacksonTypeRef(), ) - assertThat(roundtrippedUsageEstimateCostResponse).isEqualTo(usageEstimateCostResponse) + assertThat(roundtrippedUsageEstimateResponse).isEqualTo(usageEstimateResponse) } } diff --git a/stigg-java-core/src/test/kotlin/io/stigg/services/async/v1/AddonServiceAsyncTest.kt b/stigg-java-core/src/test/kotlin/io/stigg/services/async/v1/AddonServiceAsyncTest.kt index 7eed83ef..0aa69a70 100644 --- a/stigg-java-core/src/test/kotlin/io/stigg/services/async/v1/AddonServiceAsyncTest.kt +++ b/stigg-java-core/src/test/kotlin/io/stigg/services/async/v1/AddonServiceAsyncTest.kt @@ -205,6 +205,21 @@ internal class AddonServiceAsyncTest { AddonUpdateParams.Charges.OveragePricingModel.BillingCadence .RECURRING ) + .creditEntitlement( + AddonUpdateParams.Charges.OveragePricingModel + .CreditEntitlement + .builder() + .amount(1.0) + .cadence( + AddonUpdateParams.Charges.OveragePricingModel + .CreditEntitlement + .Cadence + .MONTH + ) + .customCurrencyId("customCurrencyId") + .build() + ) + .currencyId("currencyId") .entitlement( AddonUpdateParams.Charges.OveragePricingModel.Entitlement .builder() @@ -266,7 +281,6 @@ internal class AddonServiceAsyncTest { .build() ) .featureId("featureId") - .topUpCustomCurrencyId("topUpCustomCurrencyId") .build() ) .addPricingModel( diff --git a/stigg-java-core/src/test/kotlin/io/stigg/services/async/v1/EventServiceAsyncTest.kt b/stigg-java-core/src/test/kotlin/io/stigg/services/async/v1/EventServiceAsyncTest.kt index 3f6e62d5..b7e3dae3 100644 --- a/stigg-java-core/src/test/kotlin/io/stigg/services/async/v1/EventServiceAsyncTest.kt +++ b/stigg-java-core/src/test/kotlin/io/stigg/services/async/v1/EventServiceAsyncTest.kt @@ -4,7 +4,7 @@ package io.stigg.services.async.v1 import io.stigg.client.okhttp.StiggOkHttpClientAsync import io.stigg.core.JsonValue -import io.stigg.models.v1.events.EventEstimateCostParams +import io.stigg.models.v1.events.EventEstimateParams import io.stigg.models.v1.events.EventReportParams import java.time.OffsetDateTime import org.junit.jupiter.api.Disabled @@ -14,19 +14,19 @@ internal class EventServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test - fun estimateCost() { + fun estimate() { val client = StiggOkHttpClientAsync.builder().apiKey("My API Key").build() val eventServiceAsync = client.v1().events() val responseFuture = - eventServiceAsync.estimateCost( - EventEstimateCostParams.builder() + eventServiceAsync.estimate( + EventEstimateParams.builder() .xAccountId("X-ACCOUNT-ID") .xEnvironmentId("X-ENVIRONMENT-ID") .customerId("customerId") .eventName("x") .dimensions( - EventEstimateCostParams.Dimensions.builder() + EventEstimateParams.Dimensions.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) diff --git a/stigg-java-core/src/test/kotlin/io/stigg/services/async/v1/PlanServiceAsyncTest.kt b/stigg-java-core/src/test/kotlin/io/stigg/services/async/v1/PlanServiceAsyncTest.kt index f48f2eb6..83565926 100644 --- a/stigg-java-core/src/test/kotlin/io/stigg/services/async/v1/PlanServiceAsyncTest.kt +++ b/stigg-java-core/src/test/kotlin/io/stigg/services/async/v1/PlanServiceAsyncTest.kt @@ -217,6 +217,21 @@ internal class PlanServiceAsyncTest { PlanUpdateParams.Charges.OveragePricingModel.BillingCadence .RECURRING ) + .creditEntitlement( + PlanUpdateParams.Charges.OveragePricingModel + .CreditEntitlement + .builder() + .amount(1.0) + .cadence( + PlanUpdateParams.Charges.OveragePricingModel + .CreditEntitlement + .Cadence + .MONTH + ) + .customCurrencyId("customCurrencyId") + .build() + ) + .currencyId("currencyId") .entitlement( PlanUpdateParams.Charges.OveragePricingModel.Entitlement .builder() @@ -275,7 +290,6 @@ internal class PlanServiceAsyncTest { .build() ) .featureId("featureId") - .topUpCustomCurrencyId("topUpCustomCurrencyId") .build() ) .addPricingModel( diff --git a/stigg-java-core/src/test/kotlin/io/stigg/services/async/v1/UsageServiceAsyncTest.kt b/stigg-java-core/src/test/kotlin/io/stigg/services/async/v1/UsageServiceAsyncTest.kt index 56a4b201..de7f0117 100644 --- a/stigg-java-core/src/test/kotlin/io/stigg/services/async/v1/UsageServiceAsyncTest.kt +++ b/stigg-java-core/src/test/kotlin/io/stigg/services/async/v1/UsageServiceAsyncTest.kt @@ -4,7 +4,7 @@ package io.stigg.services.async.v1 import io.stigg.client.okhttp.StiggOkHttpClientAsync import io.stigg.core.JsonValue -import io.stigg.models.v1.usage.UsageEstimateCostParams +import io.stigg.models.v1.usage.UsageEstimateParams import io.stigg.models.v1.usage.UsageHistoryParams import io.stigg.models.v1.usage.UsageReportParams import java.time.OffsetDateTime @@ -15,25 +15,25 @@ internal class UsageServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test - fun estimateCost() { + fun estimate() { val client = StiggOkHttpClientAsync.builder().apiKey("My API Key").build() val usageServiceAsync = client.v1().usage() val responseFuture = - usageServiceAsync.estimateCost( - UsageEstimateCostParams.builder() + usageServiceAsync.estimate( + UsageEstimateParams.builder() .xAccountId("X-ACCOUNT-ID") .xEnvironmentId("X-ENVIRONMENT-ID") .customerId("customerId") .featureId("featureId") .value(-9007199254740991L) .dimensions( - UsageEstimateCostParams.Dimensions.builder() + UsageEstimateParams.Dimensions.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .resourceId("resourceId") - .updateBehavior(UsageEstimateCostParams.UpdateBehavior.DELTA) + .updateBehavior(UsageEstimateParams.UpdateBehavior.DELTA) .build() ) diff --git a/stigg-java-core/src/test/kotlin/io/stigg/services/async/v1beta/CustomerServiceAsyncTest.kt b/stigg-java-core/src/test/kotlin/io/stigg/services/async/v1/events/beta/CustomerServiceAsyncTest.kt similarity index 86% rename from stigg-java-core/src/test/kotlin/io/stigg/services/async/v1beta/CustomerServiceAsyncTest.kt rename to stigg-java-core/src/test/kotlin/io/stigg/services/async/v1/events/beta/CustomerServiceAsyncTest.kt index cfb64910..d1450c7f 100644 --- a/stigg-java-core/src/test/kotlin/io/stigg/services/async/v1beta/CustomerServiceAsyncTest.kt +++ b/stigg-java-core/src/test/kotlin/io/stigg/services/async/v1/events/beta/CustomerServiceAsyncTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.stigg.services.async.v1beta +package io.stigg.services.async.v1.events.beta import io.stigg.client.okhttp.StiggOkHttpClientAsync -import io.stigg.models.v1beta.customers.CustomerRetrieveGovernanceParams +import io.stigg.models.v1.events.beta.customers.CustomerRetrieveGovernanceParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -13,7 +13,7 @@ internal class CustomerServiceAsyncTest { @Test fun retrieveGovernance() { val client = StiggOkHttpClientAsync.builder().apiKey("My API Key").build() - val customerServiceAsync = client.v1Beta().customers() + val customerServiceAsync = client.v1().events().beta().customers() val responseFuture = customerServiceAsync.retrieveGovernance( diff --git a/stigg-java-core/src/test/kotlin/io/stigg/services/async/v1/events/dataexport/DestinationServiceAsyncTest.kt b/stigg-java-core/src/test/kotlin/io/stigg/services/async/v1/events/dataexport/DestinationServiceAsyncTest.kt index a4acb473..211e4a58 100644 --- a/stigg-java-core/src/test/kotlin/io/stigg/services/async/v1/events/dataexport/DestinationServiceAsyncTest.kt +++ b/stigg-java-core/src/test/kotlin/io/stigg/services/async/v1/events/dataexport/DestinationServiceAsyncTest.kt @@ -5,7 +5,7 @@ package io.stigg.services.async.v1.events.dataexport import io.stigg.client.okhttp.StiggOkHttpClientAsync import io.stigg.models.v1.events.dataexport.destinations.DestinationCreateParams import io.stigg.models.v1.events.dataexport.destinations.DestinationDeleteParams -import io.stigg.models.v1.events.dataexport.destinations.DestinationUpdateParams +import io.stigg.models.v1.events.dataexport.destinations.DestinationUpdateSelectionParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -34,18 +34,16 @@ internal class DestinationServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test - fun update() { + fun delete() { val client = StiggOkHttpClientAsync.builder().apiKey("My API Key").build() val destinationServiceAsync = client.v1().events().dataExport().destinations() val destinationFuture = - destinationServiceAsync.update( - DestinationUpdateParams.builder() + destinationServiceAsync.delete( + DestinationDeleteParams.builder() .destinationId("x") .xAccountId("X-ACCOUNT-ID") .xEnvironmentId("X-ENVIRONMENT-ID") - .addEnabledModel("x") - .integrationId("x") .build() ) @@ -55,20 +53,22 @@ internal class DestinationServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test - fun delete() { + fun updateSelection() { val client = StiggOkHttpClientAsync.builder().apiKey("My API Key").build() val destinationServiceAsync = client.v1().events().dataExport().destinations() - val destinationFuture = - destinationServiceAsync.delete( - DestinationDeleteParams.builder() + val responseFuture = + destinationServiceAsync.updateSelection( + DestinationUpdateSelectionParams.builder() .destinationId("x") .xAccountId("X-ACCOUNT-ID") .xEnvironmentId("X-ENVIRONMENT-ID") + .addEnabledModel("x") + .integrationId("x") .build() ) - val destination = destinationFuture.get() - destination.validate() + val response = responseFuture.get() + response.validate() } } diff --git a/stigg-java-core/src/test/kotlin/io/stigg/services/blocking/v1/AddonServiceTest.kt b/stigg-java-core/src/test/kotlin/io/stigg/services/blocking/v1/AddonServiceTest.kt index 454d2495..fd57adc8 100644 --- a/stigg-java-core/src/test/kotlin/io/stigg/services/blocking/v1/AddonServiceTest.kt +++ b/stigg-java-core/src/test/kotlin/io/stigg/services/blocking/v1/AddonServiceTest.kt @@ -203,6 +203,21 @@ internal class AddonServiceTest { AddonUpdateParams.Charges.OveragePricingModel.BillingCadence .RECURRING ) + .creditEntitlement( + AddonUpdateParams.Charges.OveragePricingModel + .CreditEntitlement + .builder() + .amount(1.0) + .cadence( + AddonUpdateParams.Charges.OveragePricingModel + .CreditEntitlement + .Cadence + .MONTH + ) + .customCurrencyId("customCurrencyId") + .build() + ) + .currencyId("currencyId") .entitlement( AddonUpdateParams.Charges.OveragePricingModel.Entitlement .builder() @@ -264,7 +279,6 @@ internal class AddonServiceTest { .build() ) .featureId("featureId") - .topUpCustomCurrencyId("topUpCustomCurrencyId") .build() ) .addPricingModel( diff --git a/stigg-java-core/src/test/kotlin/io/stigg/services/blocking/v1/EventServiceTest.kt b/stigg-java-core/src/test/kotlin/io/stigg/services/blocking/v1/EventServiceTest.kt index 5d3970d6..19825f76 100644 --- a/stigg-java-core/src/test/kotlin/io/stigg/services/blocking/v1/EventServiceTest.kt +++ b/stigg-java-core/src/test/kotlin/io/stigg/services/blocking/v1/EventServiceTest.kt @@ -4,7 +4,7 @@ package io.stigg.services.blocking.v1 import io.stigg.client.okhttp.StiggOkHttpClient import io.stigg.core.JsonValue -import io.stigg.models.v1.events.EventEstimateCostParams +import io.stigg.models.v1.events.EventEstimateParams import io.stigg.models.v1.events.EventReportParams import java.time.OffsetDateTime import org.junit.jupiter.api.Disabled @@ -14,19 +14,19 @@ internal class EventServiceTest { @Disabled("Mock server tests are disabled") @Test - fun estimateCost() { + fun estimate() { val client = StiggOkHttpClient.builder().apiKey("My API Key").build() val eventService = client.v1().events() val response = - eventService.estimateCost( - EventEstimateCostParams.builder() + eventService.estimate( + EventEstimateParams.builder() .xAccountId("X-ACCOUNT-ID") .xEnvironmentId("X-ENVIRONMENT-ID") .customerId("customerId") .eventName("x") .dimensions( - EventEstimateCostParams.Dimensions.builder() + EventEstimateParams.Dimensions.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) diff --git a/stigg-java-core/src/test/kotlin/io/stigg/services/blocking/v1/PlanServiceTest.kt b/stigg-java-core/src/test/kotlin/io/stigg/services/blocking/v1/PlanServiceTest.kt index f9cd8937..f5cd9610 100644 --- a/stigg-java-core/src/test/kotlin/io/stigg/services/blocking/v1/PlanServiceTest.kt +++ b/stigg-java-core/src/test/kotlin/io/stigg/services/blocking/v1/PlanServiceTest.kt @@ -215,6 +215,21 @@ internal class PlanServiceTest { PlanUpdateParams.Charges.OveragePricingModel.BillingCadence .RECURRING ) + .creditEntitlement( + PlanUpdateParams.Charges.OveragePricingModel + .CreditEntitlement + .builder() + .amount(1.0) + .cadence( + PlanUpdateParams.Charges.OveragePricingModel + .CreditEntitlement + .Cadence + .MONTH + ) + .customCurrencyId("customCurrencyId") + .build() + ) + .currencyId("currencyId") .entitlement( PlanUpdateParams.Charges.OveragePricingModel.Entitlement .builder() @@ -273,7 +288,6 @@ internal class PlanServiceTest { .build() ) .featureId("featureId") - .topUpCustomCurrencyId("topUpCustomCurrencyId") .build() ) .addPricingModel( diff --git a/stigg-java-core/src/test/kotlin/io/stigg/services/blocking/v1/UsageServiceTest.kt b/stigg-java-core/src/test/kotlin/io/stigg/services/blocking/v1/UsageServiceTest.kt index ae4b0966..17223854 100644 --- a/stigg-java-core/src/test/kotlin/io/stigg/services/blocking/v1/UsageServiceTest.kt +++ b/stigg-java-core/src/test/kotlin/io/stigg/services/blocking/v1/UsageServiceTest.kt @@ -4,7 +4,7 @@ package io.stigg.services.blocking.v1 import io.stigg.client.okhttp.StiggOkHttpClient import io.stigg.core.JsonValue -import io.stigg.models.v1.usage.UsageEstimateCostParams +import io.stigg.models.v1.usage.UsageEstimateParams import io.stigg.models.v1.usage.UsageHistoryParams import io.stigg.models.v1.usage.UsageReportParams import java.time.OffsetDateTime @@ -15,25 +15,25 @@ internal class UsageServiceTest { @Disabled("Mock server tests are disabled") @Test - fun estimateCost() { + fun estimate() { val client = StiggOkHttpClient.builder().apiKey("My API Key").build() val usageService = client.v1().usage() val response = - usageService.estimateCost( - UsageEstimateCostParams.builder() + usageService.estimate( + UsageEstimateParams.builder() .xAccountId("X-ACCOUNT-ID") .xEnvironmentId("X-ENVIRONMENT-ID") .customerId("customerId") .featureId("featureId") .value(-9007199254740991L) .dimensions( - UsageEstimateCostParams.Dimensions.builder() + UsageEstimateParams.Dimensions.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .resourceId("resourceId") - .updateBehavior(UsageEstimateCostParams.UpdateBehavior.DELTA) + .updateBehavior(UsageEstimateParams.UpdateBehavior.DELTA) .build() ) diff --git a/stigg-java-core/src/test/kotlin/io/stigg/services/blocking/v1beta/CustomerServiceTest.kt b/stigg-java-core/src/test/kotlin/io/stigg/services/blocking/v1/events/beta/CustomerServiceTest.kt similarity index 86% rename from stigg-java-core/src/test/kotlin/io/stigg/services/blocking/v1beta/CustomerServiceTest.kt rename to stigg-java-core/src/test/kotlin/io/stigg/services/blocking/v1/events/beta/CustomerServiceTest.kt index db0c2449..ee5d8a01 100644 --- a/stigg-java-core/src/test/kotlin/io/stigg/services/blocking/v1beta/CustomerServiceTest.kt +++ b/stigg-java-core/src/test/kotlin/io/stigg/services/blocking/v1/events/beta/CustomerServiceTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.stigg.services.blocking.v1beta +package io.stigg.services.blocking.v1.events.beta import io.stigg.client.okhttp.StiggOkHttpClient -import io.stigg.models.v1beta.customers.CustomerRetrieveGovernanceParams +import io.stigg.models.v1.events.beta.customers.CustomerRetrieveGovernanceParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -13,7 +13,7 @@ internal class CustomerServiceTest { @Test fun retrieveGovernance() { val client = StiggOkHttpClient.builder().apiKey("My API Key").build() - val customerService = client.v1Beta().customers() + val customerService = client.v1().events().beta().customers() val response = customerService.retrieveGovernance( diff --git a/stigg-java-core/src/test/kotlin/io/stigg/services/blocking/v1/events/dataexport/DestinationServiceTest.kt b/stigg-java-core/src/test/kotlin/io/stigg/services/blocking/v1/events/dataexport/DestinationServiceTest.kt index eee9ef2f..1a65d38b 100644 --- a/stigg-java-core/src/test/kotlin/io/stigg/services/blocking/v1/events/dataexport/DestinationServiceTest.kt +++ b/stigg-java-core/src/test/kotlin/io/stigg/services/blocking/v1/events/dataexport/DestinationServiceTest.kt @@ -5,7 +5,7 @@ package io.stigg.services.blocking.v1.events.dataexport import io.stigg.client.okhttp.StiggOkHttpClient import io.stigg.models.v1.events.dataexport.destinations.DestinationCreateParams import io.stigg.models.v1.events.dataexport.destinations.DestinationDeleteParams -import io.stigg.models.v1.events.dataexport.destinations.DestinationUpdateParams +import io.stigg.models.v1.events.dataexport.destinations.DestinationUpdateSelectionParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -33,18 +33,16 @@ internal class DestinationServiceTest { @Disabled("Mock server tests are disabled") @Test - fun update() { + fun delete() { val client = StiggOkHttpClient.builder().apiKey("My API Key").build() val destinationService = client.v1().events().dataExport().destinations() val destination = - destinationService.update( - DestinationUpdateParams.builder() + destinationService.delete( + DestinationDeleteParams.builder() .destinationId("x") .xAccountId("X-ACCOUNT-ID") .xEnvironmentId("X-ENVIRONMENT-ID") - .addEnabledModel("x") - .integrationId("x") .build() ) @@ -53,19 +51,21 @@ internal class DestinationServiceTest { @Disabled("Mock server tests are disabled") @Test - fun delete() { + fun updateSelection() { val client = StiggOkHttpClient.builder().apiKey("My API Key").build() val destinationService = client.v1().events().dataExport().destinations() - val destination = - destinationService.delete( - DestinationDeleteParams.builder() + val response = + destinationService.updateSelection( + DestinationUpdateSelectionParams.builder() .destinationId("x") .xAccountId("X-ACCOUNT-ID") .xEnvironmentId("X-ENVIRONMENT-ID") + .addEnabledModel("x") + .integrationId("x") .build() ) - destination.validate() + response.validate() } }